From 1bef784867410e9ec2728b0cadf696a4e5168d28 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 1 Jun 2020 14:06:44 -0400 Subject: [PATCH] pan/mdg: Add opcode roundmode property When the output is rounded in a specified direction. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/midgard/helpers.h | 7 +++++++ src/panfrost/midgard/midgard_ops.c | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/panfrost/midgard/helpers.h b/src/panfrost/midgard/helpers.h index a7177ce2f2e..c11cdf65f0f 100644 --- a/src/panfrost/midgard/helpers.h +++ b/src/panfrost/midgard/helpers.h @@ -120,6 +120,13 @@ /* Does the op convert types between int- and float- space (i2f/f2u/etc) */ #define OP_TYPE_CONVERT (1 << 4) +/* Is this opcode the first in a f2x (rte, rtz, rtn, rtp) sequence? If so, + * takes a roundmode argument in the IR. This has the semantic of rounding the + * source (it's all fused in), which is why it doesn't necessarily make sense + * for i2f (though folding there might be necessary for OpenCL reasons). Comes + * up in format conversion, i.e. f2u_rte */ +#define MIDGARD_ROUNDS (1 << 5) + /* Vector-independant shorthands for the above; these numbers are arbitrary and * not from the ISA. Convert to the above with unit_enum_to_midgard */ diff --git a/src/panfrost/midgard/midgard_ops.c b/src/panfrost/midgard/midgard_ops.c index 3055f0b93f5..73e471c5e85 100644 --- a/src/panfrost/midgard/midgard_ops.c +++ b/src/panfrost/midgard/midgard_ops.c @@ -106,19 +106,19 @@ struct mir_op_props alu_opcode_props[256] = { [midgard_alu_op_fexp2] = {"fexp2", UNIT_VLUT}, [midgard_alu_op_flog2] = {"flog2", UNIT_VLUT}, - [midgard_alu_op_f2i_rte] = {"f2i_rte", UNITS_ADD | OP_TYPE_CONVERT}, + [midgard_alu_op_f2i_rte] = {"f2i_rte", UNITS_ADD | OP_TYPE_CONVERT | MIDGARD_ROUNDS}, [midgard_alu_op_f2i_rtz] = {"f2i_rtz", UNITS_ADD | OP_TYPE_CONVERT}, [midgard_alu_op_f2i_rtn] = {"f2i_rtn", UNITS_ADD | OP_TYPE_CONVERT}, [midgard_alu_op_f2i_rtp] = {"f2i_rtp", UNITS_ADD | OP_TYPE_CONVERT}, - [midgard_alu_op_f2u_rte] = {"f2u_rte", UNITS_ADD | OP_TYPE_CONVERT}, + [midgard_alu_op_f2u_rte] = {"f2u_rte", UNITS_ADD | OP_TYPE_CONVERT | MIDGARD_ROUNDS}, [midgard_alu_op_f2u_rtz] = {"f2u_rtz", UNITS_ADD | OP_TYPE_CONVERT}, [midgard_alu_op_f2u_rtn] = {"f2u_rtn", UNITS_ADD | OP_TYPE_CONVERT}, [midgard_alu_op_f2u_rtp] = {"f2u_rtp", UNITS_ADD | OP_TYPE_CONVERT}, - [midgard_alu_op_i2f_rte] = {"i2f", UNITS_ADD | OP_TYPE_CONVERT}, + [midgard_alu_op_i2f_rte] = {"i2f_rte", UNITS_ADD | OP_TYPE_CONVERT}, [midgard_alu_op_i2f_rtz] = {"i2f_rtz", UNITS_ADD | OP_TYPE_CONVERT}, [midgard_alu_op_i2f_rtn] = {"i2f_rtn", UNITS_ADD | OP_TYPE_CONVERT}, [midgard_alu_op_i2f_rtp] = {"i2f_rtp", UNITS_ADD | OP_TYPE_CONVERT}, - [midgard_alu_op_u2f_rte] = {"u2f", UNITS_ADD | OP_TYPE_CONVERT}, + [midgard_alu_op_u2f_rte] = {"u2f_rte", UNITS_ADD | OP_TYPE_CONVERT}, [midgard_alu_op_u2f_rtz] = {"u2f_rtz", UNITS_ADD | OP_TYPE_CONVERT}, [midgard_alu_op_u2f_rtn] = {"u2f_rtn", UNITS_ADD | OP_TYPE_CONVERT}, [midgard_alu_op_u2f_rtp] = {"u2f_rtp", UNITS_ADD | OP_TYPE_CONVERT}, -- 2.30.2