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 # Catch-all for instructions with many outputs and inputs and no immediate
# operands. # operands.
MultiAry = InstructionFormat( MultiAry = InstructionFormat(VARIABLE_ARGS, multiple_results=True)
VARIABLE_ARGS, multiple_results=True, value_list=True)
InsertLane = InstructionFormat(VALUE, ('lane', uimm8), VALUE) InsertLane = InstructionFormat(VALUE, ('lane', uimm8), VALUE)
ExtractLane = InstructionFormat(VALUE, ('lane', uimm8)) ExtractLane = InstructionFormat(VALUE, ('lane', uimm8))
@@ -41,15 +40,15 @@ ExtractLane = InstructionFormat(VALUE, ('lane', uimm8))
IntCompare = InstructionFormat(intcc, VALUE, VALUE) IntCompare = InstructionFormat(intcc, VALUE, VALUE)
FloatCompare = InstructionFormat(floatcc, VALUE, VALUE) FloatCompare = InstructionFormat(floatcc, VALUE, VALUE)
Jump = InstructionFormat(ebb, VARIABLE_ARGS, value_list=True) Jump = InstructionFormat(ebb, VARIABLE_ARGS)
Branch = InstructionFormat(VALUE, ebb, VARIABLE_ARGS, value_list=True) Branch = InstructionFormat(VALUE, ebb, VARIABLE_ARGS)
BranchTable = InstructionFormat(VALUE, jump_table) BranchTable = InstructionFormat(VALUE, jump_table)
Call = InstructionFormat( Call = InstructionFormat(
func_ref, VARIABLE_ARGS, multiple_results=True, value_list=True) func_ref, VARIABLE_ARGS, multiple_results=True)
IndirectCall = InstructionFormat( IndirectCall = InstructionFormat(
sig_ref, VALUE, VARIABLE_ARGS, sig_ref, VALUE, VARIABLE_ARGS,
multiple_results=True, value_list=True) multiple_results=True)
# Finally extract the names of global variables in this module. # Finally extract the names of global variables in this module.
InstructionFormat.extract_names(globals()) InstructionFormat.extract_names(globals())

View File

@@ -42,11 +42,6 @@ class InstructionFormat(object):
enums. enums.
:param multiple_results: Set to `True` if this instruction format allows :param multiple_results: Set to `True` if this instruction format allows
more than one result to be produced. 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 :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 infer the controlling type variable. By default, this is `0`, the first
`value` operand. The index is relative to the values only, ignoring `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 # type: (*Union[OperandKind, Tuple[str, OperandKind]], **Any) -> None # noqa
self.name = kwargs.get('name', None) # type: str self.name = kwargs.get('name', None) # type: str
self.multiple_results = kwargs.get('multiple_results', False) 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 # Struct member names for the immediate operands. All other instruction
# operands are values or variable argument lists. They are all handled # 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 # The number of value operands stored in the format, or `None` when
# `has_value_list` is set. # `has_value_list` is set.
self.num_value_operands = 0 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. # Operand kinds for the immediate operands.
self.imm_kinds = tuple(self._process_member_names(kinds)) self.imm_kinds = tuple(self._process_member_names(kinds))
@@ -122,8 +117,7 @@ class InstructionFormat(object):
if k is VALUE: if k is VALUE:
self.num_value_operands += 1 self.num_value_operands += 1
elif k is VARIABLE_ARGS: elif k is VARIABLE_ARGS:
# We require a value list for storage of variable arguments. self.has_value_list = True
assert self.has_value_list, "Need a value list"
else: else:
self.imm_members.append(member) self.imm_members.append(member)
yield k yield k
@@ -234,7 +228,4 @@ class FormatField(object):
def rust_name(self): def rust_name(self):
# type: () -> str # type: () -> str
if self.format.boxed_storage: return self.name
return 'data.' + self.name
else:
return self.name

View File

@@ -76,15 +76,12 @@ def emit_instp(instp, fmt):
iform = instp.predicate_context() iform = instp.predicate_context()
# Which fields do we need in the InstructionData pattern match? # Which fields do we need in the InstructionData pattern match?
if iform.boxed_storage: # Collect the leaf predicates.
fields = 'ref data' leafs = set()
else: instp.predicate_leafs(leafs)
# Collect the leaf predicates # All the leafs are FieldPredicate instances. Here we just care about
leafs = set() # the field names.
instp.predicate_leafs(leafs) fields = ', '.join(sorted(set(p.field.name for p in 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('{} => {{'.format(instp.number), '}'):
with fmt.indented( with fmt.indented(

View File

@@ -87,19 +87,11 @@ def gen_arguments_method(fmt, is_mut):
arg = '&{}[]'.format(mut) arg = '&{}[]'.format(mut)
capture = '' capture = ''
elif f.num_value_operands == 1: elif f.num_value_operands == 1:
if f.boxed_storage: capture = 'ref {}arg, '.format(mut)
capture = 'ref {}data, '.format(mut) arg = '{}(arg)'.format(rslice)
arg = '{}(&{}data.arg)'.format(rslice, mut)
else:
capture = 'ref {}arg, '.format(mut)
arg = '{}(arg)'.format(rslice)
else: else:
if f.boxed_storage: capture = 'ref {}args, '.format(mut)
capture = 'ref {}data, '.format(mut) arg = 'args'
arg = '&{}data.args'.format(mut)
else:
capture = 'ref {}args, '.format(mut)
arg = 'args'
fmt.line( fmt.line(
'{} {{ {} .. }} => {},' '{} {{ {} .. }} => {},'
.format(n, capture, arg)) .format(n, capture, arg))
@@ -203,25 +195,15 @@ def gen_instruction_data_impl(fmt):
'args.get({}, pool),'.format(n, i)) 'args.get({}, pool),'.format(n, i))
elif f.num_value_operands == 1: elif f.num_value_operands == 1:
# We have a single value operand called 'arg'. # We have a single value operand called 'arg'.
if f.boxed_storage: fmt.line(n + ' { arg, .. } => Some(arg),')
fmt.line(
n + ' { ref data, .. } => Some(data.arg),')
else:
fmt.line(n + ' { arg, .. } => Some(arg),')
else: else:
# We have multiple value operands and an array `args`. # We have multiple value operands and an array `args`.
# Which `args` index to use? # Which `args` index to use?
i = f.typevar_operand i = f.typevar_operand
if f.boxed_storage: fmt.line(
fmt.line( n +
n + ' {{ ref args, .. }} => Some(args[{}]),'
' { ref data, .. } => ' + .format(i))
('Some(data.args[{}]),'.format(i)))
else:
fmt.line(
n +
' {{ ref args, .. }} => Some(args[{}]),'
.format(i))
fmt.doc_comment( fmt.doc_comment(
""" """
@@ -511,13 +493,7 @@ def gen_format_constructor(iform, fmt):
fmt.line('ty: {},'.format(result_type)) fmt.line('ty: {},'.format(result_type))
if iform.multiple_results: if iform.multiple_results:
fmt.line('second_result: None.into(),') fmt.line('second_result: None.into(),')
if iform.boxed_storage: gen_member_inits(iform, fmt)
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. # Create result values if necessary.
if iform.multiple_results: if iform.multiple_results:

View File

@@ -41,34 +41,29 @@ def unwrap_inst(iref, node, fmt):
with fmt.indented( with fmt.indented(
'let ({}) = if let InstructionData::{} {{' 'let ({}) = if let InstructionData::{} {{'
.format(', '.join(map(str, expr.args)), iform.name), '};'): .format(', '.join(map(str, expr.args)), iform.name), '};'):
if iform.boxed_storage: # Fields are encoded directly.
# This format indirects to a largish `data` struct. for m in iform.imm_members:
fmt.line('ref data,') fmt.line('{},'.format(m))
else: if nvops == 1:
# Fields are encoded directly. fmt.line('arg,')
for m in iform.imm_members: elif iform.has_value_list or nvops > 1:
fmt.line('{},'.format(m)) fmt.line('ref args,')
if nvops == 1:
fmt.line('arg,')
elif iform.has_value_list or nvops > 1:
fmt.line('ref args,')
fmt.line('..') fmt.line('..')
fmt.outdented_line('} = dfg[inst] {') fmt.outdented_line('} = dfg[inst] {')
if iform.has_value_list: if iform.has_value_list:
fmt.line('let args = args.as_slice(&dfg.value_lists);') fmt.line('let args = args.as_slice(&dfg.value_lists);')
# Generate the values for the tuple. # Generate the values for the tuple.
outs = list() outs = list()
prefix = 'data.' if iform.boxed_storage else ''
for opnum, op in enumerate(expr.inst.ins): for opnum, op in enumerate(expr.inst.ins):
if op.is_immediate(): if op.is_immediate():
n = expr.inst.imm_opnums.index(opnum) n = expr.inst.imm_opnums.index(opnum)
outs.append(prefix + iform.imm_members[n]) outs.append(iform.imm_members[n])
elif op.is_value(): elif op.is_value():
if nvops == 1: if nvops == 1:
arg = prefix + 'arg' arg = 'arg'
else: else:
n = expr.inst.value_opnums.index(opnum) n = expr.inst.value_opnums.index(opnum)
arg = '{}args[{}]'.format(prefix, n) arg = 'args[{}]'.format(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 {')