From cf3c3563e0ead2b7050efd12de377b6b6d25dd2d Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 4 May 2020 14:04:35 -0400 Subject: [PATCH] pan/bi: Use IMATH for nir_op_iadd Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bi_print.c | 12 ++++++++++++ src/panfrost/bifrost/bifrost_compile.c | 9 ++++++++- src/panfrost/bifrost/compiler.h | 6 ++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/panfrost/bifrost/bi_print.c b/src/panfrost/bifrost/bi_print.c index 066b96c41c4..1d2807f2262 100644 --- a/src/panfrost/bifrost/bi_print.c +++ b/src/panfrost/bifrost/bi_print.c @@ -238,6 +238,16 @@ bi_bitwise_op_name(enum bi_bitwise_op op) } } +static const char * +bi_imath_op_name(enum bi_imath_op op) +{ + switch (op) { + case BI_IMATH_ADD: return "iadd"; + case BI_IMATH_SUB: return "isub"; + default: return "invalid"; + } +} + const char * bi_table_op_name(enum bi_table_op op) { @@ -328,6 +338,8 @@ bi_print_instruction(bi_instruction *ins, FILE *fp) fprintf(fp, "%s", ins->op.minmax == BI_MINMAX_MIN ? "min" : "max"); else if (ins->type == BI_BITWISE) fprintf(fp, "%s", bi_bitwise_op_name(ins->op.bitwise)); + else if (ins->type == BI_IMATH) + fprintf(fp, "%s", bi_imath_op_name(ins->op.imath)); else if (ins->type == BI_SPECIAL) fprintf(fp, "%s", bi_special_op_name(ins->op.special)); else if (ins->type == BI_TABLE) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 6a3a15932f4..468e3b5c3b0 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -498,10 +498,11 @@ static enum bi_class bi_class_for_nir_alu(nir_op op) { switch (op) { - case nir_op_iadd: case nir_op_fadd: case nir_op_fsub: return BI_ADD; + + case nir_op_iadd: case nir_op_isub: return BI_IMATH; @@ -788,6 +789,12 @@ emit_alu(bi_context *ctx, nir_alu_instr *instr) case nir_op_fsub: alu.src_neg[1] = true; /* FADD */ break; + case nir_op_iadd: + alu.op.imath = BI_IMATH_ADD; + break; + case nir_op_isub: + alu.op.imath = BI_IMATH_SUB; + break; case nir_op_fmax: case nir_op_imax: case nir_op_umax: diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index 3b54c4857d1..eb0c4d17f0a 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -167,6 +167,11 @@ enum bi_bitwise_op { BI_BITWISE_XOR }; +enum bi_imath_op { + BI_IMATH_ADD, + BI_IMATH_SUB, +}; + enum bi_table_op { /* fp32 log2() with low precision, suitable for GL or half_log2() in * CL. In the first argument, takes x. Letting u be such that x = @@ -276,6 +281,7 @@ typedef struct { enum bi_table_op table; enum bi_frexp_op frexp; enum bi_tex_op texture; + enum bi_imath_op imath; /* For FMA/ADD, should we add a biased exponent? */ bool mscale; -- 2.30.2