From 5d8301977b42fdfbd5ae9f230b65c0a93c52c7bf Mon Sep 17 00:00:00 2001 From: Italo Nicola Date: Thu, 11 Mar 2021 02:41:04 +0000 Subject: [PATCH] pan/mdg: stop querying datatype by reading opcode name Signed-off-by: Italo Nicola Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/midgard_ops.h | 34 +++++++++++++++--- src/panfrost/midgard/midgard_print_constant.c | 35 ++++++++++--------- 2 files changed, 48 insertions(+), 21 deletions(-) diff --git a/src/panfrost/midgard/midgard_ops.h b/src/panfrost/midgard/midgard_ops.h index 6466a3bf8ba..62bf741ab33 100644 --- a/src/panfrost/midgard/midgard_ops.h +++ b/src/panfrost/midgard/midgard_ops.h @@ -41,12 +41,38 @@ extern struct mir_tag_props midgard_tag_props[16]; static inline bool midgard_is_integer_op(int op) { - const char *name = alu_opcode_props[op].name; + return (op >= 0x40 && op <= 0x7E) || (op >= 0xA0 && op <= 0xC1); +} - if (!name) +static inline bool +midgard_is_unsigned_op(int op) +{ + assert(midgard_is_integer_op(op)); + + switch (op) { + case midgard_alu_op_uaddsat: + case midgard_alu_op_usubsat: + case midgard_alu_op_uwmul: + case midgard_alu_op_umin: + case midgard_alu_op_umax: + case midgard_alu_op_uavg: + case midgard_alu_op_uravg: + case midgard_alu_op_ushlsat: + case midgard_alu_op_uabsdiff: + case midgard_alu_op_ult: + case midgard_alu_op_ule: + case midgard_alu_op_uball_lt: + case midgard_alu_op_uball_lte: + case midgard_alu_op_ubany_lt: + case midgard_alu_op_ubany_lte: + case midgard_alu_op_u2f_rte: + case midgard_alu_op_u2f_rtz: + case midgard_alu_op_u2f_rtn: + case midgard_alu_op_u2f_rtp: + return true; + default: return false; - - return (name[0] == 'i') || (name[0] == 'u'); + } } /* Does this opcode *write* an integer? Same as is_integer_op, unless it's a diff --git a/src/panfrost/midgard/midgard_print_constant.c b/src/panfrost/midgard/midgard_print_constant.c index a162a801971..c254574774e 100644 --- a/src/panfrost/midgard/midgard_print_constant.c +++ b/src/panfrost/midgard/midgard_print_constant.c @@ -37,27 +37,28 @@ mir_print_constant_component(FILE *fp, const midgard_constants *consts, unsigned bool is_sint = false, is_uint = false, is_hex = false; const char *opname = alu_opcode_props[op].name; + bool is_int = midgard_is_integer_op(op); + /* Add a sentinel name to prevent crashing */ if (!opname) opname = "unknown"; - if (opname[0] == 'u') { - /* If the opcode starts with a 'u' we are sure we deal with an - * unsigned int operation - */ - is_uint = true; - } else if (opname[0] == 'i') { - /* Bit ops are easier to follow when the constant is printed in - * hexadecimal. Other operations starting with a 'i' are - * considered to operate on signed integers. That might not - * be true for all of them, but it's good enough for traces. - */ - if (op >= midgard_alu_op_iand && - op <= midgard_alu_op_ipopcnt) - is_hex = true; - else - is_sint = true; - } + if (is_int) { + is_uint = midgard_is_unsigned_op(op); + + if (!is_uint) { + /* Bit ops are easier to follow when the constant is printed in + * hexadecimal. Other operations starting with a 'i' are + * considered to operate on signed integers. That might not + * be true for all of them, but it's good enough for traces. + */ + if (op >= midgard_alu_op_iand && + op <= midgard_alu_op_ipopcnt) + is_hex = true; + else + is_sint = true; + } + } if (half) reg_mode--;