From 207c35cbe85db944d4c58b54f7f9a289bd50e18f Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Mon, 18 May 2020 15:37:33 +0100 Subject: [PATCH] aco: add Info::{operand_size,definition_size} MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit No shader-db changes. Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Part-of: --- src/amd/compiler/aco_ir.h | 3 +++ src/amd/compiler/aco_opcodes.py | 31 +++++++++++++++++++++++++++++ src/amd/compiler/aco_opcodes_cpp.py | 10 ++++++++++ 3 files changed, 44 insertions(+) diff --git a/src/amd/compiler/aco_ir.h b/src/amd/compiler/aco_ir.h index 988ae6195f1..6ce1e8d0044 100644 --- a/src/amd/compiler/aco_ir.h +++ b/src/amd/compiler/aco_ir.h @@ -1566,6 +1566,9 @@ typedef struct { const std::bitset(aco_opcode::num_opcodes)> is_atomic; const char *name[static_cast(aco_opcode::num_opcodes)]; const aco::Format format[static_cast(aco_opcode::num_opcodes)]; + /* sizes used for input/output modifiers and constants */ + const unsigned operand_size[static_cast(aco_opcode::num_opcodes)]; + const unsigned definition_size[static_cast(aco_opcode::num_opcodes)]; } Info; extern const Info instr_info; diff --git a/src/amd/compiler/aco_opcodes.py b/src/amd/compiler/aco_opcodes.py index 564a8309ccf..1396b8c3af4 100644 --- a/src/amd/compiler/aco_opcodes.py +++ b/src/amd/compiler/aco_opcodes.py @@ -191,6 +191,37 @@ class Opcode(object): self.is_atomic = "1" if is_atomic else "0" self.format = format + parts = name.replace('_e64', '').rsplit('_', 2) + op_dtype = parts[-1] + def_dtype = parts[-2] if len(parts) > 1 else parts[-1] + dtype_sizes = {'{}{}'.format(prefix, size) : size for prefix in 'biuf' for size in [64, 32, 24, 16]} + self.operand_size = dtype_sizes.get(op_dtype, 0) + self.definition_size = dtype_sizes.get(def_dtype, self.operand_size) + + # exceptions + if self.operand_size == 24: + self.operand_size = 32 + elif name in ['s_sext_i32_i8', 's_sext_i32_i16', 'v_msad_u8', 'v_cvt_pk_u16_u32', 'v_cvt_pk_i16_i32']: + self.operand_size = 32 + elif name in ['v_qsad_pk_u16_u8', 'v_mqsad_pk_u16_u8', 'v_mqsad_u32_u8']: + self.definition_size = 0 + self.operand_size = 0 + elif name in ['v_mad_u64_u32', 'v_mad_i64_i32']: + self.operand_size = 0 + elif name.replace('_e64', '') in ['v_lshrrev_b16', 'v_ashrrev_i16', 'v_lshlrev_b16']: + # v_lshlrev_b16 tested on GFX10 with 1/2 PI inline constant + self.operand_size = 32 + elif '_pk_' in name or name in ['v_lerp_u8', 'v_sad_u8', 'v_sad_u16', + 'v_cvt_f32_ubyte0', 'v_cvt_f32_ubyte1', + 'v_cvt_f32_ubyte2', 'v_cvt_f32_ubyte3']: + self.operand_size = 32 + self.definition_size = 32 + elif '_pknorm_' in name: + self.definition_size = 32 + elif format == Format.PSEUDO_REDUCTION: + # 64-bit reductions can have a larger definition size, but get_subdword_definition_info() handles that + self.definition_size = 32 + # global dictionary of opcodes opcodes = {} diff --git a/src/amd/compiler/aco_opcodes_cpp.py b/src/amd/compiler/aco_opcodes_cpp.py index 8309dee18c2..6678b102adc 100644 --- a/src/amd/compiler/aco_opcodes_cpp.py +++ b/src/amd/compiler/aco_opcodes_cpp.py @@ -65,6 +65,16 @@ extern const aco::Info instr_info = { aco::Format::${str(opcodes[name].format.name)}, % endfor }, + .operand_size = { + % for name in opcode_names: + ${opcodes[name].operand_size}, + % endfor + }, + .definition_size = { + % for name in opcode_names: + ${opcodes[name].definition_size}, + % endfor + }, }; } -- 2.30.2