pan/bi: Use IMATH for nir_op_iadd
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 4 May 2020 18:04:35 +0000 (14:04 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 4 May 2020 18:45:15 +0000 (18:45 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4890>

src/panfrost/bifrost/bi_print.c
src/panfrost/bifrost/bifrost_compile.c
src/panfrost/bifrost/compiler.h

index 066b96c41c426910b04857d852fc33186c36af29..1d2807f226237a91f001489db34fdd2ccffabe97 100644 (file)
@@ -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)
index 6a3a15932f4ab29e9413750377cdc59fcc6c512e..468e3b5c3b0b776a71da614ae58d668971f2e270 100644 (file)
@@ -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:
index 3b54c4857d1ea2cb3168977c13e40ddae73c109c..eb0c4d17f0a1c48740d059e5cc9faa829dac1e3a 100644 (file)
@@ -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;