Add InstructionFormat.imm_fields.

Consolidate the imm_members and imm_kinds into this list so the
FormatField is the single definition of these properties.

This makes it easier to access the precomputed FormatFields
parametrically, avoiding going through getattr().

This is better for type checking too.
This commit is contained in:
Jakob Stoklund Olesen
2017-03-31 10:12:37 -07:00
parent b31ca83b91
commit 89ff979d75
5 changed files with 46 additions and 45 deletions

View File

@@ -43,8 +43,8 @@ def unwrap_inst(iref, node, fmt):
'let ({}) = if let InstructionData::{} {{'
.format(', '.join(map(str, expr.args)), iform.name), '};'):
# Fields are encoded directly.
for m in iform.imm_members:
fmt.line('{},'.format(m))
for f in iform.imm_fields:
fmt.line('{},'.format(f.member))
if nvops == 1:
fmt.line('arg,')
elif iform.has_value_list or nvops > 1:
@@ -58,7 +58,7 @@ def unwrap_inst(iref, node, fmt):
for opnum, op in enumerate(expr.inst.ins):
if op.is_immediate():
n = expr.inst.imm_opnums.index(opnum)
outs.append(iform.imm_members[n])
outs.append(iform.imm_fields[n].member)
elif op.is_value():
if nvops == 1:
arg = 'arg'