From b2943e73797b6544e15ea43a14cf57b2275509d6 Mon Sep 17 00:00:00 2001 From: Dmitry Selyutin Date: Sun, 10 Apr 2022 19:52:00 +0000 Subject: [PATCH] sv_binutils: generate register categories mapping --- src/openpower/sv/sv_binutils.py | 51 +++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/openpower/sv/sv_binutils.py b/src/openpower/sv/sv_binutils.py index e11c9f47..8b3dbf6c 100644 --- a/src/openpower/sv/sv_binutils.py +++ b/src/openpower/sv/sv_binutils.py @@ -334,6 +334,18 @@ class Codegen(_enum.Enum): yield f"#define SVP64_NAME_MAX {max(map(lambda entry: len(entry.name), entries))}" yield "" + yield "enum svp64_reg_category {" + yield " SVP64_REG_CATEGORY_UNKNOWN," + yield " SVP64_REG_CATEGORY_GPR," + yield " SVP64_REG_CATEGORY_FPR," + yield " SVP64_REG_CATEGORY_CR_3BIT," + yield " SVP64_REG_CATEGORY_CR_5BIT," + yield "};" + yield "" + + yield "enum svp64_reg_category" + yield "svp64_reg_category(unsigned char type);" + yield "#ifdef __cplusplus" yield "}" yield "#endif" @@ -359,6 +371,45 @@ class Codegen(_enum.Enum): yield " sizeof (svp64_entries) / sizeof (svp64_entries[0]);" yield "" + yield "#ifndef BC" + yield "#define BC CRB" + yield "#endif" + yield "" + yield "enum svp64_reg_category" + yield "svp64_reg_category(unsigned char type)" + yield "{" + yield " size_t i;" + yield " static struct {" + yield " unsigned char type;" + yield " unsigned char category;" + yield " } const table[] = {" + yield " {BF , SVP64_REG_CATEGORY_CR_3BIT}," + yield " {BFA , SVP64_REG_CATEGORY_CR_3BIT}," + yield " {BA , SVP64_REG_CATEGORY_CR_5BIT}," + yield " {BB , SVP64_REG_CATEGORY_CR_5BIT}," + yield " {BC , SVP64_REG_CATEGORY_CR_5BIT}," + yield " {BI , SVP64_REG_CATEGORY_CR_5BIT}," + yield " {BT , SVP64_REG_CATEGORY_CR_5BIT}," + yield " {RA , SVP64_REG_CATEGORY_GPR}," + yield " {RB , SVP64_REG_CATEGORY_GPR}," + yield " {RC , SVP64_REG_CATEGORY_GPR}," + yield " {RS , SVP64_REG_CATEGORY_GPR}," + yield " {RT , SVP64_REG_CATEGORY_GPR}," + yield " {FRA , SVP64_REG_CATEGORY_FPR}," + yield " {FRB , SVP64_REG_CATEGORY_FPR}," + yield " {FRC , SVP64_REG_CATEGORY_FPR}," + yield " {FRS , SVP64_REG_CATEGORY_FPR}," + yield " {FRT , SVP64_REG_CATEGORY_FPR}," + yield " };" + yield "" + yield " for (i = 0; i < sizeof (table) / sizeof (table[0]); ++i) {" + yield " if (table[i].type == type)" + yield " return (enum svp64_reg_category)table[i].category;" + yield " }" + yield "" + yield " return SVP64_REG_CATEGORY_UNKNOWN;" + yield "}" + return { Codegen.PPC_SVP64_H: ppc_svp64_h, Codegen.PPC_SVP64_OPC_C: ppc_svp64_opc_c, -- 2.30.2