Generate a RECIPE_PREDICATES table for each ISA.
It turns out that most encoding predicates are expressed as recipe predicates. This means that the encoding tables can be more compact since we can check the recipe predicate separately from individual instruction predicates, and the recipe number is already present in the table. - Don't combine recipe and encoding-specific predicates when creating an Encoding. Keep them separate. - Generate a table of recipe predicates with function pointers. Many of these are null. - Check any recipe predicate before accepting a recipe+bits pair. This has the effect of making almost all instruction predicates CODE_ALWAYS.
This commit is contained in:
@@ -23,6 +23,9 @@ try:
|
||||
# instructions.
|
||||
InstSpec = Union[MaybeBoundInst, Apply]
|
||||
BranchRange = Sequence[int]
|
||||
# A recipe predicate consisting of an ISA predicate and an instruction
|
||||
# predicate.
|
||||
RecipePred = Tuple[PredNode, PredNode]
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -62,7 +65,7 @@ class TargetISA(object):
|
||||
Finish the definition of a target ISA after adding all CPU modes and
|
||||
settings.
|
||||
|
||||
This computes some derived properties that are used in multilple
|
||||
This computes some derived properties that are used in multiple
|
||||
places.
|
||||
|
||||
:returns self:
|
||||
@@ -86,6 +89,9 @@ class TargetISA(object):
|
||||
recipe.number = len(rcps)
|
||||
rcps.add(recipe)
|
||||
self.all_recipes.append(recipe)
|
||||
# Make sure ISA predicates are registered.
|
||||
if recipe.isap:
|
||||
self.settings.number_predicate(recipe.isap)
|
||||
|
||||
def _collect_predicates(self):
|
||||
# type: () -> None
|
||||
@@ -336,6 +342,19 @@ class EncRecipe(object):
|
||||
o2i[o] = i
|
||||
return (i2o, o2i)
|
||||
|
||||
def recipe_pred(self):
|
||||
# type: () -> RecipePred
|
||||
"""
|
||||
Get the combined recipe predicate which includes both the ISA predicate
|
||||
and the instruction predicate.
|
||||
|
||||
Return `None` if this recipe has neither predicate.
|
||||
"""
|
||||
if self.isap is None and self.instp is None:
|
||||
return None
|
||||
else:
|
||||
return (self.isap, self.instp)
|
||||
|
||||
|
||||
class Encoding(object):
|
||||
"""
|
||||
@@ -386,9 +405,9 @@ class Encoding(object):
|
||||
|
||||
self.recipe = recipe
|
||||
self.encbits = encbits
|
||||
# Combine recipe predicates with the manually specified ones.
|
||||
self.instp = And.combine(recipe.instp, instp)
|
||||
self.isap = And.combine(recipe.isap, isap)
|
||||
# Record specific predicates. Note that the recipe also has predicates.
|
||||
self.instp = instp
|
||||
self.isap = isap
|
||||
|
||||
def __str__(self):
|
||||
# type: () -> str
|
||||
|
||||
Reference in New Issue
Block a user