Auto-generate boilerplate for 'impl InstructionData'.
Accessors for shared fields and multiple results can be generated automatically. Add a 'boxed_storage' flag to the instruction format definitions to enable generated code to access 'data'.
This commit is contained in:
@@ -384,6 +384,9 @@ class InstructionFormat(object):
|
||||
enums.
|
||||
:param multiple_results: Set to `True` if this instruction format allows
|
||||
more than one result to be produced.
|
||||
:param boxed_storage: Set to `True` is this instruction format requires a
|
||||
`data: Box<...>` pointer to additional storage in its `InstructionData`
|
||||
variant.
|
||||
"""
|
||||
|
||||
# Map (multiple_results, kind, kind, ...) -> InstructionFormat
|
||||
@@ -396,6 +399,7 @@ class InstructionFormat(object):
|
||||
self.name = kwargs.get('name', None)
|
||||
self.kinds = kinds
|
||||
self.multiple_results = kwargs.get('multiple_results', False)
|
||||
self.boxed_storage = kwargs.get('boxed_storage', False)
|
||||
# Compute a signature for the global registry.
|
||||
sig = (self.multiple_results,) + kinds
|
||||
if sig in InstructionFormat._registry:
|
||||
|
||||
@@ -23,11 +23,12 @@ Binary = InstructionFormat(value, value)
|
||||
BinaryImm = InstructionFormat(value, imm64)
|
||||
BinaryImmRev = InstructionFormat(imm64, value)
|
||||
|
||||
Jump = InstructionFormat(ebb, variable_args)
|
||||
Branch = InstructionFormat(value, ebb, variable_args)
|
||||
Jump = InstructionFormat(ebb, variable_args, boxed_storage=True)
|
||||
Branch = InstructionFormat(value, ebb, variable_args, boxed_storage=True)
|
||||
BranchTable = InstructionFormat(value, jump_table)
|
||||
|
||||
Call = InstructionFormat(function, variable_args, multiple_results=True)
|
||||
Call = InstructionFormat(
|
||||
function, variable_args, multiple_results=True, boxed_storage=True)
|
||||
|
||||
# Finally extract the names of global variables in this module.
|
||||
InstructionFormat.extract_names(globals())
|
||||
|
||||
Reference in New Issue
Block a user