Beispiel #1
0
def _render_h(fout):
    print("enum class OPC : uint8_t {", file=fout)
    last = 0
    print(f"    INVALID = 0x00,", file=fout)
    for opc in Opcode.Table.values():
        if opc.group != OPC_GENUS.BASE:
            continue
        if (opc.no & 0xff0) != last & 0xff0:
            print("", file=fout)
            last = opc.no

        name = opc.name.upper().replace(".", "_")
        if opc.kind == OPC_KIND.DIRECTIVE:
            name = "DIR_" + name[1:]
        print(f"    {name} = 0x{opc.no:02x},", file=fout)
    print("};", file=fout)

    # _render_enum("OpcodeFamily", ["OF.INVALID", "OF.DIRECTIVE"] +
    #             list(OFS_ALL))
    # _render_enum("OperandKind", ["OK.INVALID"] +
    #             [x.upper() for x in OKS_ALL])
    for cls in [OPC_GENUS, FUN_KIND, MEM_KIND, TC, OPC_KIND, DK, OP_KIND]:
        cgen.RenderEnum(cgen.NameValues(cls), f"class {cls.__name__} : uint8_t",
                        fout)
    cgen.RenderEnum(cgen.NameValues(OA), f"{OA.__name__} : uint16_t", fout)
Beispiel #2
0
def _EmitCodeH(fout):
    print(f"constexpr const unsigned MAX_OPERANDS = {MAX_OPERANDS};", file=fout)
    print(f"constexpr const unsigned MAX_BIT_RANGES = {MAX_BIT_RANGES};", file=fout)
    cgen.RenderEnum(cgen.NameValues(FK), "class FK : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(OK), "class OK : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(SR_UPDATE), "class SR_UPDATE : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(MEM_WIDTH), "class MEM_WIDTH : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(OPC_FLAG), "OPC_FLAG", fout)
    cgen.RenderEnum(cgen.NameValues(PRED), "class PRED : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(REG), "class REG : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(SREG), "class SREG : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(DREG), "class DREG : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(SHIFT), "class SHIFT : uint8_t", fout)
    opcodes = list(sorted(Opcode.name_to_opcode.keys()))
    # note we sneak in an invalid first entry
    _render_enum_simple(["invalid"] + opcodes, "enum class OPC : uint16_t")
Beispiel #3
0
def _EmitCodeH(fout):
    print(f"constexpr const unsigned MAX_OPERAND_COUNT = {MAX_OPERAND_COUNT};",
          file=fout)
    print(
        f"constexpr const unsigned MAX_INSTRUCTION_LENGTH = {MAX_INSTRUCTION_LENGTH};",
        file=fout)
    print(
        f"constexpr const unsigned MAX_INSTRUCTION_LENGTH_WITH_PREFIXES = {MAX_INSTRUCTION_LENGTH_WITH_PREFIXES};",
        file=fout)
    print(
        f"constexpr const unsigned MAX_INSTRUCTION_NAME_LENGTH = {MAX_INSTRUCTION_NAME_LENGTH};",
        file=fout)
    print(f"constexpr const unsigned MAX_FINGERPRINT = {MAX_FINGERPRINT};",
          file=fout)

    cgen.RenderEnum(cgen.NameValues(MEM_MODE), "class MEM_WIDTH : uint8_t",
                    fout)
    cgen.RenderEnum(cgen.NameValues(OK), "class OK : uint8_t", fout)
Beispiel #4
0
def _EmitCodeH(fout):
    for cls in [IMM_KIND, PARAM]:
        cgen.RenderEnum(cgen.NameValues(cls), f"class {cls.__name__} : uint8_t", fout)
Beispiel #5
0
def EmitEnumsH(fout):
    for cls, info in CLASSES.items():
        if info[0] is UNSUPPORTED: continue
        name = f"class {cls.__name__} : uint{info[1]}_t"
        cgen.RenderEnum(cgen.NameValues(cls), name, fout)
Beispiel #6
0
def _EmitCodeH(fout):
    cgen.RenderEnum(cgen.NameValues(OK), "class OK : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(SR_UPDATE), "class SR_UPDATE : uint8_t",
                    fout)
    cgen.RenderEnum(cgen.NameValues(BRK), "class BitRangeKind : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(MEM_WIDTH), "class MEM_WIDTH : uint8_t",
                    fout)
    cgen.RenderEnum(cgen.NameValues(OPC_FLAG), "OPC_FLAG", fout)
    cgen.RenderEnum(cgen.NameValues(PRED), "class PRED : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(REG), "class REG : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(SREG), "class SREG : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(DREG), "class DREG : uint8_t", fout)
    cgen.RenderEnum(cgen.NameValues(ADDR_MODE), "class ADDR_MODE : uint8_t",
                    fout)
    cgen.RenderEnum(cgen.NameValues(SHIFT), "class SHIFT : uint8_t", fout)
    opcodes = [
        opc.NameForEnum() for opc in _get_grouped_opcodes(_INS_CLASSIFIER)
    ]
    # note we sneak in an invalid first entry
    _render_enum_simple(["invalid"] + opcodes, "enum class OPC : uint16_t")