mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-03-22 09:30:38 +01:00
nir: support intrinsic indicies larger than 32 bits
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40299>
This commit is contained in:
parent
abfd6a4df9
commit
4ba581887e
3 changed files with 18 additions and 7 deletions
|
|
@ -34,9 +34,13 @@ src3 = ('src', 3)
|
|||
src4 = ('src', 4)
|
||||
|
||||
class Index(object):
|
||||
def __init__(self, c_data_type, name):
|
||||
def __init__(self, c_data_type, name, size):
|
||||
# 64bit non struct types are possible, but intrinsics set/get
|
||||
# need to be updated for that.
|
||||
assert "struct" in c_data_type or size == 1
|
||||
self.c_data_type = c_data_type
|
||||
self.name = name
|
||||
self.size = size
|
||||
|
||||
class Intrinsic(object):
|
||||
"""Class that represents all the information about an intrinsic opcode.
|
||||
|
|
@ -83,7 +87,14 @@ class Intrinsic(object):
|
|||
self.has_dest = (dest_components >= 0)
|
||||
self.dest_components = dest_components
|
||||
self.num_indices = len(indices)
|
||||
self.num_index_slots = sum([idx.size for idx in indices])
|
||||
self.indices = indices
|
||||
self.index_map = []
|
||||
prefix = 0
|
||||
for idx in indices:
|
||||
self.index_map.append(prefix + 1)
|
||||
prefix += idx.size
|
||||
assert prefix <= 8
|
||||
self.flags = flags
|
||||
self.sysval = sysval
|
||||
self.bit_sizes = bit_sizes if isinstance(bit_sizes, list) else []
|
||||
|
|
@ -104,8 +115,8 @@ QUADGROUP_FLAGS = [CAN_ELIMINATE, QUADGROUP]
|
|||
INTR_INDICES = []
|
||||
INTR_OPCODES = {}
|
||||
|
||||
def index(c_data_type, name):
|
||||
idx = Index(c_data_type, name)
|
||||
def index(c_data_type, name, size = 1):
|
||||
idx = Index(c_data_type, name, size)
|
||||
INTR_INDICES.append(idx)
|
||||
globals()[name.upper()] = idx
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ const nir_intrinsic_info nir_intrinsic_infos[nir_num_intrinsics] = {
|
|||
.dest_bit_sizes = ${hex(reduce(operator.or_, opcode.bit_sizes, 0))},
|
||||
.bit_size_src = ${opcode.bit_size_src},
|
||||
.num_indices = ${opcode.num_indices},
|
||||
.num_index_slots = ${opcode.num_indices},
|
||||
.num_index_slots = ${opcode.num_index_slots},
|
||||
% if opcode.indices:
|
||||
.indices = {
|
||||
% for i in range(len(opcode.indices)):
|
||||
|
|
@ -50,7 +50,7 @@ const nir_intrinsic_info nir_intrinsic_infos[nir_num_intrinsics] = {
|
|||
},
|
||||
.index_map = {
|
||||
% for i in range(len(opcode.indices)):
|
||||
[NIR_INTRINSIC_${opcode.indices[i].name.upper()}] = ${i + 1},
|
||||
[NIR_INTRINSIC_${opcode.indices[i].name.upper()}] = ${opcode.index_map[i]},
|
||||
% endfor
|
||||
},
|
||||
% endif
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ nir_intrinsic_${name}(const nir_intrinsic_instr *instr)
|
|||
assert(info->index_map[${enum}] > 0);
|
||||
% if "struct" in data_type:
|
||||
${data_type} res;
|
||||
STATIC_ASSERT(sizeof(instr->const_index[0]) == sizeof(res));
|
||||
STATIC_ASSERT(sizeof(instr->const_index[0]) * ${index.size} == sizeof(res));
|
||||
memcpy(&res, &instr->const_index[info->index_map[${enum}] - 1], sizeof(res));
|
||||
return res;
|
||||
% else:
|
||||
|
|
@ -54,7 +54,7 @@ nir_intrinsic_set_${name}(nir_intrinsic_instr *instr, ${data_type} val)
|
|||
const nir_intrinsic_info *info = &nir_intrinsic_infos[instr->intrinsic];
|
||||
assert(info->index_map[${enum}] > 0);
|
||||
% if "struct" in data_type:
|
||||
STATIC_ASSERT(sizeof(instr->const_index[0]) == sizeof(val));
|
||||
STATIC_ASSERT(sizeof(instr->const_index[0]) * ${index.size} == sizeof(val));
|
||||
/* NOTE: gcc has a a false positive here, silenced with the pragmas */
|
||||
PRAGMA_DIAGNOSTIC_PUSH
|
||||
PRAGMA_DIAGNOSTIC_IGNORED_GCC(-Wstringop-overflow)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue