aco: add Info::{operand_size,definition_size}
authorRhys Perry <pendingchaos02@gmail.com>
Mon, 18 May 2020 14:37:33 +0000 (15:37 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 10 Jun 2020 15:05:11 +0000 (15:05 +0000)
No shader-db changes.

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5040>

src/amd/compiler/aco_ir.h
src/amd/compiler/aco_opcodes.py
src/amd/compiler/aco_opcodes_cpp.py

index 988ae6195f15476d1fd664d90221c9390654660c..6ce1e8d00441edf15b3473e1e8de01fb5b85659b 100644 (file)
@@ -1566,6 +1566,9 @@ typedef struct {
    const std::bitset<static_cast<int>(aco_opcode::num_opcodes)> is_atomic;
    const char *name[static_cast<int>(aco_opcode::num_opcodes)];
    const aco::Format format[static_cast<int>(aco_opcode::num_opcodes)];
+   /* sizes used for input/output modifiers and constants */
+   const unsigned operand_size[static_cast<int>(aco_opcode::num_opcodes)];
+   const unsigned definition_size[static_cast<int>(aco_opcode::num_opcodes)];
 } Info;
 
 extern const Info instr_info;
index 564a8309ccf218751c253c6aeb7a87317d8354d6..1396b8c3af4e756000bfe65566c42b14a785bb5c 100644 (file)
@@ -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 = {}
index 8309dee18c226f6884d4bec89488dd17f2290caa..6678b102adc5a0ea7e91f5c50eaa7f6a560bbcd9 100644 (file)
@@ -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
+   },
 };
 
 }