From c8ecfb600eb709fd26c7ddc4dc9a6dda0a81317c Mon Sep 17 00:00:00 2001 From: angie Date: Tue, 5 Jul 2022 09:49:12 -0400 Subject: [PATCH] Expose Gpr registers enums to python --- rabbitizer/RegGprN32.pyi | 43 +++++++++++++++++++ rabbitizer/RegGprO32.pyi | 43 +++++++++++++++++++ rabbitizer/__init__.pyi | 3 ++ .../enums/registers/rabbitizer_enum_GprN32.c | 28 ++++++++++++ .../enums/registers/rabbitizer_enum_GprO32.c | 28 ++++++++++++ rabbitizer/rabbitizer_module.c | 2 + rabbitizer/rabbitizer_module.h | 3 ++ setup.py | 1 + 8 files changed, 151 insertions(+) create mode 100644 rabbitizer/RegGprN32.pyi create mode 100644 rabbitizer/RegGprO32.pyi create mode 100644 rabbitizer/enums/registers/rabbitizer_enum_GprN32.c create mode 100644 rabbitizer/enums/registers/rabbitizer_enum_GprO32.c diff --git a/rabbitizer/RegGprN32.pyi b/rabbitizer/RegGprN32.pyi new file mode 100644 index 0000000..5444352 --- /dev/null +++ b/rabbitizer/RegGprN32.pyi @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +# SPDX-FileCopyrightText: © 2022 Decompollaborate +# SPDX-License-Identifier: MIT + +from __future__ import annotations + +from .Enum import Enum + + +class RegGprN32: + zero: Enum + at: Enum + v0: Enum + v1: Enum + a0: Enum + a1: Enum + a2: Enum + a3: Enum + a4: Enum + a5: Enum + a6: Enum + a7: Enum + t0: Enum + t1: Enum + t2: Enum + t3: Enum + s0: Enum + s1: Enum + s2: Enum + s3: Enum + s4: Enum + s5: Enum + s6: Enum + s7: Enum + t8: Enum + t9: Enum + k0: Enum + k1: Enum + gp: Enum + sp: Enum + fp: Enum + ra: Enum diff --git a/rabbitizer/RegGprO32.pyi b/rabbitizer/RegGprO32.pyi new file mode 100644 index 0000000..f145ca3 --- /dev/null +++ b/rabbitizer/RegGprO32.pyi @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +# SPDX-FileCopyrightText: © 2022 Decompollaborate +# SPDX-License-Identifier: MIT + +from __future__ import annotations + +from .Enum import Enum + + +class RegGprO32: + zero: Enum + at: Enum + v0: Enum + v1: Enum + a0: Enum + a1: Enum + a2: Enum + a3: Enum + t0: Enum + t1: Enum + t2: Enum + t3: Enum + t4: Enum + t5: Enum + t6: Enum + t7: Enum + s0: Enum + s1: Enum + s2: Enum + s3: Enum + s4: Enum + s5: Enum + s6: Enum + s7: Enum + t8: Enum + t9: Enum + k0: Enum + k1: Enum + gp: Enum + sp: Enum + fp: Enum + ra: Enum diff --git a/rabbitizer/__init__.pyi b/rabbitizer/__init__.pyi index 39eba71..1bc27a7 100644 --- a/rabbitizer/__init__.pyi +++ b/rabbitizer/__init__.pyi @@ -11,6 +11,9 @@ from .Enum import * from .InstrCategory import * from .InstrId import * +from .RegGprO32 import * +from .RegGprN32 import * + from .Config import * from .rabbitizer import * diff --git a/rabbitizer/enums/registers/rabbitizer_enum_GprN32.c b/rabbitizer/enums/registers/rabbitizer_enum_GprN32.c new file mode 100644 index 0000000..6027d78 --- /dev/null +++ b/rabbitizer/enums/registers/rabbitizer_enum_GprN32.c @@ -0,0 +1,28 @@ +/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ +/* SPDX-License-Identifier: MIT */ + +#include "enums/enums_utils.h" +#include "instructions/RabbitizerRegister.h" + + +#define RABBITIZER_DEF_REG(prefix, name, numeric) \ + { "RegGprN32", #name, RABBITIZER_REG_##prefix##_##name, false, NULL } + +#define RABBITIZER_DEF_REG_NODOLLAR(prefix, name, numeric) \ + { "RegGprN32", #name, RABBITIZER_REG_##prefix##_##name, false, NULL } + +RabbitizerEnumMetadata rabbitizer_enum_RegGprN32_enumvalues[] = { + #include "instructions/registers/RabbitizerRegister_GprN32.inc" + + { 0 }, +}; + +#undef RABBITIZER_DEF_REG +#undef RABBITIZER_DEF_REG_NODOLLAR + + +static PyMethodDef rabbitizer_enum_RegGprN32_methods[] = { + { 0 }, +}; + +DEF_ENUM(RegGprN32, "") diff --git a/rabbitizer/enums/registers/rabbitizer_enum_GprO32.c b/rabbitizer/enums/registers/rabbitizer_enum_GprO32.c new file mode 100644 index 0000000..50cdabe --- /dev/null +++ b/rabbitizer/enums/registers/rabbitizer_enum_GprO32.c @@ -0,0 +1,28 @@ +/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ +/* SPDX-License-Identifier: MIT */ + +#include "enums/enums_utils.h" +#include "instructions/RabbitizerRegister.h" + + +#define RABBITIZER_DEF_REG(prefix, name, numeric) \ + { "RegGprO32", #name, RABBITIZER_REG_##prefix##_##name, false, NULL } + +#define RABBITIZER_DEF_REG_NODOLLAR(prefix, name, numeric) \ + { "RegGprO32", #name, RABBITIZER_REG_##prefix##_##name, false, NULL } + +RabbitizerEnumMetadata rabbitizer_enum_RegGprO32_enumvalues[] = { + #include "instructions/registers/RabbitizerRegister_GprO32.inc" + + { 0 }, +}; + +#undef RABBITIZER_DEF_REG +#undef RABBITIZER_DEF_REG_NODOLLAR + + +static PyMethodDef rabbitizer_enum_RegGprO32_methods[] = { + { 0 }, +}; + +DEF_ENUM(RegGprO32, "") diff --git a/rabbitizer/rabbitizer_module.c b/rabbitizer/rabbitizer_module.c index e08dcde..11a9a7d 100644 --- a/rabbitizer/rabbitizer_module.c +++ b/rabbitizer/rabbitizer_module.c @@ -39,6 +39,8 @@ static ModuleAttributes rabbitizer_module_attributes[] = { MODULE_ATTRIBUTE_ENUM(Abi), MODULE_ATTRIBUTE_ENUM(InstrCategory), MODULE_ATTRIBUTE_ENUM(InstrId), + MODULE_ATTRIBUTE_ENUM(RegGprO32), + MODULE_ATTRIBUTE_ENUM(RegGprN32), MODULE_ATTRIBUTE_TYPE(Instruction), MODULE_ATTRIBUTE_TYPE(RegistersTracker), }; diff --git a/rabbitizer/rabbitizer_module.h b/rabbitizer/rabbitizer_module.h index 075f22b..8e63cc0 100644 --- a/rabbitizer/rabbitizer_module.h +++ b/rabbitizer/rabbitizer_module.h @@ -33,4 +33,7 @@ DECL_ENUM(Abi) DECL_ENUM(InstrCategory) DECL_ENUM(InstrId) +DECL_ENUM(RegGprO32) +DECL_ENUM(RegGprN32) + #endif diff --git a/setup.py b/setup.py index 530e8dc..d919bad 100644 --- a/setup.py +++ b/setup.py @@ -10,6 +10,7 @@ setup( name="rabbitizer", sources=["rabbitizer/rabbitizer_module.c", "rabbitizer/rabbitizer_submodule_Utils.c", "rabbitizer/rabbitizer_type_Instruction.c", "rabbitizer/rabbitizer_global_config.c", "rabbitizer/rabbitizer_type_RegistersTracker.c", "rabbitizer/enums/rabbitizer_type_Enum.c", "rabbitizer/enums/enums_utils.c", "rabbitizer/enums/rabbitizer_enum_InstrCategory.c", "rabbitizer/enums/rabbitizer_enum_InstrId.c", "rabbitizer/enums/rabbitizer_enum_Abi.c", + "rabbitizer/enums/registers/rabbitizer_enum_GprO32.c", "rabbitizer/enums/registers/rabbitizer_enum_GprN32.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction_ProcessUniqueId.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c", "src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c", "src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_ProcessUniqueId.c", "src/instructions/RabbitizerInstrDescriptor.c", "src/instructions/RabbitizerInstrId.c", "src/instructions/RabbitizerRegister.c",