Generate instruction unwrapping code for binemit recipes.

Generate code to:

- Unwrap the instruction and generate an error if the instruction format
  doesn't match the recipe.
- Look up the value locations of register and stack arguments.

The recipe_* functions in the ISA binemit modules now take these
unwrapped items as arguments.

Also add an optional `emit` argument to the EncRecipe constructor which
makes it possible to provide inline Rust code snippets for code
emission. This requires a lot less boilerplate than recipe_* functions.
This commit is contained in:
Jakob Stoklund Olesen
2017-07-07 11:33:38 -07:00
parent 27d272ade0
commit 528e6ff3f5
6 changed files with 435 additions and 419 deletions

View File

@@ -202,6 +202,7 @@ class EncRecipe(object):
:param: branch_range `(origin, bits)` range for branches.
:param: instp Instruction predicate.
:param: isap ISA predicate.
:param: emit Rust code for binary emission.
"""
def __init__(
@@ -213,7 +214,8 @@ class EncRecipe(object):
outs, # type: ConstraintSeq
branch_range=None, # type: BranchRange
instp=None, # type: PredNode
isap=None # type: PredNode
isap=None, # type: PredNode
emit=None # type: str
):
# type: (...) -> None
self.name = name
@@ -223,6 +225,7 @@ class EncRecipe(object):
self.branch_range = branch_range
self.instp = instp
self.isap = isap
self.emit = emit
if instp:
assert instp.predicate_context() == format
self.number = None # type: int