summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_builder.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/nir/nir_builder.h')
-rw-r--r--src/compiler/nir/nir_builder.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 7c65886356d..4bd5628ff7d 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -643,4 +643,29 @@ nir_jump(nir_builder *build, nir_jump_type jump_type)
nir_builder_instr_insert(build, &jump->instr);
}
+static inline nir_ssa_def *
+nir_compare_func(nir_builder *b, enum compare_func func,
+ nir_ssa_def *src0, nir_ssa_def *src1)
+{
+ switch (func) {
+ case COMPARE_FUNC_NEVER:
+ return nir_imm_int(b, 0);
+ case COMPARE_FUNC_ALWAYS:
+ return nir_imm_int(b, ~0);
+ case COMPARE_FUNC_EQUAL:
+ return nir_feq(b, src0, src1);
+ case COMPARE_FUNC_NOTEQUAL:
+ return nir_fne(b, src0, src1);
+ case COMPARE_FUNC_GREATER:
+ return nir_flt(b, src1, src0);
+ case COMPARE_FUNC_GEQUAL:
+ return nir_fge(b, src0, src1);
+ case COMPARE_FUNC_LESS:
+ return nir_flt(b, src0, src1);
+ case COMPARE_FUNC_LEQUAL:
+ return nir_fge(b, src1, src0);
+ }
+ unreachable("bad compare func");
+}
+
#endif /* NIR_BUILDER_H */