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:
Jakob Stoklund Olesen
2017-03-10 12:43:05 -08:00
parent 519eb1934b
commit 1b6702ceba
5 changed files with 35 additions and 77 deletions

View File

@@ -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())

View File

@@ -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

View File

@@ -76,10 +76,7 @@ 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
# Collect the leaf predicates.
leafs = set()
instp.predicate_leafs(leafs)
# All the leafs are FieldPredicate instances. Here we just care about

View File

@@ -87,16 +87,8 @@ 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)
else:
if f.boxed_storage:
capture = 'ref {}data, '.format(mut)
arg = '&{}data.args'.format(mut)
else:
capture = 'ref {}args, '.format(mut)
arg = 'args'
@@ -203,21 +195,11 @@ 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),')
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[{}]),'
@@ -511,12 +493,6 @@ 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)
# Create result values if necessary.

View File

@@ -41,10 +41,6 @@ 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))
@@ -58,17 +54,16 @@ def unwrap_inst(iref, node, fmt):
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 {')