intel/brw: Add new encode/decode for use with brw_data_type_float/int

Rework:
 * Sushma: Add BF in brw_data_type_encode, brw_data_type_decode

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39007>
This commit is contained in:
Jordan Justen
2024-08-17 20:56:52 -07:00
committed by Marge Bot
parent 46e843f76e
commit 0088aae481
2 changed files with 76 additions and 0 deletions

View File

@@ -271,6 +271,75 @@ brw_type_decode_for_3src(const struct intel_device_info *devinfo,
}
}
/**
* Convert a brw_reg_type enumeration value into the hardware representation
* for the newer 3-bit data type with separate enums for float vs integer.
*/
unsigned
brw_data_type_encode(const struct intel_device_info *devinfo,
enum brw_reg_type type)
{
static const struct {
uint8_t ty:5;
bool invalid:1;
} map[] = {
[0 ... BRW_TYPE_LAST] = { .invalid = true },
[BRW_TYPE_UB] = { BRW_TYPE_INT_UB },
[BRW_TYPE_UW] = { BRW_TYPE_INT_UW },
[BRW_TYPE_UD] = { BRW_TYPE_INT_UD },
[BRW_TYPE_UQ] = { BRW_TYPE_INT_UQ },
[BRW_TYPE_B] = { BRW_TYPE_INT_B },
[BRW_TYPE_W] = { BRW_TYPE_INT_W },
[BRW_TYPE_D] = { BRW_TYPE_INT_D },
[BRW_TYPE_Q] = { BRW_TYPE_INT_Q },
[BRW_TYPE_HF] = { BRW_TYPE_FLOAT_HF },
[BRW_TYPE_F] = { BRW_TYPE_FLOAT_F },
[BRW_TYPE_DF] = { BRW_TYPE_FLOAT_DF },
[BRW_TYPE_BF] = { BRW_TYPE_FLOAT_BF },
};
if (type < ARRAY_SIZE(map) && !map[type].invalid) {
return map[type].ty;
} else {
UNREACHABLE("Unsupported brw_reg_type!");
return brw_type_is_float(type) ? BRW_TYPE_FLOAT_F : BRW_TYPE_INT_UD;
}
}
/**
* Convert a brw_reg_type enumeration value into the hardware representation
* for the newer 3-bit data type with separate enums for float vs integer.
*/
enum brw_reg_type
brw_data_type_decode(const struct intel_device_info *devinfo,
unsigned data_type, bool exec_type)
{
static const uint8_t map[2][8] = {
[0 /* int exec_type */] = {
[0 ... 7] = BRW_TYPE_INVALID,
[BRW_TYPE_INT_UB] = BRW_TYPE_UB,
[BRW_TYPE_INT_UW] = BRW_TYPE_UW,
[BRW_TYPE_INT_UD] = BRW_TYPE_UD,
[BRW_TYPE_INT_UQ] = BRW_TYPE_UQ,
[BRW_TYPE_INT_B] = BRW_TYPE_B,
[BRW_TYPE_INT_W] = BRW_TYPE_W,
[BRW_TYPE_INT_D] = BRW_TYPE_D,
[BRW_TYPE_INT_Q] = BRW_TYPE_Q,
},
[1 /* float exec_type */] = {
[0 ... 7] = BRW_TYPE_INVALID,
[BRW_TYPE_FLOAT_HF] = BRW_TYPE_HF,
[BRW_TYPE_FLOAT_F] = BRW_TYPE_F,
[BRW_TYPE_FLOAT_DF] = BRW_TYPE_DF,
[BRW_TYPE_FLOAT_BF] = BRW_TYPE_BF,
},
};
STATIC_ASSERT(ARRAY_SIZE(map) == 2 && ARRAY_SIZE(map[0]) == 8);
assert(data_type < ARRAY_SIZE(map[0]));
return map[exec_type][data_type];
}
/**
* Converts a BRW_TYPE_* enum to a short string (F, UD, and so on).
*

View File

@@ -231,6 +231,13 @@ enum brw_reg_type
brw_type_decode_for_3src(const struct intel_device_info *devinfo,
unsigned hw_type, unsigned exec_type);
unsigned
brw_data_type_encode(const struct intel_device_info *devinfo,
enum brw_reg_type type);
enum brw_reg_type
brw_data_type_decode(const struct intel_device_info *devinfo,
unsigned data_type, bool exec_type);
const char *
brw_reg_type_to_letters(enum brw_reg_type type);