diff options
author | Matt Turner <[email protected]> | 2017-07-26 17:50:22 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2017-08-21 14:05:23 -0700 |
commit | c1ac1a3d257460c2706e91ff933679d7c8889294 (patch) | |
tree | 9cc3287d72db730e6b5774ada1ab96c145e3d1b7 /src | |
parent | dbe7dd13dd46657da7fdd864c916d9d6b08c96bb (diff) |
i965: Add a brw_hw_type_to_reg_type() function
Will be used in later commits.
Reviewed-by: Scott D Phillips <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/intel/compiler/brw_reg_type.c | 25 | ||||
-rw-r--r-- | src/intel/compiler/brw_reg_type.h | 4 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/intel/compiler/brw_reg_type.c b/src/intel/compiler/brw_reg_type.c index f223f3949dc..7dbff8f08f2 100644 --- a/src/intel/compiler/brw_reg_type.c +++ b/src/intel/compiler/brw_reg_type.c @@ -70,6 +70,31 @@ brw_reg_type_to_hw_type(const struct gen_device_info *devinfo, } /** + * Convert the hardware representation into a brw_reg_type enumeration value. + * + * The hardware encoding may depend on whether the value is an immediate. + */ +enum brw_reg_type +brw_hw_type_to_reg_type(const struct gen_device_info *devinfo, + enum brw_reg_file file, unsigned hw_type) +{ + if (file == BRW_IMMEDIATE_VALUE) { + for (enum brw_reg_type i = 0; i <= BRW_REGISTER_TYPE_LAST; i++) { + if (gen4_hw_type[i].imm_type == hw_type) { + return i; + } + } + } else { + for (enum brw_reg_type i = 0; i <= BRW_REGISTER_TYPE_LAST; i++) { + if (gen4_hw_type[i].reg_type == hw_type) { + return i; + } + } + } + unreachable("not reached"); +} + +/** * Return the element size given a hardware register type and file. * * The hardware encoding may depend on whether the value is an immediate. diff --git a/src/intel/compiler/brw_reg_type.h b/src/intel/compiler/brw_reg_type.h index 3e654eedc47..a21bad5b158 100644 --- a/src/intel/compiler/brw_reg_type.h +++ b/src/intel/compiler/brw_reg_type.h @@ -63,6 +63,10 @@ unsigned brw_reg_type_to_hw_type(const struct gen_device_info *devinfo, enum brw_reg_file file, enum brw_reg_type type); +enum brw_reg_type +brw_hw_type_to_reg_type(const struct gen_device_info *devinfo, + enum brw_reg_file file, unsigned hw_type); + #define brw_element_size(devinfo, inst, operand) \ brw_hw_reg_type_to_size(devinfo, \ brw_inst_ ## operand ## _reg_file(devinfo, inst), \ |