Remove the value_list and boxed_storage format flags.
The value_list flag can be inferred from the presence of VARIABLE_ARGS in the operand list. The boxed_storage flag is obsolete. We don't need boxed storage anywhere no that we have value lists instead.
This commit is contained in:
@@ -32,8 +32,7 @@ Ternary = InstructionFormat(VALUE, VALUE, VALUE, typevar_operand=1)
|
||||
|
||||
# Catch-all for instructions with many outputs and inputs and no immediate
|
||||
# operands.
|
||||
MultiAry = InstructionFormat(
|
||||
VARIABLE_ARGS, multiple_results=True, value_list=True)
|
||||
MultiAry = InstructionFormat(VARIABLE_ARGS, multiple_results=True)
|
||||
|
||||
InsertLane = InstructionFormat(VALUE, ('lane', uimm8), VALUE)
|
||||
ExtractLane = InstructionFormat(VALUE, ('lane', uimm8))
|
||||
@@ -41,15 +40,15 @@ ExtractLane = InstructionFormat(VALUE, ('lane', uimm8))
|
||||
IntCompare = InstructionFormat(intcc, VALUE, VALUE)
|
||||
FloatCompare = InstructionFormat(floatcc, VALUE, VALUE)
|
||||
|
||||
Jump = InstructionFormat(ebb, VARIABLE_ARGS, value_list=True)
|
||||
Branch = InstructionFormat(VALUE, ebb, VARIABLE_ARGS, value_list=True)
|
||||
Jump = InstructionFormat(ebb, VARIABLE_ARGS)
|
||||
Branch = InstructionFormat(VALUE, ebb, VARIABLE_ARGS)
|
||||
BranchTable = InstructionFormat(VALUE, jump_table)
|
||||
|
||||
Call = InstructionFormat(
|
||||
func_ref, VARIABLE_ARGS, multiple_results=True, value_list=True)
|
||||
func_ref, VARIABLE_ARGS, multiple_results=True)
|
||||
IndirectCall = InstructionFormat(
|
||||
sig_ref, VALUE, VARIABLE_ARGS,
|
||||
multiple_results=True, value_list=True)
|
||||
multiple_results=True)
|
||||
|
||||
# Finally extract the names of global variables in this module.
|
||||
InstructionFormat.extract_names(globals())
|
||||
|
||||
@@ -42,11 +42,6 @@ class InstructionFormat(object):
|
||||
enums.
|
||||
:param multiple_results: Set to `True` if this instruction format allows
|
||||
more than one result to be produced.
|
||||
:param value_list: Set to `True` if this instruction format uses a
|
||||
`ValueList` member to store its value operands.
|
||||
:param boxed_storage: Set to `True` is this instruction format requires a
|
||||
`data: Box<...>` pointer to additional storage in its `InstructionData`
|
||||
variant.
|
||||
:param typevar_operand: Index of the value input operand that is used to
|
||||
infer the controlling type variable. By default, this is `0`, the first
|
||||
`value` operand. The index is relative to the values only, ignoring
|
||||
@@ -63,8 +58,6 @@ class InstructionFormat(object):
|
||||
# type: (*Union[OperandKind, Tuple[str, OperandKind]], **Any) -> None # noqa
|
||||
self.name = kwargs.get('name', None) # type: str
|
||||
self.multiple_results = kwargs.get('multiple_results', False)
|
||||
self.has_value_list = kwargs.get('value_list', False)
|
||||
self.boxed_storage = kwargs.get('boxed_storage', False)
|
||||
|
||||
# Struct member names for the immediate operands. All other instruction
|
||||
# operands are values or variable argument lists. They are all handled
|
||||
@@ -73,6 +66,8 @@ class InstructionFormat(object):
|
||||
# The number of value operands stored in the format, or `None` when
|
||||
# `has_value_list` is set.
|
||||
self.num_value_operands = 0
|
||||
# Does this format use a value list for storing value operands?
|
||||
self.has_value_list = False
|
||||
# Operand kinds for the immediate operands.
|
||||
self.imm_kinds = tuple(self._process_member_names(kinds))
|
||||
|
||||
@@ -122,8 +117,7 @@ class InstructionFormat(object):
|
||||
if k is VALUE:
|
||||
self.num_value_operands += 1
|
||||
elif k is VARIABLE_ARGS:
|
||||
# We require a value list for storage of variable arguments.
|
||||
assert self.has_value_list, "Need a value list"
|
||||
self.has_value_list = True
|
||||
else:
|
||||
self.imm_members.append(member)
|
||||
yield k
|
||||
@@ -234,7 +228,4 @@ class FormatField(object):
|
||||
|
||||
def rust_name(self):
|
||||
# type: () -> str
|
||||
if self.format.boxed_storage:
|
||||
return 'data.' + self.name
|
||||
else:
|
||||
return self.name
|
||||
return self.name
|
||||
|
||||
@@ -76,15 +76,12 @@ def emit_instp(instp, fmt):
|
||||
iform = instp.predicate_context()
|
||||
|
||||
# Which fields do we need in the InstructionData pattern match?
|
||||
if iform.boxed_storage:
|
||||
fields = 'ref data'
|
||||
else:
|
||||
# Collect the leaf predicates
|
||||
leafs = set()
|
||||
instp.predicate_leafs(leafs)
|
||||
# All the leafs are FieldPredicate instances. Here we just care about
|
||||
# the field names.
|
||||
fields = ', '.join(sorted(set(p.field.name for p in leafs)))
|
||||
# Collect the leaf predicates.
|
||||
leafs = set()
|
||||
instp.predicate_leafs(leafs)
|
||||
# All the leafs are FieldPredicate instances. Here we just care about
|
||||
# the field names.
|
||||
fields = ', '.join(sorted(set(p.field.name for p in leafs)))
|
||||
|
||||
with fmt.indented('{} => {{'.format(instp.number), '}'):
|
||||
with fmt.indented(
|
||||
|
||||
@@ -87,19 +87,11 @@ def gen_arguments_method(fmt, is_mut):
|
||||
arg = '&{}[]'.format(mut)
|
||||
capture = ''
|
||||
elif f.num_value_operands == 1:
|
||||
if f.boxed_storage:
|
||||
capture = 'ref {}data, '.format(mut)
|
||||
arg = '{}(&{}data.arg)'.format(rslice, mut)
|
||||
else:
|
||||
capture = 'ref {}arg, '.format(mut)
|
||||
arg = '{}(arg)'.format(rslice)
|
||||
capture = 'ref {}arg, '.format(mut)
|
||||
arg = '{}(arg)'.format(rslice)
|
||||
else:
|
||||
if f.boxed_storage:
|
||||
capture = 'ref {}data, '.format(mut)
|
||||
arg = '&{}data.args'.format(mut)
|
||||
else:
|
||||
capture = 'ref {}args, '.format(mut)
|
||||
arg = 'args'
|
||||
capture = 'ref {}args, '.format(mut)
|
||||
arg = 'args'
|
||||
fmt.line(
|
||||
'{} {{ {} .. }} => {},'
|
||||
.format(n, capture, arg))
|
||||
@@ -203,25 +195,15 @@ def gen_instruction_data_impl(fmt):
|
||||
'args.get({}, pool),'.format(n, i))
|
||||
elif f.num_value_operands == 1:
|
||||
# We have a single value operand called 'arg'.
|
||||
if f.boxed_storage:
|
||||
fmt.line(
|
||||
n + ' { ref data, .. } => Some(data.arg),')
|
||||
else:
|
||||
fmt.line(n + ' { arg, .. } => Some(arg),')
|
||||
fmt.line(n + ' { arg, .. } => Some(arg),')
|
||||
else:
|
||||
# We have multiple value operands and an array `args`.
|
||||
# Which `args` index to use?
|
||||
i = f.typevar_operand
|
||||
if f.boxed_storage:
|
||||
fmt.line(
|
||||
n +
|
||||
' { ref data, .. } => ' +
|
||||
('Some(data.args[{}]),'.format(i)))
|
||||
else:
|
||||
fmt.line(
|
||||
n +
|
||||
' {{ ref args, .. }} => Some(args[{}]),'
|
||||
.format(i))
|
||||
fmt.line(
|
||||
n +
|
||||
' {{ ref args, .. }} => Some(args[{}]),'
|
||||
.format(i))
|
||||
|
||||
fmt.doc_comment(
|
||||
"""
|
||||
@@ -511,13 +493,7 @@ def gen_format_constructor(iform, fmt):
|
||||
fmt.line('ty: {},'.format(result_type))
|
||||
if iform.multiple_results:
|
||||
fmt.line('second_result: None.into(),')
|
||||
if iform.boxed_storage:
|
||||
with fmt.indented(
|
||||
'data: Box::new(instructions::{}Data {{'
|
||||
.format(iform.name), '}),'):
|
||||
gen_member_inits(iform, fmt)
|
||||
else:
|
||||
gen_member_inits(iform, fmt)
|
||||
gen_member_inits(iform, fmt)
|
||||
|
||||
# Create result values if necessary.
|
||||
if iform.multiple_results:
|
||||
|
||||
@@ -41,34 +41,29 @@ def unwrap_inst(iref, node, fmt):
|
||||
with fmt.indented(
|
||||
'let ({}) = if let InstructionData::{} {{'
|
||||
.format(', '.join(map(str, expr.args)), iform.name), '};'):
|
||||
if iform.boxed_storage:
|
||||
# This format indirects to a largish `data` struct.
|
||||
fmt.line('ref data,')
|
||||
else:
|
||||
# Fields are encoded directly.
|
||||
for m in iform.imm_members:
|
||||
fmt.line('{},'.format(m))
|
||||
if nvops == 1:
|
||||
fmt.line('arg,')
|
||||
elif iform.has_value_list or nvops > 1:
|
||||
fmt.line('ref args,')
|
||||
# Fields are encoded directly.
|
||||
for m in iform.imm_members:
|
||||
fmt.line('{},'.format(m))
|
||||
if nvops == 1:
|
||||
fmt.line('arg,')
|
||||
elif iform.has_value_list or nvops > 1:
|
||||
fmt.line('ref args,')
|
||||
fmt.line('..')
|
||||
fmt.outdented_line('} = dfg[inst] {')
|
||||
if iform.has_value_list:
|
||||
fmt.line('let args = args.as_slice(&dfg.value_lists);')
|
||||
# Generate the values for the tuple.
|
||||
outs = list()
|
||||
prefix = 'data.' if iform.boxed_storage else ''
|
||||
for opnum, op in enumerate(expr.inst.ins):
|
||||
if op.is_immediate():
|
||||
n = expr.inst.imm_opnums.index(opnum)
|
||||
outs.append(prefix + iform.imm_members[n])
|
||||
outs.append(iform.imm_members[n])
|
||||
elif op.is_value():
|
||||
if nvops == 1:
|
||||
arg = prefix + 'arg'
|
||||
arg = 'arg'
|
||||
else:
|
||||
n = expr.inst.value_opnums.index(opnum)
|
||||
arg = '{}args[{}]'.format(prefix, n)
|
||||
arg = 'args[{}]'.format(n)
|
||||
outs.append('dfg.resolve_aliases({})'.format(arg))
|
||||
fmt.line('({})'.format(', '.join(outs)))
|
||||
fmt.outdented_line('} else {')
|
||||
|
||||
Reference in New Issue
Block a user