├── .clang-format ├── .gitattributes ├── .github └── workflows │ └── build.yml ├── .gitignore ├── DOCS.md ├── Makefile ├── README.md ├── elf.h ├── header.h ├── helpers.h ├── ido ├── 5.3 │ ├── LICENSE.md │ ├── lib │ │ ├── libmalloc.so │ │ ├── libmalloc_old.so │ │ └── rld │ └── usr │ │ ├── bin │ │ ├── cc │ │ └── strip │ │ └── lib │ │ ├── CC │ │ ├── DCC │ │ ├── delta_init.o │ │ ├── edg_prelink │ │ └── edgcpfe │ │ ├── acpp │ │ ├── as0 │ │ ├── as1 │ │ ├── c++ │ │ ├── c++filt │ │ ├── c++patch │ │ ├── cfront │ │ ├── markc++ │ │ ├── ptcomp │ │ └── ptlink │ │ ├── c++init.o │ │ ├── cfe │ │ ├── copt │ │ ├── crt1.o │ │ ├── crtn.o │ │ ├── err.english.cc │ │ ├── ld │ │ ├── libC.a │ │ ├── libc.so │ │ ├── libc.so.1 │ │ ├── libcomplex.a │ │ ├── libdelta.a │ │ ├── libexc.so │ │ ├── libgen.so │ │ ├── libm.so │ │ ├── libmangle.a │ │ ├── librqs.a │ │ ├── ugen │ │ ├── ujoin │ │ ├── uld │ │ ├── umerge │ │ ├── uopt │ │ ├── upas │ │ └── usplit └── 7.1 │ ├── lib │ ├── cpp │ ├── libc.so.1 │ ├── libmalloc.so │ └── rld │ └── usr │ ├── bin │ └── cc │ └── lib │ ├── DCC │ ├── delta_init.o │ ├── driver │ └── edgcpfe │ ├── acpp │ ├── as0 │ ├── as1 │ ├── cfe │ ├── copt │ ├── err.english.cc │ ├── libC.so.1 │ ├── libc.so.1 │ ├── libexc.so │ ├── libm.so │ ├── libmalloc_cv.so │ ├── pixie.a │ ├── pixie_32.a │ ├── pixie_64.a │ ├── ugen │ ├── ujoin │ ├── uld │ ├── umerge │ ├── uopt │ ├── upas │ └── usplit ├── libc_impl.c ├── libc_impl.h ├── recomp.cpp ├── tools └── rabbitizer │ ├── .clang-format │ ├── .clang-tidy │ ├── .gitattributes │ ├── .github │ └── workflows │ │ ├── ci.yml │ │ └── make.yml │ ├── .gitignore │ ├── .gitrepo │ ├── LICENSE │ ├── MANIFEST.in │ ├── Makefile │ ├── README.md │ ├── cplusplus │ ├── include │ │ ├── analysis │ │ │ ├── LoPairingInfo.hpp │ │ │ └── RegistersTracker.hpp │ │ ├── instructions │ │ │ ├── InstrId.hpp │ │ │ ├── InstructionBase.hpp │ │ │ ├── InstructionCpu.hpp │ │ │ ├── InstructionR5900.hpp │ │ │ ├── InstructionRsp.hpp │ │ │ ├── OperandType.hpp │ │ │ └── Registers.hpp │ │ └── rabbitizer.hpp │ └── src │ │ ├── analysis │ │ ├── LoPairingInfo.cpp │ │ └── RegistersTracker.cpp │ │ └── instructions │ │ ├── InstrId.cpp │ │ ├── InstructionBase.cpp │ │ ├── InstructionCpu.cpp │ │ ├── InstructionR5900.cpp │ │ └── InstructionRsp.cpp │ ├── include │ ├── analysis │ │ ├── RabbitizerLoPairingInfo.h │ │ ├── RabbitizerRegistersTracker.h │ │ └── RabbitizerTrackedRegisterState.h │ ├── common │ │ ├── Abi.inc │ │ ├── RabbitizerConfig.h │ │ ├── RabbitizerVersion.h │ │ └── Utils.h │ ├── instructions │ │ ├── InstrCategory.inc │ │ ├── RabbitizerInstrDescriptor.h │ │ ├── RabbitizerInstrId.h │ │ ├── RabbitizerInstrSuffix.h │ │ ├── RabbitizerInstruction.h │ │ ├── RabbitizerInstructionR5900.h │ │ ├── RabbitizerInstructionRsp.h │ │ ├── RabbitizerOperandType.h │ │ ├── RabbitizerRegister.h │ │ ├── instr_id │ │ │ ├── RabbitizerInstrId_cpu.inc │ │ │ ├── RabbitizerInstrId_r5900.inc │ │ │ ├── RabbitizerInstrId_rsp.inc │ │ │ ├── cpu │ │ │ │ ├── cpu_cop0.inc │ │ │ │ ├── cpu_cop0_bc0.inc │ │ │ │ ├── cpu_cop0_tlb.inc │ │ │ │ ├── cpu_cop1.inc │ │ │ │ ├── cpu_cop1_bc1.inc │ │ │ │ ├── cpu_cop1_fpu_d.inc │ │ │ │ ├── cpu_cop1_fpu_l.inc │ │ │ │ ├── cpu_cop1_fpu_s.inc │ │ │ │ ├── cpu_cop1_fpu_w.inc │ │ │ │ ├── cpu_normal.inc │ │ │ │ ├── cpu_regimm.inc │ │ │ │ └── cpu_special.inc │ │ │ ├── r5900 │ │ │ │ ├── r5900_cop0_tlb.inc │ │ │ │ ├── r5900_cop1_fpu_s.inc │ │ │ │ ├── r5900_cop2.inc │ │ │ │ ├── r5900_cop2_bc2.inc │ │ │ │ ├── r5900_cop2_special1.inc │ │ │ │ ├── r5900_cop2_special2.inc │ │ │ │ ├── r5900_mmi.inc │ │ │ │ ├── r5900_mmi_0.inc │ │ │ │ ├── r5900_mmi_1.inc │ │ │ │ ├── r5900_mmi_2.inc │ │ │ │ ├── r5900_mmi_3.inc │ │ │ │ ├── r5900_normal.inc │ │ │ │ ├── r5900_regimm.inc │ │ │ │ └── r5900_special.inc │ │ │ └── rsp │ │ │ │ ├── rsp_cop0.inc │ │ │ │ ├── rsp_cop2.inc │ │ │ │ ├── rsp_cop2_vu.inc │ │ │ │ ├── rsp_normal.inc │ │ │ │ ├── rsp_normal_lwc2.inc │ │ │ │ ├── rsp_normal_swc2.inc │ │ │ │ ├── rsp_regimm.inc │ │ │ │ └── rsp_special.inc │ │ ├── operands │ │ │ ├── RabbitizerOperandType_cpu.inc │ │ │ ├── RabbitizerOperandType_r5900.inc │ │ │ └── RabbitizerOperandType_rsp.inc │ │ └── registers │ │ │ ├── RabbitizerRegister_Cop0.inc │ │ │ ├── RabbitizerRegister_Cop1Control.inc │ │ │ ├── RabbitizerRegister_Cop1N32.inc │ │ │ ├── RabbitizerRegister_Cop1N64.inc │ │ │ ├── RabbitizerRegister_Cop1O32.inc │ │ │ ├── RabbitizerRegister_Cop2.inc │ │ │ ├── RabbitizerRegister_GprN32.inc │ │ │ ├── RabbitizerRegister_GprO32.inc │ │ │ ├── RabbitizerRegister_R5900VF.inc │ │ │ ├── RabbitizerRegister_R5900VI.inc │ │ │ ├── RabbitizerRegister_RspCop0.inc │ │ │ ├── RabbitizerRegister_RspCop2.inc │ │ │ ├── RabbitizerRegister_RspCop2Control.inc │ │ │ ├── RabbitizerRegister_RspGpr.inc │ │ │ └── RabbitizerRegister_RspVector.inc │ └── rabbitizer.h │ ├── pyproject.toml │ ├── r5900test.c │ ├── rabbitizer │ ├── Config.pyi │ ├── Enum.pyi │ ├── InstrCategory.pyi │ ├── InstrId.pyi │ ├── LoPairingInfo.pyi │ ├── RegGprN32.pyi │ ├── RegGprO32.pyi │ ├── RegistersTracker.pyi │ ├── TrackedRegisterState.pyi │ ├── Utils.pyi │ ├── __init__.pyi │ ├── enums │ │ ├── enums_utils.c │ │ ├── enums_utils.h │ │ ├── rabbitizer_enum_Abi.c │ │ ├── rabbitizer_enum_InstrCategory.c │ │ ├── rabbitizer_enum_InstrId.c │ │ ├── rabbitizer_type_Enum.c │ │ └── registers │ │ │ ├── rabbitizer_enum_GprN32.c │ │ │ └── rabbitizer_enum_GprO32.c │ ├── py.typed │ ├── rabbitizer.pyi │ ├── rabbitizer_global_config.c │ ├── rabbitizer_module.c │ ├── rabbitizer_module.h │ ├── rabbitizer_submodule_Utils.c │ ├── rabbitizer_type_Instruction.c │ ├── rabbitizer_type_LoPairingInfo.c │ ├── rabbitizer_type_RegistersTracker.c │ └── rabbitizer_type_TrackedRegisterState.c │ ├── registersTrackerTest.c │ ├── rsptest.c │ ├── setup.cfg │ ├── setup.py │ ├── src │ ├── analysis │ │ ├── RabbitizerLoPairingInfo.c │ │ ├── RabbitizerRegistersTracker.c │ │ └── RabbitizerTrackedRegisterState.c │ ├── common │ │ ├── RabbitizerConfig.c │ │ ├── RabbitizerVersion.c │ │ └── Utils.c │ └── instructions │ │ ├── RabbitizerInstrDescriptor.c │ │ ├── RabbitizerInstrId.c │ │ ├── RabbitizerInstrSuffix.c │ │ ├── RabbitizerInstruction │ │ ├── RabbitizerInstruction.c │ │ ├── RabbitizerInstruction_Disassemble.c │ │ ├── RabbitizerInstruction_Examination.c │ │ └── RabbitizerInstruction_ProcessUniqueId.c │ │ ├── RabbitizerInstructionR5900 │ │ ├── RabbitizerInstructionR5900.c │ │ └── RabbitizerInstructionR5900_ProcessUniqueId.c │ │ ├── RabbitizerInstructionRsp │ │ ├── RabbitizerInstructionRsp.c │ │ └── RabbitizerInstructionRsp_ProcessUniqueId.c │ │ └── RabbitizerRegister.c │ ├── test.c │ └── tests │ └── cplusplus │ └── test.cpp └── version_info.c /.clang-format: -------------------------------------------------------------------------------- 1 | IndentWidth: 4 2 | Language: Cpp 3 | UseTab: Never 4 | ColumnLimit: 120 5 | PointerAlignment: Left 6 | BreakBeforeBraces: Attach 7 | SpaceAfterCStyleCast: false 8 | Cpp11BracedListStyle: false 9 | IndentCaseLabels: true 10 | BinPackArguments: true 11 | BinPackParameters: true 12 | AlignAfterOpenBracket: Align 13 | AlignOperands: true 14 | BreakBeforeTernaryOperators: true 15 | BreakBeforeBinaryOperators: None 16 | AllowShortBlocksOnASingleLine: true 17 | AllowShortIfStatementsOnASingleLine: false 18 | AllowShortLoopsOnASingleLine: false 19 | AllowShortCaseLabelsOnASingleLine: false 20 | AllowShortFunctionsOnASingleLine: false 21 | AlignEscapedNewlines: Left 22 | AlignTrailingComments: true 23 | SortIncludes: false 24 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # IDO uses these files as a way to display error and warnings messages, but 2 | # IDO is hardcoded to read into an offset of the file instead of properly 3 | # parsing the file this error file. This means that if the file is modified 4 | # in any way, then IDO would output incorrect error/warning messages. 5 | # This kind of issue can happen by git automatically chaninging the line 6 | # endings depending on user and system configuration. Marking those files as 7 | # binary overrides this configuration and avoids the issue. 8 | ido/5.3/usr/lib/err.english.cc binary 9 | ido/7.1/usr/lib/err.english.cc binary 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | build/ 3 | .vscode/ 4 | 5 | qemu-irix 6 | 7 | ctx.c.m2c 8 | *.s 9 | 10 | .DS_Store 11 | 12 | 13 | *.T 14 | *.o 15 | *.ii 16 | *.B 17 | *.G 18 | -------------------------------------------------------------------------------- /DOCS.md: -------------------------------------------------------------------------------- 1 | # Custom Functionality 2 | 3 | ## Redirection 4 | 5 | IDO recomp currently has two forms of path redirection, both involving the `/usr` folder. 6 | 7 | ### `/usr/lib` and `/usr/lib/DCC` 8 | 9 | In order for users to not having to worry about installing the binaries in particular locations in `/usr/lib` or `/usr/lib/DCC`, recomp automatically redirects `/usr/lib/` and `/usr/lib/DCC` paths. This is done by determining the location of `cc` and redirecting to the same directory. This does mean all the binaries and `err.english.cc` are expected to be a part of a single flattened directory. 10 | 11 | It is also possible to override the auto redirect by using the environment variable `USR_LIB` with the desired redirection path. This can be used if the binaries are not in a flattened directory with `cc` or if on Linux and are unable to read `/proc/self/exe`. 12 | 13 | Wrapper functions implementing this redirection: 14 | 15 | * `init_file` 16 | * `wrapper_execvp` 17 | * `wrapper_open` 18 | 19 | ### `/usr/include` 20 | 21 | The other form of redirection is completely optional and is done by setting the environment variable `USR_INCLUDE` to the desired redirection path. This will than redirect all opened files files there. This is done so that the `mdebug` section file paths will still use `/usr/include` path, but the files themselves can be located elsewhere for greater flexibility. 22 | 23 | Wrapper functions implementing this redirection: 24 | 25 | * `wrapper_open` 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Static Recompilation of IRIX Programs 2 | 3 | Convert selected IRIX C toolchain programs into modern Linux or macOS programs 4 | 5 | ## Supported Programs 6 | 7 | * IDO 5.3 8 | * cc, acpp, as0, as1, cfe, copt, ugen, ujoin, uld, umerge, uopt, usplit, ld, strip, upas 9 | * IDO 7.1 10 | * cc, acpp, as0, as1, cfe, ugen, ujoin, uld, umerge, uopt, usplit, upas 11 | 12 | ## Dependencies 13 | 14 | ### Linux (Debian / Ubuntu) 15 | 16 | ```bash 17 | sudo apt-get install build-essential 18 | ``` 19 | 20 | ### macOS 21 | 22 | [Install homebrew](https://brew.sh/) and then: 23 | 24 | ```bash 25 | brew install make 26 | ``` 27 | 28 | ## Building 29 | 30 | First build the recomp binary itself 31 | 32 | ```bash 33 | make setup 34 | ``` 35 | 36 | ```bash 37 | make VERSION=5.3 38 | make VERSION=7.1 39 | ``` 40 | 41 | The build artifacts are located in `build/{7.1|5.3}/out`. Add `-j{thread num}` for multithreaded building. 42 | 43 | By default, debug builds are created with less optimizations, debug flags, and unstripped binaries. 44 | Add `RELEASE=1` to build release builds with optimizations and stripped binaries. 45 | 46 | ### Creating Universal ARM/x86_64 macOS Builds 47 | 48 | By default, make build script create native binaries on macOS. This was done to minimize the time to build the recompiled suite. 49 | In order to create "fat," universal ARM and x86_64, pass `TARGET=universal` to `gmake`. 50 | -------------------------------------------------------------------------------- /elf.h: -------------------------------------------------------------------------------- 1 | #ifndef ELF_H 2 | #define ELF_H 3 | 4 | #include 5 | 6 | #define EI_DATA 5 7 | #define EI_NIDENT 16 8 | #define SHT_SYMTAB 2 9 | #define SHT_DYNAMIC 6 10 | #define SHT_REL 9 11 | #define SHT_DYNSYM 11 12 | #define SHT_MIPS_REGINFO 0x70000006 13 | #define STN_UNDEF 0 14 | #define STT_OBJECT 1 15 | #define STT_FUNC 2 16 | #define DT_PLTGOT 3 17 | #define DT_MIPS_LOCAL_GOTNO 0x7000000a 18 | #define DT_MIPS_SYMTABNO 0x70000011 19 | #define DT_MIPS_GOTSYM 0x70000013 20 | 21 | #define ELF32_R_SYM(info) ((info) >> 8) 22 | #define ELF32_R_TYPE(info) ((info) & 0xff) 23 | 24 | #define ELF32_ST_TYPE(info) ((info) & 0xf) 25 | 26 | #define R_MIPS_26 4 27 | #define R_MIPS_HI16 5 28 | #define R_MIPS_LO16 6 29 | 30 | #define SHN_UNDEF 0 31 | #define SHN_COMMON 0xfff2 32 | #define SHN_MIPS_ACOMMON 0xff00 33 | #define SHN_MIPS_TEXT 0xff01 34 | #define SHN_MIPS_DATA 0xff02 35 | 36 | typedef uint32_t Elf32_Addr; 37 | typedef uint32_t Elf32_Off; 38 | 39 | typedef struct { 40 | uint8_t e_ident[EI_NIDENT]; 41 | uint16_t e_type; 42 | uint16_t e_machine; 43 | uint32_t e_version; 44 | Elf32_Addr e_entry; 45 | Elf32_Off e_phoff; 46 | Elf32_Off e_shoff; 47 | uint32_t e_flags; 48 | uint16_t e_ehsize; 49 | uint16_t e_phentsize; 50 | uint16_t e_phnum; 51 | uint16_t e_shentsize; 52 | uint16_t e_shnum; 53 | uint16_t e_shstrndx; 54 | } Elf32_Ehdr; 55 | 56 | typedef struct { 57 | uint32_t sh_name; 58 | uint32_t sh_type; 59 | uint32_t sh_flags; 60 | Elf32_Addr sh_addr; 61 | Elf32_Off sh_offset; 62 | uint32_t sh_size; 63 | uint32_t sh_link; 64 | uint32_t sh_info; 65 | uint32_t sh_addralign; 66 | uint32_t sh_entsize; 67 | } Elf32_Shdr; 68 | 69 | typedef struct { 70 | uint32_t st_name; 71 | Elf32_Addr st_value; 72 | uint32_t st_size; 73 | uint8_t st_info; 74 | uint8_t st_other; 75 | uint16_t st_shndx; 76 | } Elf32_Sym; 77 | 78 | typedef struct { 79 | Elf32_Addr r_offset; 80 | uint32_t r_info; 81 | } Elf32_Rel; 82 | 83 | typedef struct 84 | { 85 | uint32_t ri_gprmask; /* General registers used. */ 86 | uint32_t ri_cprmask[4]; /* Coprocessor registers used. */ 87 | int32_t ri_gp_value; /* $gp register value. */ 88 | } Elf32_RegInfo; 89 | 90 | typedef struct 91 | { 92 | int32_t d_tag; /* Dynamic entry type */ 93 | union { 94 | uint32_t d_val; /* Integer value */ 95 | Elf32_Addr d_ptr; /* Address value */ 96 | } d_un; 97 | } Elf32_Dyn; 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /header.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "libc_impl.h" 9 | #include "helpers.h" 10 | 11 | #define RM_RN 0 12 | #define RM_RZ 1 13 | #define RM_RP 2 14 | #define RM_RM 3 15 | 16 | #define cvt_w_d(f) \ 17 | ((fcsr & RM_RZ) ? ((isnan(f) || f <= -2147483649.0 || f >= 2147483648.0) ? (fcsr |= 0x40, 2147483647) : (int)f) : (assert(0), 0)) 18 | 19 | #define cvt_w_s(f) cvt_w_d((double)f) 20 | 21 | static union FloatReg 22 | f0 = {{0, 0}}, 23 | f1 = {{0, 0}}, 24 | f2 = {{0, 0}}, 25 | f3 = {{0, 0}}, 26 | f4 = {{0, 0}}, 27 | f5 = {{0, 0}}, 28 | f6 = {{0, 0}}, 29 | f7 = {{0, 0}}, 30 | f8 = {{0, 0}}, 31 | f9 = {{0, 0}}, 32 | f10 = {{0, 0}}, 33 | f11 = {{0, 0}}, 34 | f12 = {{0, 0}}, 35 | f13 = {{0, 0}}, 36 | f14 = {{0, 0}}, 37 | f15 = {{0, 0}}, 38 | f16 = {{0, 0}}, 39 | f17 = {{0, 0}}, 40 | f18 = {{0, 0}}, 41 | f19 = {{0, 0}}, 42 | f20 = {{0, 0}}, 43 | f21 = {{0, 0}}, 44 | f22 = {{0, 0}}, 45 | f23 = {{0, 0}}, 46 | f24 = {{0, 0}}, 47 | f25 = {{0, 0}}, 48 | f26 = {{0, 0}}, 49 | f27 = {{0, 0}}, 50 | f28 = {{0, 0}}, 51 | f29 = {{0, 0}}, 52 | f30 = {{0, 0}}, 53 | f31 = {{0, 0}}; 54 | static uint32_t fcsr = 1; 55 | -------------------------------------------------------------------------------- /helpers.h: -------------------------------------------------------------------------------- 1 | #ifndef HELPERS_H 2 | #define HELPERS_H 3 | 4 | #include 5 | 6 | #define MEM_F64(a) (double_from_memory(mem, a)) 7 | #define MEM_F32(a) (*(float *)(mem + a)) 8 | #define MEM_U32(a) (*(uint32_t *)(mem + a)) 9 | #define MEM_S32(a) (*(int32_t *)(mem + a)) 10 | #define MEM_U16(a) (*(uint16_t *)(mem + ((a) ^ 2))) 11 | #define MEM_S16(a) (*(int16_t *)(mem + ((a) ^ 2))) 12 | #define MEM_U8(a) (*(uint8_t *)(mem + ((a) ^ 3))) 13 | #define MEM_S8(a) (*(int8_t *)(mem + ((a) ^ 3))) 14 | 15 | #if !defined(__GNUC__) && !defined(__clang__) 16 | #define __attribute__(x) 17 | #endif 18 | 19 | #if __STDC_VERSION__ >= 202000L 20 | #define FALLTHROUGH [[fallthrough]] 21 | #define NODISCARD [[nodiscard]] 22 | #define NORETURN [[noreturn]] 23 | #define UNUSED [[maybe_unused]] 24 | #else 25 | #define FALLTHROUGH __attribute__((fallthrough)) 26 | #define NODISCARD __attribute__((warn_unused_result)) 27 | #define NORETURN _Noreturn 28 | #define UNUSED __attribute__((unused)) 29 | #endif 30 | 31 | #if defined(_MSC_VER) 32 | # define UNREACHABLE __assume(0) 33 | #elif defined(__GNUC__) || defined(__clang__) 34 | # define UNREACHABLE __builtin_unreachable() 35 | #else 36 | # define UNREACHABLE 37 | #endif 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /ido/5.3/LICENSE.md: -------------------------------------------------------------------------------- 1 | # Silicon Graphics Freeware Legal Notice 2 | ## Copyright 1995, Silicon Graphics, Inc. -- ALL RIGHTS RESERVED 3 | 4 | You may copy, modify, use and distribute this software, (i) provided that you include the entirety of this reservation of rights notice in all such copies, and (ii) you comply with any additional or different obligations and/or use restrictions specified by any third party owner or supplier of the software in other notices that may be included with the software. 5 | 6 | **SGI DISCLAIMS ALL WARRANTIES WITH RESPECT TO THIS SOFTWARE, EXPRESS, IMPLIED, OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ALL WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT. SGI SHALL NOT BE LIABLE FOR ANY SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING, WITHOUT LIMITATION, LOST REVENUES, LOST PROFITS, OR LOSS OF PROSPECTIVE ECONOMIC ADVANTAGE, RESULTING FROM THE USE OR MISUSE OF THIS SOFTWARE.** 7 | 8 | **U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:** 9 | 10 | Use, duplication or disclosure by the Government is subject to restrictions as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or in similar or successor clauses in the FAR, or the DOD or NASA FAR Supplement. Unpublished - rights reserved under the Copyright Laws of United States. Contractor/manufacturer is Silicon Graphics, Inc., 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. 11 | 12 | ## Product Support 13 | 14 | Freeware products are not supported by Silicon Graphics or any of its support providers. The software contained in this package is made available through the generous efforts of their authors. Although they are interested in your feedback, they are under no obligation to address bugs, enhancements, or answer questions. 15 | 16 | ---- 17 | 18 | **NOTE:** This license was copied verbatim from https://web.archive.org/web/19991008090202/http://toolbox.sgi.com/TasteOfDT/public/freeware1.0/legal_notice.html . 19 | -------------------------------------------------------------------------------- /ido/5.3/lib/libmalloc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/lib/libmalloc.so -------------------------------------------------------------------------------- /ido/5.3/lib/libmalloc_old.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/lib/libmalloc_old.so -------------------------------------------------------------------------------- /ido/5.3/lib/rld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/lib/rld -------------------------------------------------------------------------------- /ido/5.3/usr/bin/cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/bin/cc -------------------------------------------------------------------------------- /ido/5.3/usr/bin/strip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/bin/strip -------------------------------------------------------------------------------- /ido/5.3/usr/lib/CC: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/CC -------------------------------------------------------------------------------- /ido/5.3/usr/lib/DCC/delta_init.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/DCC/delta_init.o -------------------------------------------------------------------------------- /ido/5.3/usr/lib/DCC/edg_prelink: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/DCC/edg_prelink -------------------------------------------------------------------------------- /ido/5.3/usr/lib/DCC/edgcpfe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/DCC/edgcpfe -------------------------------------------------------------------------------- /ido/5.3/usr/lib/acpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/acpp -------------------------------------------------------------------------------- /ido/5.3/usr/lib/as0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/as0 -------------------------------------------------------------------------------- /ido/5.3/usr/lib/as1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/as1 -------------------------------------------------------------------------------- /ido/5.3/usr/lib/c++/c++filt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/c++/c++filt -------------------------------------------------------------------------------- /ido/5.3/usr/lib/c++/c++patch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/c++/c++patch -------------------------------------------------------------------------------- /ido/5.3/usr/lib/c++/cfront: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/c++/cfront -------------------------------------------------------------------------------- /ido/5.3/usr/lib/c++/markc++: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/c++/markc++ -------------------------------------------------------------------------------- /ido/5.3/usr/lib/c++/ptcomp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/c++/ptcomp -------------------------------------------------------------------------------- /ido/5.3/usr/lib/c++/ptlink: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/c++/ptlink -------------------------------------------------------------------------------- /ido/5.3/usr/lib/c++init.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/c++init.o -------------------------------------------------------------------------------- /ido/5.3/usr/lib/cfe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/cfe -------------------------------------------------------------------------------- /ido/5.3/usr/lib/copt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/copt -------------------------------------------------------------------------------- /ido/5.3/usr/lib/crt1.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/crt1.o -------------------------------------------------------------------------------- /ido/5.3/usr/lib/crtn.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/crtn.o -------------------------------------------------------------------------------- /ido/5.3/usr/lib/ld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/ld -------------------------------------------------------------------------------- /ido/5.3/usr/lib/libC.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/libC.a -------------------------------------------------------------------------------- /ido/5.3/usr/lib/libc.so: -------------------------------------------------------------------------------- 1 | libc.so.1 -------------------------------------------------------------------------------- /ido/5.3/usr/lib/libc.so.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/libc.so.1 -------------------------------------------------------------------------------- /ido/5.3/usr/lib/libcomplex.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/libcomplex.a -------------------------------------------------------------------------------- /ido/5.3/usr/lib/libdelta.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/libdelta.a -------------------------------------------------------------------------------- /ido/5.3/usr/lib/libexc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/libexc.so -------------------------------------------------------------------------------- /ido/5.3/usr/lib/libgen.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/libgen.so -------------------------------------------------------------------------------- /ido/5.3/usr/lib/libm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/libm.so -------------------------------------------------------------------------------- /ido/5.3/usr/lib/libmangle.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/libmangle.a -------------------------------------------------------------------------------- /ido/5.3/usr/lib/librqs.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/librqs.a -------------------------------------------------------------------------------- /ido/5.3/usr/lib/ugen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/ugen -------------------------------------------------------------------------------- /ido/5.3/usr/lib/ujoin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/ujoin -------------------------------------------------------------------------------- /ido/5.3/usr/lib/uld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/uld -------------------------------------------------------------------------------- /ido/5.3/usr/lib/umerge: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/umerge -------------------------------------------------------------------------------- /ido/5.3/usr/lib/uopt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/uopt -------------------------------------------------------------------------------- /ido/5.3/usr/lib/upas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/upas -------------------------------------------------------------------------------- /ido/5.3/usr/lib/usplit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/5.3/usr/lib/usplit -------------------------------------------------------------------------------- /ido/7.1/lib/cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/lib/cpp -------------------------------------------------------------------------------- /ido/7.1/lib/libc.so.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/lib/libc.so.1 -------------------------------------------------------------------------------- /ido/7.1/lib/libmalloc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/lib/libmalloc.so -------------------------------------------------------------------------------- /ido/7.1/lib/rld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/lib/rld -------------------------------------------------------------------------------- /ido/7.1/usr/bin/cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/bin/cc -------------------------------------------------------------------------------- /ido/7.1/usr/lib/DCC/delta_init.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/DCC/delta_init.o -------------------------------------------------------------------------------- /ido/7.1/usr/lib/DCC/driver: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/DCC/driver -------------------------------------------------------------------------------- /ido/7.1/usr/lib/DCC/edgcpfe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/DCC/edgcpfe -------------------------------------------------------------------------------- /ido/7.1/usr/lib/acpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/acpp -------------------------------------------------------------------------------- /ido/7.1/usr/lib/as0: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/as0 -------------------------------------------------------------------------------- /ido/7.1/usr/lib/as1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/as1 -------------------------------------------------------------------------------- /ido/7.1/usr/lib/cfe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/cfe -------------------------------------------------------------------------------- /ido/7.1/usr/lib/copt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/copt -------------------------------------------------------------------------------- /ido/7.1/usr/lib/libC.so.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/libC.so.1 -------------------------------------------------------------------------------- /ido/7.1/usr/lib/libc.so.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/libc.so.1 -------------------------------------------------------------------------------- /ido/7.1/usr/lib/libexc.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/libexc.so -------------------------------------------------------------------------------- /ido/7.1/usr/lib/libm.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/libm.so -------------------------------------------------------------------------------- /ido/7.1/usr/lib/libmalloc_cv.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/libmalloc_cv.so -------------------------------------------------------------------------------- /ido/7.1/usr/lib/pixie.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/pixie.a -------------------------------------------------------------------------------- /ido/7.1/usr/lib/pixie_32.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/pixie_32.a -------------------------------------------------------------------------------- /ido/7.1/usr/lib/pixie_64.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/pixie_64.a -------------------------------------------------------------------------------- /ido/7.1/usr/lib/ugen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/ugen -------------------------------------------------------------------------------- /ido/7.1/usr/lib/ujoin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/ujoin -------------------------------------------------------------------------------- /ido/7.1/usr/lib/uld: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/uld -------------------------------------------------------------------------------- /ido/7.1/usr/lib/umerge: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/umerge -------------------------------------------------------------------------------- /ido/7.1/usr/lib/uopt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/uopt -------------------------------------------------------------------------------- /ido/7.1/usr/lib/upas: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/upas -------------------------------------------------------------------------------- /ido/7.1/usr/lib/usplit: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/ido/7.1/usr/lib/usplit -------------------------------------------------------------------------------- /tools/rabbitizer/.clang-format: -------------------------------------------------------------------------------- 1 | IndentWidth: 4 2 | Language: Cpp 3 | UseTab: Never 4 | ColumnLimit: 160 5 | PointerAlignment: Right 6 | BreakBeforeBraces: Attach 7 | SpaceAfterCStyleCast: false 8 | Cpp11BracedListStyle: false 9 | IndentCaseLabels: true 10 | BinPackArguments: true 11 | BinPackParameters: true 12 | AlignAfterOpenBracket: Align 13 | AlignOperands: true 14 | BreakBeforeTernaryOperators: true 15 | BreakBeforeBinaryOperators: None 16 | AllowShortBlocksOnASingleLine: true 17 | AllowShortIfStatementsOnASingleLine: false 18 | AllowShortLoopsOnASingleLine: false 19 | AllowShortCaseLabelsOnASingleLine: false 20 | AllowShortFunctionsOnASingleLine: false 21 | AlignEscapedNewlines: Left 22 | AlignTrailingComments: true 23 | SortIncludes: false 24 | -------------------------------------------------------------------------------- /tools/rabbitizer/.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: 'readability-*,-readability-magic-numbers,clang-diagnostic-*,clang-analyzer-*,-clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling,bugprone*,-bugprone-branch-clone,modernize*,performance*,portability*,diagnostic-*,analyzer-*,misc*,-misc-no-recursion' 2 | WarningsAsErrors: '' 3 | HeaderFilterRegex: '(src|include)\/.*\.h$' 4 | FormatStyle: 'file' 5 | CheckOptions: 6 | # Require argument names to match exactly (instead of allowing a name to be a prefix/suffix of another) 7 | # Note: 'true' is expected by clang-tidy 12+ but '1' is used for compatibility with older versions 8 | - key: readability-inconsistent-declaration-parameter-name.Strict 9 | value: 1 10 | -------------------------------------------------------------------------------- /tools/rabbitizer/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /tools/rabbitizer/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Build and upload to PyPI 2 | 3 | # Build on every branch push, tag push, and pull request change: 4 | on: [push, pull_request] 5 | 6 | jobs: 7 | build_wheels: 8 | name: Build wheels on ${{ matrix.os }} 9 | runs-on: ${{ matrix.os }} 10 | strategy: 11 | matrix: 12 | os: [ubuntu-latest, macos-latest, windows-latest] 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | 17 | - name: Build wheels 18 | uses: pypa/cibuildwheel@v2.5.0 19 | env: 20 | CIBW_ARCHS_WINDOWS: "auto" 21 | CIBW_ARCHS_LINUX: "auto" 22 | CIBW_ARCHS_MACOS: "all" 23 | 24 | - uses: actions/upload-artifact@v2 25 | with: 26 | path: ./wheelhouse/*.whl 27 | 28 | build_sdist: 29 | name: Build source distribution 30 | runs-on: ubuntu-latest 31 | steps: 32 | - uses: actions/checkout@v2 33 | 34 | - name: Build sdist 35 | run: pipx run build --sdist 36 | 37 | - uses: actions/upload-artifact@v2 38 | with: 39 | path: dist/*.tar.gz 40 | 41 | upload_pypi: 42 | needs: [build_wheels, build_sdist] 43 | runs-on: ubuntu-latest 44 | if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') 45 | steps: 46 | - uses: actions/download-artifact@v2 47 | with: 48 | name: artifact 49 | path: dist 50 | 51 | - uses: pypa/gh-action-pypi-publish@v1.4.2 52 | with: 53 | user: __token__ 54 | password: ${{ secrets.pypi_password }} 55 | -------------------------------------------------------------------------------- /tools/rabbitizer/.github/workflows/make.yml: -------------------------------------------------------------------------------- 1 | name: make 2 | 3 | # Build on every branch push, tag push, and pull request change: 4 | on: [push, pull_request] 5 | 6 | jobs: 7 | build: 8 | 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - uses: actions/checkout@v3 13 | - name: make 14 | run: make WERROR=1 15 | -------------------------------------------------------------------------------- /tools/rabbitizer/.gitrepo: -------------------------------------------------------------------------------- 1 | ; DO NOT EDIT (unless you know what you are doing) 2 | ; 3 | ; This subdirectory is a git "subrepo", and this file is maintained by the 4 | ; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme 5 | ; 6 | [subrepo] 7 | remote = git@github.com:Decompollaborate/rabbitizer.git 8 | branch = develop 9 | commit = 72bf240f468d30286888212b5fb773fae94340f6 10 | parent = fa84f928c510147d6083b979efb28a5a07eefe10 11 | method = merge 12 | cmdver = 0.4.3 13 | -------------------------------------------------------------------------------- /tools/rabbitizer/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Decompollaborate 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /tools/rabbitizer/MANIFEST.in: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 2 | # SPDX-License-Identifier: MIT 3 | 4 | include **/*.h 5 | include **/**/*.h 6 | graft include 7 | -------------------------------------------------------------------------------- /tools/rabbitizer/README.md: -------------------------------------------------------------------------------- 1 | # rabbitizer 2 | 3 | [![PyPI - Downloads](https://img.shields.io/pypi/dm/rabbitizer)](https://pypi.org/project/rabbitizer/) 4 | ![GitHub](https://img.shields.io/github/license/Decompollaborate/rabbitizer) 5 | ![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/Decompollaborate/rabbitizer) 6 | ![PyPI](https://img.shields.io/pypi/v/rabbitizer) 7 | ![GitHub contributors](https://img.shields.io/github/contributors/Decompollaborate/rabbitizer?logo=purple) 8 | 9 | A MIPS instruction decoder API. 10 | 11 | Currently supports all the CPU instructions for MIPS I, II, III and IV. 12 | 13 | ## Installing 14 | 15 | The recommended way to install is using from the PyPi release, via `pip`: 16 | 17 | ```bash 18 | pip install rabbitizer 19 | ``` 20 | 21 | In case you want to mess with the latest development version without wanting to clone the repository, then you could use the following command: 22 | 23 | ```bash 24 | pip install git+https://github.com/Decompollaborate/rabbitizer.git@develop 25 | ``` 26 | 27 | NOTE: Installing the development version is not recommended. Proceed at your own risk. 28 | 29 | ## Features 30 | 31 | - Should produces matching assembly. 32 | - Fully written in C for fast decoding. 33 | - Python bindings. 34 | - The minimal Python version is 3.7, older versions are not guaranteed to work. 35 | - Includes some minor tools to build your own pointer/symbol detection. 36 | - Configurable, many features can be turned on and off. 37 | - MIPS instructions features: 38 | - Named registers for MIPS VR4300's coprocessors. 39 | - Support for many pseudoinstructions. 40 | - Properly handle move to/from coprocessor instructions. 41 | - Support for numeric, o32, n32 and n64 ABI register names. 42 | - Some workarounds for some specific compilers/assemblers: 43 | - `SN64`: 44 | - `div`/`divu` fix: tweaks a bit the produced `div`, `divu` and `break` instructions. 45 | - N64 RSP instruction decoding support. 46 | - RSP decoding has been tested to build back to matching assemblies with [armips](https://github.com/Kingcom/armips/). 47 | - R5900 (PS2's Emotion Engine processor) decoding support. 48 | 49 | ## References 50 | 51 | - R5900: 52 | - EmotionEngine instruction decoding: 53 | - Official documentation from Toshiba: 54 | - VU instruction manual: 55 | - GNU binutils: 56 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/include/analysis/LoPairingInfo.hpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_LO_PAIRING_INFO_HPP 5 | #define RABBITIZER_LO_PAIRING_INFO_HPP 6 | #pragma once 7 | 8 | #include "analysis/RabbitizerLoPairingInfo.h" 9 | 10 | 11 | namespace rabbitizer { 12 | class LoPairingInfo { 13 | protected: 14 | RabbitizerLoPairingInfo pairingInfo; 15 | 16 | public: 17 | LoPairingInfo(); 18 | LoPairingInfo(const RabbitizerLoPairingInfo &pairingInfo); 19 | 20 | /** 21 | * Returns a pointer to the inner RabbitizerLoPairingInfo. 22 | * It is recommended to not mess with it unless you know what you are doing. 23 | */ 24 | RabbitizerLoPairingInfo *getCPtr(); 25 | const RabbitizerLoPairingInfo *getCPtr() const; 26 | 27 | int getInstrOffset() const; 28 | int64_t getValue() const; 29 | bool shouldProcess() const; 30 | bool isGpRel() const; 31 | bool isGpGot() const; 32 | }; 33 | }; 34 | 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/include/analysis/RegistersTracker.hpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_REGISTERS_TRACKER_HPP 5 | #define RABBITIZER_REGISTERS_TRACKER_HPP 6 | #pragma once 7 | 8 | #include "analysis/RabbitizerRegistersTracker.h" 9 | 10 | #include "analysis/LoPairingInfo.hpp" 11 | #include "instructions/InstructionBase.hpp" 12 | 13 | 14 | namespace rabbitizer { 15 | class RegistersTracker { 16 | protected: 17 | RabbitizerRegistersTracker tracker; 18 | 19 | public: 20 | RegistersTracker(); 21 | RegistersTracker(const RegistersTracker &other); 22 | virtual ~RegistersTracker(); 23 | 24 | /** 25 | * Returns a pointer to the inner RabbitizerRegistersTracker. 26 | * It is recommended to not mess with it unless you know what you are doing. 27 | */ 28 | RabbitizerRegistersTracker *getCPtr(); 29 | const RabbitizerRegistersTracker *getCPtr() const; 30 | 31 | bool moveRegisters(const InstructionBase &instr); 32 | void overwriteRegisters(const InstructionBase &instr, int instrOffset); 33 | void unsetRegistersAfterFuncCall(const InstructionBase &instr, const InstructionBase &prevInstr); 34 | bool getAddressIfCanSetType(const InstructionBase &instr, int instrOffset, uint32_t *dstAddress) const; 35 | bool getJrInfo(const InstructionBase &instr, int *dstOffset, uint32_t *dstAddress) const; 36 | 37 | void processLui(const InstructionBase &instr, int instrOffset); 38 | void processLui(const InstructionBase &instr, int instrOffset, const InstructionBase &prevInstr); 39 | void processGpLoad(const InstructionBase &instr, int instrOffset); 40 | bool getLuiOffsetForConstant(const InstructionBase &instr, int *dstOffset) const; 41 | void processConstant(const InstructionBase &instr, uint32_t value, int offset); 42 | LoPairingInfo preprocessLoAndGetInfo(const InstructionBase &instr, int instrOffset); 43 | void processLo(const InstructionBase &instr, uint32_t value, int offset); 44 | bool hasLoButNoHi(const InstructionBase &instr) const; 45 | }; 46 | }; 47 | 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/include/instructions/InstrId.hpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_INSTRID_HPP 5 | #define RABBITIZER_INSTRID_HPP 6 | #pragma once 7 | 8 | #include 9 | 10 | 11 | namespace rabbitizer { 12 | namespace InstrId { 13 | #define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) \ 14 | prefix##_##name, 15 | 16 | #define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) \ 17 | RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, __VA_ARGS__) 18 | 19 | enum class UniqueId { 20 | #include "instructions/instr_id/RabbitizerInstrId_cpu.inc" 21 | 22 | #include "instructions/instr_id/RabbitizerInstrId_rsp.inc" 23 | 24 | #include "instructions/instr_id/RabbitizerInstrId_r5900.inc" 25 | 26 | ALL_MAX = RABBITIZER_DEF_INSTR_ID(r5900, , MAX, ) 27 | }; 28 | 29 | #undef RABBITIZER_DEF_INSTR_ID 30 | #undef RABBITIZER_DEF_INSTR_ID_ALTNAME 31 | 32 | 33 | std::string getOpcodeName(UniqueId uniqueId); 34 | }; 35 | }; 36 | 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/include/instructions/InstructionCpu.hpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_INSTRUCTION_CPU_HPP 5 | #define RABBITIZER_INSTRUCTION_CPU_HPP 6 | #pragma once 7 | 8 | #include "InstructionBase.hpp" 9 | 10 | 11 | namespace rabbitizer { 12 | class InstructionCpu : public InstructionBase { 13 | public: 14 | InstructionCpu(uint32_t word, uint32_t vram); 15 | virtual ~InstructionCpu(); 16 | }; 17 | }; 18 | 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/include/instructions/InstructionR5900.hpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_INSTRUCTION_R5900_HPP 5 | #define RABBITIZER_INSTRUCTION_R5900_HPP 6 | #pragma once 7 | 8 | #include "InstructionBase.hpp" 9 | 10 | 11 | namespace rabbitizer { 12 | class InstructionR5900 : public InstructionBase { 13 | public: 14 | InstructionR5900(uint32_t word, uint32_t vram); 15 | virtual ~InstructionR5900(); 16 | 17 | Registers::R5900::VF GetR5900_vfs() const; 18 | Registers::R5900::VF GetR5900_vft() const; 19 | Registers::R5900::VF GetR5900_vfd() const; 20 | 21 | Registers::R5900::VI GetR5900_vis() const; 22 | Registers::R5900::VI GetR5900_vit() const; 23 | Registers::R5900::VI GetR5900_vid() const; 24 | 25 | uint8_t GetR5900_mmi_function() const; 26 | uint8_t GetR5900_fhi_flo() const; 27 | 28 | uint8_t GetR5900_xyzw_x() const; 29 | uint8_t GetR5900_xyzw_y() const; 30 | uint8_t GetR5900_xyzw_z() const; 31 | uint8_t GetR5900_xyzw_w() const; 32 | uint8_t GetR5900_n() const; 33 | uint8_t GetR5900_l() const; 34 | uint8_t GetR5900_m() const; 35 | 36 | uint8_t GetR5900_imm5() const; 37 | }; 38 | }; 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/include/instructions/InstructionRsp.hpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_INSTRUCTION_RSP_HPP 5 | #define RABBITIZER_INSTRUCTION_RSP_HPP 6 | #pragma once 7 | 8 | #include "InstructionBase.hpp" 9 | 10 | 11 | namespace rabbitizer { 12 | class InstructionRsp : public InstructionBase { 13 | public: 14 | InstructionRsp(uint32_t word, uint32_t vram); 15 | virtual ~InstructionRsp(); 16 | 17 | Registers::Rsp::Gpr GetRsp_rs() const; 18 | Registers::Rsp::Gpr GetRsp_rt() const; 19 | Registers::Rsp::Gpr GetRsp_rd() const; 20 | 21 | Registers::Rsp::Cop0 GetRsp_cop0d() const; 22 | 23 | Registers::Rsp::Cop2 GetRsp_cop2t() const; 24 | 25 | Registers::Rsp::Cop2Control GetRsp_cop2cd() const; 26 | 27 | Registers::Rsp::Vector GetRsp_vs() const; 28 | Registers::Rsp::Vector GetRsp_vt() const; 29 | Registers::Rsp::Vector GetRsp_vd() const; 30 | 31 | uint8_t GetRsp_elementhigh() const; 32 | uint8_t GetRsp_elementlow() const; 33 | 34 | uint8_t GetRsp_index() const; 35 | uint8_t GetRsp_de() const; 36 | }; 37 | }; 38 | 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/include/instructions/OperandType.hpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_OPERAND_TYPE_HPP 5 | #define RABBITIZER_OPERAND_TYPE_HPP 6 | #pragma once 7 | 8 | 9 | namespace rabbitizer { 10 | #define RAB_DEF_OPERAND(prefix, operand) \ 11 | prefix##_##operand, 12 | 13 | enum class OperandType { 14 | RAB_DEF_OPERAND(ALL, INVALID) 15 | 16 | #include "instructions/operands/RabbitizerOperandType_cpu.inc" 17 | #include "instructions/operands/RabbitizerOperandType_rsp.inc" 18 | #include "instructions/operands/RabbitizerOperandType_r5900.inc" 19 | 20 | RAB_DEF_OPERAND(ALL, MAX) 21 | }; 22 | 23 | #undef RAB_DEF_OPERAND 24 | }; 25 | 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/include/instructions/Registers.hpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_REGISTER_HPP 5 | #define RABBITIZER_REGISTER_HPP 6 | #pragma once 7 | 8 | 9 | namespace rabbitizer { 10 | 11 | namespace Registers { 12 | #define RABBITIZER_DEF_REG(prefix, name, numeric) \ 13 | prefix##_##name 14 | 15 | #define RABBITIZER_DEF_REG_NODOLLAR(prefix, name, numeric) \ 16 | prefix##_##name 17 | 18 | namespace Cpu { 19 | enum class GprO32 { 20 | #include "instructions/registers/RabbitizerRegister_GprO32.inc" 21 | }; 22 | 23 | enum class GprN32 { 24 | #include "instructions/registers/RabbitizerRegister_GprN32.inc" 25 | }; 26 | 27 | 28 | enum class Cop0 { 29 | #include "instructions/registers/RabbitizerRegister_Cop0.inc" 30 | }; 31 | 32 | // Float registers 33 | enum class Cop1O32 { 34 | #include "instructions/registers/RabbitizerRegister_Cop1O32.inc" 35 | }; 36 | 37 | enum class Cop1N32 { 38 | #include "instructions/registers/RabbitizerRegister_Cop1N32.inc" 39 | }; 40 | 41 | enum class Cop1N64 { 42 | #include "instructions/registers/RabbitizerRegister_Cop1N64.inc" 43 | }; 44 | 45 | enum class Cop1Control { 46 | #include "instructions/registers/RabbitizerRegister_Cop1Control.inc" 47 | }; 48 | 49 | enum class Cop2 { 50 | #include "instructions/registers/RabbitizerRegister_Cop2.inc" 51 | }; 52 | }; 53 | 54 | 55 | namespace Rsp { 56 | enum class Gpr { 57 | #include "instructions/registers/RabbitizerRegister_RspGpr.inc" 58 | }; 59 | 60 | enum class Cop0 { 61 | #include "instructions/registers/RabbitizerRegister_RspCop0.inc" 62 | }; 63 | 64 | enum class Cop2 { 65 | #include "instructions/registers/RabbitizerRegister_RspCop2.inc" 66 | }; 67 | 68 | enum class Cop2Control { 69 | #include "instructions/registers/RabbitizerRegister_RspCop2Control.inc" 70 | }; 71 | 72 | enum class Vector { 73 | #include "instructions/registers/RabbitizerRegister_RspVector.inc" 74 | }; 75 | }; 76 | 77 | 78 | namespace R5900 { 79 | enum class VF { 80 | #include "instructions/registers/RabbitizerRegister_R5900VF.inc" 81 | }; 82 | 83 | enum class VI { 84 | #include "instructions/registers/RabbitizerRegister_R5900VI.inc" 85 | }; 86 | }; 87 | 88 | #undef RABBITIZER_DEF_REG 89 | #undef RABBITIZER_DEF_REG_NODOLLAR 90 | }; 91 | }; 92 | 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/include/rabbitizer.hpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_HPP 5 | #define RABBITIZER_HPP 6 | #pragma once 7 | 8 | 9 | #include "common/RabbitizerVersion.h" 10 | #include "common/RabbitizerConfig.h" 11 | 12 | #include "instructions/OperandType.hpp" 13 | #include "instructions/InstrId.hpp" 14 | //#include "instructions/InstrSuffix.hpp" 15 | //#include "instructions/InstrDescriptor.hpp" 16 | #include "instructions/Registers.hpp" 17 | #include "instructions/InstructionBase.hpp" 18 | #include "instructions/InstructionCpu.hpp" 19 | #include "instructions/InstructionRsp.hpp" 20 | #include "instructions/InstructionR5900.hpp" 21 | 22 | #include "analysis/LoPairingInfo.hpp" 23 | #include "analysis/RegistersTracker.hpp" 24 | 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/src/analysis/LoPairingInfo.cpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "analysis/LoPairingInfo.hpp" 5 | 6 | using namespace rabbitizer; 7 | 8 | LoPairingInfo::LoPairingInfo() : pairingInfo{} { 9 | } 10 | LoPairingInfo::LoPairingInfo(const RabbitizerLoPairingInfo &newPairingInfo) : pairingInfo{ newPairingInfo } { 11 | } 12 | 13 | RabbitizerLoPairingInfo *LoPairingInfo::getCPtr() { 14 | return &this->pairingInfo; 15 | } 16 | const RabbitizerLoPairingInfo *LoPairingInfo::getCPtr() const { 17 | return &this->pairingInfo; 18 | } 19 | 20 | int LoPairingInfo::getInstrOffset() const { 21 | return this->pairingInfo.instrOffset; 22 | } 23 | int64_t LoPairingInfo::getValue() const { 24 | return this->pairingInfo.value; 25 | } 26 | bool LoPairingInfo::shouldProcess() const { 27 | return this->pairingInfo.shouldProcess; 28 | } 29 | bool LoPairingInfo::isGpRel() const { 30 | return this->pairingInfo.isGpRel; 31 | } 32 | bool LoPairingInfo::isGpGot() const { 33 | return this->pairingInfo.isGpGot; 34 | } 35 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/src/analysis/RegistersTracker.cpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "analysis/RegistersTracker.hpp" 5 | 6 | using namespace rabbitizer; 7 | 8 | RegistersTracker::RegistersTracker() { 9 | RabbitizerRegistersTracker_init(&this->tracker, NULL); 10 | } 11 | RegistersTracker::RegistersTracker(const RegistersTracker &other) { 12 | RabbitizerRegistersTracker_init(&this->tracker, &other.tracker); 13 | } 14 | RegistersTracker::~RegistersTracker() { 15 | RabbitizerRegistersTracker_destroy(&this->tracker); 16 | } 17 | 18 | RabbitizerRegistersTracker *RegistersTracker::getCPtr() { 19 | return &this->tracker; 20 | } 21 | const RabbitizerRegistersTracker *RegistersTracker::getCPtr() const { 22 | return &this->tracker; 23 | } 24 | 25 | bool RegistersTracker::moveRegisters(const InstructionBase &instr) { 26 | return RabbitizerRegistersTracker_moveRegisters(&this->tracker, instr.getCPtr()); 27 | } 28 | void RegistersTracker::overwriteRegisters(const InstructionBase &instr, int instrOffset) { 29 | RabbitizerRegistersTracker_overwriteRegisters(&this->tracker, instr.getCPtr(), instrOffset); 30 | } 31 | void RegistersTracker::unsetRegistersAfterFuncCall(const InstructionBase &instr, const InstructionBase &prevInstr) { 32 | RabbitizerRegistersTracker_unsetRegistersAfterFuncCall(&this->tracker, instr.getCPtr(), prevInstr.getCPtr()); 33 | } 34 | bool RegistersTracker::getAddressIfCanSetType(const InstructionBase &instr, int instrOffset, uint32_t *dstAddress) const { 35 | return RabbitizerRegistersTracker_getAddressIfCanSetType(&this->tracker, instr.getCPtr(), instrOffset, dstAddress); 36 | } 37 | bool RegistersTracker::getJrInfo(const InstructionBase &instr, int *dstOffset, uint32_t *dstAddress) const { 38 | return RabbitizerRegistersTracker_getJrInfo(&this->tracker, instr.getCPtr(), dstOffset, dstAddress); 39 | } 40 | 41 | void RegistersTracker::processLui(const InstructionBase &instr, int instrOffset) { 42 | RabbitizerRegistersTracker_processLui(&this->tracker, instr.getCPtr(), instrOffset, NULL); 43 | } 44 | void RegistersTracker::processLui(const InstructionBase &instr, int instrOffset, const InstructionBase &prevInstr) { 45 | RabbitizerRegistersTracker_processLui(&this->tracker, instr.getCPtr(), instrOffset, prevInstr.getCPtr()); 46 | } 47 | void RegistersTracker::processGpLoad(const InstructionBase &instr, int instrOffset) { 48 | RabbitizerRegistersTracker_processGpLoad(&this->tracker, instr.getCPtr(), instrOffset); 49 | } 50 | bool RegistersTracker::getLuiOffsetForConstant(const InstructionBase &instr, int *dstOffset) const { 51 | return RabbitizerRegistersTracker_getLuiOffsetForConstant(&this->tracker, instr.getCPtr(), dstOffset); 52 | } 53 | void RegistersTracker::processConstant(const InstructionBase &instr, uint32_t value, int offset) { 54 | RabbitizerRegistersTracker_processConstant(&this->tracker, instr.getCPtr(), value, offset); 55 | } 56 | LoPairingInfo RegistersTracker::preprocessLoAndGetInfo(const InstructionBase &instr, int instrOffset) { 57 | return RabbitizerRegistersTracker_preprocessLoAndGetInfo(&this->tracker, instr.getCPtr(), instrOffset); 58 | } 59 | void RegistersTracker::processLo(const InstructionBase &instr, uint32_t value, int offset) { 60 | RabbitizerRegistersTracker_processLo(&this->tracker, instr.getCPtr(), value, offset); 61 | } 62 | bool RegistersTracker::hasLoButNoHi(const InstructionBase &instr) const { 63 | return RabbitizerRegistersTracker_hasLoButNoHi(&this->tracker, instr.getCPtr()); 64 | } 65 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/src/instructions/InstrId.cpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "instructions/InstrId.hpp" 5 | 6 | #include "instructions/RabbitizerInstrId.h" 7 | 8 | using namespace rabbitizer; 9 | 10 | std::string InstrId::getOpcodeName(InstrId::UniqueId uniqueId) { 11 | RabbitizerInstrId id = static_cast(uniqueId); 12 | 13 | return std::string(RabbitizerInstrId_getOpcodeName(id)); 14 | } 15 | -------------------------------------------------------------------------------- /tools/rabbitizer/cplusplus/src/instructions/InstructionCpu.cpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "instructions/InstructionCpu.hpp" 5 | 6 | using namespace rabbitizer; 7 | 8 | InstructionCpu::InstructionCpu(uint32_t word, uint32_t vram) : InstructionBase() { 9 | RabbitizerInstruction_init(&this->instr, word, vram); 10 | RabbitizerInstruction_processUniqueId(&this->instr); 11 | } 12 | 13 | InstructionCpu::~InstructionCpu() { 14 | RabbitizerInstruction_destroy(&this->instr); 15 | } 16 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/analysis/RabbitizerLoPairingInfo.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_LO_PAIRING_INFO_H 5 | #define RABBITIZER_LO_PAIRING_INFO_H 6 | #pragma once 7 | 8 | #include 9 | 10 | #include "common/Utils.h" 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | 17 | typedef struct RabbitizerLoPairingInfo { 18 | int instrOffset; 19 | int64_t value; // could be either an unsigned 32 bits number or a signed one, so use 64 bits to ensure it fits 20 | bool shouldProcess; 21 | bool isGpRel; 22 | bool isGpGot; 23 | } RabbitizerLoPairingInfo; 24 | 25 | 26 | NON_NULL(1) 27 | void RabbitizerLoPairingInfo_Init(RabbitizerLoPairingInfo *self); 28 | 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/analysis/RabbitizerRegistersTracker.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_REGISTERS_TRACKER_H 5 | #define RABBITIZER_REGISTERS_TRACKER_H 6 | #pragma once 7 | 8 | #include "common/Utils.h" 9 | #include "RabbitizerTrackedRegisterState.h" 10 | #include "RabbitizerLoPairingInfo.h" 11 | #include "instructions/RabbitizerInstruction.h" 12 | 13 | #ifdef __cplusplus 14 | extern "C" { 15 | #endif 16 | 17 | #define RAB_REGISTERS_COUNT 32 18 | 19 | 20 | typedef struct RabbitizerRegistersTracker { 21 | RabbitizerTrackedRegisterState registers[RAB_REGISTERS_COUNT]; 22 | } RabbitizerRegistersTracker; 23 | 24 | // TODO: Change functions which use parameters as a way to return values into actual structs returned by the functions 25 | 26 | NON_NULL(1) 27 | void RabbitizerRegistersTracker_init(RabbitizerRegistersTracker *self, const RabbitizerRegistersTracker *other); 28 | NON_NULL(1) 29 | void RabbitizerRegistersTracker_destroy(RabbitizerRegistersTracker *self); 30 | 31 | NON_NULL(1, 2) 32 | bool RabbitizerRegistersTracker_moveRegisters(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr); 33 | NON_NULL(1, 2) 34 | void RabbitizerRegistersTracker_overwriteRegisters(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset); 35 | NON_NULL(1, 2, 3) 36 | void RabbitizerRegistersTracker_unsetRegistersAfterFuncCall(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, const RabbitizerInstruction *prevInstr); 37 | NON_NULL(1, 2, 4) 38 | bool RabbitizerRegistersTracker_getAddressIfCanSetType(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset, uint32_t *dstAddress); 39 | NON_NULL(1, 2, 3, 4) 40 | bool RabbitizerRegistersTracker_getJrInfo(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int *dstOffset, uint32_t *dstAddress); 41 | 42 | // prevInstr can be NULL 43 | NON_NULL(1, 2) 44 | void RabbitizerRegistersTracker_processLui(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset, const RabbitizerInstruction *prevInstr); 45 | NON_NULL(1, 2) 46 | void RabbitizerRegistersTracker_processGpLoad(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset); 47 | NON_NULL(1, 2, 3) 48 | bool RabbitizerRegistersTracker_getLuiOffsetForConstant(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int *dstOffset); 49 | NON_NULL(1, 2) 50 | void RabbitizerRegistersTracker_processConstant(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, uint32_t value, int offset); 51 | NON_NULL(1, 2, 4, 5) // deprecated 52 | bool RabbitizerRegistersTracker_getLuiOffsetForLo(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset, int *dstOffset, bool *dstIsGp); 53 | NODISCARD NON_NULL(1, 2) 54 | RabbitizerLoPairingInfo RabbitizerRegistersTracker_preprocessLoAndGetInfo(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset); 55 | NON_NULL(1, 2) 56 | void RabbitizerRegistersTracker_processLo(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, uint32_t value, int offset); 57 | NON_NULL(1, 2) 58 | bool RabbitizerRegistersTracker_hasLoButNoHi(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr); 59 | 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/analysis/RabbitizerTrackedRegisterState.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_TRACKED_REGISTER_STATE_H 5 | #define RABBITIZER_TRACKED_REGISTER_STATE_H 6 | #pragma once 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #include "common/Utils.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | 19 | typedef struct RabbitizerTrackedRegisterState { 20 | int registerNum; 21 | 22 | bool hasLuiValue; 23 | int luiOffset; // The offset of last lui which set a value to this register 24 | bool luiSetOnBranchLikely; 25 | 26 | bool hasGpGot; 27 | int gpGotOffset; 28 | 29 | bool hasLoValue; 30 | int loOffset; 31 | bool dereferenced; 32 | int dereferenceOffset; 33 | 34 | uint32_t value; 35 | } RabbitizerTrackedRegisterState; 36 | 37 | 38 | NON_NULL(1) 39 | void RabbitizerTrackedRegisterState_init(RabbitizerTrackedRegisterState *self, int registerNum); 40 | NON_NULL(1) 41 | void RabbitizerTrackedRegisterState_destroy(RabbitizerTrackedRegisterState *self); 42 | 43 | NON_NULL(1) 44 | void RabbitizerTrackedRegisterState_clear(RabbitizerTrackedRegisterState *self); 45 | NON_NULL(1) 46 | void RabbitizerTrackedRegisterState_clearHi(RabbitizerTrackedRegisterState *self); 47 | NON_NULL(1) 48 | void RabbitizerTrackedRegisterState_clearGp(RabbitizerTrackedRegisterState *self); 49 | NON_NULL(1) 50 | void RabbitizerTrackedRegisterState_clearLo(RabbitizerTrackedRegisterState *self); 51 | 52 | NON_NULL(1, 2) 53 | void RabbitizerTrackedRegisterState_copyState(RabbitizerTrackedRegisterState *self, const RabbitizerTrackedRegisterState *other); 54 | 55 | NON_NULL(1) 56 | void RabbitizerTrackedRegisterState_setHi(RabbitizerTrackedRegisterState *self, uint32_t value, int offset); 57 | NON_NULL(1) 58 | void RabbitizerTrackedRegisterState_setGpLoad(RabbitizerTrackedRegisterState *self, uint32_t value, int offset); 59 | NON_NULL(1) 60 | void RabbitizerTrackedRegisterState_setLo(RabbitizerTrackedRegisterState *self, uint32_t value, int offset); 61 | 62 | NON_NULL(1) 63 | void RabbitizerTrackedRegisterState_deref(RabbitizerTrackedRegisterState *self, int offset); 64 | NON_NULL(1, 2) 65 | void RabbitizerTrackedRegisterState_dereferenceState(RabbitizerTrackedRegisterState *self, const RabbitizerTrackedRegisterState *other, int offset); 66 | 67 | NODISCARD NON_NULL(1) PURE 68 | bool RabbitizerTrackedRegisterState_hasAnyValue(const RabbitizerTrackedRegisterState *self); 69 | NODISCARD NON_NULL(1) PURE 70 | bool RabbitizerTrackedRegisterState_wasSetInCurrentOffset(const RabbitizerTrackedRegisterState *self, int offset); 71 | 72 | NON_NULL(1) 73 | void RabbitizerTrackedRegisterState_fprint(const RabbitizerTrackedRegisterState *self, FILE* outFile); 74 | 75 | 76 | #ifdef __cplusplus 77 | } 78 | #endif 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/common/Abi.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_ABI(NUMERIC), 5 | RABBITIZER_DEF_ABI(O32), 6 | RABBITIZER_DEF_ABI(N32), 7 | RABBITIZER_DEF_ABI(N64), 8 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/common/RabbitizerConfig.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_CONFIG_H 5 | #define RABBITIZER_CONFIG_H 6 | 7 | #include 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | 14 | #define RABBITIZER_DEF_ABI(name) RABBITIZER_ABI_##name 15 | 16 | typedef enum RabbitizerAbi { 17 | #include "Abi.inc" 18 | 19 | RABBITIZER_DEF_ABI(MAX), 20 | } RabbitizerAbi; 21 | 22 | #undef RABBITIZER_DEF_ABI 23 | 24 | RabbitizerAbi RabbitizerAbi_fromStr(const char *name); 25 | 26 | 27 | typedef struct RabbitizerConfig_RegisterNames { 28 | bool namedRegisters; // Enables using named registers. This option takes precedence over the other named register options 29 | RabbitizerAbi gprAbiNames; // The ABI names to be used for general purpose registers when disassembling the main processor's instructions 30 | RabbitizerAbi fprAbiNames; // The ABI names to be used for floating point registers when disassembling the floating point (coprocessor 1) instructions 31 | bool userFpcCsr; // Use FpcCsr as register $31 for the FP control/status register 32 | bool vr4300Cop0NamedRegisters; // Use named registers for VR4300's coprocessor 0 registers 33 | bool vr4300RspCop0NamedRegisters; // Use named registers for VR4300's RSP's coprocessor 0 registers 34 | } RabbitizerConfig_RegisterNames; 35 | 36 | typedef struct RabbitizerConfig_PseudoInstr { 37 | bool enablePseudos; // Produce pseudo instructions (like `move` or `b`) whenever those may match the desired original instruction 38 | bool pseudoBeqz; 39 | bool pseudoBnez; 40 | bool pseudoB; 41 | bool pseudoMove; 42 | bool pseudoNot; 43 | bool pseudoNegu; 44 | bool pseudoBal; 45 | } RabbitizerConfig_PseudoInstr; 46 | 47 | typedef struct RabbitizerConfig_ToolchainTweaks { 48 | bool treatJAsUnconditionalBranch; //! @deprecated 49 | /** 50 | * Enables a few fixes for SN64's assembler related to div/divu instructions 51 | * 52 | * - SN64's assembler doesn't like assembling `div $0, a, b` with .set noat active. 53 | * Removing the $0 fixes this issue (but not for handwritten asm) 54 | * 55 | * - SN64's assembler expands div to have break if dividing by zero 56 | * However, the break it generates is different than the one it generates with `break N` 57 | * So we replace break instrutions for SN64 with the exact word that the assembler generates when expanding div 58 | */ 59 | bool sn64DivFix; 60 | } RabbitizerConfig_ToolchainTweaks; 61 | 62 | typedef struct RabbitizerConfig_Misc { 63 | int opcodeLJust; // The minimal number of characters to left-align the opcode name 64 | bool unknownInstrComment; // Generate a pseudo-disassembly comment when disassembling non implemented instructions 65 | bool omit0XOnSmallImm; 66 | bool upperCaseImm; 67 | } RabbitizerConfig_Misc; 68 | 69 | typedef struct RabbitizerConfig { 70 | RabbitizerConfig_RegisterNames regNames; 71 | RabbitizerConfig_PseudoInstr pseudos; 72 | RabbitizerConfig_ToolchainTweaks toolchainTweaks; 73 | RabbitizerConfig_Misc misc; 74 | } RabbitizerConfig; 75 | 76 | extern RabbitizerConfig RabbitizerConfig_Cfg; 77 | 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/common/RabbitizerVersion.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_VERSION_H 5 | #define RABBITIZER_VERSION_H 6 | 7 | #include "Utils.h" 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif 12 | 13 | 14 | // Header version 15 | #define RAB_VERSION_MAJOR 1 16 | #define RAB_VERSION_MINOR 2 17 | #define RAB_VERSION_PATCH 3 18 | 19 | #define RAB_VERSION_STR RAB_STRINGIFY(RAB_VERSION_MAJOR) "." RAB_STRINGIFY(RAB_VERSION_MINOR) "." RAB_STRINGIFY(RAB_VERSION_PATCH) 20 | 21 | // Compiled library version 22 | extern const int RabVersion_Major; 23 | extern const int RabVersion_Minor; 24 | extern const int RabVersion_Patch; 25 | 26 | extern const char RabVersion_Str[]; 27 | 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/common/Utils.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_UTILS_H 5 | #define RABBITIZER_UTILS_H 6 | 7 | #include 8 | #include 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | 15 | #if !defined(__GNUC__) && !defined(__clang__) 16 | #define __attribute__(x) 17 | #endif 18 | 19 | #if __STDC_VERSION__ >= 202000L 20 | #define CONST [[gnu::const]] 21 | #define DEPRECATED(reason) [[deprecated (reason)]] 22 | #define FALLTHROUGH [[fallthrough]] 23 | #define NODISCARD [[nodiscard]] 24 | #define NORETURN [[noreturn]] 25 | #define NON_NULL(...) [[gnu::nonnull (__VA_ARGS__)]] 26 | #define PURE [[gnu::pure]] 27 | #define RETURNS_NON_NULL [[gnu::returns_nonnull]] 28 | #define UNUSED [[maybe_unused]] 29 | #else 30 | #define CONST __attribute__((const)) 31 | #define DEPRECATED(reason) __attribute__((deprecated (reason))) 32 | #define FALLTHROUGH __attribute__((fallthrough)) 33 | #define NODISCARD __attribute__((warn_unused_result)) 34 | #define NORETURN _Noreturn 35 | #define NON_NULL(...) __attribute__((nonnull (__VA_ARGS__))) 36 | #define PURE __attribute__((pure)) 37 | #define RETURNS_NON_NULL __attribute__((returns_nonnull)) 38 | #define UNUSED __attribute__((unused)) 39 | #endif 40 | 41 | 42 | #if defined(_MSC_VER) 43 | # define UNREACHABLE __assume(0) 44 | #elif defined(__GNUC__) || defined(__clang__) 45 | # define UNREACHABLE __builtin_unreachable() 46 | #else 47 | # define UNREACHABLE 48 | #endif 49 | 50 | 51 | #define ARRAY_COUNT(arr) (sizeof(arr) / sizeof((arr)[0])) 52 | 53 | #define RAB_STRINGIFY(x) #x 54 | 55 | #define MASK(v, w) ((v) & ((1 << (w)) - 1)) 56 | 57 | /* 58 | * the SHIFT macros take a value, a shift amount, and a width. 59 | * 60 | * For the left shift, the lower bits of the value are masked, 61 | * then shifted left. 62 | * 63 | * For the right shift, the value is shifted right, then the lower bits 64 | * are masked. 65 | * 66 | * (NOTE: SHIFTL(v, 0, 32) won't work, just use an assignment) 67 | * 68 | */ 69 | #define SHIFTL(v, s, w) (MASK((v), (w)) << (s)) 70 | #define SHIFTR(v, s, w) (MASK((v) >> (s), (w))) 71 | 72 | #define BITREPACK(fullword, v, s, w) ((SHIFTR((fullword), (s)+(w), 32-((s)+(w))) << ((s)+(w))) | SHIFTL((v), (s), (w)) | MASK((fullword), (s))) 73 | #define BITREPACK_RIGHT(fullword, v, s, w) (SHIFTL((v), (s), (w)) | MASK((fullword), (s))) 74 | 75 | 76 | #define RABUTILS_BUFFER_ADVANCE(buffer, totalSize, expression) \ 77 | do { \ 78 | size_t __tempSize = expression; \ 79 | (buffer) += __tempSize; \ 80 | (totalSize) += __tempSize; \ 81 | } while (0) 82 | 83 | #define RABUTILS_BUFFER_WRITE_CHAR(buffer, totalSize, character) \ 84 | do { \ 85 | *(buffer) = (character); \ 86 | RABUTILS_BUFFER_ADVANCE(buffer, totalSize, 1); \ 87 | } while (0) 88 | 89 | #define RABUTILS_BUFFER_SPRINTF(buffer, totalSize, format, ...) \ 90 | do { \ 91 | int _len = sprintf(buffer, format, __VA_ARGS__); \ 92 | assert(_len > 0); \ 93 | RABUTILS_BUFFER_ADVANCE(buffer, totalSize, _len); \ 94 | } while (0) 95 | 96 | #define RABUTILS_BUFFER_CPY(buffer, totalSize, string) \ 97 | do { \ 98 | size_t _tempSize = strlen(string); \ 99 | memcpy(buffer, string, _tempSize); \ 100 | RABUTILS_BUFFER_ADVANCE(buffer, totalSize, _tempSize); \ 101 | } while (0) 102 | 103 | 104 | CONST NODISCARD 105 | int32_t RabbitizerUtils_From2Complement(uint32_t number, int bits); 106 | NON_NULL(1) 107 | size_t RabbitizerUtils_CharFill(char *dst, int count, char fillchar); 108 | NON_NULL(1, 3) 109 | size_t RabbitizerUtils_escapeString(char *dst, size_t dstSize, const char *src, size_t srcSize); 110 | 111 | 112 | #ifdef __cplusplus 113 | } 114 | #endif 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/InstrCategory.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_INSTR_CATEGORY(CPU), 5 | RABBITIZER_DEF_INSTR_CATEGORY(RSP), // N64 6 | RABBITIZER_DEF_INSTR_CATEGORY(R5900), // PS2's Emotion Engine 7 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/RabbitizerInstrId.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_INSTRID_H 5 | #define RABBITIZER_INSTRID_H 6 | #pragma once 7 | 8 | #include "common/Utils.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | 15 | #define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) \ 16 | RABBITIZER_INSTR_ID_##prefix##_##name, 17 | 18 | #define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) \ 19 | RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, __VA_ARGS__) 20 | 21 | typedef enum RabbitizerInstrId { 22 | #include "instructions/instr_id/RabbitizerInstrId_cpu.inc" 23 | 24 | #include "instructions/instr_id/RabbitizerInstrId_rsp.inc" 25 | 26 | #include "instructions/instr_id/RabbitizerInstrId_r5900.inc" 27 | 28 | RABBITIZER_INSTR_ID_ALL_MAX = RABBITIZER_DEF_INSTR_ID(r5900, , MAX, ) 29 | } RabbitizerInstrId; 30 | 31 | #undef RABBITIZER_DEF_INSTR_ID 32 | #undef RABBITIZER_DEF_INSTR_ID_ALTNAME 33 | 34 | 35 | extern const char *RabbitizerInstrId_Names[]; 36 | 37 | 38 | CONST NODISCARD RETURNS_NON_NULL 39 | const char *RabbitizerInstrId_getOpcodeName(RabbitizerInstrId uniqueId); 40 | 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/RabbitizerInstrSuffix.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_INSTRSUFFIX_H 5 | #define RABBITIZER_INSTRSUFFIX_H 6 | #pragma once 7 | 8 | #include "common/Utils.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | 15 | struct RabbitizerInstruction; 16 | 17 | typedef enum RabbitizerInstrSuffix { 18 | RABINSTRSUFFIX_NONE, 19 | 20 | RABINSTRSUFFIX_R5900_xyzw, 21 | 22 | RABINSTRSUFFIX_MAX 23 | } RabbitizerInstrSuffix; 24 | 25 | CONST NODISCARD NON_NULL(1) 26 | size_t RabbitizerInstrSuffix_getSizeForBuffer(const struct RabbitizerInstruction *self, RabbitizerInstrSuffix instrSuffix); 27 | 28 | CONST NODISCARD NON_NULL(1, 2) 29 | size_t RabbitizerInstrSuffix_processSuffix(const struct RabbitizerInstruction *self, char *dst, RabbitizerInstrSuffix instrSuffix); 30 | 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/RabbitizerInstructionRsp.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_INSTRUCTION_RSP_H 5 | #define RABBITIZER_INSTRUCTION_RSP_H 6 | #pragma once 7 | 8 | #include "RabbitizerInstruction.h" 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | 15 | #define RAB_INSTR_RSP_GET_cop2t(self) (SHIFTR((self)->word, 16, 5)) 16 | #define RAB_INSTR_RSP_GET_cop2cd(self) (SHIFTR((self)->word, 11, 5)) 17 | 18 | #define RAB_INSTR_RSP_GET_vs(self) (SHIFTR((self)->word, 11, 5)) 19 | #define RAB_INSTR_RSP_GET_vt(self) (SHIFTR((self)->word, 16, 5)) 20 | #define RAB_INSTR_RSP_GET_vd(self) (SHIFTR((self)->word, 6, 5)) 21 | 22 | #define RAB_INSTR_RSP_GET_elementhigh(self) (SHIFTR((self)->word, 21, 4)) 23 | #define RAB_INSTR_RSP_GET_elementlow(self) (SHIFTR((self)->word, 7, 4)) 24 | #define RAB_INSTR_RSP_GET_OFFSET_VECTOR_RAW(self) (SHIFTR((self)->word, 0, 7)) 25 | 26 | #define RAB_INSTR_RSP_GET_index(self) (SHIFTR((self)->word, 7, 4)) 27 | #define RAB_INSTR_RSP_GET_de(self) (SHIFTR((self)->word, 11, 5)) 28 | 29 | 30 | #define RAB_INSTR_RSP_PACK_cop2t(word, value) (BITREPACK((word), value, 16, 5)) 31 | #define RAB_INSTR_RSP_PACK_cop2cd(word, value) (BITREPACK((word), value, 11, 5)) 32 | 33 | #define RAB_INSTR_RSP_PACK_vs(word, value) (BITREPACK((word), value, 11, 5)) 34 | #define RAB_INSTR_RSP_PACK_vt(word, value) (BITREPACK((word), value, 16, 5)) 35 | #define RAB_INSTR_RSP_PACK_vd(word, value) (BITREPACK((word), value, 6, 5)) 36 | 37 | #define RAB_INSTR_RSP_PACK_elementhigh(word, value) (BITREPACK((word), value, 21, 4)) 38 | #define RAB_INSTR_RSP_PACK_elementlow(word, value) (BITREPACK((word), value, 7, 4)) 39 | 40 | #define RAB_INSTR_RSP_PACK_index(word, value) (BITREPACK((word), value, 7, 4)) 41 | #define RAB_INSTR_RSP_PACK_offset(word, value) (BITREPACK((word), value, 0, 7)) 42 | #define RAB_INSTR_RSP_PACK_de(word, value) (BITREPACK((word), value, 11, 5)) 43 | 44 | 45 | NON_NULL(1) 46 | void RabbitizerInstructionRsp_init(RabbitizerInstruction *self, uint32_t word, uint32_t vram); 47 | NON_NULL(1) 48 | void RabbitizerInstructionRsp_destroy(RabbitizerInstruction *self); 49 | 50 | 51 | NON_NULL(1) 52 | void RabbitizerInstructionRsp_processUniqueId_Normal(RabbitizerInstruction *self); 53 | NON_NULL(1) 54 | void RabbitizerInstructionRsp_processUniqueId_Special(RabbitizerInstruction *self); 55 | NON_NULL(1) 56 | void RabbitizerInstructionRsp_processUniqueId_Regimm(RabbitizerInstruction *self); 57 | 58 | NON_NULL(1) 59 | void RabbitizerInstructionRsp_processUniqueId(RabbitizerInstruction *self); 60 | 61 | 62 | NODISCARD NON_NULL(1) PURE 63 | uint16_t RabbitizerInstructionRsp_GetOffsetVector(const RabbitizerInstruction *self); 64 | 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/RabbitizerOperandType.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_OPERAND_TYPE_H 5 | #define RABBITIZER_OPERAND_TYPE_H 6 | #pragma once 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | 13 | #define RAB_DEF_OPERAND(prefix, operand) \ 14 | RAB_OPERAND_##prefix##_##operand, 15 | 16 | typedef enum RabbitizerOperandType { 17 | RAB_DEF_OPERAND(ALL, INVALID) 18 | 19 | #include "operands/RabbitizerOperandType_cpu.inc" 20 | #include "operands/RabbitizerOperandType_rsp.inc" 21 | #include "operands/RabbitizerOperandType_r5900.inc" 22 | 23 | RAB_DEF_OPERAND(ALL, MAX) 24 | } RabbitizerOperandType; 25 | 26 | #undef RAB_DEF_OPERAND 27 | 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/RabbitizerInstrId_cpu.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_INSTR_ID(cpu, , INVALID, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate}) 5 | 6 | #include "instructions/instr_id/cpu/cpu_normal.inc" 7 | #include "instructions/instr_id/cpu/cpu_special.inc" 8 | #include "instructions/instr_id/cpu/cpu_regimm.inc" 9 | #include "instructions/instr_id/cpu/cpu_cop0.inc" 10 | #include "instructions/instr_id/cpu/cpu_cop0_bc0.inc" 11 | #include "instructions/instr_id/cpu/cpu_cop0_tlb.inc" 12 | #include "instructions/instr_id/cpu/cpu_cop1.inc" 13 | #include "instructions/instr_id/cpu/cpu_cop1_bc1.inc" 14 | #include "instructions/instr_id/cpu/cpu_cop1_fpu_s.inc" 15 | #include "instructions/instr_id/cpu/cpu_cop1_fpu_d.inc" 16 | #include "instructions/instr_id/cpu/cpu_cop1_fpu_w.inc" 17 | #include "instructions/instr_id/cpu/cpu_cop1_fpu_l.inc" 18 | 19 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_00, .operands={0}) 20 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_01, .operands={0}) 21 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_02, .operands={0}) 22 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_03, .operands={0}) 23 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_04, .operands={0}) 24 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_05, .operands={0}) 25 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_06, .operands={0}) 26 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_07, .operands={0}) 27 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_08, .operands={0}) 28 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_09, .operands={0}) 29 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_10, .operands={0}) 30 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_11, .operands={0}) 31 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_12, .operands={0}) 32 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_13, .operands={0}) 33 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_14, .operands={0}) 34 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_15, .operands={0}) 35 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_16, .operands={0}) 36 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_17, .operands={0}) 37 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_18, .operands={0}) 38 | RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_19, .operands={0}) 39 | 40 | RABBITIZER_DEF_INSTR_ID(cpu, , MAX, .operands={0}) 41 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/RabbitizerInstrId_r5900.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_INSTR_ID(r5900, , INVALID, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .architectureVersion=-1) 5 | 6 | #include "instructions/instr_id/r5900/r5900_normal.inc" 7 | #include "instructions/instr_id/r5900/r5900_special.inc" 8 | #include "instructions/instr_id/r5900/r5900_regimm.inc" 9 | 10 | #include "instructions/instr_id/r5900/r5900_mmi.inc" 11 | #include "instructions/instr_id/r5900/r5900_mmi_0.inc" 12 | #include "instructions/instr_id/r5900/r5900_mmi_1.inc" 13 | #include "instructions/instr_id/r5900/r5900_mmi_2.inc" 14 | #include "instructions/instr_id/r5900/r5900_mmi_3.inc" 15 | 16 | #include "instructions/instr_id/r5900/r5900_cop0_tlb.inc" 17 | 18 | #include "instructions/instr_id/r5900/r5900_cop1_fpu_s.inc" 19 | 20 | #include "instructions/instr_id/r5900/r5900_cop2.inc" 21 | #include "instructions/instr_id/r5900/r5900_cop2_bc2.inc" 22 | #include "instructions/instr_id/r5900/r5900_cop2_special1.inc" 23 | #include "instructions/instr_id/r5900/r5900_cop2_special2.inc" 24 | 25 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_00, .operands={0}) 26 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_01, .operands={0}) 27 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_02, .operands={0}) 28 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_03, .operands={0}) 29 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_04, .operands={0}) 30 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_05, .operands={0}) 31 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_06, .operands={0}) 32 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_07, .operands={0}) 33 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_08, .operands={0}) 34 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_09, .operands={0}) 35 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_10, .operands={0}) 36 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_11, .operands={0}) 37 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_12, .operands={0}) 38 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_13, .operands={0}) 39 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_14, .operands={0}) 40 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_15, .operands={0}) 41 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_16, .operands={0}) 42 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_17, .operands={0}) 43 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_18, .operands={0}) 44 | RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_19, .operands={0}) 45 | 46 | RABBITIZER_DEF_INSTR_ID(r5900, , MAX, .operands={0}) 47 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/RabbitizerInstrId_rsp.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // RSP instructions 5 | RABBITIZER_DEF_INSTR_ID(rsp, , INVALID, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) 6 | 7 | #include "instructions/instr_id/rsp/rsp_cop2.inc" 8 | #include "instructions/instr_id/rsp/rsp_cop2_vu.inc" 9 | 10 | #include "instructions/instr_id/rsp/rsp_normal_lwc2.inc" 11 | #include "instructions/instr_id/rsp/rsp_normal_swc2.inc" 12 | 13 | // CPU instructions but with rsp registers 14 | 15 | #include "instructions/instr_id/rsp/rsp_normal.inc" 16 | #include "instructions/instr_id/rsp/rsp_special.inc" 17 | #include "instructions/instr_id/rsp/rsp_regimm.inc" 18 | #include "instructions/instr_id/rsp/rsp_cop0.inc" 19 | 20 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_00, .operands={0}) 21 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_01, .operands={0}) 22 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_02, .operands={0}) 23 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_03, .operands={0}) 24 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_04, .operands={0}) 25 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_05, .operands={0}) 26 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_06, .operands={0}) 27 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_07, .operands={0}) 28 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_08, .operands={0}) 29 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_09, .operands={0}) 30 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_10, .operands={0}) 31 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_11, .operands={0}) 32 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_12, .operands={0}) 33 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_13, .operands={0}) 34 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_14, .operands={0}) 35 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_15, .operands={0}) 36 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_16, .operands={0}) 37 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_17, .operands={0}) 38 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_18, .operands={0}) 39 | RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_19, .operands={0}) 40 | 41 | RABBITIZER_DEF_INSTR_ID(rsp, , MAX, .operands={0}) 42 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop0.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP rt, cop0d 5 | RABBITIZER_DEF_INSTR_ID(cpu, 0x00, mfc0, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop0d}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .modifiesRt=true, .notEmitedByCompilers=true) // Move word From CP0 6 | RABBITIZER_DEF_INSTR_ID(cpu, 0x01, dmfc0, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop0d}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .modifiesRt=true) // Doubleword Move From CP0 7 | RABBITIZER_DEF_INSTR_ID(cpu, 0x02, cfc0, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop0d}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .modifiesRt=true) // Move control word From CP0 8 | RABBITIZER_DEF_INSTR_ID(cpu, 0x04, mtc0, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop0d}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmitedByCompilers=true) // Move word to CP0 9 | RABBITIZER_DEF_INSTR_ID(cpu, 0x05, dmtc0, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop0d}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN) // Doubleword Move To CP0 10 | RABBITIZER_DEF_INSTR_ID(cpu, 0x06, ctc0, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop0d}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN) // Move control word To CP0 11 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop0_bc0.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP IMM 5 | RABBITIZER_DEF_INSTR_ID(cpu, 0x00, bc0f, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isBranch=true) // Branch on FP False 6 | RABBITIZER_DEF_INSTR_ID(cpu, 0x01, bc0t, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isBranch=true) // Branch on FP True 7 | RABBITIZER_DEF_INSTR_ID(cpu, 0x02, bc0fl, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isBranch=true, .isBranchLikely=true) // Branch on FP False Likely 8 | RABBITIZER_DEF_INSTR_ID(cpu, 0x03, bc0tl, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isBranch=true, .isBranchLikely=true) // Branch on FP True Likely 9 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop0_tlb.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP 5 | RABBITIZER_DEF_INSTR_ID(cpu, 0x01, tlbr, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmitedByCompilers=true) // Read Indexed TLB Entry 6 | RABBITIZER_DEF_INSTR_ID(cpu, 0x02, tlbwi, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmitedByCompilers=true) // Write Indexed TLB Entry 7 | 8 | RABBITIZER_DEF_INSTR_ID(cpu, 0x06, tlbwr, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN) // Write Random TLB Entry 9 | 10 | RABBITIZER_DEF_INSTR_ID(cpu, 0x08, tlbp, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmitedByCompilers=true) // Probe TLB for Matching Entry 11 | 12 | RABBITIZER_DEF_INSTR_ID(cpu, 0x18, eret, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmitedByCompilers=true) // Return from Exception 13 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP rt, fs 5 | RABBITIZER_DEF_INSTR_ID(cpu, 0x00, mfc1, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .modifiesRt=true) // Move Word From Floating-Point 6 | RABBITIZER_DEF_INSTR_ID(cpu, 0x01, dmfc1, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .modifiesRt=true) // Doubleword Move From Floating-Point 7 | RABBITIZER_DEF_INSTR_ID(cpu, 0x04, mtc1, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Move Word to Floating-Point 8 | RABBITIZER_DEF_INSTR_ID(cpu, 0x05, dmtc1, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Doubleword Move To Floating-Point 9 | 10 | // OP rt, cop1cs 11 | RABBITIZER_DEF_INSTR_ID(cpu, 0x02, cfc1, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop1cs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .modifiesRt=true) // Move Control Word from Floating-Point 12 | RABBITIZER_DEF_INSTR_ID(cpu, 0x06, ctc1, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_cop1cs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Move Control Word to Floating-Point 13 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_bc1.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP IMM 5 | RABBITIZER_DEF_INSTR_ID(cpu, 0x00, bc1f, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isBranch=true) 6 | RABBITIZER_DEF_INSTR_ID(cpu, 0x01, bc1t, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isBranch=true) 7 | RABBITIZER_DEF_INSTR_ID(cpu, 0x02, bc1fl, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isBranch=true, .isBranchLikely=true) 8 | RABBITIZER_DEF_INSTR_ID(cpu, 0x03, bc1tl, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isBranch=true, .isBranchLikely=true) 9 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_l.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP fd, fs 5 | RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x20, cvt_s_l, cvt.s.l, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) 6 | RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x21, cvt_d_l, cvt.d.l, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .isDouble=true) 7 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_w.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP fd, fs 5 | RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x20, cvt_s_w, cvt.s.w, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) 6 | RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x21, cvt_d_w, cvt.d.w, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .isDouble=true) 7 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/cpu/cpu_regimm.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP rs, IMM 5 | RABBITIZER_DEF_INSTR_ID(cpu, 0x00, bltz, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Branch on Less Than Zero 6 | RABBITIZER_DEF_INSTR_ID(cpu, 0x01, bgez, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Branch on Greater than or Equal to Zero 7 | RABBITIZER_DEF_INSTR_ID(cpu, 0x02, bltzl, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true, .isBranchLikely=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Branch on Less Than Zero Likely 8 | RABBITIZER_DEF_INSTR_ID(cpu, 0x03, bgezl, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true, .isBranchLikely=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Branch on Greater than or Equal to Zero Likely 9 | 10 | RABBITIZER_DEF_INSTR_ID(cpu, 0x08, tgei, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isTrap=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) 11 | RABBITIZER_DEF_INSTR_ID(cpu, 0x09, tgeiu, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isTrap=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) 12 | RABBITIZER_DEF_INSTR_ID(cpu, 0x0A, tlti, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isTrap=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) 13 | RABBITIZER_DEF_INSTR_ID(cpu, 0x0B, tltiu, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isTrap=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) 14 | RABBITIZER_DEF_INSTR_ID(cpu, 0x0C, teqi, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isTrap=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) 15 | RABBITIZER_DEF_INSTR_ID(cpu, 0x0E, tnei, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isTrap=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) 16 | 17 | RABBITIZER_DEF_INSTR_ID(cpu, 0x10, bltzal, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true, .doesLink=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Branch on Less Than Zero and Link 18 | RABBITIZER_DEF_INSTR_ID(cpu, 0x11, bgezal, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true, .doesLink=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Branch on Greater Than or Equal to Zero and Link 19 | RABBITIZER_DEF_INSTR_ID(cpu, 0x12, bltzall, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true, .isBranchLikely=true, .doesLink=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Branch on Less Than Zero and Link Likely 20 | RABBITIZER_DEF_INSTR_ID(cpu, 0x13, bgezall, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true, .isBranchLikely=true, .doesLink=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Branch on Greater Than or Equal to Zero and Link Likely 21 | 22 | 23 | // Pseudo-Instruction Unique IDs 24 | 25 | RABBITIZER_DEF_INSTR_ID(cpu, -0x11, bal, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true, .doesLink=true, .isPseudo=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Branch and Link 26 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop0_tlb.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | /* 5 | 31--------26-25------21--------------------------------5--------0 6 | | = COP0 | TLB | | fmt | 7 | ------6----------5----------------------------------------------- 8 | |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 9 | 000 | --- | TLBR | TLBWI | --- | --- | --- | TLBWR | --- | 10 | 001 | TLBP | --- | --- | --- | --- | --- | --- | --- | 11 | 010 | --- | --- | --- | --- | --- | --- | --- | --- | 12 | 011 | ERET | --- | --- | --- | --- | --- | --- | --- | 13 | 100 | --- | --- | --- | --- | --- | --- | --- | --- | 14 | 101 | --- | --- | --- | --- | --- | --- | --- | --- | 15 | 110 | --- | --- | --- | --- | --- | --- | --- | --- | 16 | 111 | EI | DI | --- | --- | --- | --- | --- | --- | 17 | hi |-------|-------|-------|-------|-------|-------|-------|-------| 18 | */ 19 | 20 | // The other instructions are implemented using the main CPU table 21 | 22 | RABBITIZER_DEF_INSTR_ID(r5900, 0x38, ei, .operands={0}) 23 | RABBITIZER_DEF_INSTR_ID(r5900, 0x39, di, .operands={0}) 24 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop1_fpu_s.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | /* 5 | 31--------26-25------21 -------------------------------5--------0 6 | | = COP1 | = S | | function| 7 | ------6----------5-----------------------------------------6----- 8 | |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 9 | 000 | ADD.S | SUB.S | MUL.S | DIV.S | SQRT.S| ABS.S | MOV.S | NEG.S | 10 | 001 | --- | --- | --- | --- | --- | --- | --- | --- | 11 | 010 | --- | --- | --- | --- | --- | --- |RSQRT.S| --- | 12 | 011 | ADDA.S| SUBA.S| MULA.S| --- | MADD.S| MSUB.S|MADDA.S|MSUBA.S| 13 | 100 | --- | --- | --- | --- | CVT.W | --- | --- | --- | 14 | 101 | MAX.S | MIN.S | --- | --- | --- | --- | --- | --- | 15 | 110 | C.F | --- | C.EQ | --- | C.LT | --- | C.LE | --- | 16 | 111 | --- | --- | --- | --- | --- | --- | --- | --- | 17 | hi |-------|-------|-------|-------|-------|-------|-------|-------| 18 | */ 19 | 20 | // The other instructions are implemented using the main CPU table 21 | 22 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x04, c1__sqrt_s, c1, .operands={RAB_OPERAND_cpu_copraw}) 23 | 24 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x16, rsqrt_s, rsqrt.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) // floating point Reciprocal SQuare RooT 25 | 26 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x18, adda_s, adda.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) // floating point ADD to Accumulator 27 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x19, suba_s, suba.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) // floating point SUBtract to Accumulator 28 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x1A, mula_s, mula.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) // floating point MULtiply to Accumulator 29 | 30 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x1C, madd_s, madd.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) // floating point Multiply-ADD 31 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x1D, msub_s, msub.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) // floating point Multiply abd SUBtract 32 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x1E, madda_s, madda.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) // floating point Multiply-ADD Accumulator 33 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x1F, msuba_s, msuba.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) // floating point Multiply SUBtract from Accumulator 34 | 35 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x28, max_s, max.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) // floating point MAXimum 36 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x29, min_s, min.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) // floating point MINimum 37 | 38 | // Due to the R5900's FPU being non properly complaint the instruction cvt.w.s always behaves as trunc.w.s because is because EE can only do round-to-zero. 39 | // Assemblers like GAS workaround this issue by decoding cvt.w.s as trunc.w.s, so we mimic that behaviour to allow assembling with GAS. 40 | // Here's some reading about the binutils rationale: 41 | // https://sourceware.org/legacy-ml/binutils/2012-11/msg00360.html 42 | // https://sourceware.org/pipermail/binutils/2013-January/079863.html 43 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x24, trunc_w_s, trunc.w.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .isFloat=true) // Floating-Point Truncate to Word Fixed-Point 44 | 45 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x34, c_lt_s, c.lt.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) 46 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x36, c_le_s, c.le.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) 47 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | /* 5 | 31--------26-25------21 ----------------------------------------0 6 | | = COP2 | fmt | | 7 | ------6----------5----------------------------------------------- 8 | |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 9 | 00 | --- | QMFC2 | CFC2 | --- | --- | QMTC2 | CTC2 | --- | 10 | 01 | *1 | --- | --- | --- | --- | --- | --- | --- | 11 | 10 | *2 | *2 | *2 | *2 | *2 | *2 | *2 | *2 | 12 | 11 | *2 | *2 | *2 | *2 | *2 | *2 | *2 | *2 | 13 | hi |-------|-------|-------|-------|-------|-------|-------|-------| 14 | *1 = BC instructions, see BC2 list *2 =see special1 table 15 | */ 16 | 17 | // TODO: properties 18 | RABBITIZER_DEF_INSTR_ID(r5900, 0x01, qmfc2, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_r5900_vfs}) 19 | RABBITIZER_DEF_INSTR_ID(r5900, 0x02, cfc2, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_r5900_vis}) 20 | RABBITIZER_DEF_INSTR_ID(r5900, 0x05, qmtc2, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_r5900_vfs}) 21 | RABBITIZER_DEF_INSTR_ID(r5900, 0x06, ctc2, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_r5900_vis}) 22 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2_bc2.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | /* 5 | 31--------26-25------21-20------16------------------------------0 6 | | = COP0 | BC2 | fmt | | 7 | ------6----------5----------5------------------------------------ 8 | |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 9 | 00 | BC2F | BC2T | BC2FL | BC2TL | --- | --- | --- | --- | 10 | 01 | --- | --- | --- | --- | --- | --- | --- | --- | 11 | 10 | --- | --- | --- | --- | --- | --- | --- | --- | 12 | 11 | --- | --- | --- | --- | --- | --- | --- | --- | 13 | hi |-------|-------|-------|-------|-------|-------|-------|-------| 14 | */ 15 | 16 | // TODO: operands and properties 17 | 18 | RABBITIZER_DEF_INSTR_ID(r5900, 0x00, bc2f, .operands={RAB_OPERAND_cpu_branch_target_label}, .isBranch=true) 19 | RABBITIZER_DEF_INSTR_ID(r5900, 0x01, bc2t, .operands={RAB_OPERAND_cpu_branch_target_label}, .isBranch=true) 20 | RABBITIZER_DEF_INSTR_ID(r5900, 0x02, bc2fl, .operands={RAB_OPERAND_cpu_branch_target_label}, .isBranch=true, .isBranchLikely=true) 21 | RABBITIZER_DEF_INSTR_ID(r5900, 0x03, bc2tl, .operands={RAB_OPERAND_cpu_branch_target_label}, .isBranch=true, .isBranchLikely=true) 22 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_1.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | /* 5 | 31---------26------------------------------------------5--------0 6 | | | |function | MMI1 | 7 | ------6----------------------------------------------------6----- 8 | |---00--|---01--|---10--|---11--| lo 9 | 000 | --- | PABSW | PCEQW | PMINW | 10 | 001 |PADSBH | PABSH | PCEQH | PMINH | 11 | 010 | --- | --- | PCEQB | --- | 12 | 011 | --- | --- | --- | --- | 13 | 100 |PADDUW |PSUBUW |PEXTUW | --- | 14 | 101 |PADDUH |PSUBUH |PEXTUH | --- | 15 | 110 |PADDUB |PSUBUB |PEXTUB | QFSRV | 16 | 111 | --- | --- | --- | --- | 17 | hi |-------|-------|-------|-------| 18 | */ 19 | 20 | // TODO: operands and properties 21 | RABBITIZER_DEF_INSTR_ID(r5900, 0x01, pabsw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ABSolute Word 22 | RABBITIZER_DEF_INSTR_ID(r5900, 0x02, pceqw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Compare for EQual Word 23 | RABBITIZER_DEF_INSTR_ID(r5900, 0x03, pminw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel MINimum Word 24 | 25 | RABBITIZER_DEF_INSTR_ID(r5900, 0x04, padsbh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ADd/SuBtract Halfword 26 | RABBITIZER_DEF_INSTR_ID(r5900, 0x05, pabsh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ABSolute Halfword 27 | RABBITIZER_DEF_INSTR_ID(r5900, 0x06, pceqh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Compare for EQual Halfword 28 | RABBITIZER_DEF_INSTR_ID(r5900, 0x07, pminh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel MINimum Halfword 29 | 30 | RABBITIZER_DEF_INSTR_ID(r5900, 0x0A, pceqb, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Compare for EQual Byte 31 | 32 | RABBITIZER_DEF_INSTR_ID(r5900, 0x10, padduw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ADD Unsigned saturation Word 33 | RABBITIZER_DEF_INSTR_ID(r5900, 0x11, psubuw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel SUBtract Unsigned saturation Word 34 | RABBITIZER_DEF_INSTR_ID(r5900, 0x12, pextuw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXTend Upper from Word 35 | 36 | RABBITIZER_DEF_INSTR_ID(r5900, 0x14, padduh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ADD Unsigned saturation Halfword 37 | RABBITIZER_DEF_INSTR_ID(r5900, 0x15, psubuh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel SUBtract Unsigned saturation Halfword 38 | RABBITIZER_DEF_INSTR_ID(r5900, 0x16, pextuh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXTend Upper from Halfword 39 | 40 | RABBITIZER_DEF_INSTR_ID(r5900, 0x18, paddub, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ADD Unsigned saturation Byte 41 | RABBITIZER_DEF_INSTR_ID(r5900, 0x19, psubub, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel SUBtract Unsigned saturation Byte 42 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1A, pextub, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXTend Upper from Byte 43 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1B, qfsrv, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Quadword Funnel Shift Right Variable 44 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_2.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | /* 5 | 31---------26------------------------------------------5--------0 6 | | | |function | MMI2 | 7 | ------6----------------------------------------------------6----- 8 | |---00--|---01--|---10--|---11--| lo 9 | 000 |PMADDW | --- |PSLLVW |PSRLVW | 10 | 001 |PMSUBW | --- | --- | --- | 11 | 010 |PMFHI |PMFLO |PINTH | --- | 12 | 011 |PMULTW |PDIVW |PCPYLD | --- | 13 | 100 |PMADDH |PHMADH | PAND | PXOR | 14 | 101 |PMSUBH |PHMSBH | --- | --- | 15 | 110 | --- | --- | PEXEH | PREVH | 16 | 111 |PMULTH |PDIVBW | PEXEW |PROT3W | 17 | hi |-------|-------|-------|-------| 18 | */ 19 | 20 | RABBITIZER_DEF_INSTR_ID(r5900, 0x00, pmaddw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Multiply-ADD Word 21 | RABBITIZER_DEF_INSTR_ID(r5900, 0x02, psllvw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs}, .modifiesRd=true) // Parallel Shift Left Logical Variable Word 22 | RABBITIZER_DEF_INSTR_ID(r5900, 0x03, psrlvw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs}, .modifiesRd=true) // Parallel Shift Right Logical Variable Word 23 | 24 | RABBITIZER_DEF_INSTR_ID(r5900, 0x04, pmsubw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Multiply-SUBtract Word 25 | 26 | RABBITIZER_DEF_INSTR_ID(r5900, 0x08, pmfhi, .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true) // Parallel Move From HI register 27 | RABBITIZER_DEF_INSTR_ID(r5900, 0x09, pmflo, .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true) // Parallel Move From LO register 28 | RABBITIZER_DEF_INSTR_ID(r5900, 0x0A, pinth, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel INTerleave Halfword 29 | 30 | RABBITIZER_DEF_INSTR_ID(r5900, 0x0C, pmultw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel MULTiply Word 31 | RABBITIZER_DEF_INSTR_ID(r5900, 0x0D, pdivw, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}) // Parallel DIVide Word 32 | RABBITIZER_DEF_INSTR_ID(r5900, 0x0E, pcpyld, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel CoPY Lower Doubleword 33 | 34 | RABBITIZER_DEF_INSTR_ID(r5900, 0x10, pmaddh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Multiply-ADD Halfword 35 | RABBITIZER_DEF_INSTR_ID(r5900, 0x11, phmadh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Horizontal Multiply-ADd Halfword 36 | RABBITIZER_DEF_INSTR_ID(r5900, 0x12, pand, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel AND 37 | RABBITIZER_DEF_INSTR_ID(r5900, 0x13, pxor, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel eXclusive OR 38 | 39 | RABBITIZER_DEF_INSTR_ID(r5900, 0x14, pmsubh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Multiply-SUBtract Halfword 40 | RABBITIZER_DEF_INSTR_ID(r5900, 0x15, phmsbh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Horizontal Multiply-Subtract Halfword 41 | 42 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1A, pexeh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXchange Even Halfword 43 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1B, prevh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel REVerse Halfword 44 | 45 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1C, pmulth, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Multiply Halfword 46 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1D, pdivbw, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel DIVide Broadcast Word 47 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1E, pexew, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXchange Even Word 48 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1F, prot3w, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ROTate 3 Words left 49 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_3.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | /* 5 | 31---------26------------------------------------------5--------0 6 | | | |function | MMI3 | 7 | ------6----------------------------------------------------6----- 8 | |---00--|---01--|---10--|---11--| lo 9 | 000 |PMADDUW| --- | --- |PSRAVW | 10 | 001 | --- | --- | --- | --- | 11 | 010 |PMTHI | PMTLO |PINTEH | --- | 12 | 011 |PMULTUW| PDIVUW|PCPYUD | --- | 13 | 100 | --- | --- | POR | PNOR | 14 | 101 | --- | --- | --- | --- | 15 | 110 | --- | --- | PEXCH | PCPYH | 16 | 111 | --- | --- | PEXCW | --- | 17 | hi |-------|-------|-------|-------| 18 | */ 19 | 20 | RABBITIZER_DEF_INSTR_ID(r5900, 0x00, pmadduw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Multiply-ADD Unsigned Word 21 | RABBITIZER_DEF_INSTR_ID(r5900, 0x03, psravw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs}, .modifiesRd=true) // Parallel Shift Right Arithmetic Variable Word 22 | 23 | RABBITIZER_DEF_INSTR_ID(r5900, 0x08, pmthi, .operands={RAB_OPERAND_cpu_rs}) // Parallel Move To HI register 24 | RABBITIZER_DEF_INSTR_ID(r5900, 0x09, pmtlo, .operands={RAB_OPERAND_cpu_rs}) // Parallel Move To LO register 25 | RABBITIZER_DEF_INSTR_ID(r5900, 0x0A, pinteh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel INTerleave Even Halfword 26 | 27 | RABBITIZER_DEF_INSTR_ID(r5900, 0x0C, pmultuw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel MULTiply Unsigned Word 28 | RABBITIZER_DEF_INSTR_ID(r5900, 0x0D, pdivuw, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}) // Prallel DIVide Unsigned Word 29 | RABBITIZER_DEF_INSTR_ID(r5900, 0x0E, pcpyud, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel CoPY Upper Doubleword 30 | 31 | RABBITIZER_DEF_INSTR_ID(r5900, 0x12, por, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel OR 32 | RABBITIZER_DEF_INSTR_ID(r5900, 0x13, pnor, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Not OR 33 | 34 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1A, pexch, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXchange Center Halfword 35 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1B, pcpyh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel CoPY Halfword 36 | 37 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1E, pexcw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXchange Center Word 38 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/r5900/r5900_normal.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | /* 5 | 31---------26---------------------------------------------------0 6 | | opcode | | 7 | ------6---------------------------------------------------------- 8 | |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 9 | 000 | *1 | *2 | J | JAL | BEQ | BNE | BLEZ | BGTZ | 10 | 001 | ADDI | ADDIU | SLTI | SLTIU | ANDI | ORI | XORI | LUI | 11 | 010 | *3 | *4 | *5 | --- | BEQL | BNEL | BLEZL | BGTZL | 12 | 011 | DADDI |DADDIU | LDL | LDR | *6 | --- | LQ | SQ | 13 | 100 | LB | LH | LWL | LW | LBU | LHU | LWR | LWU | 14 | 101 | SB | SH | SWL | SW | SDL | SDR | SWR | CACHE | 15 | 110 | --- | LWC1 | --- | PREF | --- | --- | LQC2 | LD | 16 | 111 | --- | SWC1 | --- | --- | --- | --- | SQC2 | SD | 17 | hi |-------|-------|-------|-------|-------|-------|-------|-------| 18 | *1 = SPECIAL, see SPECIAL list *2 = REGIMM, see REGIMM list 19 | *3 = COP0 *4 = COP1 20 | *5 = COP2 *6 = MMI table 21 | */ 22 | 23 | // The other instructions are implemented using the main CPU table 24 | 25 | 26 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1E, lq, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true) // Load Quadword 27 | RABBITIZER_DEF_INSTR_ID(r5900, 0x1F, sq, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true) // Store Quadword 28 | 29 | RABBITIZER_DEF_INSTR_ID(r5900, 0x36, lqc2, .operands={RAB_OPERAND_r5900_vft, RAB_OPERAND_cpu_immediate_base}, .canBeLo=true, .doesDereference=true, .doesLoad=true) 30 | 31 | RABBITIZER_DEF_INSTR_ID(r5900, 0x3E, sqc2, .operands={RAB_OPERAND_r5900_vft, RAB_OPERAND_cpu_immediate_base}, .canBeLo=true, .doesDereference=true, .doesStore=true) 32 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/r5900/r5900_regimm.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | /* 5 | 31---------26----------20-------16------------------------------0 6 | | = REGIMM | | rt | | 7 | ------6---------------------5------------------------------------ 8 | |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 9 | 00 | BLTZ | BGEZ | BLTZL | BGEZL | --- | --- | --- | --- | 10 | 01 | TGEI | TGEIU | TLTI | TLTIU | TEQI | --- | TNEI | --- | 11 | 10 | BLTZAL| BGEZAL|BLTZALL|BGEZALL| --- | --- | --- | --- | 12 | 11 | MTSAB | MTSAH | --- | --- | --- | --- | --- | --- | 13 | hi |-------|-------|-------|-------|-------|-------|-------|-------| 14 | */ 15 | 16 | // The other instructions are implemented using the main CPU table 17 | 18 | // OP rs, IMM 19 | RABBITIZER_DEF_INSTR_ID(r5900, 0x18, mtsab, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM) 20 | RABBITIZER_DEF_INSTR_ID(r5900, 0x19, mtsah, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM) 21 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/r5900/r5900_special.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | /* 5 | 31---------26------------------------------------------5--------0 6 | | = SPECIAL | | function| 7 | ------6----------------------------------------------------6----- 8 | |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo 9 | 000 | SLL | --- | SRL | SRA | SLLV | --- | SRLV | SRAV | 10 | 001 | JR | JALR | MOVZ | MOVN |SYSCALL| BREAK | --- | SYNC | 11 | 010 | MFHI | MTHI | MFLO | MTLO | DSLLV | --- | DSRLV | DSRAV | 12 | 011 | MULT | MULTU | DIV | DIVU | ---- | --- | ---- | ----- | 13 | 100 | ADD | ADDU | SUB | SUBU | AND | OR | XOR | NOR | 14 | 101 | MFSA | MTSA | SLT | SLTU | DADD | DADDU | DSUB | DSUBU | 15 | 110 | TGE | TGEU | TLT | TLTU | TEQ | --- | TNE | --- | 16 | 111 | DSLL | --- | DSRL | DSRA |DSLL32 | --- |DSRL32 |DSRA32 | 17 | hi |-------|-------|-------|-------|-------|-------|-------|-------| 18 | */ 19 | 20 | // The other instructions are implemented using the main CPU table 21 | 22 | RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, -0x0F, sync_p, sync.p, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Sync 23 | 24 | RABBITIZER_DEF_INSTR_ID(r5900, 0x18, mult, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // MULTtiply word 25 | 26 | RABBITIZER_DEF_INSTR_ID(r5900, 0x28, mfsa, .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true) // Move From Shift Amount register 27 | RABBITIZER_DEF_INSTR_ID(r5900, 0x29, mtsa, .operands={RAB_OPERAND_cpu_rs}) // Move To Shift Amount register 28 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/rsp/rsp_cop0.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP rt, cop0d 5 | RABBITIZER_DEF_INSTR_ID(rsp, 0x00, mfc0, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_cop0d}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .modifiesRt=true, .notEmitedByCompilers=true) // Move word From CP0 6 | RABBITIZER_DEF_INSTR_ID(rsp, 0x04, mtc0, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_cop0d}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmitedByCompilers=true) // Move word to CP0 7 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/rsp/rsp_cop2.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP cop2t, vd[index] 5 | RABBITIZER_DEF_INSTR_ID(rsp, 0x00, mfc2, .operands={RAB_OPERAND_rsp_cop2t, RAB_OPERAND_rsp_vs_index}, .modifiesRt=true) 6 | RABBITIZER_DEF_INSTR_ID(rsp, 0x04, mtc2, .operands={RAB_OPERAND_rsp_cop2t, RAB_OPERAND_rsp_vs_index}) 7 | 8 | // OP rt, cop2cd 9 | RABBITIZER_DEF_INSTR_ID(rsp, 0x02, cfc2, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_rsp_cop2cd}, .modifiesRt=true) 10 | RABBITIZER_DEF_INSTR_ID(rsp, 0x06, ctc2, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_rsp_cop2cd}) 11 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/rsp/rsp_normal_lwc2.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP vt[elementlow], offset(vs) 5 | RABBITIZER_DEF_INSTR_ID(rsp, 0x00, lbv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 6 | RABBITIZER_DEF_INSTR_ID(rsp, 0x01, lsv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 7 | RABBITIZER_DEF_INSTR_ID(rsp, 0x02, llv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 8 | RABBITIZER_DEF_INSTR_ID(rsp, 0x03, ldv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 9 | RABBITIZER_DEF_INSTR_ID(rsp, 0x04, lqv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 10 | RABBITIZER_DEF_INSTR_ID(rsp, 0x05, lrv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 11 | RABBITIZER_DEF_INSTR_ID(rsp, 0x06, lpv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 12 | RABBITIZER_DEF_INSTR_ID(rsp, 0x07, luv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 13 | RABBITIZER_DEF_INSTR_ID(rsp, 0x08, lhv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 14 | RABBITIZER_DEF_INSTR_ID(rsp, 0x09, lfv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 15 | RABBITIZER_DEF_INSTR_ID(rsp, 0x0B, ltv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 16 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/rsp/rsp_normal_swc2.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP vt[elementlow], offset(vs) 5 | RABBITIZER_DEF_INSTR_ID(rsp, 0x00, sbv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 6 | RABBITIZER_DEF_INSTR_ID(rsp, 0x01, ssv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 7 | RABBITIZER_DEF_INSTR_ID(rsp, 0x02, slv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 8 | RABBITIZER_DEF_INSTR_ID(rsp, 0x03, sdv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 9 | RABBITIZER_DEF_INSTR_ID(rsp, 0x04, sqv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 10 | RABBITIZER_DEF_INSTR_ID(rsp, 0x05, srv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 11 | RABBITIZER_DEF_INSTR_ID(rsp, 0x06, spv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 12 | RABBITIZER_DEF_INSTR_ID(rsp, 0x07, suv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 13 | RABBITIZER_DEF_INSTR_ID(rsp, 0x08, shv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 14 | RABBITIZER_DEF_INSTR_ID(rsp, 0x09, sfv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 15 | RABBITIZER_DEF_INSTR_ID(rsp, 0x0B, stv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 16 | 17 | RABBITIZER_DEF_INSTR_ID(rsp, -0x07, swv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) 18 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/instr_id/rsp/rsp_regimm.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | // OP rs, IMM 5 | RABBITIZER_DEF_INSTR_ID(rsp, 0x00, bltz, .operands={RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true) // Branch on Less Than Zero 6 | RABBITIZER_DEF_INSTR_ID(rsp, 0x01, bgez, .operands={RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true) // Branch on Greater than or Equal to Zero 7 | 8 | RABBITIZER_DEF_INSTR_ID(rsp, 0x10, bltzal, .operands={RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true, .doesLink=true) // Branch on Less Than Zero and Link 9 | RABBITIZER_DEF_INSTR_ID(rsp, 0x11, bgezal, .operands={RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true, .doesLink=true) // Branch on Greater Than or Equal to Zero and Link 10 | 11 | 12 | // Pseudo-Instruction Unique IDs 13 | 14 | RABBITIZER_DEF_INSTR_ID(rsp, -0x11, bal, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true, .doesLink=true, .isPseudo=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Branch and Link 15 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/operands/RabbitizerOperandType_cpu.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RAB_DEF_OPERAND(cpu, rs) 5 | RAB_DEF_OPERAND(cpu, rt) 6 | RAB_DEF_OPERAND(cpu, rd) 7 | RAB_DEF_OPERAND(cpu, sa) 8 | RAB_DEF_OPERAND(cpu, zero) // $zero 9 | // RAB_DEF_OPERAND(cpu, function) 10 | RAB_DEF_OPERAND(cpu, cop0d) 11 | RAB_DEF_OPERAND(cpu, fs) 12 | RAB_DEF_OPERAND(cpu, ft) 13 | RAB_DEF_OPERAND(cpu, fd) 14 | RAB_DEF_OPERAND(cpu, cop1cs) // Coprocessor 1 control fs 15 | RAB_DEF_OPERAND(cpu, cop2t) 16 | RAB_DEF_OPERAND(cpu, op) 17 | RAB_DEF_OPERAND(cpu, code) 18 | RAB_DEF_OPERAND(cpu, code_lower) 19 | RAB_DEF_OPERAND(cpu, copraw) 20 | RAB_DEF_OPERAND(cpu, label) 21 | RAB_DEF_OPERAND(cpu, immediate) 22 | RAB_DEF_OPERAND(cpu, branch_target_label) 23 | 24 | // composed/aliased operands 25 | RAB_DEF_OPERAND(cpu, immediate_base) 26 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/operands/RabbitizerOperandType_r5900.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RAB_DEF_OPERAND(r5900, I) 5 | RAB_DEF_OPERAND(r5900, Q) 6 | RAB_DEF_OPERAND(r5900, R) 7 | RAB_DEF_OPERAND(r5900, ACC) 8 | RAB_DEF_OPERAND(r5900, ACCxyzw) 9 | RAB_DEF_OPERAND(r5900, vfs) 10 | RAB_DEF_OPERAND(r5900, vft) 11 | RAB_DEF_OPERAND(r5900, vfd) 12 | RAB_DEF_OPERAND(r5900, vfsxyzw) 13 | RAB_DEF_OPERAND(r5900, vftxyzw) 14 | RAB_DEF_OPERAND(r5900, vfdxyzw) 15 | RAB_DEF_OPERAND(r5900, vfsn) 16 | RAB_DEF_OPERAND(r5900, vftn) 17 | RAB_DEF_OPERAND(r5900, vfdn) 18 | RAB_DEF_OPERAND(r5900, vfsl) 19 | RAB_DEF_OPERAND(r5900, vftl) 20 | RAB_DEF_OPERAND(r5900, vfdl) 21 | RAB_DEF_OPERAND(r5900, vfsm) 22 | RAB_DEF_OPERAND(r5900, vftm) 23 | RAB_DEF_OPERAND(r5900, vfdm) 24 | RAB_DEF_OPERAND(r5900, vis) 25 | RAB_DEF_OPERAND(r5900, vit) 26 | RAB_DEF_OPERAND(r5900, vid) 27 | RAB_DEF_OPERAND(r5900, vis_predecr) 28 | RAB_DEF_OPERAND(r5900, vit_predecr) 29 | RAB_DEF_OPERAND(r5900, vid_predecr) 30 | RAB_DEF_OPERAND(r5900, vis_postincr) 31 | RAB_DEF_OPERAND(r5900, vit_postincr) 32 | RAB_DEF_OPERAND(r5900, vid_postincr) 33 | RAB_DEF_OPERAND(r5900, immediate5) 34 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/operands/RabbitizerOperandType_rsp.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RAB_DEF_OPERAND(rsp, rs) 5 | RAB_DEF_OPERAND(rsp, rt) 6 | RAB_DEF_OPERAND(rsp, rd) 7 | RAB_DEF_OPERAND(rsp, cop0d) 8 | RAB_DEF_OPERAND(rsp, cop2t) 9 | RAB_DEF_OPERAND(rsp, cop2cd) // Coprocessor 2 control rd 10 | RAB_DEF_OPERAND(rsp, vs) 11 | RAB_DEF_OPERAND(rsp, vt) 12 | RAB_DEF_OPERAND(rsp, vd) 13 | // RAB_DEF_OPERAND(rsp, elementhigh) 14 | // RAB_DEF_OPERAND(rsp, elementlow) 15 | // RAB_DEF_OPERAND(rsp, index) 16 | // RAB_DEF_OPERAND(rsp, offset) 17 | 18 | // composed/aliased operands 19 | RAB_DEF_OPERAND(rsp, vt_elementhigh) 20 | RAB_DEF_OPERAND(rsp, vt_elementlow) 21 | RAB_DEF_OPERAND(rsp, vd_de) 22 | RAB_DEF_OPERAND(rsp, vs_index) 23 | RAB_DEF_OPERAND(rsp, offset_rs) 24 | RAB_DEF_OPERAND(rsp, immediate_base) 25 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop0.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Index, 0), 5 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Random, 1), 6 | RABBITIZER_DEF_REG_NODOLLAR(COP0, EntryLo0, 2), 7 | RABBITIZER_DEF_REG_NODOLLAR(COP0, EntryLo1, 3), 8 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Context, 4), 9 | RABBITIZER_DEF_REG_NODOLLAR(COP0, PageMask, 5), 10 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Wired, 6), 11 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved07, 7), 12 | RABBITIZER_DEF_REG_NODOLLAR(COP0, BadVaddr, 8), 13 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Count, 9), 14 | RABBITIZER_DEF_REG_NODOLLAR(COP0, EntryHi, 10), 15 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Compare, 11), 16 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Status, 12), 17 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Cause, 13), 18 | RABBITIZER_DEF_REG_NODOLLAR(COP0, EPC, 14), 19 | RABBITIZER_DEF_REG_NODOLLAR(COP0, PRevID, 15), 20 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Config, 16), 21 | RABBITIZER_DEF_REG_NODOLLAR(COP0, LLAddr, 17), 22 | RABBITIZER_DEF_REG_NODOLLAR(COP0, WatchLo, 18), 23 | RABBITIZER_DEF_REG_NODOLLAR(COP0, WatchHi, 19), 24 | RABBITIZER_DEF_REG_NODOLLAR(COP0, XContext, 20), 25 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved21, 21), 26 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved22, 22), 27 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved23, 23), 28 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved24, 24), 29 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved25, 25), 30 | RABBITIZER_DEF_REG_NODOLLAR(COP0, PErr, 26), 31 | RABBITIZER_DEF_REG_NODOLLAR(COP0, CacheErr, 27), 32 | RABBITIZER_DEF_REG_NODOLLAR(COP0, TagLo, 28), 33 | RABBITIZER_DEF_REG_NODOLLAR(COP0, TagHi, 29), 34 | RABBITIZER_DEF_REG_NODOLLAR(COP0, ErrorEPC, 30), 35 | RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved31, 31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1Control.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(COP1_CONTROL, 0, 0), 5 | RABBITIZER_DEF_REG(COP1_CONTROL, 1, 1), 6 | RABBITIZER_DEF_REG(COP1_CONTROL, 2, 2), 7 | RABBITIZER_DEF_REG(COP1_CONTROL, 3, 3), 8 | RABBITIZER_DEF_REG(COP1_CONTROL, 4, 4), 9 | RABBITIZER_DEF_REG(COP1_CONTROL, 5, 5), 10 | RABBITIZER_DEF_REG(COP1_CONTROL, 6, 6), 11 | RABBITIZER_DEF_REG(COP1_CONTROL, 7, 7), 12 | RABBITIZER_DEF_REG(COP1_CONTROL, 8, 8), 13 | RABBITIZER_DEF_REG(COP1_CONTROL, 9, 9), 14 | RABBITIZER_DEF_REG(COP1_CONTROL, 10, 10), 15 | RABBITIZER_DEF_REG(COP1_CONTROL, 11, 11), 16 | RABBITIZER_DEF_REG(COP1_CONTROL, 12, 12), 17 | RABBITIZER_DEF_REG(COP1_CONTROL, 13, 13), 18 | RABBITIZER_DEF_REG(COP1_CONTROL, 14, 14), 19 | RABBITIZER_DEF_REG(COP1_CONTROL, 15, 15), 20 | RABBITIZER_DEF_REG(COP1_CONTROL, 16, 16), 21 | RABBITIZER_DEF_REG(COP1_CONTROL, 17, 17), 22 | RABBITIZER_DEF_REG(COP1_CONTROL, 18, 18), 23 | RABBITIZER_DEF_REG(COP1_CONTROL, 19, 19), 24 | RABBITIZER_DEF_REG(COP1_CONTROL, 20, 20), 25 | RABBITIZER_DEF_REG(COP1_CONTROL, 21, 21), 26 | RABBITIZER_DEF_REG(COP1_CONTROL, 22, 22), 27 | RABBITIZER_DEF_REG(COP1_CONTROL, 23, 23), 28 | RABBITIZER_DEF_REG(COP1_CONTROL, 24, 24), 29 | RABBITIZER_DEF_REG(COP1_CONTROL, 25, 25), 30 | RABBITIZER_DEF_REG(COP1_CONTROL, 26, 26), 31 | RABBITIZER_DEF_REG(COP1_CONTROL, 27, 27), 32 | RABBITIZER_DEF_REG(COP1_CONTROL, 28, 28), 33 | RABBITIZER_DEF_REG(COP1_CONTROL, 29, 29), 34 | RABBITIZER_DEF_REG(COP1_CONTROL, 30, 30), 35 | RABBITIZER_DEF_REG(COP1_CONTROL, FpcCsr, 31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1N32.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(COP1_N32, fv0, f0), 5 | RABBITIZER_DEF_REG(COP1_N32, ft14, f1), 6 | RABBITIZER_DEF_REG(COP1_N32, fv1, f2), 7 | RABBITIZER_DEF_REG(COP1_N32, ft15, f3), 8 | RABBITIZER_DEF_REG(COP1_N32, ft0, f4), 9 | RABBITIZER_DEF_REG(COP1_N32, ft1, f5), 10 | RABBITIZER_DEF_REG(COP1_N32, ft2, f6), 11 | RABBITIZER_DEF_REG(COP1_N32, ft3, f7), 12 | RABBITIZER_DEF_REG(COP1_N32, ft4, f8), 13 | RABBITIZER_DEF_REG(COP1_N32, ft5, f9), 14 | RABBITIZER_DEF_REG(COP1_N32, ft6, f10), 15 | RABBITIZER_DEF_REG(COP1_N32, ft7, f11), 16 | RABBITIZER_DEF_REG(COP1_N32, fa0, f12), 17 | RABBITIZER_DEF_REG(COP1_N32, fa1, f13), 18 | RABBITIZER_DEF_REG(COP1_N32, fa2, f14), 19 | RABBITIZER_DEF_REG(COP1_N32, fa3, f15), 20 | RABBITIZER_DEF_REG(COP1_N32, fa4, f16), 21 | RABBITIZER_DEF_REG(COP1_N32, fa5, f17), 22 | RABBITIZER_DEF_REG(COP1_N32, fa6, f18), 23 | RABBITIZER_DEF_REG(COP1_N32, fa7, f19), 24 | RABBITIZER_DEF_REG(COP1_N32, fs0, f20), 25 | RABBITIZER_DEF_REG(COP1_N32, ft8, f21), 26 | RABBITIZER_DEF_REG(COP1_N32, fs1, f22), 27 | RABBITIZER_DEF_REG(COP1_N32, ft9, f23), 28 | RABBITIZER_DEF_REG(COP1_N32, fs2, f24), 29 | RABBITIZER_DEF_REG(COP1_N32, ft10, f25), 30 | RABBITIZER_DEF_REG(COP1_N32, fs3, f26), 31 | RABBITIZER_DEF_REG(COP1_N32, ft11, f27), 32 | RABBITIZER_DEF_REG(COP1_N32, fs4, f28), 33 | RABBITIZER_DEF_REG(COP1_N32, ft12, f29), 34 | RABBITIZER_DEF_REG(COP1_N32, fs5, f30), 35 | RABBITIZER_DEF_REG(COP1_N32, ft13, f31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1N64.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(COP1_N64, fv0, f0), 5 | RABBITIZER_DEF_REG(COP1_N64, ft12, f1), 6 | RABBITIZER_DEF_REG(COP1_N64, fv1, f2), 7 | RABBITIZER_DEF_REG(COP1_N64, ft13, f3), 8 | RABBITIZER_DEF_REG(COP1_N64, ft0, f4), 9 | RABBITIZER_DEF_REG(COP1_N64, ft1, f5), 10 | RABBITIZER_DEF_REG(COP1_N64, ft2, f6), 11 | RABBITIZER_DEF_REG(COP1_N64, ft3, f7), 12 | RABBITIZER_DEF_REG(COP1_N64, ft4, f8), 13 | RABBITIZER_DEF_REG(COP1_N64, ft5, f9), 14 | RABBITIZER_DEF_REG(COP1_N64, ft6, f10), 15 | RABBITIZER_DEF_REG(COP1_N64, ft7, f11), 16 | RABBITIZER_DEF_REG(COP1_N64, fa0, f12), 17 | RABBITIZER_DEF_REG(COP1_N64, fa1, f13), 18 | RABBITIZER_DEF_REG(COP1_N64, fa2, f14), 19 | RABBITIZER_DEF_REG(COP1_N64, fa3, f15), 20 | RABBITIZER_DEF_REG(COP1_N64, fa4, f16), 21 | RABBITIZER_DEF_REG(COP1_N64, fa5, f17), 22 | RABBITIZER_DEF_REG(COP1_N64, fa6, f18), 23 | RABBITIZER_DEF_REG(COP1_N64, fa7, f19), 24 | RABBITIZER_DEF_REG(COP1_N64, ft8, f20), 25 | RABBITIZER_DEF_REG(COP1_N64, ft9, f21), 26 | RABBITIZER_DEF_REG(COP1_N64, ft10, f22), 27 | RABBITIZER_DEF_REG(COP1_N64, ft11, f23), 28 | RABBITIZER_DEF_REG(COP1_N64, fs0, f24), 29 | RABBITIZER_DEF_REG(COP1_N64, fs1, f25), 30 | RABBITIZER_DEF_REG(COP1_N64, fs2, f26), 31 | RABBITIZER_DEF_REG(COP1_N64, fs3, f27), 32 | RABBITIZER_DEF_REG(COP1_N64, fs4, f28), 33 | RABBITIZER_DEF_REG(COP1_N64, fs5, f29), 34 | RABBITIZER_DEF_REG(COP1_N64, fs6, f30), 35 | RABBITIZER_DEF_REG(COP1_N64, fs7, f31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1O32.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(COP1_O32, fv0, f0), 5 | RABBITIZER_DEF_REG(COP1_O32, fv0f, f1), 6 | RABBITIZER_DEF_REG(COP1_O32, fv1, f2), 7 | RABBITIZER_DEF_REG(COP1_O32, fv1f, f3), 8 | RABBITIZER_DEF_REG(COP1_O32, ft0, f4), 9 | RABBITIZER_DEF_REG(COP1_O32, ft0f, f5), 10 | RABBITIZER_DEF_REG(COP1_O32, ft1, f6), 11 | RABBITIZER_DEF_REG(COP1_O32, ft1f, f7), 12 | RABBITIZER_DEF_REG(COP1_O32, ft2, f8), 13 | RABBITIZER_DEF_REG(COP1_O32, ft2f, f9), 14 | RABBITIZER_DEF_REG(COP1_O32, ft3, f10), 15 | RABBITIZER_DEF_REG(COP1_O32, ft3f, f11), 16 | RABBITIZER_DEF_REG(COP1_O32, fa0, f12), 17 | RABBITIZER_DEF_REG(COP1_O32, fa0f, f13), 18 | RABBITIZER_DEF_REG(COP1_O32, fa1, f14), 19 | RABBITIZER_DEF_REG(COP1_O32, fa1f, f15), 20 | RABBITIZER_DEF_REG(COP1_O32, ft4, f16), 21 | RABBITIZER_DEF_REG(COP1_O32, ft4f, f17), 22 | RABBITIZER_DEF_REG(COP1_O32, ft5, f18), 23 | RABBITIZER_DEF_REG(COP1_O32, ft5f, f19), 24 | RABBITIZER_DEF_REG(COP1_O32, fs0, f20), 25 | RABBITIZER_DEF_REG(COP1_O32, fs0f, f21), 26 | RABBITIZER_DEF_REG(COP1_O32, fs1, f22), 27 | RABBITIZER_DEF_REG(COP1_O32, fs1f, f23), 28 | RABBITIZER_DEF_REG(COP1_O32, fs2, f24), 29 | RABBITIZER_DEF_REG(COP1_O32, fs2f, f25), 30 | RABBITIZER_DEF_REG(COP1_O32, fs3, f26), 31 | RABBITIZER_DEF_REG(COP1_O32, fs3f, f27), 32 | RABBITIZER_DEF_REG(COP1_O32, fs4, f28), 33 | RABBITIZER_DEF_REG(COP1_O32, fs4f, f29), 34 | RABBITIZER_DEF_REG(COP1_O32, fs5, f30), 35 | RABBITIZER_DEF_REG(COP1_O32, fs5f, f31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop2.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(COP2, 0, 0), 5 | RABBITIZER_DEF_REG(COP2, 1, 1), 6 | RABBITIZER_DEF_REG(COP2, 2, 2), 7 | RABBITIZER_DEF_REG(COP2, 3, 3), 8 | RABBITIZER_DEF_REG(COP2, 4, 4), 9 | RABBITIZER_DEF_REG(COP2, 5, 5), 10 | RABBITIZER_DEF_REG(COP2, 6, 6), 11 | RABBITIZER_DEF_REG(COP2, 7, 7), 12 | RABBITIZER_DEF_REG(COP2, 8, 8), 13 | RABBITIZER_DEF_REG(COP2, 9, 9), 14 | RABBITIZER_DEF_REG(COP2, 10, 10), 15 | RABBITIZER_DEF_REG(COP2, 11, 11), 16 | RABBITIZER_DEF_REG(COP2, 12, 12), 17 | RABBITIZER_DEF_REG(COP2, 13, 13), 18 | RABBITIZER_DEF_REG(COP2, 14, 14), 19 | RABBITIZER_DEF_REG(COP2, 15, 15), 20 | RABBITIZER_DEF_REG(COP2, 16, 16), 21 | RABBITIZER_DEF_REG(COP2, 17, 17), 22 | RABBITIZER_DEF_REG(COP2, 18, 18), 23 | RABBITIZER_DEF_REG(COP2, 19, 19), 24 | RABBITIZER_DEF_REG(COP2, 20, 20), 25 | RABBITIZER_DEF_REG(COP2, 21, 21), 26 | RABBITIZER_DEF_REG(COP2, 22, 22), 27 | RABBITIZER_DEF_REG(COP2, 23, 23), 28 | RABBITIZER_DEF_REG(COP2, 24, 24), 29 | RABBITIZER_DEF_REG(COP2, 25, 25), 30 | RABBITIZER_DEF_REG(COP2, 26, 26), 31 | RABBITIZER_DEF_REG(COP2, 27, 27), 32 | RABBITIZER_DEF_REG(COP2, 28, 28), 33 | RABBITIZER_DEF_REG(COP2, 29, 29), 34 | RABBITIZER_DEF_REG(COP2, 30, 30), 35 | RABBITIZER_DEF_REG(COP2, 31, 31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_GprN32.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(GPR_N32, zero, 0), 5 | RABBITIZER_DEF_REG(GPR_N32, at, 1), 6 | RABBITIZER_DEF_REG(GPR_N32, v0, 2), 7 | RABBITIZER_DEF_REG(GPR_N32, v1, 3), 8 | RABBITIZER_DEF_REG(GPR_N32, a0, 4), 9 | RABBITIZER_DEF_REG(GPR_N32, a1, 5), 10 | RABBITIZER_DEF_REG(GPR_N32, a2, 6), 11 | RABBITIZER_DEF_REG(GPR_N32, a3, 7), 12 | RABBITIZER_DEF_REG(GPR_N32, a4, 8), 13 | RABBITIZER_DEF_REG(GPR_N32, a5, 9), 14 | RABBITIZER_DEF_REG(GPR_N32, a6, 10), 15 | RABBITIZER_DEF_REG(GPR_N32, a7, 11), 16 | RABBITIZER_DEF_REG(GPR_N32, t0, 12), 17 | RABBITIZER_DEF_REG(GPR_N32, t1, 13), 18 | RABBITIZER_DEF_REG(GPR_N32, t2, 14), 19 | RABBITIZER_DEF_REG(GPR_N32, t3, 15), 20 | RABBITIZER_DEF_REG(GPR_N32, s0, 16), 21 | RABBITIZER_DEF_REG(GPR_N32, s1, 17), 22 | RABBITIZER_DEF_REG(GPR_N32, s2, 18), 23 | RABBITIZER_DEF_REG(GPR_N32, s3, 19), 24 | RABBITIZER_DEF_REG(GPR_N32, s4, 20), 25 | RABBITIZER_DEF_REG(GPR_N32, s5, 21), 26 | RABBITIZER_DEF_REG(GPR_N32, s6, 22), 27 | RABBITIZER_DEF_REG(GPR_N32, s7, 23), 28 | RABBITIZER_DEF_REG(GPR_N32, t8, 24), 29 | RABBITIZER_DEF_REG(GPR_N32, t9, 25), 30 | RABBITIZER_DEF_REG(GPR_N32, k0, 26), 31 | RABBITIZER_DEF_REG(GPR_N32, k1, 27), 32 | RABBITIZER_DEF_REG(GPR_N32, gp, 28), 33 | RABBITIZER_DEF_REG(GPR_N32, sp, 29), 34 | RABBITIZER_DEF_REG(GPR_N32, fp, 30), 35 | RABBITIZER_DEF_REG(GPR_N32, ra, 31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_GprO32.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(GPR_O32, zero, 0), 5 | RABBITIZER_DEF_REG(GPR_O32, at, 1), 6 | RABBITIZER_DEF_REG(GPR_O32, v0, 2), 7 | RABBITIZER_DEF_REG(GPR_O32, v1, 3), 8 | RABBITIZER_DEF_REG(GPR_O32, a0, 4), 9 | RABBITIZER_DEF_REG(GPR_O32, a1, 5), 10 | RABBITIZER_DEF_REG(GPR_O32, a2, 6), 11 | RABBITIZER_DEF_REG(GPR_O32, a3, 7), 12 | RABBITIZER_DEF_REG(GPR_O32, t0, 8), 13 | RABBITIZER_DEF_REG(GPR_O32, t1, 9), 14 | RABBITIZER_DEF_REG(GPR_O32, t2, 10), 15 | RABBITIZER_DEF_REG(GPR_O32, t3, 11), 16 | RABBITIZER_DEF_REG(GPR_O32, t4, 12), 17 | RABBITIZER_DEF_REG(GPR_O32, t5, 13), 18 | RABBITIZER_DEF_REG(GPR_O32, t6, 14), 19 | RABBITIZER_DEF_REG(GPR_O32, t7, 15), 20 | RABBITIZER_DEF_REG(GPR_O32, s0, 16), 21 | RABBITIZER_DEF_REG(GPR_O32, s1, 17), 22 | RABBITIZER_DEF_REG(GPR_O32, s2, 18), 23 | RABBITIZER_DEF_REG(GPR_O32, s3, 19), 24 | RABBITIZER_DEF_REG(GPR_O32, s4, 20), 25 | RABBITIZER_DEF_REG(GPR_O32, s5, 21), 26 | RABBITIZER_DEF_REG(GPR_O32, s6, 22), 27 | RABBITIZER_DEF_REG(GPR_O32, s7, 23), 28 | RABBITIZER_DEF_REG(GPR_O32, t8, 24), 29 | RABBITIZER_DEF_REG(GPR_O32, t9, 25), 30 | RABBITIZER_DEF_REG(GPR_O32, k0, 26), 31 | RABBITIZER_DEF_REG(GPR_O32, k1, 27), 32 | RABBITIZER_DEF_REG(GPR_O32, gp, 28), 33 | RABBITIZER_DEF_REG(GPR_O32, sp, 29), 34 | RABBITIZER_DEF_REG(GPR_O32, fp, 30), 35 | RABBITIZER_DEF_REG(GPR_O32, ra, 31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_R5900VF.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(R5900_VF, vf0, 0), 5 | RABBITIZER_DEF_REG(R5900_VF, vf1, 1), 6 | RABBITIZER_DEF_REG(R5900_VF, vf2, 2), 7 | RABBITIZER_DEF_REG(R5900_VF, vf3, 3), 8 | RABBITIZER_DEF_REG(R5900_VF, vf4, 4), 9 | RABBITIZER_DEF_REG(R5900_VF, vf5, 5), 10 | RABBITIZER_DEF_REG(R5900_VF, vf6, 6), 11 | RABBITIZER_DEF_REG(R5900_VF, vf7, 7), 12 | RABBITIZER_DEF_REG(R5900_VF, vf8, 8), 13 | RABBITIZER_DEF_REG(R5900_VF, vf9, 9), 14 | RABBITIZER_DEF_REG(R5900_VF, vf10, 10), 15 | RABBITIZER_DEF_REG(R5900_VF, vf11, 11), 16 | RABBITIZER_DEF_REG(R5900_VF, vf12, 12), 17 | RABBITIZER_DEF_REG(R5900_VF, vf13, 13), 18 | RABBITIZER_DEF_REG(R5900_VF, vf14, 14), 19 | RABBITIZER_DEF_REG(R5900_VF, vf15, 15), 20 | RABBITIZER_DEF_REG(R5900_VF, vf16, 16), 21 | RABBITIZER_DEF_REG(R5900_VF, vf17, 17), 22 | RABBITIZER_DEF_REG(R5900_VF, vf18, 18), 23 | RABBITIZER_DEF_REG(R5900_VF, vf19, 19), 24 | RABBITIZER_DEF_REG(R5900_VF, vf20, 20), 25 | RABBITIZER_DEF_REG(R5900_VF, vf21, 21), 26 | RABBITIZER_DEF_REG(R5900_VF, vf22, 22), 27 | RABBITIZER_DEF_REG(R5900_VF, vf23, 23), 28 | RABBITIZER_DEF_REG(R5900_VF, vf24, 24), 29 | RABBITIZER_DEF_REG(R5900_VF, vf25, 25), 30 | RABBITIZER_DEF_REG(R5900_VF, vf26, 26), 31 | RABBITIZER_DEF_REG(R5900_VF, vf27, 27), 32 | RABBITIZER_DEF_REG(R5900_VF, vf28, 28), 33 | RABBITIZER_DEF_REG(R5900_VF, vf29, 29), 34 | RABBITIZER_DEF_REG(R5900_VF, vf30, 30), 35 | RABBITIZER_DEF_REG(R5900_VF, vf31, 31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_R5900VI.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(R5900_VI, vi0, 0), 5 | RABBITIZER_DEF_REG(R5900_VI, vi1, 1), 6 | RABBITIZER_DEF_REG(R5900_VI, vi2, 2), 7 | RABBITIZER_DEF_REG(R5900_VI, vi3, 3), 8 | RABBITIZER_DEF_REG(R5900_VI, vi4, 4), 9 | RABBITIZER_DEF_REG(R5900_VI, vi5, 5), 10 | RABBITIZER_DEF_REG(R5900_VI, vi6, 6), 11 | RABBITIZER_DEF_REG(R5900_VI, vi7, 7), 12 | RABBITIZER_DEF_REG(R5900_VI, vi8, 8), 13 | RABBITIZER_DEF_REG(R5900_VI, vi9, 9), 14 | RABBITIZER_DEF_REG(R5900_VI, vi10, 10), 15 | RABBITIZER_DEF_REG(R5900_VI, vi11, 11), 16 | RABBITIZER_DEF_REG(R5900_VI, vi12, 12), 17 | RABBITIZER_DEF_REG(R5900_VI, vi13, 13), 18 | RABBITIZER_DEF_REG(R5900_VI, vi14, 14), 19 | RABBITIZER_DEF_REG(R5900_VI, vi15, 15), 20 | RABBITIZER_DEF_REG(R5900_VI, vi16, 16), 21 | RABBITIZER_DEF_REG(R5900_VI, vi17, 17), 22 | RABBITIZER_DEF_REG(R5900_VI, vi18, 18), 23 | RABBITIZER_DEF_REG(R5900_VI, vi19, 19), 24 | RABBITIZER_DEF_REG(R5900_VI, vi20, 20), 25 | RABBITIZER_DEF_REG(R5900_VI, vi21, 21), 26 | RABBITIZER_DEF_REG(R5900_VI, vi22, 22), 27 | RABBITIZER_DEF_REG(R5900_VI, vi23, 23), 28 | RABBITIZER_DEF_REG(R5900_VI, vi24, 24), 29 | RABBITIZER_DEF_REG(R5900_VI, vi25, 25), 30 | RABBITIZER_DEF_REG(R5900_VI, vi26, 26), 31 | RABBITIZER_DEF_REG(R5900_VI, vi27, 27), 32 | RABBITIZER_DEF_REG(R5900_VI, vi28, 28), 33 | RABBITIZER_DEF_REG(R5900_VI, vi29, 29), 34 | RABBITIZER_DEF_REG(R5900_VI, vi30, 30), 35 | RABBITIZER_DEF_REG(R5900_VI, vi31, 31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspCop0.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_MEM_ADDR, 0), 5 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_DRAM_ADDR, 1), 6 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_RD_LEN, 2), 7 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_WR_LEN, 3), 8 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_STATUS, 4), 9 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_DMA_FULL, 5), 10 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_DMA_BUSY, 6), 11 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_SEMAPHORE, 7), 12 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_START, 8), 13 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_END, 9), 14 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_CURRENT, 10), 15 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_STATUS, 11), 16 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_CLOCK, 12), 17 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_BUFBUSY, 13), 18 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_PIPEBUSY, 14), 19 | RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_TMEM, 15), 20 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspCop2.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(RSP_COP2, 0, 0), 5 | RABBITIZER_DEF_REG(RSP_COP2, 1, 1), 6 | RABBITIZER_DEF_REG(RSP_COP2, 2, 2), 7 | RABBITIZER_DEF_REG(RSP_COP2, 3, 3), 8 | RABBITIZER_DEF_REG(RSP_COP2, 4, 4), 9 | RABBITIZER_DEF_REG(RSP_COP2, 5, 5), 10 | RABBITIZER_DEF_REG(RSP_COP2, 6, 6), 11 | RABBITIZER_DEF_REG(RSP_COP2, 7, 7), 12 | RABBITIZER_DEF_REG(RSP_COP2, 8, 8), 13 | RABBITIZER_DEF_REG(RSP_COP2, 9, 9), 14 | RABBITIZER_DEF_REG(RSP_COP2, 10, 10), 15 | RABBITIZER_DEF_REG(RSP_COP2, 11, 11), 16 | RABBITIZER_DEF_REG(RSP_COP2, 12, 12), 17 | RABBITIZER_DEF_REG(RSP_COP2, 13, 13), 18 | RABBITIZER_DEF_REG(RSP_COP2, 14, 14), 19 | RABBITIZER_DEF_REG(RSP_COP2, 15, 15), 20 | RABBITIZER_DEF_REG(RSP_COP2, 16, 16), 21 | RABBITIZER_DEF_REG(RSP_COP2, 17, 17), 22 | RABBITIZER_DEF_REG(RSP_COP2, 18, 18), 23 | RABBITIZER_DEF_REG(RSP_COP2, 19, 19), 24 | RABBITIZER_DEF_REG(RSP_COP2, 20, 20), 25 | RABBITIZER_DEF_REG(RSP_COP2, 21, 21), 26 | RABBITIZER_DEF_REG(RSP_COP2, 22, 22), 27 | RABBITIZER_DEF_REG(RSP_COP2, 23, 23), 28 | RABBITIZER_DEF_REG(RSP_COP2, 24, 24), 29 | RABBITIZER_DEF_REG(RSP_COP2, 25, 25), 30 | RABBITIZER_DEF_REG(RSP_COP2, 26, 26), 31 | RABBITIZER_DEF_REG(RSP_COP2, 27, 27), 32 | RABBITIZER_DEF_REG(RSP_COP2, 28, 28), 33 | RABBITIZER_DEF_REG(RSP_COP2, 29, 29), 34 | RABBITIZER_DEF_REG(RSP_COP2, 30, 30), 35 | RABBITIZER_DEF_REG(RSP_COP2, 31, 31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspCop2Control.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 0, 0), 5 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 1, 1), 6 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 2, 2), 7 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 3, 3), 8 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 4, 4), 9 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 5, 5), 10 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 6, 6), 11 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 7, 7), 12 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 8, 8), 13 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 9, 9), 14 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 10, 10), 15 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 11, 11), 16 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 12, 12), 17 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 13, 13), 18 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 14, 14), 19 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 15, 15), 20 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 16, 16), 21 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 17, 17), 22 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 18, 18), 23 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 19, 19), 24 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 20, 20), 25 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 21, 21), 26 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 22, 22), 27 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 23, 23), 28 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 24, 24), 29 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 25, 25), 30 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 26, 26), 31 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 27, 27), 32 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 28, 28), 33 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 29, 29), 34 | RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 30, 30), 35 | RABBITIZER_DEF_REG(COP1_CONTROL, 31, 31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspGpr.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(RSP_GPR, zero, 0), 5 | RABBITIZER_DEF_REG(RSP_GPR, 1, 1), 6 | RABBITIZER_DEF_REG(RSP_GPR, 2, 2), 7 | RABBITIZER_DEF_REG(RSP_GPR, 3, 3), 8 | RABBITIZER_DEF_REG(RSP_GPR, 4, 4), 9 | RABBITIZER_DEF_REG(RSP_GPR, 5, 5), 10 | RABBITIZER_DEF_REG(RSP_GPR, 6, 6), 11 | RABBITIZER_DEF_REG(RSP_GPR, 7, 7), 12 | RABBITIZER_DEF_REG(RSP_GPR, 8, 8), 13 | RABBITIZER_DEF_REG(RSP_GPR, 9, 9), 14 | RABBITIZER_DEF_REG(RSP_GPR, 10, 10), 15 | RABBITIZER_DEF_REG(RSP_GPR, 11, 11), 16 | RABBITIZER_DEF_REG(RSP_GPR, 12, 12), 17 | RABBITIZER_DEF_REG(RSP_GPR, 13, 13), 18 | RABBITIZER_DEF_REG(RSP_GPR, 14, 14), 19 | RABBITIZER_DEF_REG(RSP_GPR, 15, 15), 20 | RABBITIZER_DEF_REG(RSP_GPR, 16, 16), 21 | RABBITIZER_DEF_REG(RSP_GPR, 17, 17), 22 | RABBITIZER_DEF_REG(RSP_GPR, 18, 18), 23 | RABBITIZER_DEF_REG(RSP_GPR, 19, 19), 24 | RABBITIZER_DEF_REG(RSP_GPR, 20, 20), 25 | RABBITIZER_DEF_REG(RSP_GPR, 21, 21), 26 | RABBITIZER_DEF_REG(RSP_GPR, 22, 22), 27 | RABBITIZER_DEF_REG(RSP_GPR, 23, 23), 28 | RABBITIZER_DEF_REG(RSP_GPR, 24, 24), 29 | RABBITIZER_DEF_REG(RSP_GPR, 25, 25), 30 | RABBITIZER_DEF_REG(RSP_GPR, 26, 26), 31 | RABBITIZER_DEF_REG(RSP_GPR, 27, 27), 32 | RABBITIZER_DEF_REG(RSP_GPR, 28, 28), 33 | RABBITIZER_DEF_REG(RSP_GPR, 29, 29), 34 | RABBITIZER_DEF_REG(RSP_GPR, 30, 30), 35 | RABBITIZER_DEF_REG(RSP_GPR, ra, 31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspVector.inc: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | RABBITIZER_DEF_REG(RSP_VECTOR, v0, 0), 5 | RABBITIZER_DEF_REG(RSP_VECTOR, v1, 1), 6 | RABBITIZER_DEF_REG(RSP_VECTOR, v2, 2), 7 | RABBITIZER_DEF_REG(RSP_VECTOR, v3, 3), 8 | RABBITIZER_DEF_REG(RSP_VECTOR, v4, 4), 9 | RABBITIZER_DEF_REG(RSP_VECTOR, v5, 5), 10 | RABBITIZER_DEF_REG(RSP_VECTOR, v6, 6), 11 | RABBITIZER_DEF_REG(RSP_VECTOR, v7, 7), 12 | RABBITIZER_DEF_REG(RSP_VECTOR, v8, 8), 13 | RABBITIZER_DEF_REG(RSP_VECTOR, v9, 9), 14 | RABBITIZER_DEF_REG(RSP_VECTOR, v10, 10), 15 | RABBITIZER_DEF_REG(RSP_VECTOR, v11, 11), 16 | RABBITIZER_DEF_REG(RSP_VECTOR, v12, 12), 17 | RABBITIZER_DEF_REG(RSP_VECTOR, v13, 13), 18 | RABBITIZER_DEF_REG(RSP_VECTOR, v14, 14), 19 | RABBITIZER_DEF_REG(RSP_VECTOR, v15, 15), 20 | RABBITIZER_DEF_REG(RSP_VECTOR, v16, 16), 21 | RABBITIZER_DEF_REG(RSP_VECTOR, v17, 17), 22 | RABBITIZER_DEF_REG(RSP_VECTOR, v18, 18), 23 | RABBITIZER_DEF_REG(RSP_VECTOR, v19, 19), 24 | RABBITIZER_DEF_REG(RSP_VECTOR, v20, 20), 25 | RABBITIZER_DEF_REG(RSP_VECTOR, v21, 21), 26 | RABBITIZER_DEF_REG(RSP_VECTOR, v22, 22), 27 | RABBITIZER_DEF_REG(RSP_VECTOR, v23, 23), 28 | RABBITIZER_DEF_REG(RSP_VECTOR, v24, 24), 29 | RABBITIZER_DEF_REG(RSP_VECTOR, v25, 25), 30 | RABBITIZER_DEF_REG(RSP_VECTOR, v26, 26), 31 | RABBITIZER_DEF_REG(RSP_VECTOR, v27, 27), 32 | RABBITIZER_DEF_REG(RSP_VECTOR, v28, 28), 33 | RABBITIZER_DEF_REG(RSP_VECTOR, v29, 29), 34 | RABBITIZER_DEF_REG(RSP_VECTOR, v30, 30), 35 | RABBITIZER_DEF_REG(RSP_VECTOR, v31, 31), 36 | -------------------------------------------------------------------------------- /tools/rabbitizer/include/rabbitizer.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_H 5 | #define RABBITIZER_H 6 | #pragma once 7 | 8 | #include "common/Utils.h" 9 | #include "common/RabbitizerVersion.h" 10 | #include "common/RabbitizerConfig.h" 11 | 12 | #include "instructions/RabbitizerOperandType.h" 13 | #include "instructions/RabbitizerInstrId.h" 14 | #include "instructions/RabbitizerInstrSuffix.h" 15 | #include "instructions/RabbitizerInstrDescriptor.h" 16 | #include "instructions/RabbitizerRegister.h" 17 | #include "instructions/RabbitizerInstruction.h" 18 | #include "instructions/RabbitizerInstructionRsp.h" 19 | #include "instructions/RabbitizerInstructionR5900.h" 20 | 21 | #include "analysis/RabbitizerTrackedRegisterState.h" 22 | #include "analysis/RabbitizerLoPairingInfo.h" 23 | #include "analysis/RabbitizerRegistersTracker.h" 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /tools/rabbitizer/pyproject.toml: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 2 | # SPDX-License-Identifier: MIT 3 | 4 | [build-system] 5 | requires = ["setuptools>=61.0", "wheel"] 6 | build-backend = "setuptools.build_meta" 7 | 8 | [tool.cibuildwheel] 9 | skip = ["cp36-*"] 10 | -------------------------------------------------------------------------------- /tools/rabbitizer/r5900test.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "instructions/RabbitizerInstructionR5900.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | int main() { 13 | uint32_t word; 14 | RabbitizerInstruction instr; 15 | char *buffer; 16 | int extraLJust = 5; 17 | #if 1 18 | uint32_t validbits; 19 | #endif 20 | 21 | word = 0x4BE1634B; 22 | 23 | RabbitizerInstructionR5900_init(&instr, word, 0x00100000); 24 | 25 | RabbitizerInstructionR5900_processUniqueId(&instr); 26 | 27 | buffer = malloc(RabbitizerInstruction_getSizeForBuffer(&instr, 0, extraLJust) + 1); 28 | assert(buffer != NULL); 29 | 30 | RabbitizerInstruction_disassemble(&instr, buffer, NULL, 0, extraLJust); 31 | 32 | printf("%08X: %s\n", word, buffer); 33 | 34 | #if 1 35 | validbits = RabbitizerInstruction_getValidBits(&instr); 36 | 37 | printf("word: %08X\n", instr.word); 38 | printf("mandatory bits: %08X\n", instr._mandatorybits); 39 | printf("valid bits: %08X\n", validbits); 40 | printf("invalid bits: %08X\n", (~validbits) & instr.word); 41 | #endif 42 | 43 | free(buffer); 44 | RabbitizerInstructionR5900_destroy(&instr); 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/Config.pyi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 4 | # SPDX-License-Identifier: MIT 5 | 6 | from __future__ import annotations 7 | 8 | from .Enum import Enum 9 | 10 | 11 | class Abi: 12 | NUMERIC: Enum 13 | O32: Enum 14 | N32: Enum 15 | N64: Enum 16 | 17 | @staticmethod 18 | def fromStr(name: str | None) -> Enum: ... 19 | 20 | 21 | class _RabbitizerConfig: 22 | regNames_namedRegisters: bool = True 23 | regNames_gprAbiNames: Enum = Abi.O32 24 | regNames_fprAbiNames: Enum = Abi.NUMERIC 25 | regNames_userFpcCsr: bool = True 26 | regNames_vr4300Cop0NamedRegisters: bool = True 27 | regNames_vr4300RspCop0NamedRegisters: bool = True 28 | 29 | pseudos_enablePseudos: bool = True 30 | pseudos_pseudoBeqz: bool = True 31 | pseudos_pseudoBnez: bool = True 32 | pseudos_pseudoB: bool = True 33 | pseudos_pseudoMove: bool = True 34 | pseudos_pseudoNot: bool = True 35 | pseudos_pseudoNegu: bool = True 36 | pseudos_pseudoBal: bool = True 37 | 38 | toolchainTweaks_sn64DivFix: bool = False 39 | toolchainTweaks_treatJAsUnconditionalBranch: bool = False 40 | 41 | misc_opcodeLJust: int = 11 42 | misc_unknownInstrComment: bool = True 43 | misc_omit0XOnSmallImm: bool = False 44 | misc_upperCaseImm: bool = True 45 | 46 | config: _RabbitizerConfig 47 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/Enum.pyi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 4 | # SPDX-License-Identifier: MIT 5 | 6 | from __future__ import annotations 7 | 8 | 9 | class Enum: 10 | name: str 11 | value: int 12 | 13 | def __init__(self, enumType: str, name: str, value: int) -> None: ... 14 | 15 | def __reduce__(self) -> tuple: ... 16 | 17 | def __lt__(self, __o: object) -> bool: ... 18 | def __le__(self, __o: object) -> bool: ... 19 | def __eq__(self, __o: object) -> bool: ... 20 | def __gt__(self, __o: object) -> bool: ... 21 | def __ge__(self, __o: object) -> bool: ... 22 | 23 | def __repr__(self) -> str: ... 24 | def __str__(self) -> str: ... 25 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/InstrCategory.pyi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 4 | # SPDX-License-Identifier: MIT 5 | 6 | from __future__ import annotations 7 | 8 | from .Enum import Enum 9 | 10 | 11 | class InstrCategory: 12 | CPU: Enum 13 | RSP: Enum 14 | R5900: Enum 15 | MAX: Enum 16 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/LoPairingInfo.pyi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 4 | # SPDX-License-Identifier: MIT 5 | 6 | from __future__ import annotations 7 | 8 | 9 | class LoPairingInfo: 10 | instrOffset: int 11 | value: int 12 | shouldProcess: bool 13 | isGpRel: bool 14 | isGpGot: bool 15 | 16 | def __init__(self): ... 17 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/RegGprN32.pyi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 4 | # SPDX-License-Identifier: MIT 5 | 6 | from __future__ import annotations 7 | 8 | from .Enum import Enum 9 | 10 | 11 | class RegGprN32: 12 | zero: Enum 13 | at: Enum 14 | v0: Enum 15 | v1: Enum 16 | a0: Enum 17 | a1: Enum 18 | a2: Enum 19 | a3: Enum 20 | a4: Enum 21 | a5: Enum 22 | a6: Enum 23 | a7: Enum 24 | t0: Enum 25 | t1: Enum 26 | t2: Enum 27 | t3: Enum 28 | s0: Enum 29 | s1: Enum 30 | s2: Enum 31 | s3: Enum 32 | s4: Enum 33 | s5: Enum 34 | s6: Enum 35 | s7: Enum 36 | t8: Enum 37 | t9: Enum 38 | k0: Enum 39 | k1: Enum 40 | gp: Enum 41 | sp: Enum 42 | fp: Enum 43 | ra: Enum 44 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/RegGprO32.pyi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 4 | # SPDX-License-Identifier: MIT 5 | 6 | from __future__ import annotations 7 | 8 | from .Enum import Enum 9 | 10 | 11 | class RegGprO32: 12 | zero: Enum 13 | at: Enum 14 | v0: Enum 15 | v1: Enum 16 | a0: Enum 17 | a1: Enum 18 | a2: Enum 19 | a3: Enum 20 | t0: Enum 21 | t1: Enum 22 | t2: Enum 23 | t3: Enum 24 | t4: Enum 25 | t5: Enum 26 | t6: Enum 27 | t7: Enum 28 | s0: Enum 29 | s1: Enum 30 | s2: Enum 31 | s3: Enum 32 | s4: Enum 33 | s5: Enum 34 | s6: Enum 35 | s7: Enum 36 | t8: Enum 37 | t9: Enum 38 | k0: Enum 39 | k1: Enum 40 | gp: Enum 41 | sp: Enum 42 | fp: Enum 43 | ra: Enum 44 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/RegistersTracker.pyi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 4 | # SPDX-License-Identifier: MIT 5 | 6 | from __future__ import annotations 7 | 8 | from .rabbitizer import Instruction 9 | from .LoPairingInfo import LoPairingInfo 10 | 11 | 12 | class RegistersTracker: 13 | def __init__(self, other: RegistersTracker|None=None): ... 14 | 15 | def moveRegisters(self, instr: Instruction) -> bool: ... 16 | def overwriteRegisters(self, instr: Instruction, instructionOffset: int) -> None: ... 17 | def unsetRegistersAfterFuncCall(self, instr: Instruction, prevInstr: Instruction) -> None: ... 18 | def getAddressIfCanSetType(self, instr: Instruction, instrOffset: int) -> int|None: ... 19 | def getJrInfo(self, instr: Instruction) -> tuple[int, int]|None: ... 20 | 21 | def processLui(self, instr: Instruction, instrOffset: int, prevInstr: Instruction|None=None) -> None: ... 22 | def processGpLoad(self, instr: Instruction, instrOffset: int) -> None: ... 23 | def getLuiOffsetForConstant(self, instr: Instruction) -> int|None: ... 24 | def processConstant(self, instr: Instruction, value: int, offset: int) -> None: ... 25 | def getLuiOffsetForLo(self, instr: Instruction, instrOffset: int) -> tuple[int, bool, bool]: ... #! deprecated 26 | def preprocessLoAndGetInfo(self, instr: Instruction, instrOffset: int) -> LoPairingInfo: ... 27 | def processLo(self, instr: Instruction, value: int, offset: int) -> None: ... 28 | def hasLoButNoHi(self, instr: Instruction) -> bool: ... 29 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/TrackedRegisterState.pyi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 4 | # SPDX-License-Identifier: MIT 5 | 6 | from __future__ import annotations 7 | 8 | 9 | class RegistersTracker: 10 | registerNum: int 11 | 12 | hasLuiValue: bool 13 | luiOffset: int # The offset of last lui which set a value to this register 14 | luiSetOnBranchLikely: bool 15 | 16 | hasGpGot: bool 17 | gpGotOffset: int 18 | 19 | hasLoValue: bool 20 | loOffset: int 21 | dereferenced: bool 22 | dereferenceOffset: int 23 | 24 | value: int 25 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/Utils.pyi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 4 | # SPDX-License-Identifier: MIT 5 | 6 | from __future__ import annotations 7 | 8 | 9 | class Utils: 10 | @staticmethod 11 | def from2Complement(number: int, bits: int) -> int: ... 12 | 13 | @staticmethod 14 | def escapeString(src: str) -> str: ... 15 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/__init__.pyi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 4 | # SPDX-License-Identifier: MIT 5 | 6 | from __future__ import annotations 7 | 8 | from .Utils import * 9 | 10 | from .Enum import * 11 | from .InstrCategory import * 12 | from .InstrId import * 13 | 14 | from .RegGprO32 import * 15 | from .RegGprN32 import * 16 | 17 | from .Config import * 18 | 19 | from .rabbitizer import * 20 | 21 | from .RegistersTracker import * 22 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/enums/enums_utils.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "enums_utils.h" 5 | 6 | 7 | int rabbitizer_EnumMetadata_Initialize(PyObject *submodule, RabbitizerEnumMetadata *enumValues) { 8 | for (size_t i = 0; enumValues[i].enumType != 0; i++) { 9 | PyObject *args; 10 | 11 | args = Py_BuildValue("ssi", enumValues[i].enumType, enumValues[i].name, enumValues[i].value); 12 | if (args == NULL) { 13 | goto error; 14 | } 15 | 16 | enumValues[i].instance = PyObject_CallObject((PyObject*)&rabbitizer_type_Enum_TypeObject, args); 17 | Py_DECREF(args); 18 | if (enumValues[i].instance == NULL) { 19 | goto error; 20 | } 21 | 22 | enumValues[i].isInstanced = true; 23 | if (PyModule_AddObject(submodule, enumValues[i].name, enumValues[i].instance) < 0) { 24 | goto error; 25 | } 26 | } 27 | return 0; 28 | 29 | error: 30 | for (size_t i = 0; enumValues[i].enumType != 0; i++) { 31 | if (enumValues[i].isInstanced) { 32 | Py_DECREF(enumValues[i].instance); 33 | } 34 | enumValues[i].isInstanced = false; 35 | } 36 | 37 | return -1; 38 | } 39 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/enums/enums_utils.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_ENUMS_UTILS_H 5 | #define RABBITIZER_ENUMS_UTILS_H 6 | #pragma once 7 | 8 | 9 | #define PY_SSIZE_T_CLEAN 10 | #include 11 | #include "structmember.h" 12 | 13 | #include 14 | 15 | 16 | extern PyTypeObject rabbitizer_type_Enum_TypeObject; 17 | 18 | 19 | typedef struct PyRabbitizerEnum { 20 | PyObject_HEAD 21 | PyObject *enumType; 22 | PyObject *name; 23 | int value; 24 | } PyRabbitizerEnum; 25 | 26 | typedef struct RabbitizerEnumMetadata { 27 | const char *enumType; 28 | const char *name; 29 | int value; 30 | bool isInstanced; 31 | PyObject *instance; 32 | } RabbitizerEnumMetadata; 33 | 34 | 35 | int rabbitizer_EnumMetadata_Initialize(PyObject *submodule, RabbitizerEnumMetadata *enumValues); 36 | 37 | 38 | #define DECL_ENUM(enumName) \ 39 | extern RabbitizerEnumMetadata rabbitizer_enum_##enumName##_enumvalues[]; \ 40 | PyObject *rabbitizer_enum_##enumName##_Init(void); \ 41 | /* Return true if o is of this enum type */ \ 42 | int rabbitizer_enum_##enumName##_Check(PyObject *o); 43 | 44 | #define DEF_ENUM(enumName, docs) \ 45 | static PyModuleDef rabbitizer_enum_##enumName##_module = { \ 46 | PyModuleDef_HEAD_INIT, \ 47 | .m_name = "rabbitizer." #enumName, \ 48 | .m_doc = PyDoc_STR(docs), \ 49 | .m_size = -1, \ 50 | .m_methods = rabbitizer_enum_##enumName##_methods, \ 51 | }; \ 52 | PyObject *rabbitizer_enum_##enumName##_Init(void) { \ 53 | PyObject *submodule; \ 54 | if (PyType_Ready(&rabbitizer_type_Enum_TypeObject) < 0) { \ 55 | return NULL; \ 56 | } \ 57 | submodule = PyModule_Create(&rabbitizer_enum_##enumName##_module); \ 58 | if (submodule == NULL) { \ 59 | return NULL; \ 60 | } \ 61 | if (rabbitizer_EnumMetadata_Initialize(submodule, rabbitizer_enum_##enumName##_enumvalues) < 0) { \ 62 | Py_DECREF(submodule); \ 63 | return NULL; \ 64 | } \ 65 | return submodule; \ 66 | } \ 67 | /* Return true if o is of this enum type */ \ 68 | int rabbitizer_enum_##enumName##_Check(PyObject *o) { \ 69 | int isInstance = PyObject_IsInstance(o, (PyObject*)&rabbitizer_type_Enum_TypeObject); \ 70 | int enumTypeCmp; \ 71 | if (isInstance < 0) { \ 72 | /* An error happened */ \ 73 | /* PyObject_IsInstance already sets an exception, so nothing else to do here */ \ 74 | return -1; \ 75 | } \ 76 | if (isInstance == 0) { \ 77 | /* `other` isn't an instance of the Enum type */ \ 78 | return 0; \ 79 | } \ 80 | /* Check if both enums have the same `enumType` */ \ 81 | enumTypeCmp = PyUnicode_CompareWithASCIIString(((PyRabbitizerEnum*)o)->enumType, #enumName); \ 82 | return enumTypeCmp == 0; \ 83 | } 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/enums/rabbitizer_enum_Abi.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "enums_utils.h" 5 | #include "common/RabbitizerConfig.h" 6 | #include "common/Utils.h" 7 | 8 | 9 | #define RABBITIZER_DEF_ABI(name) { "Abi", #name, RABBITIZER_ABI_##name, false, NULL } 10 | 11 | RabbitizerEnumMetadata rabbitizer_enum_Abi_enumvalues[] = { 12 | #include "common/Abi.inc" 13 | RABBITIZER_DEF_ABI(MAX), 14 | 15 | { 0 }, 16 | }; 17 | 18 | #undef RABBITIZER_DEF_ABI 19 | 20 | 21 | static PyObject *rabbitizer_enum_Abi_fromStr(UNUSED PyObject *self, PyObject *args, PyObject *kwds) { 22 | static char *kwlist[] = { "name", NULL }; 23 | const char *name = NULL; 24 | RabbitizerAbi abi; 25 | PyObject *ret; 26 | 27 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "z", kwlist, &name)) { 28 | return NULL; 29 | } 30 | 31 | abi = RabbitizerAbi_fromStr(name); 32 | 33 | ret = rabbitizer_enum_Abi_enumvalues[abi].instance; 34 | Py_INCREF(ret); 35 | return ret; 36 | } 37 | 38 | 39 | #define METHOD_NO_ARGS(name, docs) { #name, (PyCFunction) rabbitizer_enum_Abi_##name, METH_NOARGS, PyDoc_STR(docs) } 40 | #define METHOD_ARGS(name, docs) { #name, (PyCFunction) rabbitizer_enum_Abi_##name, METH_VARARGS | METH_KEYWORDS, PyDoc_STR(docs) } 41 | 42 | static PyMethodDef rabbitizer_enum_Abi_methods[] = { 43 | METHOD_ARGS(fromStr, ""), 44 | 45 | { 0 }, 46 | }; 47 | 48 | DEF_ENUM(Abi, "") 49 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/enums/rabbitizer_enum_InstrCategory.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "enums_utils.h" 5 | #include "instructions/RabbitizerInstruction.h" 6 | 7 | 8 | #define RABBITIZER_DEF_INSTR_CATEGORY(name) { "InstrCategory", #name, RABBITIZER_INSTRCAT_##name, false, NULL } 9 | 10 | RabbitizerEnumMetadata rabbitizer_enum_InstrCategory_enumvalues[] = { 11 | #include "instructions/InstrCategory.inc" 12 | RABBITIZER_DEF_INSTR_CATEGORY(MAX), 13 | 14 | { 0 }, 15 | }; 16 | 17 | #undef RABBITIZER_DEF_INSTR_CATEGORY 18 | 19 | static PyMethodDef rabbitizer_enum_InstrCategory_methods[] = { 20 | { 0 }, 21 | }; 22 | 23 | DEF_ENUM(InstrCategory, "") 24 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/enums/rabbitizer_enum_InstrId.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "enums_utils.h" 5 | #include "instructions/RabbitizerInstrId.h" 6 | 7 | 8 | #define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) { "InstrId", #prefix "_" #name, RABBITIZER_INSTR_ID_##prefix##_##name, false, NULL }, 9 | #define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, __VA_ARGS__) 10 | 11 | RabbitizerEnumMetadata rabbitizer_enum_InstrId_enumvalues[] = { 12 | #include "instructions/instr_id/RabbitizerInstrId_cpu.inc" 13 | 14 | #include "instructions/instr_id/RabbitizerInstrId_rsp.inc" 15 | 16 | #include "instructions/instr_id/RabbitizerInstrId_r5900.inc" 17 | 18 | RABBITIZER_DEF_INSTR_ID(ALL, , MAX, ) 19 | { 0 }, 20 | }; 21 | 22 | #undef RABBITIZER_DEF_INSTR_ID 23 | #undef RABBITIZER_DEF_INSTR_ID_ALTNAME 24 | 25 | static PyMethodDef rabbitizer_enum_InstrId_methods[] = { 26 | { 0 }, 27 | }; 28 | 29 | DEF_ENUM(InstrId, "") 30 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/enums/registers/rabbitizer_enum_GprN32.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "enums/enums_utils.h" 5 | #include "instructions/RabbitizerRegister.h" 6 | 7 | 8 | #define RABBITIZER_DEF_REG(prefix, name, numeric) \ 9 | { "RegGprN32", #name, RABBITIZER_REG_##prefix##_##name, false, NULL } 10 | 11 | #define RABBITIZER_DEF_REG_NODOLLAR(prefix, name, numeric) \ 12 | { "RegGprN32", #name, RABBITIZER_REG_##prefix##_##name, false, NULL } 13 | 14 | RabbitizerEnumMetadata rabbitizer_enum_RegGprN32_enumvalues[] = { 15 | #include "instructions/registers/RabbitizerRegister_GprN32.inc" 16 | 17 | { 0 }, 18 | }; 19 | 20 | #undef RABBITIZER_DEF_REG 21 | #undef RABBITIZER_DEF_REG_NODOLLAR 22 | 23 | 24 | static PyMethodDef rabbitizer_enum_RegGprN32_methods[] = { 25 | { 0 }, 26 | }; 27 | 28 | DEF_ENUM(RegGprN32, "") 29 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/enums/registers/rabbitizer_enum_GprO32.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "enums/enums_utils.h" 5 | #include "instructions/RabbitizerRegister.h" 6 | 7 | 8 | #define RABBITIZER_DEF_REG(prefix, name, numeric) \ 9 | { "RegGprO32", #name, RABBITIZER_REG_##prefix##_##name, false, NULL } 10 | 11 | #define RABBITIZER_DEF_REG_NODOLLAR(prefix, name, numeric) \ 12 | { "RegGprO32", #name, RABBITIZER_REG_##prefix##_##name, false, NULL } 13 | 14 | RabbitizerEnumMetadata rabbitizer_enum_RegGprO32_enumvalues[] = { 15 | #include "instructions/registers/RabbitizerRegister_GprO32.inc" 16 | 17 | { 0 }, 18 | }; 19 | 20 | #undef RABBITIZER_DEF_REG 21 | #undef RABBITIZER_DEF_REG_NODOLLAR 22 | 23 | 24 | static PyMethodDef rabbitizer_enum_RegGprO32_methods[] = { 25 | { 0 }, 26 | }; 27 | 28 | DEF_ENUM(RegGprO32, "") 29 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/decompals/ido-static-recomp/86d98a715566881825400a21daba76448f753b86/tools/rabbitizer/rabbitizer/py.typed -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/rabbitizer.pyi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 4 | # SPDX-License-Identifier: MIT 5 | 6 | from __future__ import annotations 7 | 8 | from .Enum import Enum 9 | from .InstrCategory import InstrCategory 10 | 11 | 12 | class Instruction: 13 | rs: Enum 14 | """The value of the `rs` register for this instruction. 15 | The type of this attribute will be either a `RegGprO32` or a `RegGprN32` depending on the current `config.regNames_gprAbiNames` value. 16 | If the current instruction does not use the `rs` register, then a Runtime exception will be raised. 17 | Read-only.""" 18 | rt: Enum 19 | """The value of the `rt` register for this instruction. 20 | The type of this attribute will be either a `RegGprO32` or a `RegGprN32` depending on the current `config.regNames_gprAbiNames` value. 21 | If the current instruction does not use the `rt` register, then a Runtime exception will be raised. 22 | Read-only.""" 23 | rd: Enum 24 | """The value of the `rd` register for this instruction. 25 | The type of this attribute will be either a `RegGprO32` or a `RegGprN32` depending on the current `config.regNames_gprAbiNames` value. 26 | If the current instruction does not use the `rd` register, then a Runtime exception will be raised. 27 | Read-only.""" 28 | sa: int 29 | """The value of the `sa` field for this instruction. 30 | If the current instruction does not have a `sa` field, then a Runtime exception will be raised. 31 | Read-only.""" 32 | 33 | uniqueId: Enum 34 | """An unique identificator for the opcode of this instruction. 35 | The type is an `InstrId` enum. 36 | Read-only.""" 37 | 38 | vram: int = 0 39 | """The vram (virtual ram) address for this instruction""" 40 | inHandwrittenFunction: bool = False 41 | """Boolean value indicating if the current instruction is used on a handwritten function. This is intended to be determined by the user.""" 42 | 43 | 44 | def __init__(self, word: int, vram: int=0, category: Enum=InstrCategory.CPU) -> None: ... 45 | 46 | def getRaw(self) -> int: ... 47 | def getImmediate(self) -> int: ... 48 | def getProcessedImmediate(self) -> int: ... 49 | def getInstrIndexAsVram(self) -> int: ... 50 | def getBranchOffset(self) -> int: ... 51 | def getGenericBranchOffset(self, currentVram: int) -> int: ... 52 | def getOpcodeName(self) -> str: ... 53 | 54 | def blankOut(self) -> None: ... 55 | 56 | def isImplemented(self) -> bool: ... 57 | def isLikelyHandwritten(self) -> bool: ... 58 | def isNop(self) -> bool: ... 59 | def isUnconditionalBranch(self) -> bool: ... 60 | def isJrRa(self) -> bool: ... 61 | def isJrNotRa(self) -> bool: ... 62 | def hasDelaySlot(self) -> bool: ... 63 | def mapInstrToType(self) -> str|None: ... 64 | 65 | def sameOpcode(self, other: Instruction) -> bool: ... 66 | def sameOpcodeButDifferentArguments(self, other: Instruction) -> bool: ... 67 | 68 | def isValid(self) -> bool: ... 69 | 70 | def isUnknownType(self) -> bool: ... 71 | def isJType(self) -> bool: ... 72 | def isIType(self) -> bool: ... 73 | def isRType(self) -> bool: ... 74 | def isRegimmType(self) -> bool: ... 75 | def isBranch(self) -> bool: ... 76 | def isBranchLikely(self) -> bool: ... 77 | def isJump(self) -> bool: ... 78 | def isTrap(self) -> bool: ... 79 | def isFloat(self) -> bool: ... 80 | def isDouble(self) -> bool: ... 81 | def isUnsigned(self) -> bool: ... 82 | def modifiesRt(self) -> bool: ... 83 | def modifiesRd(self) -> bool: ... 84 | def notEmitedByCompilers(self) -> bool: ... 85 | def canBeHi(self) -> bool: ... 86 | def canBeLo(self) -> bool: ... 87 | def doesLink(self) -> bool: ... 88 | def doesDereference(self) -> bool: ... 89 | def doesLoad(self) -> bool: ... 90 | def doesStore(self) -> bool: ... 91 | def maybeIsMove(self) -> bool: ... 92 | def isPseudo(self) -> bool: ... 93 | 94 | def disassemble(self, immOverride: str|None=None, extraLJust: int=0) -> str: ... 95 | 96 | def __reduce__(self) -> tuple: ... 97 | 98 | def __repr__(self) -> str: ... 99 | def __str__(self) -> str: ... 100 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/rabbitizer_module.h: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #ifndef RABBITIZER_MODULE_H 5 | #define RABBITIZER_MODULE_H 6 | #pragma once 7 | 8 | #define PY_SSIZE_T_CLEAN 9 | #include 10 | #include "structmember.h" 11 | 12 | #include "enums/enums_utils.h" 13 | 14 | #include "instructions/RabbitizerInstruction.h" 15 | #include "analysis/RabbitizerTrackedRegisterState.h" 16 | #include "analysis/RabbitizerLoPairingInfo.h" 17 | 18 | // TODO: clean up this... 19 | 20 | 21 | typedef struct PyRabbitizerInstruction { 22 | PyObject_HEAD 23 | RabbitizerInstruction instr; 24 | } PyRabbitizerInstruction; 25 | 26 | typedef struct PyRabbitizerTrackedRegisterState { 27 | PyObject_HEAD 28 | RabbitizerTrackedRegisterState registerState; 29 | } PyRabbitizerTrackedRegisterState; 30 | 31 | typedef struct PyRabbitizerLoPairingInfo { 32 | PyObject_HEAD 33 | RabbitizerLoPairingInfo pairingInfo; 34 | } PyRabbitizerLoPairingInfo; 35 | 36 | 37 | PyObject *rabbitizer_submodule_Utils_Init(void); 38 | 39 | extern PyTypeObject rabbitizer_global_config_TypeObject; 40 | 41 | extern PyTypeObject rabbitizer_type_Enum_TypeObject; 42 | extern PyTypeObject rabbitizer_type_Instruction_TypeObject; 43 | extern PyTypeObject rabbitizer_type_LoPairingInfo_TypeObject; 44 | extern PyTypeObject rabbitizer_type_TrackedRegisterState_TypeObject; 45 | extern PyTypeObject rabbitizer_type_RegistersTracker_TypeObject; 46 | 47 | DECL_ENUM(Abi) 48 | DECL_ENUM(InstrCategory) 49 | DECL_ENUM(InstrId) 50 | 51 | DECL_ENUM(RegGprO32) 52 | DECL_ENUM(RegGprN32) 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/rabbitizer_submodule_Utils.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "rabbitizer_module.h" 5 | 6 | #include "common/Utils.h" 7 | 8 | 9 | static PyObject *rabbitizer_submodule_Utils_from2Complement(UNUSED PyObject *self, PyObject *args, PyObject *kwds) { 10 | static char *kwlist[] = { "number", "bits", NULL }; 11 | uint32_t number = 0; 12 | int bits = 0; 13 | 14 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "Ii", kwlist, &number, &bits)) { 15 | return NULL; 16 | } 17 | 18 | return PyLong_FromLong(RabbitizerUtils_From2Complement(number, bits)); 19 | } 20 | 21 | static PyObject *rabbitizer_submodule_Utils_escapeString(UNUSED PyObject *self, PyObject *args, PyObject *kwds) { 22 | static char *kwlist[] = { "src", NULL }; 23 | const char *src = NULL; 24 | Py_ssize_t srcSize = 0; 25 | char *dst; 26 | size_t dstSize; 27 | size_t wroteBytes; 28 | PyObject *ret; 29 | 30 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#", kwlist, &src, &srcSize)) { 31 | return NULL; 32 | } 33 | 34 | dstSize = 2 * srcSize; 35 | dst = malloc(dstSize * sizeof(char)); 36 | if (dst == NULL) { 37 | PyErr_SetString(PyExc_RuntimeError, "Internal error on 'escapeString'"); 38 | return NULL; 39 | } 40 | 41 | wroteBytes = RabbitizerUtils_escapeString(dst, dstSize, src, srcSize); 42 | if (wroteBytes > dstSize) { 43 | PyErr_SetString(PyExc_RuntimeError, "Internal error on 'escapeString'"); 44 | return NULL; 45 | } 46 | 47 | ret = PyUnicode_FromStringAndSize(dst, wroteBytes); 48 | free(dst); 49 | return ret; 50 | } 51 | 52 | 53 | #define METHOD_NO_ARGS(name, docs) { #name, (PyCFunction) rabbitizer_submodule_Utils_##name, METH_NOARGS, PyDoc_STR(docs) } 54 | #define METHOD_ARGS(name, docs) { #name, (PyCFunction) rabbitizer_submodule_Utils_##name, METH_VARARGS | METH_KEYWORDS, PyDoc_STR(docs) } 55 | 56 | static PyMethodDef rabbitizer_submodule_Utils_methods[] = { 57 | METHOD_ARGS(from2Complement, ""), 58 | METHOD_ARGS(escapeString, ""), 59 | 60 | { 0 }, 61 | }; 62 | 63 | 64 | static PyModuleDef rabbitizer_submodule_Utils_module = { 65 | PyModuleDef_HEAD_INIT, 66 | .m_name = "rabbitizer.Utils", 67 | .m_doc = "", 68 | .m_size = -1, 69 | .m_methods = rabbitizer_submodule_Utils_methods, 70 | }; 71 | 72 | PyObject *rabbitizer_submodule_Utils_Init(void) { 73 | PyObject *submodule; 74 | 75 | submodule = PyModule_Create(&rabbitizer_submodule_Utils_module); 76 | if (submodule == NULL) { 77 | return NULL; 78 | } 79 | 80 | return submodule; 81 | } 82 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/rabbitizer_type_LoPairingInfo.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "rabbitizer_module.h" 5 | 6 | 7 | static void rabbitizer_type_LoPairingInfo_dealloc(PyRabbitizerLoPairingInfo *self) { 8 | Py_TYPE(self)->tp_free((PyObject *) self); 9 | } 10 | 11 | static int rabbitizer_type_LoPairingInfo_init(PyRabbitizerLoPairingInfo *self, PyObject *args, PyObject *kwds) { 12 | static char *kwlist[] = { NULL }; 13 | 14 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist)) { 15 | return -1; 16 | } 17 | 18 | RabbitizerLoPairingInfo_Init(&self->pairingInfo); 19 | 20 | return 0; 21 | } 22 | 23 | 24 | static PyMemberDef rabbitizer_type_LoPairingInfo_members[] = { 25 | { "instrOffset", T_INT, offsetof(PyRabbitizerLoPairingInfo, pairingInfo.instrOffset), 0, "" }, 26 | { "value", T_LONG, offsetof(PyRabbitizerLoPairingInfo, pairingInfo.value), 0, "" }, 27 | { "shouldProcess", T_BOOL, offsetof(PyRabbitizerLoPairingInfo, pairingInfo.shouldProcess), 0, "" }, 28 | { "isGpRel", T_BOOL, offsetof(PyRabbitizerLoPairingInfo, pairingInfo.isGpRel), 0, "" }, 29 | { "isGpGot", T_BOOL, offsetof(PyRabbitizerLoPairingInfo, pairingInfo.isGpGot), 0, "" }, 30 | 31 | { 0 } 32 | }; 33 | 34 | 35 | PyTypeObject rabbitizer_type_LoPairingInfo_TypeObject = { 36 | PyVarObject_HEAD_INIT(NULL, 0) 37 | .tp_name = "rabbitizer.LoPairingInfo", 38 | .tp_doc = PyDoc_STR("LoPairingInfo"), 39 | .tp_basicsize = sizeof(PyRabbitizerLoPairingInfo), 40 | .tp_itemsize = 0, 41 | .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, 42 | .tp_new = PyType_GenericNew, 43 | .tp_init = (initproc) rabbitizer_type_LoPairingInfo_init, 44 | .tp_dealloc = (destructor) rabbitizer_type_LoPairingInfo_dealloc, 45 | // .tp_repr = (reprfunc) rabbitizer_type_LoPairingInfo_repr, 46 | // .tp_str = (reprfunc) rabbitizer_type_LoPairingInfo_str, 47 | .tp_members = rabbitizer_type_LoPairingInfo_members, 48 | // .tp_methods = rabbitizer_type_Instr_methods, 49 | // .tp_getset = Instr_getsetters, 50 | }; 51 | -------------------------------------------------------------------------------- /tools/rabbitizer/rabbitizer/rabbitizer_type_TrackedRegisterState.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "rabbitizer_module.h" 5 | 6 | 7 | static void rabbitizer_type_TrackedRegisterState_dealloc(PyRabbitizerTrackedRegisterState *self) { 8 | RabbitizerTrackedRegisterState_destroy(&self->registerState); 9 | Py_TYPE(self)->tp_free((PyObject *) self); 10 | } 11 | 12 | static int rabbitizer_type_TrackedRegisterState_init(PyRabbitizerTrackedRegisterState *self, PyObject *args, PyObject *kwds) { 13 | static char *kwlist[] = { "registerNum", NULL }; 14 | int registerNum; 15 | 16 | if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, ®isterNum)) { 17 | return -1; 18 | } 19 | 20 | RabbitizerTrackedRegisterState_init(&self->registerState, registerNum); 21 | 22 | return 0; 23 | } 24 | 25 | 26 | #define DEF_MEMBER_GET_BOOL(name) \ 27 | static PyObject *rabbitizer_type_TrackedRegisterState_member_get_##name(PyRabbitizerTrackedRegisterState *self, UNUSED PyObject *closure) { \ 28 | if (self->registerState.name) { \ 29 | Py_RETURN_TRUE; \ 30 | } \ 31 | Py_RETURN_FALSE; \ 32 | } 33 | 34 | #define DEF_MEMBER_GET_INT(name) \ 35 | static PyObject *rabbitizer_type_TrackedRegisterState_member_get_##name(PyRabbitizerTrackedRegisterState *self, UNUSED PyObject *closure) { \ 36 | return PyLong_FromLong(self->registerState.name); \ 37 | } 38 | 39 | #define DEF_MEMBER_GET_UINT(name) \ 40 | static PyObject *rabbitizer_type_TrackedRegisterState_member_get_##name(PyRabbitizerTrackedRegisterState *self, UNUSED PyObject *closure) { \ 41 | return PyLong_FromUnsignedLong(self->registerState.name); \ 42 | } 43 | 44 | 45 | DEF_MEMBER_GET_INT(registerNum) 46 | 47 | DEF_MEMBER_GET_BOOL(hasLuiValue) 48 | DEF_MEMBER_GET_INT(luiOffset) 49 | DEF_MEMBER_GET_BOOL(luiSetOnBranchLikely) 50 | 51 | DEF_MEMBER_GET_BOOL(hasGpGot) 52 | DEF_MEMBER_GET_INT(gpGotOffset) 53 | 54 | DEF_MEMBER_GET_BOOL(hasLoValue) 55 | DEF_MEMBER_GET_INT(loOffset) 56 | DEF_MEMBER_GET_BOOL(dereferenced) 57 | DEF_MEMBER_GET_INT(dereferenceOffset) 58 | 59 | DEF_MEMBER_GET_UINT(value) 60 | 61 | 62 | #define MEMBER_GET(name, docs, closure) { #name, (getter) rabbitizer_type_TrackedRegisterState_member_get_##name, (setter) NULL, PyDoc_STR(docs), closure } 63 | #define MEMBER_SET(name, docs, closure) { #name, (getter) NULL, (setter) rabbitizer_type_TrackedRegisterState_member_set_##name, PyDoc_STR(docs), closure } 64 | #define MEMBER_GET_SET(name, docs, closure) { #name, (getter) rabbitizer_type_TrackedRegisterState_member_get_##name, (setter) rabbitizer_type_TrackedRegisterState_member_set_##name, PyDoc_STR(docs), closure } 65 | 66 | 67 | static PyGetSetDef rabbitizer_type_TrackedRegisterState_getsetters[] = { 68 | MEMBER_GET(registerNum, "", NULL), 69 | 70 | MEMBER_GET(hasLuiValue, "", NULL), 71 | MEMBER_GET(luiOffset, "", NULL), 72 | MEMBER_GET(luiSetOnBranchLikely, "", NULL), 73 | 74 | MEMBER_GET(hasGpGot, "", NULL), 75 | MEMBER_GET(gpGotOffset, "", NULL), 76 | 77 | MEMBER_GET(hasLoValue, "", NULL), 78 | MEMBER_GET(loOffset, "", NULL), 79 | MEMBER_GET(dereferenced, "", NULL), 80 | MEMBER_GET(dereferenceOffset, "", NULL), 81 | 82 | MEMBER_GET(value, "", NULL), 83 | 84 | { 0 } 85 | }; 86 | 87 | 88 | PyTypeObject rabbitizer_type_TrackedRegisterState_TypeObject = { 89 | PyVarObject_HEAD_INIT(NULL, 0) 90 | .tp_name = "rabbitizer.TrackedRegisterState", 91 | .tp_doc = PyDoc_STR("TrackedRegisterState"), 92 | .tp_basicsize = sizeof(PyRabbitizerTrackedRegisterState), 93 | .tp_itemsize = 0, 94 | .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, 95 | .tp_new = PyType_GenericNew, 96 | .tp_init = (initproc) rabbitizer_type_TrackedRegisterState_init, 97 | .tp_dealloc = (destructor) rabbitizer_type_TrackedRegisterState_dealloc, 98 | // .tp_repr = (reprfunc) rabbitizer_type_TrackedRegisterState_repr, 99 | // .tp_str = (reprfunc) rabbitizer_type_TrackedRegisterState_str, 100 | // .tp_methods = rabbitizer_type_TrackedRegisterState_methods, 101 | .tp_getset = rabbitizer_type_TrackedRegisterState_getsetters, 102 | }; 103 | -------------------------------------------------------------------------------- /tools/rabbitizer/registersTrackerTest.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "instructions/RabbitizerInstruction.h" 5 | #include "analysis/RabbitizerRegistersTracker.h" 6 | 7 | 8 | int main() { 9 | RabbitizerRegistersTracker regsTracker; 10 | RabbitizerInstruction instr; 11 | uint32_t word = 0x002D0821; // addu $at, $at, $t5 12 | uint32_t vram = 0x0042F170; 13 | int instrOffset = 220; 14 | 15 | RabbitizerRegistersTracker_init(®sTracker, NULL); 16 | 17 | RabbitizerInstruction_init(&instr, word, vram); 18 | RabbitizerInstruction_processUniqueId(&instr); 19 | 20 | regsTracker.registers[1] = (RabbitizerTrackedRegisterState){ 21 | .dereferenceOffset = 212, 22 | .dereferenced = true, 23 | .gpGotOffset = 212, 24 | .hasGpGot = true, 25 | .hasLoValue = true, 26 | .hasLuiValue = false, 27 | .loOffset = 212, 28 | .luiOffset = 0, 29 | .luiSetOnBranchLikely = false, 30 | .value = 0x10010000, 31 | .registerNum = regsTracker.registers[1].registerNum, 32 | }; 33 | 34 | RabbitizerRegistersTracker_overwriteRegisters(®sTracker, &instr, instrOffset); 35 | 36 | RabbitizerInstruction_destroy(&instr); 37 | 38 | RabbitizerRegistersTracker_destroy(®sTracker); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /tools/rabbitizer/rsptest.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "instructions/RabbitizerInstructionRsp.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | int main() { 13 | uint32_t word; 14 | RabbitizerInstruction instr; 15 | char *buffer; 16 | int extraLJust = 5; 17 | uint32_t validbits; 18 | 19 | //word = 0x4B01C8E8; // vand $v3, $v25, $v1[0] 20 | word = 0x48952000; // mtc2 $21, $v4[0] 21 | 22 | RabbitizerInstructionRsp_init(&instr, word, 0x80000000); 23 | 24 | RabbitizerInstructionRsp_processUniqueId(&instr); 25 | 26 | buffer = malloc(RabbitizerInstruction_getSizeForBuffer(&instr, 0, extraLJust) + 1); 27 | assert(buffer != NULL); 28 | 29 | RabbitizerInstruction_disassemble(&instr, buffer, NULL, 0, extraLJust); 30 | 31 | printf("%08X: %s\n", word, buffer); 32 | 33 | validbits = RabbitizerInstruction_getValidBits(&instr); 34 | 35 | printf("word: %08X\n", instr.word); 36 | printf("mandatory bits: %08X\n", instr._mandatorybits); 37 | printf("valid bits: %08X\n", validbits); 38 | printf("invalid bits: %08X\n", (~validbits) & instr.word); 39 | 40 | free(buffer); 41 | RabbitizerInstructionRsp_destroy(&instr); 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /tools/rabbitizer/setup.cfg: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 2 | # SPDX-License-Identifier: MIT 3 | 4 | [metadata] 5 | name = rabbitizer 6 | # Version should be synced with include/common/RabbitizerVersion.h 7 | version = 1.2.3 8 | author = Decompollaborate 9 | license = MIT 10 | description = MIPS instruction decoder 11 | url = https://github.com/Decompollaborate/rabbitizer 12 | project_urls = 13 | Source = https://github.com/Decompollaborate/rabbitizer 14 | Bug Tracker = https://github.com/Decompollaborate/rabbitizer/issues 15 | long_description = file: README.md 16 | long_description_content_type = text/markdown 17 | 18 | [options] 19 | packages = rabbitizer 20 | 21 | [options.package_data] 22 | rabbitizer = 23 | **/*.pyi 24 | **/py.typed 25 | -------------------------------------------------------------------------------- /tools/rabbitizer/setup.py: -------------------------------------------------------------------------------- 1 | # SPDX-FileCopyrightText: © 2022 Decompollaborate 2 | # SPDX-License-Identifier: MIT 3 | 4 | from setuptools import setup, Extension 5 | 6 | 7 | setup( 8 | ext_modules=[ 9 | Extension( 10 | name="rabbitizer", 11 | sources=["rabbitizer/rabbitizer_module.c", "rabbitizer/rabbitizer_submodule_Utils.c", "rabbitizer/rabbitizer_type_Instruction.c", "rabbitizer/rabbitizer_global_config.c", "rabbitizer/rabbitizer_type_TrackedRegisterState.c", "rabbitizer/rabbitizer_type_RegistersTracker.c", "rabbitizer/rabbitizer_type_LoPairingInfo.c", 12 | "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", 13 | "rabbitizer/enums/registers/rabbitizer_enum_GprO32.c", "rabbitizer/enums/registers/rabbitizer_enum_GprN32.c", 14 | "src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction_ProcessUniqueId.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c", 15 | "src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c", "src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_ProcessUniqueId.c", 16 | "src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c", "src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c", 17 | "src/instructions/RabbitizerInstrDescriptor.c", "src/instructions/RabbitizerInstrId.c", "src/instructions/RabbitizerRegister.c", "src/instructions/RabbitizerInstrSuffix.c", 18 | "src/analysis/RabbitizerTrackedRegisterState.c", "src/analysis/RabbitizerRegistersTracker.c", "src/analysis/RabbitizerLoPairingInfo.c", 19 | "src/common/Utils.c", "src/common/RabbitizerVersion.c", "src/common/RabbitizerConfig.c"], 20 | include_dirs=["include", "rabbitizer"], 21 | extra_compile_args = [ 22 | "-std=c11", 23 | "-Wall", 24 | "-g", 25 | ], 26 | ), 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /tools/rabbitizer/src/analysis/RabbitizerLoPairingInfo.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "analysis/RabbitizerLoPairingInfo.h" 5 | 6 | void RabbitizerLoPairingInfo_Init(RabbitizerLoPairingInfo *self) { 7 | *self = (RabbitizerLoPairingInfo){ 8 | .instrOffset = 0, 9 | .value = 0, 10 | .shouldProcess = false, 11 | .isGpRel = false, 12 | .isGpGot = false, 13 | }; 14 | } 15 | -------------------------------------------------------------------------------- /tools/rabbitizer/src/common/RabbitizerConfig.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "common/RabbitizerConfig.h" 5 | 6 | #include 7 | 8 | RabbitizerAbi RabbitizerAbi_fromStr(const char *name) { 9 | if (name == NULL || strcmp(name, "32") == 0 || strcmp(name, "o32") == 0 || strcmp(name, "O32") == 0) { 10 | return RABBITIZER_ABI_O32; 11 | } 12 | if (strcmp(name, "n32") == 0 || strcmp(name, "N32") == 0) { 13 | return RABBITIZER_ABI_N32; 14 | } 15 | if (strcmp(name, "64") == 0 || strcmp(name, "n64") == 0 || strcmp(name, "N64") == 0) { 16 | return RABBITIZER_ABI_N64; 17 | } 18 | return RABBITIZER_ABI_NUMERIC; 19 | } 20 | 21 | RabbitizerConfig RabbitizerConfig_Cfg = { 22 | .regNames = { 23 | .namedRegisters = true, 24 | .gprAbiNames = RABBITIZER_ABI_O32, 25 | .fprAbiNames = RABBITIZER_ABI_NUMERIC, 26 | .userFpcCsr = true, 27 | .vr4300Cop0NamedRegisters = true, 28 | .vr4300RspCop0NamedRegisters = true, 29 | }, 30 | .pseudos = { 31 | .enablePseudos = true, 32 | .pseudoBeqz = true, 33 | .pseudoBnez = true, 34 | .pseudoB = true, 35 | .pseudoMove = true, 36 | .pseudoNot = true, 37 | .pseudoNegu = true, 38 | .pseudoBal = true, 39 | }, 40 | .toolchainTweaks = { 41 | .treatJAsUnconditionalBranch = false, 42 | .sn64DivFix = false, 43 | }, 44 | .misc = { 45 | .opcodeLJust = 7+4, 46 | .unknownInstrComment = true, 47 | .omit0XOnSmallImm = false, 48 | .upperCaseImm = true, 49 | } 50 | }; 51 | -------------------------------------------------------------------------------- /tools/rabbitizer/src/common/RabbitizerVersion.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "common/RabbitizerVersion.h" 5 | 6 | const int RabVersion_Major = RAB_VERSION_MAJOR; 7 | const int RabVersion_Minor = RAB_VERSION_MINOR; 8 | const int RabVersion_Patch = RAB_VERSION_PATCH; 9 | 10 | const char RabVersion_Str[] = RAB_VERSION_STR; 11 | -------------------------------------------------------------------------------- /tools/rabbitizer/src/common/Utils.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "common/Utils.h" 5 | 6 | #include 7 | #include 8 | 9 | int32_t RabbitizerUtils_From2Complement(uint32_t number, int bits) { 10 | bool isNegative = number & (1ULL << (bits - 1)); 11 | 12 | if (isNegative) { 13 | return -((~number + 1) & ((1ULL << bits) - 1)); 14 | } 15 | 16 | return number; 17 | } 18 | 19 | size_t RabbitizerUtils_CharFill(char *dst, int count, char fillchar) { 20 | if (count <= 0) { 21 | return 0; 22 | } 23 | 24 | memset(dst, fillchar, count); 25 | 26 | return count; 27 | } 28 | 29 | size_t RabbitizerUtils_escapeString(char *dst, size_t dstSize, const char *src, size_t srcSize) { 30 | size_t srcPos = 0; 31 | size_t dstpos = 0; 32 | 33 | for (; srcPos < srcSize && dstpos < dstSize; srcPos++, src++) { 34 | // The cases of this switch are sorted by ASCII order 35 | switch (*src) { 36 | case '\a': 37 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); 38 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, 'a'); 39 | break; 40 | 41 | case '\t': 42 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); 43 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, 't'); 44 | break; 45 | 46 | case '\n': 47 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); 48 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, 'n'); 49 | break; 50 | 51 | case '\f': 52 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); 53 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, 'f'); 54 | break; 55 | 56 | case '\r': 57 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); 58 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, 'r'); 59 | break; 60 | 61 | case '"': 62 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); 63 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '"'); 64 | break; 65 | 66 | case '\\': 67 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); 68 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); 69 | break; 70 | 71 | default: 72 | RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, *src); 73 | break; 74 | } 75 | } 76 | 77 | return dstpos; 78 | } 79 | -------------------------------------------------------------------------------- /tools/rabbitizer/src/instructions/RabbitizerInstrDescriptor.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "instructions/RabbitizerInstrDescriptor.h" 5 | 6 | #include "instructions/RabbitizerInstruction.h" 7 | 8 | #define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) [RABBITIZER_INSTR_ID_##prefix##_##name] = { __VA_ARGS__ }, 9 | 10 | #define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, __VA_ARGS__) 11 | 12 | const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[] = { 13 | #include "instructions/instr_id/RabbitizerInstrId_cpu.inc" 14 | #include "instructions/instr_id/RabbitizerInstrId_rsp.inc" 15 | #include "instructions/instr_id/RabbitizerInstrId_r5900.inc" 16 | }; 17 | 18 | #undef RABBITIZER_DEF_INSTR_ID 19 | #undef RABBITIZER_DEF_INSTR_ID_ALTNAME 20 | 21 | bool RabbitizerInstrDescriptor_isUnknownType(const RabbitizerInstrDescriptor *self) { 22 | return self->instrType == RABBITIZER_INSTR_TYPE_UNKNOWN; 23 | } 24 | bool RabbitizerInstrDescriptor_isJType(const RabbitizerInstrDescriptor *self) { 25 | return self->instrType == RABBITIZER_INSTR_TYPE_J; 26 | } 27 | bool RabbitizerInstrDescriptor_isIType(const RabbitizerInstrDescriptor *self) { 28 | return self->instrType == RABBITIZER_INSTR_TYPE_I; 29 | } 30 | bool RabbitizerInstrDescriptor_isRType(const RabbitizerInstrDescriptor *self) { 31 | return self->instrType == RABBITIZER_INSTR_TYPE_R; 32 | } 33 | bool RabbitizerInstrDescriptor_isRegimmType(const RabbitizerInstrDescriptor *self) { 34 | return self->instrType == RABBITIZER_INSTR_TYPE_REGIMM; 35 | } 36 | 37 | RabbitizerInstrSuffix RabbitizerInstrDescriptor_instrSuffix(const RabbitizerInstrDescriptor *self) { 38 | return self->instrSuffix; 39 | } 40 | 41 | bool RabbitizerInstrDescriptor_isBranch(const RabbitizerInstrDescriptor *self) { 42 | return self->isBranch; 43 | } 44 | bool RabbitizerInstrDescriptor_isBranchLikely(const RabbitizerInstrDescriptor *self) { 45 | return self->isBranchLikely; 46 | } 47 | bool RabbitizerInstrDescriptor_isJump(const RabbitizerInstrDescriptor *self) { 48 | return self->isJump; 49 | } 50 | bool RabbitizerInstrDescriptor_isTrap(const RabbitizerInstrDescriptor *self) { 51 | return self->isTrap; 52 | } 53 | 54 | bool RabbitizerInstrDescriptor_isFloat(const RabbitizerInstrDescriptor *self) { 55 | return self->isFloat; 56 | } 57 | bool RabbitizerInstrDescriptor_isDouble(const RabbitizerInstrDescriptor *self) { 58 | return self->isDouble; 59 | } 60 | 61 | bool RabbitizerInstrDescriptor_isUnsigned(const RabbitizerInstrDescriptor *self) { 62 | return self->isUnsigned; 63 | } 64 | 65 | bool RabbitizerInstrDescriptor_modifiesRt(const RabbitizerInstrDescriptor *self) { 66 | return self->modifiesRt; 67 | } 68 | bool RabbitizerInstrDescriptor_modifiesRd(const RabbitizerInstrDescriptor *self) { 69 | return self->modifiesRd; 70 | } 71 | 72 | bool RabbitizerInstrDescriptor_notEmitedByCompilers(const RabbitizerInstrDescriptor *self) { 73 | return self->notEmitedByCompilers; 74 | } 75 | 76 | bool RabbitizerInstrDescriptor_canBeHi(const RabbitizerInstrDescriptor *self) { 77 | return self->canBeHi; 78 | } 79 | bool RabbitizerInstrDescriptor_canBeLo(const RabbitizerInstrDescriptor *self) { 80 | return self->canBeLo; 81 | } 82 | bool RabbitizerInstrDescriptor_doesLink(const RabbitizerInstrDescriptor *self) { 83 | return self->doesLink; 84 | } 85 | bool RabbitizerInstrDescriptor_doesDereference(const RabbitizerInstrDescriptor *self) { 86 | return self->doesDereference; 87 | } 88 | bool RabbitizerInstrDescriptor_doesLoad(const RabbitizerInstrDescriptor *self) { 89 | return self->doesLoad; 90 | } 91 | bool RabbitizerInstrDescriptor_doesStore(const RabbitizerInstrDescriptor *self) { 92 | return self->doesStore; 93 | } 94 | bool RabbitizerInstrDescriptor_maybeIsMove(const RabbitizerInstrDescriptor *self) { 95 | return self->maybeIsMove; 96 | } 97 | 98 | bool RabbitizerInstrDescriptor_isPseudo(const RabbitizerInstrDescriptor *self) { 99 | return self->isPseudo; 100 | } 101 | 102 | RabbitizerArchitectureVersion RabbitizerInstrDescriptor_getArchitectureVersion(const RabbitizerInstrDescriptor *self) { 103 | return self->architectureVersion; 104 | } 105 | -------------------------------------------------------------------------------- /tools/rabbitizer/src/instructions/RabbitizerInstrId.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "instructions/RabbitizerInstrId.h" 5 | 6 | #include 7 | 8 | #define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) [RABBITIZER_INSTR_ID_##prefix##_##name] = #name, 9 | 10 | #define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) [RABBITIZER_INSTR_ID_##prefix##_##name] = #altname, 11 | 12 | const char *RabbitizerInstrId_Names[] = { 13 | #include "instructions/instr_id/RabbitizerInstrId_cpu.inc" 14 | #include "instructions/instr_id/RabbitizerInstrId_rsp.inc" 15 | #include "instructions/instr_id/RabbitizerInstrId_r5900.inc" 16 | }; 17 | 18 | #undef RABBITIZER_DEF_INSTR_ID 19 | #undef RABBITIZER_DEF_INSTR_ID_ALTNAME 20 | 21 | const char *RabbitizerInstrId_getOpcodeName(RabbitizerInstrId uniqueId) { 22 | assert(uniqueId >= RABBITIZER_INSTR_ID_cpu_INVALID && uniqueId < RABBITIZER_INSTR_ID_ALL_MAX); 23 | assert(uniqueId != RABBITIZER_INSTR_ID_cpu_MAX); 24 | assert(uniqueId != RABBITIZER_INSTR_ID_rsp_MAX); 25 | assert(uniqueId != RABBITIZER_INSTR_ID_r5900_MAX); 26 | 27 | return RabbitizerInstrId_Names[uniqueId]; 28 | } 29 | -------------------------------------------------------------------------------- /tools/rabbitizer/src/instructions/RabbitizerInstrSuffix.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "instructions/RabbitizerInstrSuffix.h" 5 | 6 | #include 7 | 8 | #include "common/Utils.h" 9 | #include "instructions/RabbitizerInstruction.h" 10 | #include "instructions/RabbitizerInstructionRsp.h" 11 | #include "instructions/RabbitizerInstructionR5900.h" 12 | 13 | typedef size_t (*InstrSuffixCallback)(const RabbitizerInstruction *self, char *dst); 14 | 15 | size_t RabbitizerInstrSuffix_None(UNUSED const RabbitizerInstruction *self, UNUSED char *dst) { 16 | return 0; 17 | } 18 | 19 | size_t RabbitizerInstrSuffixR5900_xyzw(const RabbitizerInstruction *self, char *dst) { 20 | size_t totalSize = 0; 21 | 22 | if (RAB_INSTR_R5900_GET_xyzw_x(self) || RAB_INSTR_R5900_GET_xyzw_y(self) || RAB_INSTR_R5900_GET_xyzw_z(self) || RAB_INSTR_R5900_GET_xyzw_w(self)) { 23 | RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '.'); 24 | } 25 | 26 | if (RAB_INSTR_R5900_GET_xyzw_x(self)) { 27 | RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x'); 28 | } 29 | if (RAB_INSTR_R5900_GET_xyzw_y(self)) { 30 | RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y'); 31 | } 32 | if (RAB_INSTR_R5900_GET_xyzw_z(self)) { 33 | RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z'); 34 | } 35 | if (RAB_INSTR_R5900_GET_xyzw_w(self)) { 36 | RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w'); 37 | } 38 | 39 | return totalSize; 40 | } 41 | const InstrSuffixCallback instrSuffixCallbacks[] = { 42 | [RABINSTRSUFFIX_NONE] = RabbitizerInstrSuffix_None, 43 | 44 | [RABINSTRSUFFIX_R5900_xyzw] = RabbitizerInstrSuffixR5900_xyzw, 45 | }; 46 | 47 | size_t RabbitizerInstrSuffix_getSizeForBuffer(UNUSED const RabbitizerInstruction *self, UNUSED RabbitizerInstrSuffix instrSuffix) { 48 | // Just hardcode the size of the bigger possible suffix, faster than actually computing it. 49 | return 5; 50 | } 51 | 52 | size_t RabbitizerInstrSuffix_processSuffix(const RabbitizerInstruction *self, char *dst, RabbitizerInstrSuffix instrSuffix) { 53 | InstrSuffixCallback callback; 54 | 55 | assert(instrSuffix >= RABINSTRSUFFIX_NONE); 56 | assert(instrSuffix < RABINSTRSUFFIX_MAX); 57 | 58 | callback = instrSuffixCallbacks[instrSuffix]; 59 | assert(callback != NULL); 60 | 61 | return callback(self, dst); 62 | } 63 | -------------------------------------------------------------------------------- /tools/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "instructions/RabbitizerInstructionR5900.h" 5 | 6 | void RabbitizerInstructionR5900_init(RabbitizerInstruction *self, uint32_t word, uint32_t vram) { 7 | RabbitizerInstruction_init(self, word, vram); 8 | 9 | self->uniqueId = RABBITIZER_INSTR_ID_r5900_INVALID; 10 | self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; 11 | 12 | self->category = RABBITIZER_INSTRCAT_R5900; 13 | } 14 | 15 | void RabbitizerInstructionR5900_destroy(RabbitizerInstruction *self) { 16 | RabbitizerInstruction_destroy(self); 17 | } 18 | -------------------------------------------------------------------------------- /tools/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "instructions/RabbitizerInstructionRsp.h" 5 | 6 | void RabbitizerInstructionRsp_init(RabbitizerInstruction *self, uint32_t word, uint32_t vram) { 7 | RabbitizerInstruction_init(self, word, vram); 8 | 9 | self->uniqueId = RABBITIZER_INSTR_ID_rsp_INVALID; 10 | self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; 11 | 12 | self->_handwrittenCategory = true; 13 | self->category = RABBITIZER_INSTRCAT_RSP; 14 | } 15 | 16 | void RabbitizerInstructionRsp_destroy(RabbitizerInstruction *self) { 17 | RabbitizerInstruction_destroy(self); 18 | } 19 | 20 | uint16_t RabbitizerInstructionRsp_GetOffsetVector(const RabbitizerInstruction *self) { 21 | uint16_t offset = RAB_INSTR_RSP_GET_OFFSET_VECTOR_RAW(self); 22 | 23 | switch (self->uniqueId) { 24 | case RABBITIZER_INSTR_ID_rsp_lsv: 25 | case RABBITIZER_INSTR_ID_rsp_ssv: 26 | return offset << 1; 27 | 28 | case RABBITIZER_INSTR_ID_rsp_llv: 29 | case RABBITIZER_INSTR_ID_rsp_slv: 30 | return offset << 2; 31 | 32 | case RABBITIZER_INSTR_ID_rsp_ldv: 33 | case RABBITIZER_INSTR_ID_rsp_sdv: 34 | case RABBITIZER_INSTR_ID_rsp_lpv: 35 | case RABBITIZER_INSTR_ID_rsp_spv: 36 | case RABBITIZER_INSTR_ID_rsp_luv: 37 | case RABBITIZER_INSTR_ID_rsp_suv: 38 | return offset << 3; 39 | 40 | case RABBITIZER_INSTR_ID_rsp_lqv: 41 | case RABBITIZER_INSTR_ID_rsp_sqv: 42 | case RABBITIZER_INSTR_ID_rsp_lrv: 43 | case RABBITIZER_INSTR_ID_rsp_srv: 44 | case RABBITIZER_INSTR_ID_rsp_lhv: 45 | case RABBITIZER_INSTR_ID_rsp_shv: 46 | case RABBITIZER_INSTR_ID_rsp_lfv: 47 | case RABBITIZER_INSTR_ID_rsp_sfv: 48 | case RABBITIZER_INSTR_ID_rsp_ltv: 49 | case RABBITIZER_INSTR_ID_rsp_stv: 50 | case RABBITIZER_INSTR_ID_rsp_swv: 51 | return offset << 4; 52 | 53 | default: 54 | return offset; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /tools/rabbitizer/test.c: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "instructions/RabbitizerInstruction.h" 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | int main() { 13 | uint32_t word; 14 | RabbitizerInstruction instr; 15 | char *buffer; 16 | int extraLJust = 5; 17 | size_t bufferSize; 18 | size_t disassembledSize; 19 | 20 | word = 0x8D4A7E18; // lw 21 | //word = 0x00004010; // mfhi 22 | 23 | RabbitizerInstruction_init(&instr, word, 0x80000000); 24 | 25 | RabbitizerInstruction_processUniqueId(&instr); 26 | 27 | bufferSize = RabbitizerInstruction_getSizeForBuffer(&instr, 0, extraLJust); 28 | buffer = malloc(bufferSize + 1); 29 | assert(buffer != NULL); 30 | 31 | disassembledSize = RabbitizerInstruction_disassemble(&instr, buffer, NULL, 0, extraLJust); 32 | assert(disassembledSize <= bufferSize); 33 | 34 | printf("%08X: %s\n", word, buffer); 35 | 36 | free(buffer); 37 | RabbitizerInstruction_destroy(&instr); 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /tools/rabbitizer/tests/cplusplus/test.cpp: -------------------------------------------------------------------------------- 1 | /* SPDX-FileCopyrightText: © 2022 Decompollaborate */ 2 | /* SPDX-License-Identifier: MIT */ 3 | 4 | #include "instructions/InstructionCpu.hpp" 5 | 6 | 7 | int main() { 8 | uint32_t word = 0x8D4A7E18; // lw 9 | uint32_t vram = 0x80000000; 10 | int extraLJust = 5; 11 | rabbitizer::InstructionCpu instr(word, vram); 12 | 13 | printf("%08X: %s\n", word, instr.disassemble(extraLJust).c_str()); 14 | 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /version_info.c: -------------------------------------------------------------------------------- 1 | /** 2 | * Function that prints version info. This file should be compiled with the following defined: 3 | * - PACKAGE_VERSION, e.g. with `-DPACKAGE_VERSION="\"$(LC_ALL=C git --git-dir .git describe --tags --dirty)\""` 4 | * - DATETIME, e.g. with `-DDATETIME="\"$(date +'%F %T UTC%z')\""` 5 | * 6 | * The code in this file is mostly taken from 7 | * - CPython: https://github.com/python/cpython/, licensed under the PSF, available here: https://docs.python.org/3/license.html 8 | * - The Ocarina of Time practice rom, gz: https://github.com/glankk/gz/ 9 | */ 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #if defined(IDO53) 16 | #define IDO_VERSION "IDO 5.3" 17 | #elif defined(IDO71) 18 | #define IDO_VERSION "IDO 7.1" 19 | #else 20 | #define IDO_VERSION "" 21 | #endif 22 | 23 | #ifndef COMPILER 24 | 25 | // Note the __clang__ conditional has to come before the __GNUC__ one because 26 | // clang pretends to be GCC. 27 | #if defined(__clang__) 28 | #define COMPILER "Clang " __clang_version__ 29 | #elif defined(__GNUC__) 30 | #define COMPILER "GCC " __VERSION__ 31 | // Generic fallbacks. 32 | #elif defined(__cplusplus) 33 | #define COMPILER "C++" 34 | #else 35 | #define COMPILER "C" 36 | #endif 37 | 38 | #endif /* !COMPILER */ 39 | 40 | /* git */ 41 | #ifndef PACKAGE_VERSION 42 | #define PACKAGE_VERSION "Unknown version" 43 | #endif 44 | 45 | /* Date and time */ 46 | #ifndef DATETIME 47 | #define DATETIME "Unknown date" 48 | #endif 49 | 50 | extern char* progname; 51 | 52 | void print_version_info(void) { 53 | char* buf = malloc(strlen(progname) + 1); 54 | strcpy(buf, progname); 55 | char* name = basename(buf); 56 | 57 | printf("%s `%s` static recompilation, Decompals version\n", IDO_VERSION, name); 58 | printf("Source: https://github.com/decompals/ido-static-recomp\n"); 59 | printf("Version: %s\n", PACKAGE_VERSION); 60 | printf("Build date: %s\n", DATETIME); 61 | printf("Compiler: %s\n", COMPILER); 62 | 63 | free(buf); 64 | } 65 | --------------------------------------------------------------------------------