From 27b5817b6c234d266425956287351dc424abe9ea Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Mon, 1 Apr 2019 16:01:50 -0700 Subject: intel/mi: Add gen_mi_nz() and gen_mi_z() helpers. These provide comparisons against zero. Reviewed-by: Caio Marcelo de Oliveira Filho --- src/intel/common/gen_mi_builder.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/intel/common') diff --git a/src/intel/common/gen_mi_builder.h b/src/intel/common/gen_mi_builder.h index 90ac795f48d..61d44eda5ae 100644 --- a/src/intel/common/gen_mi_builder.h +++ b/src/intel/common/gen_mi_builder.h @@ -644,6 +644,26 @@ gen_mi_iand(struct gen_mi_builder *b, MI_ALU_STORE, MI_ALU_ACCU); } +/** + * Returns (src != 0) ? 1 : 0. + */ +static inline struct gen_mi_value +gen_mi_nz(struct gen_mi_builder *b, struct gen_mi_value src) +{ + return gen_mi_math_binop(b, MI_ALU_ADD, src, gen_mi_imm(0), + MI_ALU_STOREINV, MI_ALU_ZF); +} + +/** + * Returns (src == 0) ? 1 : 0. + */ +static inline struct gen_mi_value +gen_mi_z(struct gen_mi_builder *b, struct gen_mi_value src) +{ + return gen_mi_math_binop(b, MI_ALU_ADD, src, gen_mi_imm(0), + MI_ALU_STORE, MI_ALU_ZF); +} + static inline struct gen_mi_value gen_mi_ior(struct gen_mi_builder *b, struct gen_mi_value src0, struct gen_mi_value src1) -- cgit v1.2.3