Avoid using 'members' and 'value_operands' in the legalizer.
Use the new Instruction fields instead.
This commit is contained in:
@@ -35,7 +35,7 @@ def unwrap_inst(iref, node, fmt):
|
|||||||
fmt.comment('Unwrap {}'.format(node))
|
fmt.comment('Unwrap {}'.format(node))
|
||||||
expr = node.expr
|
expr = node.expr
|
||||||
iform = expr.inst.format
|
iform = expr.inst.format
|
||||||
nvops = len(iform.value_operands)
|
nvops = iform.num_value_operands
|
||||||
|
|
||||||
# The tuple of locals we're extracting is `expr.args`.
|
# The tuple of locals we're extracting is `expr.args`.
|
||||||
with fmt.indented(
|
with fmt.indented(
|
||||||
@@ -50,31 +50,31 @@ def unwrap_inst(iref, node, fmt):
|
|||||||
fmt.line('{},'.format(m))
|
fmt.line('{},'.format(m))
|
||||||
if nvops == 1:
|
if nvops == 1:
|
||||||
fmt.line('arg,')
|
fmt.line('arg,')
|
||||||
elif nvops > 1:
|
elif nvops != 0:
|
||||||
fmt.line('args,')
|
fmt.line('args,')
|
||||||
fmt.line('..')
|
fmt.line('..')
|
||||||
fmt.outdented_line('} = dfg[inst] {')
|
fmt.outdented_line('} = dfg[inst] {')
|
||||||
# Generate the values for the tuple.
|
# Generate the values for the tuple.
|
||||||
outs = list()
|
outs = list()
|
||||||
prefix = 'data.' if iform.boxed_storage else ''
|
prefix = 'data.' if iform.boxed_storage else ''
|
||||||
for i, m in enumerate(iform.members):
|
for opnum, op in enumerate(expr.inst.ins):
|
||||||
if m:
|
if op.is_immediate():
|
||||||
outs.append(prefix + m)
|
n = expr.inst.imm_opnums.index(opnum)
|
||||||
else:
|
outs.append(prefix + iform.imm_members[n])
|
||||||
# This is a value operand.
|
elif op.is_value():
|
||||||
if nvops == 1:
|
if nvops == 1:
|
||||||
arg = prefix + 'arg'
|
arg = prefix + 'arg'
|
||||||
else:
|
else:
|
||||||
arg = '{}args[{}]'.format(
|
n = expr.inst.value_opnums.index(opnum)
|
||||||
prefix, iform.value_operands.index(i))
|
arg = '{}args[{}]'.format(prefix, n)
|
||||||
outs.append('dfg.resolve_aliases({})'.format(arg))
|
outs.append('dfg.resolve_aliases({})'.format(arg))
|
||||||
fmt.line('({})'.format(', '.join(outs)))
|
fmt.line('({})'.format(', '.join(outs)))
|
||||||
fmt.outdented_line('} else {')
|
fmt.outdented_line('} else {')
|
||||||
fmt.line('unreachable!("bad instruction format")')
|
fmt.line('unreachable!("bad instruction format")')
|
||||||
|
|
||||||
# Get the types of any variables where it is needed.
|
# Get the types of any variables where it is needed.
|
||||||
for i in iform.value_operands:
|
for opnum in expr.inst.value_opnums:
|
||||||
v = expr.args[i]
|
v = expr.args[opnum]
|
||||||
if isinstance(v, Var) and v.has_free_typevar():
|
if isinstance(v, Var) and v.has_free_typevar():
|
||||||
fmt.line('let typeof_{0} = dfg.value_type({0});'.format(v))
|
fmt.line('let typeof_{0} = dfg.value_type({0});'.format(v))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user