Move encoding-related information into an EncInfo struct.

The tables returned by recipe_names() and recipe_constraints() are now
collected into an EncInfo struct that is available from
TargetIsa::encoding_info(). This is equivalent to the register bank
tables available fro TargetIsa::register_info().

This cleans of the TargetIsa interface and makes it easier to add
encoding-related information.
This commit is contained in:
Jakob Stoklund Olesen
2017-04-05 10:07:19 -07:00
parent 72cb6459a9
commit f47c62ba8c
15 changed files with 88 additions and 83 deletions

View File

@@ -450,7 +450,7 @@ def emit_recipe_names(isa, fmt):
This is used for pretty-printing encodings.
"""
with fmt.indented(
'pub static RECIPE_NAMES: [&\'static str; {}] = ['
'static RECIPE_NAMES: [&\'static str; {}] = ['
.format(len(isa.all_recipes)), '];'):
for r in isa.all_recipes:
fmt.line('"{}",'.format(r.name))
@@ -465,7 +465,7 @@ def emit_recipe_constraints(isa, fmt):
properly encoded.
"""
with fmt.indented(
'pub static RECIPE_CONSTRAINTS: [RecipeConstraints; {}] = ['
'static RECIPE_CONSTRAINTS: [RecipeConstraints; {}] = ['
.format(len(isa.all_recipes)), '];'):
for r in isa.all_recipes:
fmt.comment(r.name)
@@ -536,6 +536,11 @@ def gen_isa(isa, fmt):
emit_recipe_names(isa, fmt)
emit_recipe_constraints(isa, fmt)
# Finally, tie it all together in an `EncInfo`.
with fmt.indented('pub static INFO: EncInfo = EncInfo {', '};'):
fmt.line('constraints: &RECIPE_CONSTRAINTS,')
fmt.line('names: &RECIPE_NAMES,')
def generate(isas, out_dir):
# type: (Sequence[TargetISA], str) -> None