From: Kenneth Graunke Date: Mon, 1 Apr 2019 23:01:50 +0000 (-0700) Subject: intel/mi: Add gen_mi_nz() and gen_mi_z() helpers. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=27b5817b6c234d266425956287351dc424abe9ea;p=mesa.git intel/mi: Add gen_mi_nz() and gen_mi_z() helpers. These provide comparisons against zero. Reviewed-by: Caio Marcelo de Oliveira Filho --- 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)