mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 11:18:08 +02:00
pan/bi: Union modifiers from across variants
itertools.groupby depends on sorting, so this code was quietly broken on cases like FADD.v2f16. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10392>
This commit is contained in:
parent
394f3f8b74
commit
d35075a7be
1 changed files with 12 additions and 6 deletions
|
|
@ -245,13 +245,15 @@ def simplify_to_ir(ins):
|
|||
}
|
||||
|
||||
|
||||
def combine_ir_variants(instructions, v):
|
||||
variants = sum([[simplify_to_ir(Q[1]) for Q in instructions[x]] for x in v], [])
|
||||
def combine_ir_variants(instructions, key):
|
||||
seen = [op for op in instructions.keys() if op[1:] == key]
|
||||
variant_objs = [[simplify_to_ir(Q[1]) for Q in instructions[x]] for x in seen]
|
||||
variants = sum(variant_objs, [])
|
||||
|
||||
# Accumulate modifiers across variants
|
||||
modifiers = {}
|
||||
|
||||
for s in variants:
|
||||
for s in variants[0:]:
|
||||
# Check consistency
|
||||
assert(s['srcs'] == variants[0]['srcs'])
|
||||
assert(s['dests'] == variants[0]['dests'])
|
||||
|
|
@ -271,15 +273,19 @@ def combine_ir_variants(instructions, v):
|
|||
'dests': variants[0]['dests'],
|
||||
'staging': variants[0]['staging'],
|
||||
'immediates': sorted(variants[0]['immediates']),
|
||||
'modifiers': modifiers
|
||||
'modifiers': modifiers,
|
||||
'v': len(variants),
|
||||
'ir': variants
|
||||
}
|
||||
|
||||
# Partition instructions to mnemonics, considering units and variants
|
||||
# equivalent.
|
||||
|
||||
def partition_mnemonics(instructions):
|
||||
partitions = itertools.groupby(instructions, lambda x: x[1:])
|
||||
return { k: combine_ir_variants(instructions, v) for (k, v) in partitions }
|
||||
key_func = lambda x: x[1:]
|
||||
sorted_instrs = sorted(instructions.keys(), key = key_func)
|
||||
partitions = itertools.groupby(sorted_instrs, key_func)
|
||||
return { k: combine_ir_variants(instructions, k) for k, v in partitions }
|
||||
|
||||
# Generate modifier lists, by accumulating all the possible modifiers, and
|
||||
# deduplicating thus assigning canonical enum values. We don't try _too_ hard
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue