}[self]
def generate(self, entries):
- def ppc_svp64_h(entries):
+ def ppc_svp64_h(entries, num_entries):
yield from DISCLAIMER
yield ""
yield f"svp64_record_{name}_opsel(const struct svp64_record *record);"
yield ""
- yield "extern const struct svp64_entry svp64_entries[];"
- yield "extern const unsigned int svp64_num_entries;"
+ yield from entries.__class__.c_var("svp64_entries", prefix="extern const ", suffix=";")
+ yield from num_entries.__class__.c_var("svp64_num_entries", prefix="extern const ", suffix=";")
yield ""
yield f"#define SVP64_NAME_MAX {max(map(lambda entry: len(entry.name), entries))}"
yield f"#endif /* {self.name} */"
yield ""
- def ppc_svp64_opc_c(entries):
+ def ppc_svp64_opc_c(entries, num_entries):
yield from DISCLAIMER
yield ""
CROutSel.WHOLE_REG: "FXM",
})
- yield "const struct svp64_entry svp64_entries[] = {"
- for (index, entry) in enumerate(entries):
- yield from indent(entry.c_value(prefix=f"[{index}] = ", suffix=","))
- yield f"}};"
+ yield from entries.__class__.c_var("svp64_entries", prefix="const ", suffix=" = \\")
+ yield from entries.c_value(prefix="", suffix=";")
yield ""
-
- yield "const unsigned int svp64_num_entries = \\"
- yield " sizeof (svp64_entries) / sizeof (svp64_entries[0]);"
+ yield from num_entries.__class__.c_var("svp64_num_entries", prefix="const ", suffix=" = \\")
+ yield from indent(num_entries.c_value(suffix=";"))
yield ""
+ entries = Entry[...](entries)
+ num_entries = Size("(sizeof (svp64_entries) / sizeof (svp64_entries[0])")
+
return {
Codegen.PPC_SVP64_H: ppc_svp64_h,
Codegen.PPC_SVP64_OPC_C: ppc_svp64_opc_c,
- }[self](entries)
+ }[self](entries, num_entries)
ISA = _SVP64RM()