diff options
author | Francisco Jerez <[email protected]> | 2018-06-11 12:54:17 -0700 |
---|---|---|
committer | Francisco Jerez <[email protected]> | 2019-10-11 12:24:16 -0700 |
commit | 25dd67099df301f09ce40b8f9c5a3bbc857e367c (patch) | |
tree | 857fbb0010ea87f081ac5e42b2dce90f2b87ad73 /src/intel/compiler/brw_eu.h | |
parent | 51dc40cefb0b04726668bb3f3ee0e51cdaf30d72 (diff) |
intel/eu: Rework opcode description tables to allow efficient look-up by either HW or IR opcode.
This rewrites the current opcode description tables as a more compact
flat data structure. The purpose is to allow efficient constant-time
look-up by either HW or IR opcode, which will allow us to drop the
hard-coded correspondence between HW and IR opcodes -- See the next
commits for the rationale.
brw_eu.c is now built as C++ source so we can take advantage of
pointers to member in order to make the look-up function work
regardless of the opcode_desc member used as look-up key.
v2: Optimize devinfo struct comparison (Caio)
Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]>
Reviewed-by: Jordan Justen <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/intel/compiler/brw_eu.h')
-rw-r--r-- | src/intel/compiler/brw_eu.h | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h index ef2cf889cd1..282ebd7d563 100644 --- a/src/intel/compiler/brw_eu.h +++ b/src/intel/compiler/brw_eu.h @@ -1221,32 +1221,33 @@ next_offset(const struct gen_device_info *devinfo, void *store, int offset) } struct opcode_desc { - /* The union is an implementation detail used by brw_opcode_desc() to handle - * opcodes that have been reused for different instructions across hardware - * generations. - * - * The gens field acts as a tag. If it is non-zero, name points to a string - * containing the instruction mnemonic. If it is zero, the table field is - * valid and either points to a secondary opcode_desc table with 'size' - * elements or is NULL and no such instruction exists for the opcode. - */ - union { - struct { - char *name; - int nsrc; - }; - struct { - const struct opcode_desc *table; - unsigned size; - }; - }; - int ndst; - int gens; + unsigned ir; + unsigned hw; + const char *name; + int nsrc; + int ndst; + int gens; }; const struct opcode_desc * brw_opcode_desc(const struct gen_device_info *devinfo, enum opcode opcode); +const struct opcode_desc * +brw_opcode_desc_from_hw(const struct gen_device_info *devinfo, unsigned hw); + +static inline unsigned +brw_opcode_encode(const struct gen_device_info *devinfo, enum opcode opcode) +{ + return brw_opcode_desc(devinfo, opcode)->hw; +} + +static inline enum opcode +brw_opcode_decode(const struct gen_device_info *devinfo, unsigned hw) +{ + const struct opcode_desc *desc = brw_opcode_desc_from_hw(devinfo, hw); + return desc ? (enum opcode)desc->ir : BRW_OPCODE_ILLEGAL; +} + static inline bool is_3src(const struct gen_device_info *devinfo, enum opcode opcode) { |