diff --git a/tools/Makefile b/tools/Makefile index f3f9496f..41840771 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -49,25 +49,19 @@ endif all-except-recomp: $(LIBAUDIOFILE) $(BUILD_PROGRAMS) -all: all-except-recomp ido-static-recomp +all: all-except-recomp clean: $(RM) $(ALL_PROGRAMS) $(MAKE) -C audiofile clean - $(MAKE) -C ido-static-recomp clean - define COMPILE $(1): $($1_SOURCES) $$(CC) $(CFLAGS) $($1_CFLAGS) $$^ -o $$@ $($1_LDFLAGS) $(LDFLAGS) endef -ido-static-recomp: - @$(MAKE) -C ido-static-recomp setup - @$(MAKE) -C ido-static-recomp - $(foreach p,$(BUILD_PROGRAMS),$(eval $(call COMPILE,$(p)))) $(LIBAUDIOFILE): @$(MAKE) -C audiofile -.PHONY: all all-except-recomp clean default ido-static-recomp +.PHONY: all all-except-recomp clean default diff --git a/tools/ido-static-recomp/.clang-format b/tools/ido-static-recomp/.clang-format deleted file mode 100644 index c7b900f0..00000000 --- a/tools/ido-static-recomp/.clang-format +++ /dev/null @@ -1,23 +0,0 @@ -IndentWidth: 4 -Language: Cpp -UseTab: Never -ColumnLimit: 120 -PointerAlignment: Left -BreakBeforeBraces: Attach -SpaceAfterCStyleCast: false -Cpp11BracedListStyle: false -IndentCaseLabels: true -BinPackArguments: true -BinPackParameters: true -AlignAfterOpenBracket: Align -AlignOperands: true -BreakBeforeTernaryOperators: true -BreakBeforeBinaryOperators: None -AllowShortBlocksOnASingleLine: true -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: false -AlignEscapedNewlines: Left -AlignTrailingComments: true -SortIncludes: false diff --git a/tools/ido-static-recomp/.gitignore b/tools/ido-static-recomp/.gitignore deleted file mode 100644 index e36efc8d..00000000 --- a/tools/ido-static-recomp/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -.idea/ -build/ -.vscode/ - -qemu-irix - -ctx.c.m2c -*.s - -.DS_Store diff --git a/tools/ido-static-recomp/DOCS.md b/tools/ido-static-recomp/DOCS.md deleted file mode 100644 index 1953751c..00000000 --- a/tools/ido-static-recomp/DOCS.md +++ /dev/null @@ -1,19 +0,0 @@ -# Custom Functionality - -## Redirection -IDO recomp currently has two forms of path redirection, both involving the `/usr` folder. - -### `/usr/lib` -In order for users to not having to worry about installing the binaries in particular locations in `/usr/lib`, recomp automatically redirects `/usr/lib/` 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. - -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`. - -Wrapper functions implementing this redirection: -* `init_file` -* `wrapper_execvp` - -### /usr/include -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. - -Wrapper functions implementing this redirection: -* `wrapper_open` diff --git a/tools/ido-static-recomp/Makefile b/tools/ido-static-recomp/Makefile deleted file mode 100644 index 69a50d16..00000000 --- a/tools/ido-static-recomp/Makefile +++ /dev/null @@ -1,231 +0,0 @@ -# Build options can be changed by modifying the makefile or by building with 'make SETTING=value'. -# It is also possible to override the settings in Defaults in a file called .make_options as 'SETTING=value'. - --include .make_options - -#### Defaults #### - -# if WERROR is 1, pass -Werror to CC, so warnings would be treated as errors -WERROR ?= 0 -# if RELEASE is 1 strip binaries as well as enable optimizations -RELEASE ?= 1 -# On Mac, set this to `universal` to build universal (x86+ARM) binaries -TARGET ?= native -# Set to 1 to build with sanitization enabled -# N.B. cannot be used for `make setup` at the moment due to recomp.cpp not respecting it -ASAN ?= 0 - -# IDO 5.3 only for Super Mario 64 -IDO_VERSION := IDO53 -IDO_TC := cc acpp as0 as1 cfe copt ugen ujoin uld umerge uopt usplit - - -# -- determine the host environment and target -# | Host | Targets | -# |-------|-------------------| -# | macOS | native, universal | -# | linux | native | -# | win | native | - -UNAME_S := $(shell uname -s) -UNAME_P := $(shell uname -p) - -MAKE := make -ifeq ($(OS),Windows_NT) - DETECTED_OS := windows -else ifeq ($(UNAME_S),Linux) - DETECTED_OS := linux -else ifeq ($(UNAME_S),Darwin) - DETECTED_OS := macos - MAKE := gmake - CPPFLAGS += -xc++ -else - $(error Unsupported host OS for Makefile) -endif - -RABBITIZER := tools/rabbitizer -RABBITIZER_LIB := $(RABBITIZER)/build/librabbitizerpp.a - -CC := gcc -CXX := g++ -STRIP := strip - -CSTD ?= -std=c11 -CFLAGS ?= -MMD -fno-strict-aliasing -I. -CXXSTD ?= -std=c++17 -CXXFLAGS ?= -MMD -WARNINGS ?= -Wall -Wextra -LDFLAGS ?= -lm -RECOMP_FLAGS ?= - -ifneq ($(WERROR),0) - WARNINGS += -Werror -endif - -ifeq ($(RELEASE),1) - OPTFLAGS ?= -Os -else - OPTFLAGS ?= -Og -g3 - STRIP := @: -endif - -ifneq ($(ASAN),0) - CFLAGS += -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -fno-sanitize-recover=all - CXXFLAGS += -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -fno-sanitize-recover=all -endif - - -ifeq ($(DETECTED_OS),windows) - CXXFLAGS += -static -endif - -# -- Build Directories -# designed to work with Make 3.81 (macOS/last GPL-2 version) -# https://ismail.badawi.io/blog/automatic-directory-creation-in-make/ -BUILD_BASE ?= build -BUILD_DIR := $(BUILD_BASE) -BUILT_BIN := $(BUILD_DIR)/out - - -# -- Location of original IDO binaries in SM64 repo -IRIX_USR_DIR ?= ../ido5.3_compiler/usr - -# -- Location of the irix tool chain error messages -ERR_STRS := $(BUILT_BIN)/err.english.cc - -RECOMP_ELF := $(BUILD_BASE)/recomp.elf -LIBC_IMPL_O := libc_impl.o - -TARGET_BINARIES := $(foreach binary,$(IDO_TC),$(BUILT_BIN)/$(binary)) -O_FILES := $(foreach binary,$(IDO_TC),$(BUILD_DIR)/$(binary).o) -C_FILES := $(O_FILES:.o=.c) - -# Automatic dependency files -DEP_FILES := $(O_FILES:.o=.d) - -# create build directories -$(shell mkdir -p $(BUILT_BIN)) - -# per-file flags -# 5.3 ugen relies on UB stack reads -# to emulate, pass the conservative flag to `recomp` -$(BUILD_BASE)/ugen.c: RECOMP_FLAGS := --conservative - -$(RECOMP_ELF): CXXFLAGS += -I$(RABBITIZER)/include -I$(RABBITIZER)/cplusplus/include -$(RECOMP_ELF): LDFLAGS += -L$(RABBITIZER)/build -lrabbitizerpp - -ifneq ($(DETECTED_OS),windows) -# For traceback -$(RECOMP_ELF): LDFLAGS += -ldl -endif -ifeq ($(DETECTED_OS),linux) -# For traceback -$(RECOMP_ELF): LDFLAGS += -Wl,-export-dynamic -endif - -# Too many warnings, disable everything for now... -$(RECOMP_ELF): WARNINGS += -Wpedantic -Wno-shadow -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter -Wno-implicit-fallthrough -%/$(LIBC_IMPL_O): CFLAGS += -D$(IDO_VERSION) -# TODO: fix warnings -%/$(LIBC_IMPL_O): WARNINGS += -Wno-unused-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-sign-compare -Wno-deprecated-declarations - -#### Main Targets ### - -all: $(TARGET_BINARIES) $(ERR_STRS) - -setup: - $(MAKE) -C $(RABBITIZER) static CC=$(CC) CXX=$(CXX) DEBUG=$(DEBUG) - $(MAKE) $(RECOMP_ELF) - -clean: - $(RM) -r $(BUILD_DIR) - -distclean: - $(RM) -r $(BUILD_BASE) - $(MAKE) -C $(RABBITIZER) distclean - -c_files: $(C_FILES) - - -.PHONY: all clean distclean setup -.DEFAULT_GOAL := all -# Prevent removing intermediate files -.SECONDARY: - - -#### Various Recipes #### - -$(BUILD_BASE)/%.elf: %.cpp - $(CXX) $(CXXSTD) $(OPTFLAGS) $(CXXFLAGS) $(WARNINGS) -o $@ $^ $(LDFLAGS) - - -$(BUILD_DIR)/%.c: $(IRIX_USR_DIR)/lib/% - $(RECOMP_ELF) $(RECOMP_FLAGS) $< > $@ || ($(RM) -f $@ && false) - -# cc and strip are special and are stored in the `bin` folder instead of the `lib` one -$(BUILD_DIR)/%.c: $(IRIX_USR_DIR)/bin/% - $(RECOMP_ELF) $(RECOMP_FLAGS) $< > $@ || ($(RM) -f $@ && false) - - -$(BUILT_BIN)/%.cc: $(IRIX_USR_DIR)/lib/%.cc - cp $^ $@ - - -ifeq ($(TARGET),universal) -MACOS_FAT_TARGETS ?= arm64-apple-macos11 x86_64-apple-macos10.14 - -FAT_FOLDERS := $(foreach target,$(MACOS_FAT_TARGETS),$(BUILD_DIR)/$(target)) - -# create build directories -$(shell mkdir -p $(FAT_FOLDERS)) - -# TODO: simplify -FAT_BINARIES := $(foreach binary,$(IDO_TC),$(BUILT_BIN)/arm64-apple-macos11/$(binary)) \ - $(foreach binary,$(IDO_TC),$(BUILT_BIN)/x86_64-apple-macos10.14/$(binary)) - -$(BUILT_BIN)/%: $(BUILD_DIR)/arm64-apple-macos11/% $(BUILD_DIR)/x86_64-apple-macos10.14/% | $(ERR_STRS) - lipo -create -output $@ $^ - - -$(BUILD_DIR)/arm64-apple-macos11/%: $(BUILD_DIR)/arm64-apple-macos11/%.o $(BUILD_DIR)/arm64-apple-macos11/$(LIBC_IMPL_O) | $(ERR_STRS) - $(CC) $(CSTD) $(OPTFLAGS) $(CFLAGS) -target arm64-apple-macos11 -o $@ $^ $(LDFLAGS) - $(STRIP) $@ - -$(BUILD_DIR)/x86_64-apple-macos10.14/%: $(BUILD_DIR)/x86_64-apple-macos10.14/%.o $(BUILD_DIR)/x86_64-apple-macos10.14/$(LIBC_IMPL_O) | $(ERR_STRS) - $(CC) $(CSTD) $(OPTFLAGS) $(CFLAGS) -target x86_64-apple-macos10.14 -o $@ $^ $(LDFLAGS) - $(STRIP) $@ - -$(BUILD_DIR)/arm64-apple-macos11/%.o: $(BUILD_DIR)/%.c - $(CC) -c $(CSTD) $(OPTFLAGS) $(CFLAGS) -target arm64-apple-macos11 -o $@ $< - -$(BUILD_DIR)/x86_64-apple-macos10.14/%.o: $(BUILD_DIR)/%.c - $(CC) -c $(CSTD) $(OPTFLAGS) $(CFLAGS) -target x86_64-apple-macos10.14 -o $@ $< - - -$(BUILD_DIR)/arm64-apple-macos11/$(LIBC_IMPL_O): libc_impl.c - $(CC) -c $(CSTD) $(OPTFLAGS) $(CFLAGS) $(WARNINGS) -target arm64-apple-macos11 -o $@ $< - -$(BUILD_DIR)/x86_64-apple-macos10.14/$(LIBC_IMPL_O): libc_impl.c - $(CC) -c $(CSTD) $(OPTFLAGS) $(CFLAGS) $(WARNINGS) -target x86_64-apple-macos10.14 -o $@ $< - -else -$(BUILT_BIN)/%: $(BUILD_DIR)/%.o $(BUILD_DIR)/$(LIBC_IMPL_O) | $(ERR_STRS) - $(CC) $(CSTD) $(OPTFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS) - $(STRIP) $@ - -$(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c - $(CC) -c $(CSTD) $(OPTFLAGS) $(CFLAGS) -o $@ $< - - -$(BUILD_DIR)/$(LIBC_IMPL_O): libc_impl.c - $(CC) -c $(CSTD) $(OPTFLAGS) $(CFLAGS) $(WARNINGS) -o $@ $< -endif - -# Remove built-in rules, to improve performance -MAKEFLAGS += --no-builtin-rules - --include $(DEP_FILES) - -# --- Debugging -# run `make print-VARIABLE` to debug that variable -print-% : ; $(info $* is a $(flavor $*) variable set to [$($*)]) @true diff --git a/tools/ido-static-recomp/README.md b/tools/ido-static-recomp/README.md deleted file mode 100644 index 83ae760f..00000000 --- a/tools/ido-static-recomp/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# Static Recompilation of IRIX Programs - -Convert selected IRIX C toolchain programs into modern Linux or macOS programs - -## Supported Programs - -* IDO 5.3 - * cc, acpp, as0, as1, cfe, copt, ugen, ujoin, uld, umerge, uopt, usplit, ld, strip, upas -* IDO 7.1 - * cc, acpp, as0, as1, cfe, ugen, ujoin, uld, umerge, uopt, usplit, upas - -## Dependencies - -### Linux (Debian / Ubuntu) - -```bash -sudo apt-get install build-essential -``` - -### macOS - -[Install homebrew](https://brew.sh/) and then: - -```bash -brew install make -``` - -## Building - -First build the recomp binary itself - -```bash -make setup -``` - -```bash -make VERSION=5.3 -make VERSION=7.1 -``` - -The build artifacts are located in `build/{7.1|5.3}/out`. Add `-j{thread num}` for multithreaded building. - -By default, debug builds are created with less optimizations, debug flags, and unstripped binaries. -Add `RELEASE=1` to build release builds with optimizations and stripped binaries. - -### Creating Universal ARM/x86_64 macOS Builds - -By default, make build script create native binaries on macOS. This was done to minimize the time to build the recompiled suite. -In order to create "fat," universal ARM and x86_64, pass `TARGET=universal` to `gmake`. - -### Manual Building - -Example for compiling `as1` in a Linux environment: - -```bash -make -C tools/rabbitizer -g++ -Itools/rabbitizer/include -Itools/rabbitizer/cplusplus/include recomp.cpp -o recomp.elf -g -Ltools/rabbitizer/build -lrabbitizerpp -./recomp.elf ido/7.1/usr/lib/as1 > as1_c.c -gcc libc_impl.c as1_c.c -o as1 -g -fno-strict-aliasing -lm -DIDO71 -``` - -Use the same approach for `cc`, `cfe`, `uopt`, `ugen`, `as1` (and `copt` if you need that). - -Use `-DIDO53` instead of `-DIDO71` if the program you are trying to recompile was compiled with IDO 5.3 rather than IDO 7.1. - -To compile `ugen` for IDO 5.3, add `--conservative` when invoking `./recomp.elf`. This mimics UB present in `ugen53`. That program reads uninitialized stack memory and its result depends on that stack memory. diff --git a/tools/ido-static-recomp/elf.h b/tools/ido-static-recomp/elf.h deleted file mode 100644 index 91ba5fe2..00000000 --- a/tools/ido-static-recomp/elf.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef ELF_H -#define ELF_H - -#include - -#define EI_DATA 5 -#define EI_NIDENT 16 -#define SHT_SYMTAB 2 -#define SHT_DYNAMIC 6 -#define SHT_REL 9 -#define SHT_DYNSYM 11 -#define SHT_MIPS_REGINFO 0x70000006 -#define STN_UNDEF 0 -#define STT_OBJECT 1 -#define STT_FUNC 2 -#define DT_PLTGOT 3 -#define DT_MIPS_LOCAL_GOTNO 0x7000000a -#define DT_MIPS_SYMTABNO 0x70000011 -#define DT_MIPS_GOTSYM 0x70000013 - -#define ELF32_R_SYM(info) ((info) >> 8) -#define ELF32_R_TYPE(info) ((info) & 0xff) - -#define ELF32_ST_TYPE(info) ((info) & 0xf) - -#define R_MIPS_26 4 -#define R_MIPS_HI16 5 -#define R_MIPS_LO16 6 - -#define SHN_UNDEF 0 -#define SHN_COMMON 0xfff2 -#define SHN_MIPS_ACOMMON 0xff00 -#define SHN_MIPS_TEXT 0xff01 -#define SHN_MIPS_DATA 0xff02 - -typedef uint32_t Elf32_Addr; -typedef uint32_t Elf32_Off; - -typedef struct { - uint8_t e_ident[EI_NIDENT]; - uint16_t e_type; - uint16_t e_machine; - uint32_t e_version; - Elf32_Addr e_entry; - Elf32_Off e_phoff; - Elf32_Off e_shoff; - uint32_t e_flags; - uint16_t e_ehsize; - uint16_t e_phentsize; - uint16_t e_phnum; - uint16_t e_shentsize; - uint16_t e_shnum; - uint16_t e_shstrndx; -} Elf32_Ehdr; - -typedef struct { - uint32_t sh_name; - uint32_t sh_type; - uint32_t sh_flags; - Elf32_Addr sh_addr; - Elf32_Off sh_offset; - uint32_t sh_size; - uint32_t sh_link; - uint32_t sh_info; - uint32_t sh_addralign; - uint32_t sh_entsize; -} Elf32_Shdr; - -typedef struct { - uint32_t st_name; - Elf32_Addr st_value; - uint32_t st_size; - uint8_t st_info; - uint8_t st_other; - uint16_t st_shndx; -} Elf32_Sym; - -typedef struct { - Elf32_Addr r_offset; - uint32_t r_info; -} Elf32_Rel; - -typedef struct -{ - uint32_t ri_gprmask; /* General registers used. */ - uint32_t ri_cprmask[4]; /* Coprocessor registers used. */ - int32_t ri_gp_value; /* $gp register value. */ -} Elf32_RegInfo; - -typedef struct -{ - int32_t d_tag; /* Dynamic entry type */ - union { - uint32_t d_val; /* Integer value */ - Elf32_Addr d_ptr; /* Address value */ - } d_un; -} Elf32_Dyn; - -#endif diff --git a/tools/ido-static-recomp/header.h b/tools/ido-static-recomp/header.h deleted file mode 100644 index 0a72f1ab..00000000 --- a/tools/ido-static-recomp/header.h +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "libc_impl.h" -#include "helpers.h" - -#define RM_RN 0 -#define RM_RZ 1 -#define RM_RP 2 -#define RM_RM 3 - -#define cvt_w_d(f) \ - ((fcsr & RM_RZ) ? ((isnan(f) || f <= -2147483649.0 || f >= 2147483648.0) ? (fcsr |= 0x40, 2147483647) : (int)f) : (assert(0), 0)) - -#define cvt_w_s(f) cvt_w_d((double)f) - -static union FloatReg f0 = {{0, 0}}, f2 = {{0, 0}}, f4 = {{0, 0}}, f6 = {{0, 0}}, f8 = {{0, 0}}, -f10 = {{0, 0}}, f12 = {{0, 0}}, f14 = {{0, 0}}, f16 = {{0, 0}}, f18 = {{0, 0}}, f20 = {{0, 0}}, -f22 = {{0, 0}}, f24 = {{0, 0}}, f26 = {{0, 0}}, f28 = {{0, 0}}, f30 = {{0, 0}}; -static uint32_t fcsr = 1; diff --git a/tools/ido-static-recomp/helpers.h b/tools/ido-static-recomp/helpers.h deleted file mode 100644 index 9e031e0f..00000000 --- a/tools/ido-static-recomp/helpers.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef HELPERS_H -#define HELPERS_H - -#include - -#define MEM_F64(a) (double_from_memory(mem, a)) -#define MEM_F32(a) (*(float *)(mem + a)) -#define MEM_U32(a) (*(uint32_t *)(mem + a)) -#define MEM_S32(a) (*(int32_t *)(mem + a)) -#define MEM_U16(a) (*(uint16_t *)(mem + ((a) ^ 2))) -#define MEM_S16(a) (*(int16_t *)(mem + ((a) ^ 2))) -#define MEM_U8(a) (*(uint8_t *)(mem + ((a) ^ 3))) -#define MEM_S8(a) (*(int8_t *)(mem + ((a) ^ 3))) - -#endif diff --git a/tools/ido-static-recomp/libc_impl.c b/tools/ido-static-recomp/libc_impl.c deleted file mode 100644 index a6a11b96..00000000 --- a/tools/ido-static-recomp/libc_impl.c +++ /dev/null @@ -1,2971 +0,0 @@ -#define _GNU_SOURCE // for sigset -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __CYGWIN__ -#include -#endif - -#ifdef __APPLE__ -#include -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "libc_impl.h" -#include "helpers.h" -#include "header.h" - -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#define MAX(a, b) ((a) > (b) ? (a) : (b)) - -#define STRING(param) \ - size_t param##_len = wrapper_strlen(mem, param##_addr); \ - char param[param##_len + 1]; \ - for (size_t i = 0; i <= param##_len; i++) { \ - param[i] = MEM_S8(param##_addr + i); \ - } - -#if !defined(IDO53) && !defined(IDO71) && !defined(IDO72) -#define IDO71 -#endif - -#define MEM_REGION_START 0xfb00000 -#define MEM_REGION_SIZE (512 * 1024 * 1024) - -#ifdef IDO53 -// IDO 5.3 -#define IOB_ADDR 0x0fb528e4 -#define ERRNO_ADDR 0x0fb52720 -#define CTYPE_ADDR 0x0fb504f0 -#define LIBC_ADDR 0x0fb50000 -#define LIBC_SIZE 0x3000 -#endif - -#ifdef IDO71 -// IDO 7.1 -#define IOB_ADDR 0x0fb4ee44 -#define ERRNO_ADDR 0x0fb4ec80 -#define CTYPE_ADDR 0x0fb4cba0 -#define LIBC_ADDR 0x0fb4c000 -#define LIBC_SIZE 0x3000 -#endif - -#ifdef IDO72 -// IDO 7.2 -#define IOB_ADDR 0x0fb49454 -#define ERRNO_ADDR 0x0fb49290 -#define CTYPE_ADDR 0x0fb46db0 -#define LIBC_ADDR 0x0fb46000 -#define LIBC_SIZE 0x4000 -#endif - -#define STDIN_ADDR IOB_ADDR -#define STDOUT_ADDR (IOB_ADDR + 0x10) -#define STDERR_ADDR (IOB_ADDR + 0x20) -#define STDIN ((struct FILE_irix*)&MEM_U32(STDIN_ADDR)) -#define STDOUT ((struct FILE_irix*)&MEM_U32(STDOUT_ADDR)) -#define STDERR ((struct FILE_irix*)&MEM_U32(STDERR_ADDR)) - -#define MALLOC_BINS_ADDR custom_libc_data_addr -#define STRTOK_DATA_ADDR (MALLOC_BINS_ADDR + (30 - 3) * 4) -#define INTBUF_ADDR (STRTOK_DATA_ADDR + 4) - -#define SIGNAL_HANDLER_STACK_START LIBC_ADDR - -#define NFILE 100 - -#define IOFBF 0000 /* full buffered */ -#define IOLBF 0100 /* line buffered */ -#define IONBF 0004 /* not buffered */ -#define IOEOF 0020 /* EOF reached on read */ -#define IOERR 0040 /* I/O error from system */ - -#define IOREAD 0001 /* currently reading */ -#define IOWRT 0002 /* currently writing */ -#define IORW 0200 /* opened for reading and writing */ -#define IOMYBUF 0010 /* stdio malloc()'d buffer */ - -#define STDIO_BUFSIZE 16384 - -struct timespec_t_irix { - int tv_sec; - int tv_nsec; -}; - -struct FILE_irix { - int _cnt; - uint32_t _ptr_addr; - uint32_t _base_addr; - uint8_t pad[2]; - uint8_t _file; - uint8_t _flag; -}; - -typedef uint64_t (*fptr_trampoline)(uint8_t* mem, uint32_t sp, uint32_t a0, uint32_t a1, uint32_t a2, uint32_t a3, - uint32_t fp_dest); - -static struct { - struct { - fptr_trampoline trampoline; - uint8_t* mem; - uint32_t fp_dest; - } handlers[65]; - volatile uint32_t recursion_level; -} signal_context; - -static uint32_t cur_sbrk; -static uint32_t bufendtab[NFILE]; // this version contains the size and not the end ptr -static uint32_t custom_libc_data_addr; - -#define _U 01 /* Upper case */ -#define _L 02 /* Lower case */ -#define _N 04 /* Numeral (digit) */ -#define _S 010 /* Spacing character */ -#define _P 020 /* Punctuation */ -#define _C 040 /* Control character */ -#define _B 0100 /* Blank */ -#define _X 0200 /* heXadecimal digit */ - -static char ctype[] = { - 0, - // clang-format off -/* 00 01 02 03 04 05 06 07 */ -/* 0 */ _C, _C, _C, _C, _C, _C, _C, _C, -/* 010 */ _C, _S|_C, _S|_C, _S|_C, _S|_C, _S|_C, _C, _C, -/* 020 */ _C, _C, _C, _C, _C, _C, _C, _C, -/* 030 */ _C, _C, _C, _C, _C, _C, _C, _C, -/* 040 */ _S|_B, _P, _P, _P, _P, _P, _P, _P, -/* 050 */ _P, _P, _P, _P, _P, _P, _P, _P, -/* 060 */ _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, -/* 070 */ _N|_X, _N|_X, _P, _P, _P, _P, _P, _P, -/* 0100 */ _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, -/* 0110 */ _U, _U, _U, _U, _U, _U, _U, _U, -/* 0120 */ _U, _U, _U, _U, _U, _U, _U, _U, -/* 0130 */ _U, _U, _U, _P, _P, _P, _P, _P, -/* 0140 */ _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, -/* 0150 */ _L, _L, _L, _L, _L, _L, _L, _L, -/* 0160 */ _L, _L, _L, _L, _L, _L, _L, _L, -/* 0170 */ _L, _L, _L, _P, _P, _P, _P, _C, -/* 0200 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0210 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0220 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0230 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0240 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0250 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0260 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0270 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0300 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0310 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0320 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0330 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0340 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0350 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0360 */ 0, 0, 0, 0, 0, 0, 0, 0, -/* 0370 */ 0, 0, 0, 0, 0, 0, 0, 0, - // clang-format on -}; - - -static char usr_lib_redirect[PATH_MAX + 1]; -static char usr_include_redirect[PATH_MAX + 1]; - -static int g_file_max = 3; - - -/* Compilation Target/Emulation Host Page Size Determination */ -#if defined(__CYGWIN__) || (defined(__linux__) && defined(__aarch64__)) -#define RUNTIME_PAGESIZE -/* ARM64 linux can have page sizes of 4kb, 16kb, or 64kb */ -/* Set in main before running the translated code */ -static size_t g_Pagesize; - -#define TRUNC_PAGE(x) ((x) & ~(g_Pagesize - 1)) -#define ROUND_PAGE(x) (TRUNC_PAGE((x) + (g_Pagesize - 1))) - -#elif defined(__APPLE__) -/* https://developer.apple.com/documentation/apple-silicon/addressing-architectural-differences-in-your-macos-code */ -#define TRUNC_PAGE(x) (trunc_page((x))) -#define ROUND_PAGE(x) (round_page((x))) - -#else -/* A fixed 4KB page size for x64 linux (is there anything else?) */ -#define TRUNC_PAGE(x) ((x) & ~(0x1000 - 1)) -#define ROUND_PAGE(x) (TRUNC_PAGE((x) + (0x1000 - 1))) -#endif /* PageSize Macros */ - -static uint8_t* memory_map(size_t length) { -#ifdef __CYGWIN__ - uint8_t* mem = mmap(0, length, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); -#else - uint8_t* mem = mmap(0, length, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); -#endif - - assert(TRUNC_PAGE((uintptr_t)mem) == (uintptr_t)mem && - "Page size too small, try increasing `page_size` in recomp.cpp"); - if (mem == MAP_FAILED) { - perror("mmap (memory_map)"); - exit(1); - } - return mem; -} - -static void memory_allocate(uint8_t* mem, uint32_t start, uint32_t end) { - assert(start >= MEM_REGION_START); - assert(end <= MEM_REGION_START + MEM_REGION_SIZE); - // `start` will be passed to mmap, - // so it has to be host aligned in order to keep the guest's pages valid - assert(start == TRUNC_PAGE(start) && "Page size too small, try increasing `page_size` in recomp.cpp"); -#ifdef __CYGWIN__ - uintptr_t _start = TRUNC_PAGE((uintptr_t)mem + start); - uintptr_t _end = ROUND_PAGE((uintptr_t)mem + end); - - if (mprotect((void*)_start, _end - _start, PROT_READ | PROT_WRITE) < 0) { - perror("mprotect (memory_allocate)"); - exit(1); - } -#else - void* addr = (void*)TRUNC_PAGE((uintptr_t)mem + start); - size_t len = end - start; - - if (mmap(addr, len, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0) == MAP_FAILED) { - perror("mmap (memory_allocate)"); - exit(1); - } -#endif /* __CYGWIN__ */ -} - -static void memory_unmap(uint8_t* mem, size_t length) { - if (munmap(mem, length)) { - perror("munmap"); - exit(1); - } -} - -static void free_all_file_bufs(uint8_t* mem) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(IOB_ADDR); - for (int i = 0; i < g_file_max; i++) { - if (f[i]._flag & IOMYBUF) { - wrapper_free(mem, f[i]._base_addr); - } - } -} - -void get_env_var(char* out, char* name) { - char* env = getenv(name); - - if (env == NULL) { // No environment variable found, so just return empty string - out[0] = '\0'; - return; - } - - if (snprintf(out, PATH_MAX, "%s", env) >= PATH_MAX) { - fprintf(stderr, "Error: Environment variable %s is too large\n", name); - exit(1); - } - -} - -static void init_usr_lib_redirect(void) { - char path[PATH_MAX + 1] = { 0 }; - - get_env_var(path, "USR_LIB"); - - if (path[0] != '\0') { - strcpy(usr_lib_redirect, path); - return; - } - - // gets the current executable's path -#ifdef __CYGWIN__ - uint32_t size = GetModuleFileName(NULL, path, PATH_MAX); - if (size == 0 || size == PATH_MAX) { - return; - } -#elif defined __APPLE__ - uint32_t size = PATH_MAX; - if (_NSGetExecutablePath(path, &size) < 0) { - return; - } -#else - ssize_t size = readlink("/proc/self/exe", path, PATH_MAX); - if (size < 0 || size == PATH_MAX) { - return; - } -#endif - - strcpy(usr_lib_redirect, dirname(path)); -} - -static void init_usr_include_redirect(void) { - char path[PATH_MAX + 1] = {0}; - - get_env_var(path, "USR_INCLUDE"); - - strcpy(usr_include_redirect, path); -} - -static void init_redirect_paths(void) { - init_usr_lib_redirect(); - init_usr_include_redirect(); -} - -/** - * Redirects `path` by replacing the initial segment `from` by `to`. The result is placed in `out`. - * If `path` does not have `from` as its initial segment, or there is no `to`, the original path is used. - * If an error occurs, an error message will be printed, and the program exited. -*/ -void redirect_path(char* out, const char* path, const char* from, const char* to) { - int from_len = strlen(from); - - if(!strncmp(path, from, from_len) && (to[0] != '\0')) { - char redirected_path[PATH_MAX + 1] = {0}; - int n; - - n = snprintf(redirected_path, sizeof(redirected_path), "%s%s", to, path + from_len); - - if (n >= 0 && n < sizeof(redirected_path)) { - strcpy(out, redirected_path); - } else { - fprintf(stderr, "Error: Unable to redirect %s->%s for %s\n", from, to, path); - exit(1); - } - } else { - strcpy(out, path); - } -} - -void final_cleanup(uint8_t* mem) { - wrapper_fflush(mem, 0); - free_all_file_bufs(mem); - mem += MEM_REGION_START; - memory_unmap(mem, MEM_REGION_SIZE); -} - -int main(int argc, char* argv[]) { - int ret; - - init_redirect_paths(); -#ifdef RUNTIME_PAGESIZE - g_Pagesize = sysconf(_SC_PAGESIZE); -#endif /* RUNTIME_PAGESIZE */ - - uint8_t* mem = memory_map(MEM_REGION_SIZE); - mem -= MEM_REGION_START; - int run(uint8_t * mem, int argc, char* argv[]); - ret = run(mem, argc, argv); - final_cleanup(mem); - return ret; -} - -void mmap_initial_data_range(uint8_t* mem, uint32_t start, uint32_t end) { - custom_libc_data_addr = end; -#ifdef __APPLE__ - end += vm_page_size; -#else - end += 4096; -#endif /* __APPLE__ */ - memory_allocate(mem, start, end); - cur_sbrk = end; -} - -void setup_libc_data(uint8_t* mem) { - memory_allocate(mem, LIBC_ADDR, (LIBC_ADDR + LIBC_SIZE)); - for (size_t i = 0; i < sizeof(ctype); i++) { - MEM_S8(CTYPE_ADDR + i) = ctype[i]; - } - STDIN->_flag = IOREAD; - STDIN->_file = 0; - STDOUT->_flag = IOWRT; - STDOUT->_file = 1; - STDERR->_flag = IOWRT | IONBF; - STDERR->_file = 2; -} - -static uint32_t strcpy1(uint8_t* mem, uint32_t dest_addr, const char* str) { - for (;;) { - char c = *str; - ++str; - MEM_S8(dest_addr) = c; - ++dest_addr; - if (c == '\0') { - return dest_addr - 1; - } - } -} - -static uint32_t strcpy2(uint8_t* mem, uint32_t dest_addr, uint32_t src_addr) { - for (;;) { - char c = MEM_S8(src_addr); - ++src_addr; - MEM_S8(dest_addr) = c; - ++dest_addr; - if (c == '\0') { - return dest_addr - 1; - } - } -} - -uint32_t wrapper_sbrk(uint8_t* mem, int increment) { - uint32_t old = cur_sbrk; - size_t alignedInc = ROUND_PAGE(old + increment) - old; - memory_allocate(mem, old, old + alignedInc); - cur_sbrk += alignedInc; - return old; -} - -/* -Simple bin-based malloc algorithm - -The memory is divided into bins of item sizes 8, 16, 32, 64, 128, ..., 2^30. -Size requests are divided into these bin sizes and each bin is handled -completely separate from other bins. - -For each bin there is a linked list of free'd items. -Linked list node: -struct FreeListNode { - struct Node *next; - size_t free_space_after; - uint8_t data[bin_item_size]; -}; -At most one value of next and space_after is non-zero. -If a node exists in the linked list, it is the memory node to return. -struct AllocatedNode { - int bin; - uint32_t current_size; - uint8_t data[bin_item_size]; -}; -The returned address is the data element. -When the last list node is returned, and free_space_after is big enough -for a new node, a new node is created having free_space_after set to -(free_space_after - (8 + bin_item_size)), and is appended to the list. - -If the list was empty, a new memory chunk is requested from the system -of 65536 bytes, or at least (8 + bin_item_size), rounded up to nearest -page size boundary. It can also be smaller if it leaves holes bigger than -4096 bytes that can never be used. This chunk is then inserted to the list, -and the algorithm restarts. - -This algorithm, for each bin, never uses more than twice as much as is -maximally in use (plus 65536 bytes). -The malloc/free calls run in O(1) and calloc/realloc calls run in O(size). -*/ - -size_t mem_used; -size_t mem_allocated; -size_t max_mem_used; -size_t num_sbrks; -size_t num_allocs; -uint32_t wrapper_malloc(uint8_t* mem, uint32_t size) { - int bin = -1; - for (int i = 3; i < 30; i++) { - if (size <= (1 << i)) { - bin = i; - break; - } - } - if (bin == -1) { - return 0; - } - ++num_allocs; - mem_used += size; - max_mem_used = MAX(mem_used, max_mem_used); - uint32_t item_size = 1 << bin; - uint32_t list_ptr = MALLOC_BINS_ADDR + (bin - 3) * 4; - uint32_t node_ptr = MEM_U32(list_ptr); - if (node_ptr == 0) { - uint32_t sbrk_request = 0x10000; - if (8 + item_size > sbrk_request) { - sbrk_request = 8 + item_size; - sbrk_request = ROUND_PAGE(sbrk_request); - } - uint32_t left_over = sbrk_request % (8 + item_size); - sbrk_request -= left_over & ~(4096 - 1); - mem_allocated += sbrk_request; - ++num_sbrks; - node_ptr = wrapper_sbrk(mem, sbrk_request); - MEM_U32(node_ptr + 4) = sbrk_request - (8 + item_size); - } - uint32_t next = MEM_U32(node_ptr); - if (next == 0) { - uint32_t free_space_after = MEM_U32(node_ptr + 4); - if (free_space_after >= 8 + item_size) { - next = node_ptr + 8 + item_size; - MEM_U32(next + 4) = free_space_after - (8 + item_size); - } - } else { - assert(MEM_U32(node_ptr + 4) == 0); - } - MEM_U32(list_ptr) = next; - MEM_U32(node_ptr) = bin; - MEM_U32(node_ptr + 4) = size; - return node_ptr + 8; -} - -uint32_t wrapper_calloc(uint8_t* mem, uint32_t num, uint32_t size) { - uint64_t new_size = (uint64_t)num * size; - assert(new_size == (uint32_t)new_size); - uint32_t ret = wrapper_malloc(mem, new_size); - return wrapper_memset(mem, ret, 0, new_size); -} - -uint32_t wrapper_realloc(uint8_t* mem, uint32_t data_addr, uint32_t size) { - if (data_addr == 0) { - return wrapper_malloc(mem, size); - } else { - uint32_t node_ptr = data_addr - 8; - int bin = MEM_U32(node_ptr); - uint32_t old_size = MEM_U32(node_ptr + 4); - uint32_t max_size = 1 << bin; - assert(bin >= 3 && bin < 30); - assert(old_size <= max_size); - if (size <= max_size) { - mem_used = mem_used - old_size + size; - MEM_U32(node_ptr + 4) = size; - return data_addr; - } else { - uint32_t new_addr = wrapper_malloc(mem, size); - wrapper_memcpy(mem, new_addr, data_addr, old_size); - wrapper_free(mem, data_addr); - return new_addr; - } - } -} - -void wrapper_free(uint8_t* mem, uint32_t data_addr) { - if (data_addr == 0) { - return; - } - uint32_t node_ptr = data_addr - 8; - int bin = MEM_U32(node_ptr); - uint32_t size = MEM_U32(node_ptr + 4); - if (size == 0) { - // Double free. IDO 5.3 strip relies on this. - fprintf(stderr, "warning: double free: 0x%x\n", data_addr); - return; - } - uint32_t list_ptr = MALLOC_BINS_ADDR + (bin - 3) * 4; - assert(bin >= 3 && bin < 30); - assert(size <= (1 << bin)); - MEM_U32(node_ptr) = MEM_U32(list_ptr); - MEM_U32(node_ptr + 4) = 0; - MEM_U32(list_ptr) = node_ptr; - mem_used -= size; -} - -int wrapper_fscanf(uint8_t* mem, uint32_t fp_addr, uint32_t format_addr, uint32_t sp) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - STRING(format) // for debug - - int ret = 0; - char c; - int ch; - sp += 2 * 4; - for (;;) { - c = MEM_S8(format_addr); - ++format_addr; - if (c == '%') { - c = MEM_S8(format_addr); - ++format_addr; - if (c == '%') { - goto percent; - } - for (;;) { - ch = wrapper_fgetc(mem, fp_addr); - if (ch == -1) { - return ret; - } - if (!isspace(ch)) { - break; - } - } - bool l = false; - continue_format: - switch (c) { - case 'l': - assert(!l && "ll not implemented in fscanf"); - l = true; - c = MEM_S8(format_addr); - ++format_addr; - goto continue_format; - case 'd': { - int64_t num = 0; - int sign = 1; - bool found_first = false; - if (ch == '-') { - sign = -1; - ch = wrapper_fgetc(mem, fp_addr); - if (ch == -1) { - return ret; - } - } - for (;;) { - if (isdigit(ch)) { - num *= 10; - num += ch - '0'; - found_first = true; - ch = wrapper_fgetc(mem, fp_addr); - if (ch == -1) { - break; - } - } else { - wrapper_ungetc(mem, ch, fp_addr); - break; - } - } - if (found_first) { - uint32_t int_addr = MEM_U32(sp); - sp += 4; - MEM_S32(int_addr) = (int)(num * sign); - ++ret; - } else { - return ret; - } - break; - } - default: - assert(0 && "fscanf format not implemented"); - } - } else if (c == '\0') { - break; - } else { - percent: - ch = wrapper_fgetc(mem, fp_addr); - if (ch == -1) { - break; - } - if ((char)ch != c) { - break; - } - } - } - - return ret; -} - -int wrapper_printf(uint8_t* mem, uint32_t format_addr, uint32_t sp) { - STRING(format) - if (!strcmp(format, " child died due to signal %d.\n")) { - printf(format, MEM_U32(sp + 4)); - return 1; - } - assert(0 && "printf not implemented"); - return 0; -} - -int wrapper_sprintf(uint8_t* mem, uint32_t str_addr, uint32_t format_addr, uint32_t sp) { - STRING(format) // for debug - char temp[32]; - - if (!strcmp(format, "%.16e")) { - union { - uint32_t w[2]; - double d; - } d; - d.w[1] = MEM_U32(sp + 2 * 4); - d.w[0] = MEM_U32(sp + 3 * 4); - sprintf(temp, "%.16e", d.d); - strcpy1(mem, str_addr, temp); - return 1; - } - if (!strcmp(format, "\\%03o")) { - sprintf(temp, "\\%03o", MEM_U32(sp + 2 * 4)); - strcpy1(mem, str_addr, temp); - return 1; - } - if (!strcmp(format, "%*ld=")) { - sprintf(temp, "%*d=", MEM_U32(sp + 2 * 4), MEM_U32(sp + 3 * 4)); - strcpy1(mem, str_addr, temp); - return 1; - } - - uint32_t orig_str_addr = str_addr; - uint32_t pos = 0; - int ret = 0; - char c; - sp += 2 * 4; - for (;;) { - c = MEM_S8(format_addr + pos); - ++pos; - if (c == '%') { - bool l = false; - c = MEM_S8(format_addr + pos); - ++pos; - uint32_t zeros = 0; - bool zero_prefix = false; - continue_format: - switch (c) { - case '\0': - goto finish_str; - - case '0': - do { - c = MEM_S8(format_addr + pos); - ++pos; - if (c >= '0' && c <= '9') { - zeros *= 10; - zeros += c - '0'; - } - } while (c >= '0' && c <= '9'); - goto continue_format; - case '#': - c = MEM_S8(format_addr + pos); - ++pos; - zero_prefix = true; - goto continue_format; - break; - case 'l': - assert(!l && "ll not implemented in fscanf"); - c = MEM_S8(format_addr + pos); - ++pos; - l = true; - goto continue_format; - break; - case 'd': - if (zeros != 0) { - char temp1[32]; - sprintf(temp1, "%%0%dd", zeros); - sprintf(temp, temp1, MEM_S32(sp)); - } else { - sprintf(temp, "%d", MEM_S32(sp)); - } - sp += 4; - str_addr = strcpy1(mem, str_addr, temp); - ++ret; - break; - case 'o': - if (zero_prefix) { - sprintf(temp, "%#o", MEM_S32(sp)); - } else { - sprintf(temp, "%o", MEM_S32(sp)); - } - sp += 4; - str_addr = strcpy1(mem, str_addr, temp); - ++ret; - break; - case 'x': - if (zero_prefix) { - sprintf(temp, "%#x", MEM_S32(sp)); - } else { - sprintf(temp, "%x", MEM_S32(sp)); - } - sp += 4; - str_addr = strcpy1(mem, str_addr, temp); - ++ret; - break; - case 'u': - sprintf(temp, "%u", MEM_S32(sp)); - sp += 4; - str_addr = strcpy1(mem, str_addr, temp); - ++ret; - break; - case 's': - str_addr = strcpy2(mem, str_addr, MEM_U32(sp)); - sp += 4; - ++ret; - break; - case 'c': - MEM_S8(str_addr) = (char)MEM_U32(sp); - ++str_addr; - sp += 4; - ++ret; - break; - case '%': - MEM_S8(str_addr) = '%'; - ++str_addr; - break; - default: - fprintf(stderr, "%s\n", format); - assert(0 && "non-implemented sprintf format"); - } - } else if (c == '\0') { - break; - } else { - MEM_S8(str_addr) = c; - ++str_addr; - } - } - -finish_str: - MEM_S8(str_addr) = '\0'; - return ret; -} - -int wrapper_fprintf(uint8_t* mem, uint32_t fp_addr, uint32_t format_addr, uint32_t sp) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - STRING(format) - sp += 8; - - // Special-case this one format string. This seems to be the only one that uses `%f` or width specifiers. - if (!strcmp(format, "%.2fu %.2fs %u:%04.1f %.0f%%\n") && fp_addr == STDERR_ADDR) { - double arg0 = MEM_F64(sp + 0); - double arg1 = MEM_F64(sp + 8); - uint32_t arg2 = MEM_U32(sp + 16); - double arg3 = MEM_F64(sp + 24); - double arg4 = MEM_F64(sp + 32); - fprintf(stderr, format, arg0, arg1, arg2, arg3, arg4); - fflush(stderr); - return 1; - } - if (strcmp(format, "%s phase time: %.2fu %.2fs %u:%04.1f %.0f%%\n") == 0 && fp_addr == STDERR_ADDR) { - if (wrapper_fputs(mem, MEM_U32(sp), fp_addr) == -1) { - return 0; - } - sp += 4; - // align - sp += 4; - - double arg0 = MEM_F64(sp + 0); - double arg1 = MEM_F64(sp + 8); - uint32_t arg2 = MEM_U32(sp + 16); - double arg3 = MEM_F64(sp + 24); - double arg4 = MEM_F64(sp + 32); - fprintf(stderr, " phase time: %.2fu %.2fs %u:%04.1f %.0f%%\n", arg0, arg1, arg2, arg3, arg4); - fflush(stderr); - return 1; - } - int ret = 0; - for (;;) { - int width = 1; - uint32_t pos = format_addr; - char ch = MEM_S8(pos); - - while (ch != '%' && ch != '\0') { - ++pos; - ch = MEM_S8(pos); - } - if (format_addr != pos) { - if (wrapper_fwrite(mem, format_addr, 1, pos - format_addr, fp_addr) != pos - format_addr) { - break; - } - } - if (ch == '\0') { - break; - } - ++pos; - ch = MEM_S8(pos); - if (ch >= '1' && ch <= '9') { - ++pos; - width = ch - '0'; - ch = MEM_S8(pos); - } - - switch (ch) { - case 'd': - case 'x': - case 'X': - case 'c': - case 'u': { - char buf[32]; - - char formatSpecifier[0x100] = { 0 }; - - formatSpecifier[0] = '%'; - formatSpecifier[1] = width + '0'; - formatSpecifier[2] = ch; - - sprintf(buf, formatSpecifier, MEM_U32(sp)); - - strcpy1(mem, INTBUF_ADDR, buf); - if (wrapper_fputs(mem, INTBUF_ADDR, fp_addr) == -1) { - return ret; - } - sp += 4; - ++ret; - break; - } - case 's': { - if (wrapper_fputs(mem, MEM_U32(sp), fp_addr) == -1) { - return ret; - } - sp += 4; - ++ret; - break; - } - default: - fprintf(stderr, "missing format: '%s'\n", format); - assert(0 && "non-implemented fprintf format"); - } - format_addr = ++pos; - } - return ret; -} - -int wrapper__doprnt(uint8_t* mem, uint32_t format_addr, uint32_t params_addr, uint32_t fp_addr) { - assert(0 && "_doprnt not implemented"); - return 0; -} - -uint32_t wrapper_strlen(uint8_t* mem, uint32_t str_addr) { - uint32_t len = 0; - while (MEM_S8(str_addr) != '\0') { - ++str_addr; - ++len; - } - return len; -} - -int wrapper_open(uint8_t* mem, uint32_t pathname_addr, int flags, int mode) { - STRING(pathname) - - char rpathname[PATH_MAX + 1]; - redirect_path(rpathname, pathname, "/usr/include", usr_include_redirect); - - int f = flags & O_ACCMODE; - if (flags & 0x100) { - f |= O_CREAT; - } - if (flags & 0x200) { - f |= O_TRUNC; - } - if (flags & 0x400) { - f |= O_EXCL; - } - if (flags & 0x800) { - f |= O_NOCTTY; - } - if (flags & 0x08) { - f |= O_APPEND; - } - - int fd = open(rpathname, f, mode); - MEM_U32(ERRNO_ADDR) = errno; - return fd; -} - -int wrapper_creat(uint8_t* mem, uint32_t pathname_addr, int mode) { - STRING(pathname) - int ret = creat(pathname, mode); - if (ret < 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_access(uint8_t* mem, uint32_t pathname_addr, int mode) { - STRING(pathname) - int ret = access(pathname, mode); - if (ret != 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_rename(uint8_t* mem, uint32_t oldpath_addr, uint32_t newpath_addr) { - STRING(oldpath) - STRING(newpath) - int ret = rename(oldpath, newpath); - if (ret != 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_utime(uint8_t* mem, uint32_t filename_addr, uint32_t times_addr) { - STRING(filename) - struct utimbuf buf = { 0, 0 }; - int ret = utime(filename, times_addr == 0 ? NULL : &buf); - if (ret == 0) { - if (times_addr != 0) { - MEM_U32(times_addr + 0) = buf.actime; - MEM_U32(times_addr + 4) = buf.modtime; - } - } else { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_flock(uint8_t* mem, int fd, int operation) { - int ret = flock(fd, operation); - if (ret != 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_chmod(uint8_t* mem, uint32_t path_addr, uint32_t mode) { - STRING(path) - int ret = chmod(path, mode); - if (ret < 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_umask(int mode) { - return umask(mode); -} - -uint32_t wrapper_ecvt(uint8_t* mem, double number, int ndigits, uint32_t decpt_addr, uint32_t sign_addr) { - assert(0); -} - -uint32_t wrapper_fcvt(uint8_t* mem, double number, int ndigits, uint32_t decpt_addr, uint32_t sign_addr) { - assert(0); -} - -double wrapper_sqrt(double v) { - return sqrt(v); -} - -float wrapper_sqrtf(float v) { - return sqrtf(v); -} - -int wrapper_atoi(uint8_t* mem, uint32_t nptr_addr) { - STRING(nptr) - return atoi(nptr); -} - -int wrapper_atol(uint8_t* mem, uint32_t nptr_addr) { - return wrapper_atoi(mem, nptr_addr); -} - -double wrapper_atof(uint8_t* mem, uint32_t nptr_addr) { - STRING(nptr); - return atof(nptr); -} - -int wrapper_strtol(uint8_t* mem, uint32_t nptr_addr, uint32_t endptr_addr, int base) { - STRING(nptr) - char* endptr = NULL; - int64_t res = strtoll(nptr, endptr_addr != 0 ? &endptr : NULL, base); - if (res > INT_MAX) { - MEM_U32(ERRNO_ADDR) = ERANGE; - res = INT_MAX; - } - if (res < INT_MIN) { - MEM_U32(ERRNO_ADDR) = ERANGE; - res = INT_MIN; - } - if (endptr != NULL) { - MEM_U32(endptr_addr) = nptr_addr + (uint32_t)(endptr - nptr); - } - return res; -} - -uint32_t wrapper_strtoul(uint8_t* mem, uint32_t nptr_addr, uint32_t endptr_addr, int base) { - STRING(nptr) - char* endptr = NULL; - uint64_t res = strtoull(nptr, endptr_addr != 0 ? &endptr : NULL, base); - if (res > INT_MAX) { - MEM_U32(ERRNO_ADDR) = ERANGE; - res = INT_MAX; - } - if (endptr != NULL) { - MEM_U32(endptr_addr) = nptr_addr + (uint32_t)(endptr - nptr); - } - return res; -} - -int64_t wrapper_strtoll(uint8_t* mem, uint32_t nptr_addr, uint32_t endptr_addr, int base) { - STRING(nptr) - char* endptr = NULL; - errno = 0; - int64_t res = strtoll(nptr, endptr_addr != 0 ? &endptr : NULL, base); - if (errno != 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - if (endptr != NULL) { - MEM_U32(endptr_addr) = nptr_addr + (uint32_t)(endptr - nptr); - } - return res; -} - -uint64_t wrapper_strtoull(uint8_t* mem, uint32_t nptr_addr, uint32_t endptr_addr, int base) { - STRING(nptr) - char* endptr = NULL; - errno = 0; - uint64_t res = strtoull(nptr, endptr_addr != 0 ? &endptr : NULL, base); - if (errno != 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - if (endptr != NULL) { - MEM_U32(endptr_addr) = nptr_addr + (uint32_t)(endptr - nptr); - } - return res; -} - -double wrapper_strtod(uint8_t* mem, uint32_t nptr_addr, uint32_t endptr_addr) { - STRING(nptr) - char* endptr = NULL; - errno = 0; - double res = strtod(nptr, endptr_addr != 0 ? &endptr : NULL); - if (errno != 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - if (endptr != NULL) { - MEM_U32(endptr_addr) = nptr_addr + (uint32_t)(endptr - nptr); - } - return res; -} - -uint32_t wrapper_strchr(uint8_t* mem, uint32_t str_addr, int c) { - c = c & 0xff; - for (;;) { - unsigned char ch = MEM_U8(str_addr); - if (ch == c) { - return str_addr; - } - if (ch == '\0') { - return 0; - } - ++str_addr; - } -} - -uint32_t wrapper_strrchr(uint8_t* mem, uint32_t str_addr, int c) { - c = c & 0xff; - uint32_t ret = 0; - for (;;) { - unsigned char ch = MEM_U8(str_addr); - if (ch == c) { - ret = str_addr; - } - if (ch == '\0') { - return ret; - } - ++str_addr; - } -} - -uint32_t wrapper_strcspn(uint8_t* mem, uint32_t str_addr, uint32_t invalid_addr) { - STRING(invalid) - uint32_t n = strlen(invalid); - uint32_t pos = 0; - char c; - while ((c = MEM_S8(str_addr)) != 0) { - for (int i = 0; i < n; i++) { - if (c == invalid[i]) { - return pos; - } - } - ++pos; - ++str_addr; - } - return pos; -} - -uint32_t wrapper_strpbrk(uint8_t* mem, uint32_t str_addr, uint32_t accept_addr) { - STRING(accept) - uint32_t n = strlen(accept); - char c; - while ((c = MEM_S8(str_addr)) != 0) { - for (int i = 0; i < n; i++) { - if (c == accept[i]) { - return str_addr; - } - } - ++str_addr; - } - return 0; -} - -static void stat_common(uint8_t* mem, uint32_t buf_addr, struct stat* statbuf) { - struct irix_stat { - int st_dev; - int pad1[3]; - int st_ino; - int st_mode; - int st_nlink; - int st_uid; - int st_gid; - int st_rdev; - int pad2[2]; - int st_size; - int pad3; - struct timespec_t_irix st_atim; - struct timespec_t_irix st_mtim; - struct timespec_t_irix st_ctim; - int st_blksize; - int st_blocks; - } s; - s.st_dev = statbuf->st_dev; - s.st_ino = statbuf->st_ino; - s.st_mode = statbuf->st_mode; - s.st_nlink = statbuf->st_nlink; - s.st_uid = statbuf->st_uid; - s.st_gid = statbuf->st_gid; - s.st_rdev = statbuf->st_rdev; - s.st_size = statbuf->st_size; -#ifdef __APPLE__ - s.st_atim.tv_sec = statbuf->st_atimespec.tv_sec; - s.st_atim.tv_nsec = statbuf->st_atimespec.tv_nsec; - s.st_mtim.tv_sec = statbuf->st_mtimespec.tv_sec; - s.st_mtim.tv_nsec = statbuf->st_mtimespec.tv_nsec; - s.st_ctim.tv_sec = statbuf->st_ctimespec.tv_sec; - s.st_ctim.tv_nsec = statbuf->st_ctimespec.tv_nsec; -#else - s.st_atim.tv_sec = statbuf->st_atim.tv_sec; - s.st_atim.tv_nsec = statbuf->st_atim.tv_nsec; - s.st_mtim.tv_sec = statbuf->st_mtim.tv_sec; - s.st_mtim.tv_nsec = statbuf->st_mtim.tv_nsec; - s.st_ctim.tv_sec = statbuf->st_ctim.tv_sec; - s.st_ctim.tv_nsec = statbuf->st_ctim.tv_nsec; -#endif - memcpy(&MEM_U32(buf_addr), &s, sizeof(s)); -} - -int wrapper_fstat(uint8_t* mem, int fildes, uint32_t buf_addr) { - struct stat statbuf; - if (fstat(fildes, &statbuf) < 0) { - MEM_U32(ERRNO_ADDR) = errno; - return -1; - } else { - stat_common(mem, buf_addr, &statbuf); - return 0; - } -} - -int wrapper_stat(uint8_t* mem, uint32_t pathname_addr, uint32_t buf_addr) { - STRING(pathname) - struct stat statbuf; - if (stat(pathname, &statbuf) < 0) { - MEM_U32(ERRNO_ADDR) = errno; - return -1; - } else { - stat_common(mem, buf_addr, &statbuf); - return 0; - } -} - -int wrapper_ftruncate(uint8_t* mem, int fd, int length) { - int ret = ftruncate(fd, length); - if (ret != 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_truncate(uint8_t* mem, uint32_t pathname_addr, int length) { - STRING(pathname) - int ret = truncate(pathname, length); - if (ret != 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -void wrapper_bcopy(uint8_t* mem, uint32_t src_addr, uint32_t dst_addr, uint32_t len) { - if (dst_addr % 4 == 0 && src_addr % 4 == 0 && len % 4 == 0) { - // Use memmove to copy regions that are 4-byte aligned. - // This prevents the byte-swapped mem from causing issues when copying normally. - // Memmove handles overlapping copies correctly, so overlap does not need to be checked. - memmove(&MEM_U32(dst_addr), &MEM_U32(src_addr), len); - } else if (dst_addr > src_addr) { - // Perform a reverse byte-swapped copy when the destination is ahead of the source. - // This prevents overwriting the source contents before they're read. - dst_addr += len - 1; - src_addr += len - 1; - while (len--) { - MEM_U8(dst_addr) = MEM_U8(src_addr); - --dst_addr; - --src_addr; - } - } else { - // Otherwise, perform a normal byte-swapped copy. - while (len--) { - MEM_U8(dst_addr) = MEM_U8(src_addr); - ++dst_addr; - ++src_addr; - } - } -} - -/** - * IRIX's memcpy seems to allow overlapping destination and source pointers, while the C standard dictates - * both pointer should not overlap, (UB otherwise). - * Because of this, we only use host bcopy since it can handle overlapping regions - */ -uint32_t wrapper_memcpy(uint8_t* mem, uint32_t dst_addr, uint32_t src_addr, uint32_t len) { - wrapper_bcopy(mem, src_addr, dst_addr, len); - return dst_addr; -} - -uint32_t wrapper_memccpy(uint8_t* mem, uint32_t dst_addr, uint32_t src_addr, int c, uint32_t len) { - while (len--) { - uint8_t ch = MEM_U8(src_addr); - MEM_U8(dst_addr) = ch; - ++dst_addr; - ++src_addr; - if (ch == c) { - return dst_addr; - } - } - return 0; -} - -int wrapper_read(uint8_t* mem, int fd, uint32_t buf_addr, uint32_t nbytes) { - uint8_t* buf = (uint8_t*)malloc(nbytes); - ssize_t ret = read(fd, buf, nbytes); - if (ret < 0) { - MEM_U32(ERRNO_ADDR) = errno; - } else { - for (ssize_t i = 0; i < ret; i++) { - MEM_U8(buf_addr + i) = buf[i]; - } - } - free(buf); - return (int)ret; -} - -int wrapper_write(uint8_t* mem, int fd, uint32_t buf_addr, uint32_t nbytes) { - uint8_t* buf = (uint8_t*)malloc(nbytes); - for (size_t i = 0; i < nbytes; i++) { - buf[i] = MEM_U8(buf_addr + i); - } - ssize_t ret = write(fd, buf, nbytes); - if (ret < 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - free(buf); - return (int)ret; -} - -static uint32_t init_file(uint8_t* mem, int fd, int i, const char* path, const char* mode) { - int flags = O_RDONLY; - if (strcmp(mode, "r") == 0 || strcmp(mode, "rb") == 0) { - flags = O_RDONLY; - } else if (strcmp(mode, "w") == 0 || strcmp(mode, "wb") == 0) { - flags = O_WRONLY | O_CREAT | O_TRUNC; - } else if (strcmp(mode, "a") == 0 || strcmp(mode, "ab") == 0) { - flags = O_WRONLY | O_CREAT | O_APPEND; - } else if (strcmp(mode, "r+") == 0 || strcmp(mode, "r+b") == 0) { - flags = O_RDWR; - } else if (strcmp(mode, "w+") == 0 || strcmp(mode, "w+b") == 0) { - flags = O_RDWR | O_CREAT | O_TRUNC; - } else if (strcmp(mode, "a+") == 0 || strcmp(mode, "a+b") == 0) { - flags = O_RDWR | O_CREAT | O_APPEND; - } - if (fd == -1) { - char rpathname[PATH_MAX + 1]; - redirect_path(rpathname, path, "/usr/lib", usr_lib_redirect); - - fd = open(rpathname, flags, 0666); - - if (fd < 0) { - MEM_U32(ERRNO_ADDR) = errno; - return 0; - } - } - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(IOB_ADDR); - uint32_t ret = 0; - if (i == -1) { - for (i = 3; i < NFILE; i++) { - if (f[i]._flag == 0) { - break; - } - } - } - assert(i < NFILE); - g_file_max = i + 1; - ret = IOB_ADDR + i * sizeof(struct FILE_irix); - f[i]._cnt = 0; - f[i]._ptr_addr = 0; - f[i]._base_addr = 0; - f[i]._file = fd; - f[i]._flag = (flags & O_ACCMODE) == O_RDONLY ? IOREAD : 0; - f[i]._flag |= (flags & O_ACCMODE) == O_WRONLY ? IOWRT : 0; - f[i]._flag |= (flags & O_ACCMODE) == O_RDWR ? IORW : 0; - bufendtab[i] = 0; - return ret; -} - -uint32_t wrapper_fopen(uint8_t* mem, uint32_t path_addr, uint32_t mode_addr) { - assert(path_addr != 0); - assert(mode_addr != 0); - - STRING(path) - STRING(mode) - return init_file(mem, -1, -1, path, mode); -} - -uint32_t wrapper_freopen(uint8_t* mem, uint32_t path_addr, uint32_t mode_addr, uint32_t fp_addr) { - STRING(path) - STRING(mode) - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - wrapper_fclose(mem, fp_addr); - return init_file(mem, -1, f - (struct FILE_irix*)&MEM_U32(IOB_ADDR), path, mode); -} - -int wrapper_fclose(uint8_t* mem, uint32_t fp_addr) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - wrapper_fflush(mem, fp_addr); - if (f->_flag & IOMYBUF) { - wrapper_free(mem, f->_base_addr); - } - f->_flag = 0; - close(f->_file); - return 0; -} - -static int flush_all(uint8_t* mem) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(IOB_ADDR); - int ret = 0; - for (int i = 0; i < g_file_max; i++) { - if (f[i]._flag & IOWRT) { - ret |= wrapper_fflush(mem, IOB_ADDR + i * sizeof(struct FILE_irix)); - } - } - return ret; -} - -int wrapper_fflush(uint8_t* mem, uint32_t fp_addr) { - if (fp_addr == 0) { - // Flush all - return flush_all(mem); - } - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - if (f->_flag & IOWRT) { - int p = 0; - int to_flush = f->_ptr_addr - f->_base_addr; - int c = to_flush; - while (c > 0) { - int r = wrapper_write(mem, f->_file, f->_base_addr + p, c); - if (r < 0) { - f->_file |= IOERR; - return -1; - } - p += r; - c -= r; - } - f->_ptr_addr = f->_base_addr; - f->_cnt += to_flush; - } - return 0; -} - -int wrapper_fchown(uint8_t* mem, int fd, int owner, int group) { - int ret = fchown(fd, owner, group); - if (ret != 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_ftell(uint8_t* mem, uint32_t fp_addr) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - int adjust; - if (f->_cnt < 0) { - f->_cnt = 0; - } - if (f->_flag & IOREAD) { - adjust = -f->_cnt; - } else if (f->_flag & (IOWRT | IORW)) { - adjust = 0; - if ((f->_flag & IOWRT) && f->_base_addr != 0 && (f->_flag & IONBF) == 0) { - adjust = f->_ptr_addr - f->_base_addr; - } - } else { - return -1; - } - int res = wrapper_lseek(mem, f->_file, 0, 1); - if (res >= 0) { - res += adjust; - } - return res; -} - -void wrapper_rewind(uint8_t* mem, uint32_t fp_addr) { - (void)wrapper_fseek(mem, fp_addr, 0, SEEK_SET); - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - f->_flag &= ~IOERR; -} - -int wrapper_fseek(uint8_t* mem, uint32_t fp_addr, int offset, int origin) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - int c, p; - f->_flag &= ~IOEOF; - if (f->_flag & IOREAD) { - if (origin < SEEK_END && f->_base_addr && !(f->_flag & IONBF)) { - c = f->_cnt; - p = offset; - if (origin == SEEK_SET) { - p += c - lseek(f->_file, 0L, SEEK_CUR); - } else { - offset -= c; - } - if (!(f->_flag & IORW) && c > 0 && p <= c && p >= f->_base_addr - f->_ptr_addr) { - f->_ptr_addr += p; - f->_cnt -= p; - return 0; - } - } - if (f->_flag & IORW) { - f->_ptr_addr = f->_base_addr; - f->_flag &= ~IOREAD; - } - p = lseek(f->_file, offset, origin); - f->_cnt = 0; - } else if (f->_flag & (IOWRT | IORW)) { - wrapper_fflush(mem, fp_addr); - if (f->_flag & IORW) { - f->_cnt = 0; - f->_flag &= ~IOWRT; - f->_ptr_addr = f->_base_addr; - } - p = lseek(f->_file, offset, origin); - } - if (p < 0) { - MEM_U32(ERRNO_ADDR) = errno; - return p; - } - return 0; -} - -int wrapper_lseek(uint8_t* mem, int fd, int offset, int whence) { - int ret = (int)lseek(fd, offset, whence); - if (ret == -1) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_dup(uint8_t* mem, int fd) { - fd = dup(fd); - if (fd < 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return fd; -} - -int wrapper_dup2(uint8_t* mem, int oldfd, int newfd) { - int fd = dup2(oldfd, newfd); - if (fd < 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return fd; -} - -int wrapper_pipe(uint8_t* mem, uint32_t pipefd_addr) { - int pipefd[2]; - int ret = pipe(pipefd); - if (ret == 0) { - MEM_U32(pipefd_addr + 0) = pipefd[0]; - MEM_U32(pipefd_addr + 4) = pipefd[1]; - } else { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -void wrapper_perror(uint8_t* mem, uint32_t str_addr) { - STRING(str) - perror(str); -} - -int wrapper_fdopen(uint8_t* mem, int fd, uint32_t mode_addr) { - STRING(mode) - return init_file(mem, fd, -1, NULL, mode); -} - -uint32_t wrapper_memset(uint8_t* mem, uint32_t dest_addr, int byte, uint32_t n) { - uint32_t saved = dest_addr; - if (dest_addr % 4 == 0 && n % 4 == 0) { - memset(&MEM_U32(dest_addr), byte, n); - } else { - while (n--) { - MEM_U8(dest_addr) = (uint8_t)byte; - ++dest_addr; - } - } - return saved; -} - -int wrapper_bcmp(uint8_t* mem, uint32_t s1_addr, uint32_t s2_addr, uint32_t n) { - while (n--) { - if (MEM_U8(s1_addr) != MEM_U8(s2_addr)) { - return 1; - } - ++s1_addr; - ++s2_addr; - } - return 0; -} - -int wrapper_memcmp(uint8_t* mem, uint32_t s1_addr, uint32_t s2_addr, uint32_t n) { - while (n--) { - unsigned char c1 = MEM_U8(s1_addr); - unsigned char c2 = MEM_U8(s2_addr); - if (c1 < c2) { - return -1; - } - if (c1 > c2) { - return 1; - } - ++s1_addr; - ++s2_addr; - } - return 0; -} - -int wrapper_getpid(void) { - return getpid(); -} - -int wrapper_getpgrp(uint8_t* mem) { - int ret = getpgrp(); - if (ret == -1) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_remove(uint8_t* mem, uint32_t path_addr) { - STRING(path) - int ret = remove(path); - if (ret < 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_unlink(uint8_t* mem, uint32_t path_addr) { - if (path_addr == 0) { - fprintf(stderr, "Warning: unlink with NULL as arguement\n"); - MEM_U32(ERRNO_ADDR) = EFAULT; - return -1; - } - STRING(path) - int ret = unlink(path); - if (ret < 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_close(uint8_t* mem, int fd) { - int ret = close(fd); - if (ret < 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_strcmp(uint8_t* mem, uint32_t s1_addr, uint32_t s2_addr) { - for (;;) { - char c1 = MEM_S8(s1_addr); - char c2 = MEM_S8(s2_addr); - if (c1 != c2) { - return c1 < c2 ? -1 : 1; - } - if (c1 == '\0') { - return 0; - } - ++s1_addr; - ++s2_addr; - } -} - -int wrapper_strncmp(uint8_t* mem, uint32_t s1_addr, uint32_t s2_addr, uint32_t n) { - if (n == 0) { - return 0; - } - for (;;) { - char c1 = MEM_S8(s1_addr); - char c2 = MEM_S8(s2_addr); - if (c1 != c2) { - return c1 < c2 ? -1 : 1; - } - if (--n == 0 || c1 == '\0') { - return 0; - } - ++s1_addr; - ++s2_addr; - } -} - -uint32_t wrapper_strcpy(uint8_t* mem, uint32_t dest_addr, uint32_t src_addr) { - uint32_t saved = dest_addr; - for (;;) { - char c = MEM_S8(src_addr); - ++src_addr; - MEM_S8(dest_addr) = c; - ++dest_addr; - if (c == '\0') { - return saved; - } - } -} - -uint32_t wrapper_strncpy(uint8_t* mem, uint32_t dest_addr, uint32_t src_addr, uint32_t n) { - uint32_t i; - for (i = 0; i < n && MEM_S8(src_addr) != '\0'; i++) { - MEM_S8(dest_addr + i) = MEM_S8(src_addr + i); - } - for (; i < n; i++) { - MEM_S8(dest_addr + i) = '\0'; - } - return dest_addr; -} - -uint32_t wrapper_strcat(uint8_t* mem, uint32_t dest_addr, uint32_t src_addr) { - uint32_t saved = dest_addr; - while (MEM_S8(dest_addr) != '\0') { - ++dest_addr; - } - while (MEM_S8(src_addr) != '\0') { - MEM_S8(dest_addr) = MEM_S8(src_addr); - ++src_addr; - ++dest_addr; - } - MEM_S8(dest_addr) = '\0'; - return saved; -} - -uint32_t wrapper_strncat(uint8_t* mem, uint32_t dest_addr, uint32_t src_addr, uint32_t n) { - uint32_t saved = dest_addr; - while (MEM_S8(dest_addr) != '\0') { - ++dest_addr; - } - while (n-- && MEM_S8(src_addr) != '\0') { - MEM_S8(dest_addr) = MEM_S8(src_addr); - ++src_addr; - ++dest_addr; - } - MEM_S8(dest_addr) = '\0'; - return saved; -} - -uint32_t wrapper_strtok(uint8_t* mem, uint32_t str_addr, uint32_t delimiters_addr) { - if (str_addr == 0) { - str_addr = MEM_U32(STRTOK_DATA_ADDR); - } - if (str_addr == 0) { - // nothing remaining - return 0; - } - uint32_t p; - for (p = str_addr; MEM_S8(p) != '\0'; p++) { - uint32_t q; - for (q = delimiters_addr; MEM_S8(q) != '\0' && MEM_S8(q) != MEM_S8(p); q++) {} - if (MEM_S8(q) == '\0') { - break; - } - } - if (MEM_S8(p) == '\0') { - return 0; - } - uint32_t ret = p; - for (;;) { - uint32_t q; - for (q = delimiters_addr; MEM_S8(q) != '\0' && MEM_S8(q) != MEM_S8(p); q++) {} - if (MEM_S8(q) != '\0') { - MEM_S8(p) = '\0'; - MEM_U32(STRTOK_DATA_ADDR) = ++p; - return ret; - } - char next = MEM_S8(p); - ++p; - if (next == '\0') { - MEM_U32(STRTOK_DATA_ADDR) = 0; - return ret; - } - } -} - -uint32_t wrapper_strstr(uint8_t* mem, uint32_t str1_addr, uint32_t str2_addr) { - for (;;) { - if (MEM_S8(str1_addr) == '\0') { - return 0; - } - uint32_t s1 = str1_addr; - uint32_t s2 = str2_addr; - for (;;) { - char c2 = MEM_S8(s2); - if (c2 == '\0') { - return str1_addr; - } - if (MEM_S8(s1) == c2) { - ++s1; - ++s2; - } else { - break; - } - } - ++str1_addr; - } -} - -uint32_t wrapper_strdup(uint8_t* mem, uint32_t str_addr) { - uint32_t len = wrapper_strlen(mem, str_addr) + 1; - uint32_t ret = wrapper_malloc(mem, len); - if (ret == 0) { - MEM_U32(ERRNO_ADDR) = ENOMEM; - return 0; - } - return wrapper_memcpy(mem, ret, str_addr, len); -} - -int wrapper_toupper(int c) { - return toupper(c); -} - -int wrapper_tolower(int c) { - return tolower(c); -} - -int wrapper_gethostname(uint8_t* mem, uint32_t name_addr, uint32_t len) { - char buf[256] = { 0 }; - if (len > 256) { - len = 256; - } - int ret = gethostname(buf, len); - if (ret < 0) { - MEM_U32(ERRNO_ADDR) = errno; - } else { - for (uint32_t i = 0; i < len; i++) { - MEM_S8(name_addr + i) = buf[i]; - } - } - return ret; -} - -int wrapper_isatty(uint8_t* mem, int fd) { - int ret = isatty(fd); - if (ret == 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -uint32_t wrapper_strftime(uint8_t* mem, uint32_t ptr_addr, uint32_t maxsize, uint32_t format_addr, - uint32_t timeptr_addr) { - MEM_S8(ptr_addr) = 0; - return 0; -} - -int wrapper_times(uint8_t* mem, uint32_t buffer_addr) { - struct tms_irix { - int tms_utime; - int tms_stime; - int tms_cutime; - int tms_cstime; - } r; - struct tms t; - clock_t ret = times(&t); - if (ret == (clock_t)-1) { - MEM_U32(ERRNO_ADDR) = errno; - } else { - r.tms_utime = t.tms_utime; - r.tms_stime = t.tms_stime; - r.tms_cutime = t.tms_cutime; - r.tms_cstime = t.tms_cstime; - MEM_U32(buffer_addr + 0x0) = t.tms_utime; - MEM_U32(buffer_addr + 0x4) = t.tms_stime; - MEM_U32(buffer_addr + 0x8) = t.tms_cutime; - MEM_U32(buffer_addr + 0xC) = t.tms_cstime; - } - return (int)ret; -} - -int wrapper_clock(void) { - return (int)clock(); -} - -uint32_t wrapper_ctime(uint8_t* mem, uint32_t timep_addr) { - time_t t = MEM_S32(timep_addr); - char* res = ctime(&t); - size_t len = strlen(res) + 1; - uint32_t ret_addr = wrapper_malloc(mem, len); - uint32_t pos = ret_addr; - while (len--) { - MEM_S8(pos) = *res; - ++pos; - ++res; - } - return ret_addr; -} - -uint32_t wrapper_localtime(uint8_t* mem, uint32_t timep_addr) { - time_t t = MEM_S32(timep_addr); - struct irix_tm { - int tm_sec; - int tm_min; - int tm_hour; - int tm_mday; - int tm_mon; - int tm_year; - int tm_wday; - int tm_yday; - int tm_isdst; - }; - uint32_t ret = wrapper_malloc(mem, sizeof(struct irix_tm)); - struct irix_tm* r = (struct irix_tm*)&MEM_U32(ret); - struct tm* l = localtime(&t); - r->tm_sec = l->tm_sec; - r->tm_min = l->tm_min; - r->tm_hour = l->tm_hour; - r->tm_mday = l->tm_mday; - r->tm_mon = l->tm_mon; - r->tm_year = l->tm_year; - r->tm_wday = l->tm_wday; - r->tm_yday = l->tm_yday; - r->tm_isdst = l->tm_isdst; - return ret; -} - -int wrapper_setvbuf(uint8_t* mem, uint32_t fp_addr, uint32_t buf_addr, int mode, uint32_t size) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - wrapper_fflush(mem, fp_addr); - if ((f->_flag & IOMYBUF) && f->_base_addr != 0) { - wrapper_free(mem, f->_base_addr); - } - size &= ~0xf; - f->_flag &= ~IOMYBUF; - - if (buf_addr == 0) { - assert(size > 0); - buf_addr = wrapper_malloc(mem, size); - f->_flag |= IOMYBUF; - } - - f->_base_addr = buf_addr; - f->_ptr_addr = buf_addr; - f->_cnt = 0; - bufendtab[(fp_addr - IOB_ADDR) / sizeof(struct FILE_irix)] = size; - return 0; -} - -int wrapper___semgetc(uint8_t* mem, uint32_t fp_addr) { - assert(0); -} - -int wrapper___semputc(uint8_t* mem, int c, uint32_t fp_addr) { - assert(0); -} - -int wrapper_fgetc(uint8_t* mem, uint32_t fp_addr) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - if (--f->_cnt < 0) { - return wrapper___filbuf(mem, fp_addr); - } else { - int ret = MEM_U8(f->_ptr_addr); - ++f->_ptr_addr; - return ret; - } -} - -int wrapper_fgets(uint8_t* mem, uint32_t str_addr, int count, uint32_t fp_addr) { - bool modified = false; - uint32_t saved = str_addr; - for (count--; count > 0; count--) { - int ch = wrapper_fgetc(mem, fp_addr); - if (ch == -1) { - MEM_S8(str_addr) = '\0'; - return modified ? saved : 0; - } - modified = true; - MEM_S8(str_addr) = (char)ch; - ++str_addr; - if (ch == '\n') { - break; - } - } - MEM_S8(str_addr) = '\0'; - return saved; -} - -static void file_assign_buffer(uint8_t* mem, struct FILE_irix* f) { - f->_base_addr = wrapper_malloc(mem, STDIO_BUFSIZE); - f->_ptr_addr = f->_base_addr; - f->_flag |= IOMYBUF; - f->_cnt = 0; - bufendtab[f - (struct FILE_irix*)&MEM_U32(IOB_ADDR)] = STDIO_BUFSIZE; -} - -int wrapper___filbuf(uint8_t* mem, uint32_t fp_addr) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - if (!(f->_flag & IOREAD)) { - if (f->_flag & IORW) { - f->_flag |= IOREAD; - } else { - MEM_U32(ERRNO_ADDR) = 9; // EBADF - return -1; - } - } - if (f->_base_addr == 0) { - file_assign_buffer(mem, f); - } - uint32_t size = bufendtab[(fp_addr - IOB_ADDR) / sizeof(struct FILE_irix)]; - int nread = wrapper_read(mem, f->_file, f->_base_addr, size); - int ret = -1; - if (nread > 0) { - f->_ptr_addr = f->_base_addr; - f->_cnt = nread; - ret = MEM_U8(f->_ptr_addr); - ++f->_ptr_addr; - --f->_cnt; - } else if (nread == 0) { - f->_flag |= IOEOF; - } else { - f->_flag |= IOERR; - } - return ret; -} - -int wrapper___flsbuf(uint8_t* mem, int ch, uint32_t fp_addr) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - if (wrapper_fflush(mem, fp_addr) != 0) { - return -1; - } - if (f->_base_addr == 0) { - file_assign_buffer(mem, f); - f->_cnt = bufendtab[f - (struct FILE_irix*)&MEM_U32(IOB_ADDR)]; - } - MEM_U8(f->_ptr_addr) = ch; - ++f->_ptr_addr; - --f->_cnt; - if (f->_flag & IONBF) { - if (wrapper_fflush(mem, fp_addr) != 0) { - return -1; - } - f->_cnt = 0; - } - return ch; -} - -int wrapper_ungetc(uint8_t* mem, int ch, uint32_t fp_addr) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - if (ch == -1 || f->_ptr_addr == f->_base_addr) { - return -1; - } - --f->_ptr_addr; - MEM_U8(f->_ptr_addr) = (uint8_t)ch; - ++f->_cnt; - f->_flag &= ~IOEOF; - return ch; -} - -uint32_t wrapper_gets(uint8_t* mem, uint32_t str_addr) { - uint32_t p, str0 = str_addr; - int n; - - for (;;) { - if (STDIN->_cnt <= 0) { - if (wrapper___filbuf(mem, STDIN_ADDR) == -1) { - if (str0 == str_addr) { - return 0; - } - break; - } - --STDIN->_ptr_addr; - ++STDIN->_cnt; - } - n = STDIN->_cnt; - if ((p = wrapper_memccpy(mem, str_addr, STDIN->_ptr_addr, '\n', n)) != 0) { - n = p - str_addr; - } - str_addr += n; - STDIN->_cnt -= n; - STDIN->_ptr_addr += n; - // bufsync - if (p != 0) { - // found '\n' in buffer - --str_addr; - break; - } - } - MEM_S8(str_addr) = '\0'; - return str0; -} - -uint32_t wrapper_fread(uint8_t* mem, uint32_t data_addr, uint32_t size, uint32_t count, uint32_t fp_addr) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - int nleft = count * size; - int n; - for (;;) { - if (f->_cnt <= 0) { - if (wrapper___filbuf(mem, fp_addr) == -1) { - return count - (nleft + size - 1) / size; - } - --f->_ptr_addr; - ++f->_cnt; - } - n = MIN(nleft, f->_cnt); - data_addr = wrapper_memcpy(mem, data_addr, f->_ptr_addr, n) + n; - f->_cnt -= n; - f->_ptr_addr += n; - if ((nleft -= n) <= 0) { - return count; - } - } -} - -uint32_t wrapper_fwrite(uint8_t* mem, uint32_t data_addr, uint32_t size, uint32_t count, uint32_t fp_addr) { - struct FILE_irix* f = (struct FILE_irix*)&MEM_U32(fp_addr); - if (size > 0 && count > 0 && f->_base_addr == 0) { - file_assign_buffer(mem, f); - f->_cnt = bufendtab[f - (struct FILE_irix*)&MEM_U32(IOB_ADDR)]; - f->_flag |= IOWRT; - } - uint32_t num_written = 0; - while (count--) { - uint32_t s = size; - while (s > 0) { - uint32_t to_write = f->_cnt; - if (s < to_write) { - to_write = s; - } - if (f->_cnt == 0) { - if (wrapper_fflush(mem, fp_addr) != 0) { - return num_written; - } - } - wrapper_memcpy(mem, f->_ptr_addr, data_addr, to_write); - data_addr += to_write; - f->_ptr_addr += to_write; - f->_cnt -= to_write; - s -= to_write; - } - num_written++; - } - if (f->_flag & IONBF) { - wrapper_fflush(mem, fp_addr); // TODO check error return value - } - return num_written; -} - -int wrapper_fputs(uint8_t* mem, uint32_t str_addr, uint32_t fp_addr) { - assert(str_addr != 0); - - uint32_t len = wrapper_strlen(mem, str_addr); - uint32_t ret = wrapper_fwrite(mem, str_addr, 1, len, fp_addr); - return ret == 0 && len != 0 ? -1 : 0; -} - -int wrapper_puts(uint8_t* mem, uint32_t str_addr) { - int ret = wrapper_fputs(mem, str_addr, STDOUT_ADDR); - if (ret != 0) { - return ret; - } - struct FILE_irix* f = STDOUT; - if (--f->_cnt < 0) { - if (wrapper___flsbuf(mem, '\n', STDOUT_ADDR) != '\n') { - return -1; - } - } else { - MEM_S8(f->_ptr_addr) = '\n'; - ++f->_ptr_addr; - } - return 0; -} - -uint32_t wrapper_getcwd(uint8_t* mem, uint32_t buf_addr, uint32_t size) { - char buf[size]; - if (getcwd(buf, size) == NULL) { - MEM_U32(ERRNO_ADDR) = errno; - return 0; - } else { - if (buf_addr == 0) { - buf_addr = wrapper_malloc(mem, size); - } - strcpy1(mem, buf_addr, buf); - return buf_addr; - } -} - -int wrapper_time(uint8_t* mem, uint32_t tloc_addr) { - time_t ret = time(NULL); - if (ret == (time_t)-1) { - MEM_U32(ERRNO_ADDR) = errno; - } else if (tloc_addr != 0) { - MEM_S32(tloc_addr) = ret; - } - return ret; -} - -void wrapper_bzero(uint8_t* mem, uint32_t str_addr, uint32_t n) { - while (n--) { - MEM_U8(str_addr) = 0; - ++str_addr; - } -} - -int wrapper_fp_class_d(double d) { - union { - uint32_t w[2]; - double d; - } bits; - bits.d = d; - uint32_t a2 = bits.w[1]; - uint32_t a1 = a2 >> 20; - uint32_t a0 = a1; - a2 &= 0xfffff; - uint32_t a3 = bits.w[0]; - a1 &= 0x7ff; - a0 &= 0x800; - if (a1 == 0x7ff) { - if (a2 == 0 && a3 == 0) { - return a0 == 0 ? 2 : 3; - } - a0 = a2 & 0x80000; - return a0 == 0 ? 1 : 0; - } - if (a1 == 0) { - if (a2 == 0 && a3 == 0) { - return a0 == 0 ? 8 : 9; - } - return a0 == 0 ? 6 : 7; - } - return a0 == 0 ? 4 : 5; -} - -double wrapper_ldexp(double d, int i) { - return ldexp(d, i); -} - -uint64_t wrapper___ll_mul(uint64_t a0, uint64_t a1) { - return a0 * a1; -} - -int64_t wrapper___ll_div(int64_t a0, int64_t a1) { - return a0 / a1; -} - -int64_t wrapper___ll_rem(uint64_t a0, int64_t a1) { - return a0 % a1; -} - -uint64_t wrapper___ll_lshift(uint64_t a0, uint64_t shift) { - return a0 << (shift & 0x3F); -} - -int64_t wrapper___ll_rshift(int64_t a0, uint64_t shift) { - return a0 >> (shift & 0x3F); -} - -uint64_t wrapper___ull_div(uint64_t a0, uint64_t a1) { - return a0 / a1; -} - -uint64_t wrapper___ull_rem(uint64_t a0, uint64_t a1) { - return a0 % a1; -} - -uint64_t wrapper___ull_rshift(uint64_t a0, uint64_t shift) { - return a0 >> (shift & 0x3f); -} - -uint64_t wrapper___d_to_ull(double d) { - return d; -} - -int64_t wrapper___d_to_ll(double d) { - return d; -} - -uint64_t wrapper___f_to_ull(float f) { - return f; -} - -int64_t wrapper___f_to_ll(float f) { - return f; -} - -float wrapper___ull_to_f(uint64_t v) { - return v; -} - -float wrapper___ll_to_f(int64_t v) { - return v; -} - -double wrapper___ull_to_d(uint64_t v) { - return v; -} - -double wrapper___ll_to_d(int64_t v) { - return v; -} - -void wrapper_abort(uint8_t* mem) { - abort(); -} - -void wrapper_exit(uint8_t* mem, int status) { - final_cleanup(mem); - exit(status); -} - -void wrapper__exit(uint8_t* mem, int status) { - assert(0 && "_exit not implemented"); // exit() is already overridden -} - -void wrapper__cleanup(uint8_t* mem) { -} - -uint32_t wrapper__rld_new_interface(uint8_t* mem, uint32_t operation, uint32_t sp) { - assert(0 && "_rld_new_interface not implemented"); - return 0; -} - -void wrapper__exithandle(uint8_t* mem) { - assert(0 && "_exithandle not implemented"); -} - -int wrapper__prctl(uint8_t* mem, int operation, uint32_t sp) { - assert(0 && "_prctl not implemented"); - return 0; -} - -double wrapper__atod(uint8_t* mem, uint32_t buffer_addr, int ndigits, int dexp) { - // ftp://atoum.hst.nerim.net/irix/src/irix-6.5.5-src/6.5.5/m/irix/lib/libc/src/math/atod.c - assert(0 && "_atod not implemented"); - return 0.0; -} - -int wrapper_pathconf(uint8_t* mem, uint32_t path_addr, int name) { - STRING(path) - if (name == 5) { - errno = 0; - int ret = pathconf(path, _PC_PATH_MAX); - if (errno != 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; - } - assert(0 && "pathconf not implemented for the specific 'name'"); - return 0; -} - -uint32_t wrapper_getenv(uint8_t* mem, uint32_t name_addr) { - STRING(name); - const char* value = getenv(name); - if (value == NULL) { - return 0; - } - size_t value_size = strlen(value) + 1; - uint32_t buf_addr = wrapper_malloc(mem, value_size); - strcpy1(mem, buf_addr, value); - return buf_addr; -} - -uint32_t wrapper_gettxt(uint8_t* mem, uint32_t msgid_addr, uint32_t default_str_addr) { - // Return default for now - return default_str_addr; -} - -uint32_t wrapper_setlocale(uint8_t* mem, int category, uint32_t locale_addr) { - assert(locale_addr != 0); - STRING(locale) - assert(category == 6); // LC_ALL - char* ret = setlocale(LC_ALL, locale); - // Let's hope the caller doesn't use the return value - return 0; -} - -uint32_t wrapper_mmap(uint8_t* mem, uint32_t addr, uint32_t length, int prot, int flags, int fd, int offset) { - if (addr == 0 && prot == (prot & 3) && flags == 2) { - // Read/write, map private. Just make a copy. - uint8_t* ptr = mmap(0, length, PROT_READ, MAP_PRIVATE, fd, offset); - if (ptr == MAP_FAILED) { - MEM_U32(ERRNO_ADDR) = errno; - return -1; - } - uint32_t out = wrapper_malloc(mem, length); - for (uint32_t i = 0; i < length; i++) { - MEM_S8(out + i) = ptr[i]; - } - munmap(ptr, length); - return out; - } - assert(0 && "mmap not implemented"); - return 0; -} - -int wrapper_munmap(uint8_t* mem, uint32_t addr, uint32_t length) { - return 0; -} - -int wrapper_mprotect(uint8_t* mem, uint32_t addr, uint32_t length, int prot) { - assert(0 && "mprotect not implemented"); - return 0; -} - -int wrapper_sysconf(uint8_t* mem, int name) { - assert(0 && "sysconf not implemented"); - return 0; -} - -int wrapper_getpagesize(uint8_t* mem) { - return 4096; -} - -int wrapper_strerror(uint8_t* mem, int errnum) { - errno = errnum; - perror("strerror"); - assert(0 && "strerror not implemented"); - return 0; -} - -int wrapper_ioctl(uint8_t* mem, int fd, uint32_t request, uint32_t sp) { - assert(0 && "ioctl not implemented"); - return 0; -} - -int wrapper_fcntl(uint8_t* mem, int fd, int cmd, uint32_t sp) { - assert(0 && "fcntl not implemented"); - return 0; -} - -static void signal_handler(int signum) { - uint32_t level = signal_context.recursion_level++; - uint8_t* mem = signal_context.handlers[signum].mem; - uint32_t fp_dest = signal_context.handlers[signum].fp_dest; - uint32_t sp = SIGNAL_HANDLER_STACK_START - 16 - level * 0x1000; - signal_context.handlers[signum].trampoline(mem, sp, signum, 0, 0, 0, fp_dest); - signal_context.recursion_level--; -} - -uint32_t wrapper_signal(uint8_t* mem, int signum, - uint64_t (*trampoline)(uint8_t* mem, uint32_t sp, uint32_t a0, uint32_t a1, uint32_t a2, - uint32_t a3, uint32_t fp_dest), - uint32_t handler_addr, uint32_t sp) { - return 0; -} - -uint32_t wrapper_sigset(uint8_t* mem, int signum, - uint64_t (*trampoline)(uint8_t* mem, uint32_t sp, uint32_t a0, uint32_t a1, uint32_t a2, - uint32_t a3, uint32_t fp_dest), - uint32_t disp_addr, uint32_t sp) { - void (*handler)(int) = signal_handler; - - if ((int)disp_addr >= -1 && (int)disp_addr <= 1) { - // SIG_DFL etc. - handler = (void (*)(int))(intptr_t)(int)disp_addr; - } - - switch (signum) { - case 2: - signum = SIGINT; - break; - case 13: - signum = SIGPIPE; - break; - case 15: - signum = SIGTERM; - break; - default: - assert(0 && "sigset with this signum not implemented"); - break; - } - - signal_context.handlers[signum].trampoline = trampoline; - signal_context.handlers[signum].mem = mem; - signal_context.handlers[signum].fp_dest = disp_addr; - - return (uint32_t)(uintptr_t)sigset(signum, handler); // for now only support SIG_DFL etc. as return value -} - -int wrapper_get_fpc_csr(uint8_t* mem) { - return 0; -} - -int wrapper_set_fpc_csr(uint8_t* mem, int csr) { - return 0; -} - -int wrapper_setjmp(uint8_t* mem, uint32_t addr) { - return 0; -} - -void wrapper_longjmp(uint8_t* mem, uint32_t addr, int status) { - assert(0 && "longjmp not implemented"); -} - -uint32_t wrapper_tempnam(uint8_t *mem, uint32_t dir_addr, uint32_t pfx_addr) { - STRING(dir) - STRING(pfx) - char *ret = tempnam(dir, pfx); - char *ret_saved = ret; - if (ret == NULL) { - MEM_U32(ERRNO_ADDR) = errno; - return 0; - } - size_t len = strlen(ret) + 1; - uint32_t ret_addr = wrapper_malloc(mem, len); - uint32_t pos = ret_addr; - while (len--) { - MEM_S8(pos) = *ret; - ++pos; - ++ret; - } - free(ret_saved); - return ret_addr; -} - -uint32_t wrapper_tmpnam(uint8_t *mem, uint32_t str_addr) { - char buf[1024]; - assert(str_addr != 0 && "s NULL not implemented for tmpnam"); - char *ret = tmpnam(buf); - if (ret == NULL) { - return 0; - } else { - strcpy1(mem, str_addr, ret); - return str_addr; - } -} - -uint32_t wrapper_mktemp(uint8_t *mem, uint32_t template_addr) { - STRING(template) - mktemp(template); - strcpy1(mem, template_addr, template); - return template_addr; -} - -int wrapper_mkstemp(uint8_t* mem, uint32_t name_addr) { - STRING(name) - int fd = mkstemp(name); - if (fd < 0) { - MEM_U32(ERRNO_ADDR) = errno; - } else { - strcpy1(mem, name_addr, name); - } - return fd; -} - -uint32_t wrapper_tmpfile(uint8_t* mem) { - // create and fopen a temporary file that is removed when the program exits - const char* tmpdir = getenv("TMPDIR"); - if (tmpdir == NULL) { - tmpdir = "/tmp"; - } - - char name[PATH_MAX + 1] = { 0 }; - int n = snprintf(name, sizeof(name), "%s/copt_temp_XXXXXX", tmpdir); - if (n < 0 || n >= sizeof(name)) { - // This isn't the best errno code, but it is one that can be returned by tmpfile - MEM_U32(ERRNO_ADDR) = EACCES; - return 0; - } - - int fd = mkstemp(name); - if (fd < 0) { - MEM_U32(ERRNO_ADDR) = errno; - return 0; - } - - // the file will be removed from disk when it's closed later - unlink(name); - - // fdopen: - uint32_t ret = init_file(mem, fd, -1, NULL, "w+"); - if (ret == 0) { - close(fd); - } - return ret; -} - -int wrapper_wait(uint8_t* mem, uint32_t wstatus_addr) { - int wstatus; - pid_t ret = wait(&wstatus); - MEM_S32(wstatus_addr) = wstatus; - return ret; -} - -int wrapper_kill(uint8_t* mem, int pid, int sig) { - int ret = kill(pid, sig); - if (ret != 0) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_execlp(uint8_t* mem, uint32_t file_addr, uint32_t sp) { - uint32_t argv_addr = sp + 4; - return wrapper_execvp(mem, file_addr, argv_addr); -} - -int wrapper_execv(uint8_t* mem, uint32_t pathname_addr, uint32_t argv_addr) { - STRING(pathname) - uint32_t argc = 0; - while (MEM_U32(argv_addr + argc * 4) != 0) { - ++argc; - } - char* argv[argc + 1]; - for (uint32_t i = 0; i < argc; i++) { - uint32_t str_addr = MEM_U32(argv_addr + i * 4); - uint32_t len = wrapper_strlen(mem, str_addr) + 1; - argv[i] = (char*)malloc(len); - char* pos = argv[i]; - while (len--) { - *pos++ = MEM_S8(str_addr); - ++str_addr; - } - } - argv[argc] = NULL; - execv(pathname, argv); - MEM_U32(ERRNO_ADDR) = errno; - for (uint32_t i = 0; i < argc; i++) { - free(argv[i]); - } - return -1; -} - -int wrapper_execvp(uint8_t* mem, uint32_t file_addr, uint32_t argv_addr) { - STRING(file) - uint32_t argc = 0; - while (MEM_U32(argv_addr + argc * 4) != 0) { - ++argc; - } - char* argv[argc + 1]; - for (uint32_t i = 0; i < argc; i++) { - uint32_t str_addr = MEM_U32(argv_addr + i * 4); - uint32_t len = wrapper_strlen(mem, str_addr) + 1; - argv[i] = (char*)malloc(len); - char* pos = argv[i]; - while (len--) { - *pos++ = MEM_S8(str_addr); - ++str_addr; - } - } - argv[argc] = NULL; - - char rfile[PATH_MAX + 1]; - redirect_path(rfile, file, "/usr/lib", usr_lib_redirect); - - execvp(rfile, argv); - - MEM_U32(ERRNO_ADDR) = errno; - for (uint32_t i = 0; i < argc; i++) { - free(argv[i]); - } - return -1; -} - -int wrapper_fork(uint8_t* mem) { - int ret = fork(); - if (ret == -1) { - MEM_U32(ERRNO_ADDR) = errno; - } - return ret; -} - -int wrapper_system(uint8_t* mem, uint32_t command_addr) { - STRING(command) - return system(command); // no errno -} - -static int name_compare(uint8_t* mem, uint32_t a_addr, uint32_t b_addr) { - return wrapper_strcmp(mem, MEM_U32(a_addr), MEM_U32(b_addr)); -} - -static uint32_t tsearch_tfind(uint8_t* mem, uint32_t key_addr, uint32_t rootp_addr, uint32_t compar_addr, bool insert) { - if (rootp_addr == 0) { - return 0; - } - while (MEM_U32(rootp_addr) != 0) { - uint32_t node_addr = MEM_U32(rootp_addr); - int r = name_compare(mem, key_addr, MEM_U32(node_addr)); - if (r == 0) { - return node_addr; - } - rootp_addr = r < 0 ? node_addr + 4 : node_addr + 8; - } - if (insert) { - uint32_t node_addr = wrapper_malloc(mem, 12); - if (node_addr != 0) { - MEM_U32(rootp_addr) = node_addr; - MEM_U32(node_addr) = key_addr; - MEM_U32(node_addr + 4) = 0; - MEM_U32(node_addr + 8) = 0; - return node_addr; - } - } - return 0; -} - -uint32_t wrapper_tsearch(uint8_t* mem, uint32_t key_addr, uint32_t rootp_addr, uint32_t compar_addr) { - return tsearch_tfind(mem, key_addr, rootp_addr, compar_addr, true); -} - -uint32_t wrapper_tfind(uint8_t* mem, uint32_t key_addr, uint32_t rootp_addr, uint32_t compar_addr) { - return tsearch_tfind(mem, key_addr, rootp_addr, compar_addr, false); -} - -// qsort implementation from SGI libc, originally derived from -// https://people.ece.ubc.ca/~eddieh/glu_dox/d7/da4/qsort_8c_source.html (public domain) - -#define CMP(x, y) (int32_t)(trampoline(mem, sp, (x), (y), 0, 0, compare_addr) >> 32) - -static void qst(uint8_t* mem, uint32_t start, uint32_t end, fptr_trampoline trampoline, uint32_t compare_addr, - uint32_t sp, uint32_t size, uint32_t minSortSize, uint32_t medianOfThreeThreshold); - -uint32_t wrapper_qsort(uint8_t* mem, uint32_t base_addr, uint32_t count, uint32_t size, fptr_trampoline trampoline, - uint32_t compare_addr, uint32_t sp) { - uint32_t end; - uint32_t it; - uint32_t prevIt; - uint32_t byteIt; - uint32_t hi; - uint32_t insPos; - uint32_t cur; - uint32_t smallest; - uint8_t temp; - - if (count < 2) { - return 0; - } - - end = base_addr + (count * size); - - if (count >= 4) { - // run a rough quicksort - qst(mem, base_addr, end, trampoline, compare_addr, sp, size, size * 4, size * 6); - // the smallest element will be one of the first 4 - hi = base_addr + size * 4; - } else { - hi = end; - } - - // Find the smallest element and swap it to the front - smallest = base_addr; - for (it = base_addr + size; it < hi; it += size) { - if (CMP(smallest, it) > 0) { - smallest = it; - } - } - - if (smallest != base_addr) { - for (it = base_addr; it < base_addr + size; smallest++, it++) { - temp = MEM_U8(smallest); - MEM_U8(smallest) = MEM_U8(it); - MEM_U8(it) = temp; - } - } - - // Do insertion sort on the rest of the elements - for (cur = base_addr + size; cur < end; cur += size) { - - // Find where cur should go - insPos = cur - size; - while (CMP(insPos, cur) > 0) { - if (base_addr == insPos) { - // This isn't logically possible, because we've put the smallest element first. - // But it can happen if the comparator function is faulty, and it's best not to - // write out of bounds in that situation. - break; - } - insPos -= size; - } - insPos += size; - - if (insPos == cur) { - continue; - } - - for (byteIt = cur + size; --byteIt >= cur;) { - temp = MEM_U8(byteIt); - prevIt = byteIt; - for (it = byteIt - size; it >= insPos; it -= size) { - MEM_U8(prevIt) = MEM_U8(it); - prevIt = it; - } - MEM_U8(prevIt) = temp; - } - } - - return 0; -} - -static void qst(uint8_t* mem, uint32_t start, uint32_t end, fptr_trampoline trampoline, uint32_t compare_addr, - uint32_t sp, uint32_t size, uint32_t minSortSize, uint32_t medianOfThreeThreshold) { - uint32_t sizeAfterPivot; - uint32_t sizeBeforePivot; - uint32_t totalSize; - int32_t i; - uint32_t afterPivot; - uint32_t last; - uint32_t newPartitionFirst; - uint32_t median; - uint32_t partitionFirst; - uint32_t partitionLast; - uint32_t pivot; - uint32_t swapWith; - uint8_t temp; - - totalSize = end - start; - do { - last = end - size; - pivot = partitionFirst = (((totalSize / size) >> 1) * size) + start; - if (totalSize >= medianOfThreeThreshold) { - // compute median of three - median = CMP(start, pivot) > 0 ? start : pivot; - if (CMP(median, last) > 0) { - median = median == start ? pivot : start; - median = CMP(median, last) < 0 ? last : median; - } - - // swap the median so it ends up in the middle - if (median != pivot) { - // Fake-match: use partitionFirst here instead of e.g. swapWith. - i = size; - do { - temp = MEM_U8(partitionFirst); - MEM_U8(partitionFirst) = MEM_U8(median); - MEM_U8(median) = temp; - partitionFirst++; - median++; - i--; - } while (i != 0); - } - } - - // Partition the elements start, ..., pivot, ..., last, such that values smaller than the - // pivot are on the left, and values greater than the pivot are on the right (equal ones can - // go wherever). The pivot may end up getting swapped into another position in the process. - - partitionFirst = start; - partitionLast = last; - - // Loop invariant: Elements partitionFirst, ..., partitionLast remain to be partitioned, - // and pivot is in that range. - for (;;) { - while (partitionFirst < pivot && CMP(partitionFirst, pivot) < 0) { - // Skip over smaller values on the left. - partitionFirst += size; - } - - while (pivot < partitionLast) { - if (CMP(pivot, partitionLast) < 0) { - // Skip over greater values on the right. - partitionLast -= size; - } else { - // We have found a value we cannot skip over. Put it at the front. - // If the pivot was at the front, it gets swapped to the last position, - // otherwise, the value at the front is something we know isn't smaller - // than the pivot, so we can skip partitioning it. - newPartitionFirst = partitionFirst + size; - if (partitionFirst == pivot) { - swapWith = partitionLast; - pivot = partitionLast; - } else { - swapWith = partitionLast; - partitionLast -= size; - } - goto swapFront; - } - } - - // We have hit up against the pivot at the end. Swap it to the front to we can - // skip over it. The front element is known to not be smaller than the pivot, - // except if the pivot is at the front also, i.e. if the range has been reduced - // down to size 1 -- in that case it's time to break out of the loop. - partitionLast -= size; - if (partitionFirst == pivot) { - break; - } - swapWith = pivot; - pivot = partitionFirst; - newPartitionFirst = partitionFirst; - - swapFront: - i = size; - do { - temp = MEM_U8(partitionFirst); - MEM_U8(partitionFirst) = MEM_U8(swapWith); - MEM_U8(swapWith) = temp; - partitionFirst++; - swapWith++; - i--; - } while (i != 0); - partitionFirst = newPartitionFirst; - } - - afterPivot = pivot + size; - sizeBeforePivot = pivot - start; - sizeAfterPivot = end - afterPivot; - totalSize = sizeBeforePivot; - if (sizeAfterPivot >= sizeBeforePivot) { - if (sizeBeforePivot >= minSortSize) { - qst(mem, start, pivot, trampoline, compare_addr, sp, size, minSortSize, medianOfThreeThreshold); - } - start = afterPivot; - totalSize = sizeAfterPivot; - } else { - if (sizeAfterPivot >= minSortSize) { - qst(mem, afterPivot, end, trampoline, compare_addr, sp, size, minSortSize, medianOfThreeThreshold); - } - end = pivot; - } - } while (totalSize >= minSortSize); -} - -#undef CMP - -uint32_t wrapper_regcmp(uint8_t* mem, uint32_t string1_addr, uint32_t sp) { - STRING(string1); - fprintf(stderr, "regex string: %s\n", string1); - assert(0 && "regcmp not implemented"); - return 0; -} - -uint32_t wrapper_regex(uint8_t* mem, uint32_t re_addr, uint32_t subject_addr, uint32_t sp) { - STRING(subject); - assert(0 && "regex not implemented"); - return 0; -} - -void wrapper___assert(uint8_t* mem, uint32_t assertion_addr, uint32_t file_addr, int line) { - STRING(assertion) - STRING(file) - __assert(assertion, file, line); -} - -union host_doubleword { - uint64_t ww; - double d; -}; - -union FloatReg FloatReg_from_double(double d) { - union host_doubleword val; - union FloatReg floatreg; - - val.d = d; - - floatreg.w[0] = val.ww & 0xFFFFFFFF; - floatreg.w[1] = (val.ww >> 32) & 0xFFFFFFFF; - - return floatreg; -} - -double double_from_FloatReg(union FloatReg floatreg) { - union host_doubleword val; - - val.ww = floatreg.w[1]; - val.ww <<= 32; - val.ww |= floatreg.w[0]; - return val.d; -} - -double double_from_memory(uint8_t* mem, uint32_t address) { - union host_doubleword val; - - val.ww = MEM_U32(address); - val.ww <<= 32; - val.ww |= MEM_U32(address + 4); - return val.d; -} diff --git a/tools/ido-static-recomp/libc_impl.h b/tools/ido-static-recomp/libc_impl.h deleted file mode 100644 index b9f50b37..00000000 --- a/tools/ido-static-recomp/libc_impl.h +++ /dev/null @@ -1,182 +0,0 @@ -#ifndef LIBC_IMPL_H -#define LIBC_IMPL_H - -#include - -union FloatReg { - float f[2]; - uint32_t w[2]; - //double d; -}; - -void mmap_initial_data_range(uint8_t *mem, uint32_t start, uint32_t end); -void setup_libc_data(uint8_t *mem); - -uint32_t wrapper_sbrk(uint8_t *mem, int increment); -uint32_t wrapper_malloc(uint8_t *mem, uint32_t size); -uint32_t wrapper_calloc(uint8_t *mem, uint32_t num, uint32_t size); -uint32_t wrapper_realloc(uint8_t *mem, uint32_t data_addr, uint32_t size); -int wrapper_fscanf(uint8_t *mem, uint32_t fp_addr, uint32_t format_addr, uint32_t sp); -int wrapper_printf(uint8_t *mem, uint32_t format_addr, uint32_t sp); -int wrapper_sprintf(uint8_t *mem, uint32_t str_addr, uint32_t format_addr, uint32_t sp); -int wrapper_fprintf(uint8_t *mem, uint32_t fp_addr, uint32_t format_addr, uint32_t sp); -int wrapper__doprnt(uint8_t *mem, uint32_t format_addr, uint32_t params_addr, uint32_t fp_addr); -void wrapper_free(uint8_t *mem, uint32_t data_addr); -uint32_t wrapper_strlen(uint8_t *mem, uint32_t str_addr); -int wrapper_open(uint8_t *mem, uint32_t pathname_addr, int flags, int mode); -int wrapper_creat(uint8_t *mem, uint32_t pathname_addr, int mode); -int wrapper_access(uint8_t *mem, uint32_t pathname_addr, int mode); -int wrapper_rename(uint8_t *mem, uint32_t oldpath_addr, uint32_t newpath_addr); -int wrapper_utime(uint8_t *mem, uint32_t filename_addr, uint32_t times_addr); -int wrapper_flock(uint8_t *mem, int fd, int operation); -int wrapper_chmod(uint8_t *mem, uint32_t path_addr, uint32_t mode); -int wrapper_umask(int mode); -uint32_t wrapper_ecvt(uint8_t *mem, double number, int ndigits, uint32_t decpt_addr, uint32_t sign_addr); -uint32_t wrapper_fcvt(uint8_t *mem, double number, int ndigits, uint32_t decpt_addr, uint32_t sign_addr); -double wrapper_sqrt(double v); -float wrapper_sqrtf(float v); -int wrapper_atoi(uint8_t *mem, uint32_t nptr_addr); -int wrapper_atol(uint8_t *mem, uint32_t nptr_addr); -double wrapper_atof(uint8_t *mem, uint32_t nptr_addr); -int wrapper_strtol(uint8_t *mem, uint32_t nptr_addr, uint32_t endptr_addr, int base); -uint32_t wrapper_strtoul(uint8_t *mem, uint32_t nptr_addr, uint32_t endptr_addr, int base); -int64_t wrapper_strtoll(uint8_t *mem, uint32_t nptr_addr, uint32_t endptr_addr, int base); -uint64_t wrapper_strtoull(uint8_t *mem, uint32_t nptr_addr, uint32_t endptr_addr, int base); -double wrapper_strtod(uint8_t *mem, uint32_t nptr_addr, uint32_t endptr_addr); -uint32_t wrapper_strchr(uint8_t *mem, uint32_t str_addr, int c); -uint32_t wrapper_strrchr(uint8_t *mem, uint32_t str_addr, int c); -uint32_t wrapper_strcspn(uint8_t *mem, uint32_t str_addr, uint32_t invalid_addr); -uint32_t wrapper_strpbrk(uint8_t *mem, uint32_t str_addr, uint32_t accept_addr); -int wrapper_fstat(uint8_t *mem, int fildes, uint32_t buf_addr); -int wrapper_stat(uint8_t *mem, uint32_t pathname_addr, uint32_t buf_addr); -int wrapper_ftruncate(uint8_t *mem, int fd, int length); -int wrapper_truncate(uint8_t *mem, uint32_t pathname_addr, int length); -void wrapper_bcopy(uint8_t *mem, uint32_t src_addr, uint32_t dst_addr, uint32_t len); -uint32_t wrapper_memcpy(uint8_t *mem, uint32_t dst_addr, uint32_t src_addr, uint32_t len); -uint32_t wrapper_memccpy(uint8_t *mem, uint32_t dst_addr, uint32_t src_addr, int c, uint32_t len); -int wrapper_read(uint8_t *mem, int fd, uint32_t buf_addr, uint32_t nbytes); -int wrapper_write(uint8_t *mem, int fd, uint32_t buf_addr, uint32_t nbytes); -uint32_t wrapper_fopen(uint8_t *mem, uint32_t path_addr, uint32_t mode_addr); -uint32_t wrapper_freopen(uint8_t *mem, uint32_t path_addr, uint32_t mode_addr, uint32_t fp_addr); -int wrapper_fclose(uint8_t *mem, uint32_t fp_addr); -int wrapper_fflush(uint8_t *mem, uint32_t fp_addr); -int wrapper_fchown(uint8_t *mem, int fd, int owner, int group); -int wrapper_ftell(uint8_t *mem, uint32_t fp_addr); -void wrapper_rewind(uint8_t *mem, uint32_t fp_addr); -int wrapper_fseek(uint8_t *mem, uint32_t fp_addr, int offset, int origin); -int wrapper_lseek(uint8_t *mem, int fd, int offset, int whence); -int wrapper_dup(uint8_t *mem, int fd); -int wrapper_dup2(uint8_t *mem, int oldfd, int newfd); -int wrapper_pipe(uint8_t *mem, uint32_t pipefd_addr); -void wrapper_perror(uint8_t *mem, uint32_t str_addr); -int wrapper_fdopen(uint8_t *mem, int fd, uint32_t mode_addr); -uint32_t wrapper_memset(uint8_t *mem, uint32_t dest_addr, int byte, uint32_t n); -int wrapper_bcmp(uint8_t *mem, uint32_t s1_addr, uint32_t s2_addr, uint32_t n); -int wrapper_memcmp(uint8_t *mem, uint32_t s1_addr, uint32_t s2_addr, uint32_t n); -int wrapper_getpid(void); -int wrapper_getpgrp(uint8_t *mem); -int wrapper_remove(uint8_t *mem, uint32_t path_addr); -int wrapper_unlink(uint8_t *mem, uint32_t path_addr); -int wrapper_close(uint8_t *mem, int fd); -int wrapper_strcmp(uint8_t *mem, uint32_t s1_addr, uint32_t s2_addr); -int wrapper_strncmp(uint8_t *mem, uint32_t s1_addr, uint32_t s2_addr, uint32_t n); -uint32_t wrapper_strcpy(uint8_t *mem, uint32_t dest_addr, uint32_t src_addr); -uint32_t wrapper_strncpy(uint8_t *mem, uint32_t dest_addr, uint32_t src_addr, uint32_t n); -uint32_t wrapper_strcat(uint8_t *mem, uint32_t dest_addr, uint32_t src_addr); -uint32_t wrapper_strncat(uint8_t *mem, uint32_t dest_addr, uint32_t src_addr, uint32_t n); -uint32_t wrapper_strtok(uint8_t *mem, uint32_t str_addr, uint32_t delimiters_addr); -uint32_t wrapper_strstr(uint8_t *mem, uint32_t str1_addr, uint32_t str2_addr); -uint32_t wrapper_strdup(uint8_t *mem, uint32_t str_addr); -int wrapper_toupper(int c); -int wrapper_tolower(int c); -int wrapper_gethostname(uint8_t *mem, uint32_t name_addr, uint32_t len); -int wrapper_isatty(uint8_t *mem, int fd); -int wrapper_times(uint8_t *mem, uint32_t buffer_addr); -uint32_t wrapper_strftime(uint8_t *mem, uint32_t ptr_addr, uint32_t maxsize, uint32_t format_addr, uint32_t timeptr_addr); -int wrapper_clock(void); -uint32_t wrapper_ctime(uint8_t *mem, uint32_t timep_addr); -uint32_t wrapper_localtime(uint8_t *mem, uint32_t timep_addr); -int wrapper_setvbuf(uint8_t *mem, uint32_t fp_addr, uint32_t buf_addr, int mode, uint32_t size); -int wrapper___semgetc(uint8_t *mem, uint32_t fp_addr); -int wrapper___semputc(uint8_t *mem, int c, uint32_t fp_addr); -int wrapper_fgetc(uint8_t *mem, uint32_t fp_addr); -int wrapper_fgets(uint8_t *mem, uint32_t str_addr, int count, uint32_t fp_addr); -int wrapper___filbuf(uint8_t *mem, uint32_t fp_addr); -int wrapper___flsbuf(uint8_t *mem, int ch, uint32_t fp_addr); -int wrapper_ungetc(uint8_t *mem, int ch, uint32_t fp_addr); -uint32_t wrapper_gets(uint8_t *mem, uint32_t str_addr); -uint32_t wrapper_fread(uint8_t *mem, uint32_t data_addr, uint32_t size, uint32_t count, uint32_t fp_addr); -uint32_t wrapper_fwrite(uint8_t *mem, uint32_t data_addr, uint32_t size, uint32_t count, uint32_t fp_addr); -int wrapper_fputs(uint8_t *mem, uint32_t str_addr, uint32_t fp_addr); -int wrapper_puts(uint8_t *mem, uint32_t str_addr); -uint32_t wrapper_getcwd(uint8_t *mem, uint32_t buf_addr, uint32_t size); -int wrapper_time(uint8_t *mem, uint32_t tloc_addr); -void wrapper_bzero(uint8_t *mem, uint32_t str_addr, uint32_t n); -int wrapper_fp_class_d(double d); -double wrapper_ldexp(double d, int i); -uint64_t wrapper___ll_mul(uint64_t a0, uint64_t a1); -int64_t wrapper___ll_div(int64_t a0, int64_t a1); -int64_t wrapper___ll_rem(uint64_t a0, int64_t a1); -uint64_t wrapper___ll_lshift(uint64_t a0, uint64_t shift); -int64_t wrapper___ll_rshift(int64_t a0, uint64_t shift); -uint64_t wrapper___ull_div(uint64_t a0, uint64_t a1); -uint64_t wrapper___ull_rem(uint64_t a0, uint64_t a1); -uint64_t wrapper___ull_rshift(uint64_t a0, uint64_t shift); -uint64_t wrapper___d_to_ull(double d); -int64_t wrapper___d_to_ll(double d); -uint64_t wrapper___f_to_ull(float f); -int64_t wrapper___f_to_ll(float f); -float wrapper___ull_to_f(uint64_t v); -float wrapper___ll_to_f(int64_t v); -double wrapper___ull_to_d(uint64_t v); -double wrapper___ll_to_d(int64_t v); -void wrapper_abort(uint8_t *mem); -void wrapper_exit(uint8_t *mem, int status); -void wrapper__exit(uint8_t *mem, int status); -void wrapper__cleanup(uint8_t *mem); -uint32_t wrapper__rld_new_interface(uint8_t *mem, uint32_t operation, uint32_t sp); -void wrapper__exithandle(uint8_t *mem); -int wrapper__prctl(uint8_t *mem, int operation, uint32_t sp); -double wrapper__atod(uint8_t *mem, uint32_t buffer_addr, int ndigits, int dexp); -int wrapper_pathconf(uint8_t *mem, uint32_t path_addr, int name); -uint32_t wrapper_getenv(uint8_t *mem, uint32_t name_addr); -uint32_t wrapper_gettxt(uint8_t *mem, uint32_t msgid_addr, uint32_t default_str_addr); -uint32_t wrapper_setlocale(uint8_t *mem, int category, uint32_t locale_addr); -uint32_t wrapper_mmap(uint8_t *mem, uint32_t addr, uint32_t length, int prot, int flags, int fd, int offset); -int wrapper_munmap(uint8_t *mem, uint32_t addr, uint32_t length); -int wrapper_mprotect(uint8_t *mem, uint32_t addr, uint32_t length, int prot); -int wrapper_sysconf(uint8_t *mem, int name); -int wrapper_getpagesize(uint8_t *mem); -int wrapper_strerror(uint8_t *mem, int errnum); -int wrapper_ioctl(uint8_t *mem, int fd, uint32_t request, uint32_t sp); -int wrapper_fcntl(uint8_t *mem, int fd, int cmd, uint32_t sp); -uint32_t wrapper_signal(uint8_t *mem, int signum, uint64_t (*trampoline)(uint8_t *mem, uint32_t sp, uint32_t a0, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t fp_dest), uint32_t handler_addr, uint32_t sp); -uint32_t wrapper_sigset(uint8_t *mem, int signum, uint64_t (*trampoline)(uint8_t *mem, uint32_t sp, uint32_t a0, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t fp_dest), uint32_t disp_addr, uint32_t sp); -int wrapper_get_fpc_csr(uint8_t *mem); -int wrapper_set_fpc_csr(uint8_t *mem, int csr); -int wrapper_setjmp(uint8_t *mem, uint32_t addr); -void wrapper_longjmp(uint8_t *mem, uint32_t addr, int status); -uint32_t wrapper_tempnam(uint8_t *mem, uint32_t dir_addr, uint32_t pfx_addr); -uint32_t wrapper_tmpnam(uint8_t *mem, uint32_t str_addr); -uint32_t wrapper_mktemp(uint8_t *mem, uint32_t template_addr); -int wrapper_mkstemp(uint8_t *mem, uint32_t name_addr); -uint32_t wrapper_tmpfile(uint8_t *mem); -int wrapper_wait(uint8_t *mem, uint32_t wstatus_addr); -int wrapper_kill(uint8_t *mem, int pid, int sig); -int wrapper_execlp(uint8_t *mem, uint32_t file_addr, uint32_t sp); -int wrapper_execv(uint8_t *mem, uint32_t pathname_addr, uint32_t argv_addr); -int wrapper_execvp(uint8_t *mem, uint32_t file_addr, uint32_t argv_addr); -int wrapper_fork(uint8_t *mem); -int wrapper_system(uint8_t *mem, uint32_t command_addr); -uint32_t wrapper_tsearch(uint8_t *mem, uint32_t key_addr, uint32_t rootp_addr, uint32_t compar_addr); -uint32_t wrapper_tfind(uint8_t *mem, uint32_t key_addr, uint32_t rootp_addr, uint32_t compar_addr); -uint32_t wrapper_qsort(uint8_t *mem, uint32_t base_addr, uint32_t num, uint32_t size, uint64_t (*trampoline)(uint8_t *mem, uint32_t sp, uint32_t a0, uint32_t a1, uint32_t a2, uint32_t a3, uint32_t fp_dest), uint32_t compare_addr, uint32_t sp); -uint32_t wrapper_regcmp(uint8_t *mem, uint32_t string1_addr, uint32_t sp); -uint32_t wrapper_regex(uint8_t *mem, uint32_t re_addr, uint32_t subject_addr, uint32_t sp); -void wrapper___assert(uint8_t *mem, uint32_t assertion_addr, uint32_t file_addr, int line); - -union FloatReg FloatReg_from_double(double d); -double double_from_FloatReg(union FloatReg floatreg); -double double_from_memory(uint8_t *mem, uint32_t address); - -#endif diff --git a/tools/ido-static-recomp/recomp.cpp b/tools/ido-static-recomp/recomp.cpp deleted file mode 100644 index 683e750d..00000000 --- a/tools/ido-static-recomp/recomp.cpp +++ /dev/null @@ -1,3813 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "rabbitizer.hpp" -#include "rabbitizer.h" - -#include "elf.h" - -#if defined(_WIN32) && !defined(__CYGWIN__) -#include -#endif /* _WIN32 && !__CYGWIN__ */ - -#if !defined(_MSC_VER) && !defined(__CYGWIN__) && !defined(_WIN32) -#define UNIX_PLATFORM -#endif - -#ifdef UNIX_PLATFORM -// TODO: determine if any of those headers are not required -#include -#include -#include // for __cxa_demangle -#include // for dladdr -#include -#include -#endif - -#ifndef FULL_TRACEBACK -// Change to non-zero to have full traceback, including names not exported -#define FULL_TRACEBACK 0 -#endif - -// set this to 1 when testing a new program, to verify that no false function pointers are found -#define INSPECT_FUNCTION_POINTERS 0 - -#ifndef TRACE -#define TRACE 0 -#endif - -#define LABELS_64_BIT 1 - -#ifndef DUMP_INSTRUCTIONS -// Set to non-zero to dump actual disassembly when dumping C code -#define DUMP_INSTRUCTIONS 0 -#endif - -#define u32be(x) (uint32_t)(((x & 0xff) << 24) + ((x & 0xff00) << 8) + ((x & 0xff0000) >> 8) + ((uint32_t)(x) >> 24)) -#define u16be(x) (uint16_t)(((x & 0xff) << 8) + ((x & 0xff00) >> 8)) -#define read_u32_be(buf) (uint32_t)(((buf)[0] << 24) + ((buf)[1] << 16) + ((buf)[2] << 8) + ((buf)[3])) - -#define UniqueId_cpu_li rabbitizer::InstrId::UniqueId::cpu_USERDEF_00 -#define UniqueId_cpu_la rabbitizer::InstrId::UniqueId::cpu_USERDEF_01 - -using namespace std; - -struct Edge { - uint32_t i; - uint8_t function_entry : 1; - uint8_t function_exit : 1; - uint8_t extern_function : 1; - uint8_t function_pointer : 1; -}; - -struct Insn { - // base instruction - rabbitizer::InstructionCpu instruction; - - // - bool is_global_got_memop; - bool no_following_successor; - - // patching instructions - bool patched; - // lui pairs - uint32_t patched_addr; - // immediates are 16 bits wide, but they can be either signed or unsigned - // a 32 bits signed member can hold all those possible values - int32_t patched_imms; - rabbitizer::Registers::Cpu::GprO32 lila_dst_reg; - int linked_insn; - union { - uint32_t linked_value; - float linked_float; - }; - - // jumptable instructions - uint32_t jtbl_addr; - uint32_t num_cases; - rabbitizer::Registers::Cpu::GprO32 index_reg; - - // graph - vector successors; - vector predecessors; - uint64_t b_liveout; - uint64_t b_livein; - uint64_t f_livein; - uint64_t f_liveout; - - Insn(uint32_t word, uint32_t vram) : instruction(word, vram) { - this->is_global_got_memop = false; - this->no_following_successor = false; - - this->patched = false; - this->patched_addr = 0; - this->patched_imms = 0; - this->lila_dst_reg = rabbitizer::Registers::Cpu::GprO32::GPR_O32_zero; - this->linked_insn = -1; - this->linked_value = 0; - - this->jtbl_addr = 0; - this->num_cases = 0; - this->index_reg = rabbitizer::Registers::Cpu::GprO32::GPR_O32_zero; - - this->b_liveout = 0; - this->b_livein = 0; - this->f_livein = 0; - this->f_liveout = 0; - } - - void patchInstruction(rabbitizer::InstrId::UniqueId instructionId) { - this->patched = true; - RabbitizerInstruction* innerInstr = this->instruction.getCPtr(); - innerInstr->uniqueId = (RabbitizerInstrId)(instructionId); - innerInstr->descriptor = &RabbitizerInstrDescriptor_Descriptors[innerInstr->uniqueId]; - } - - void patchAddress(rabbitizer::InstrId::UniqueId instructionId, uint32_t newAddress) { - this->patchInstruction(instructionId); - this->patched_addr = newAddress; - } - - uint32_t getAddress() const { - if (this->patched && this->patched_addr != 0) { - return this->patched_addr; - } - - if (this->instruction.hasOperandAlias(rabbitizer::OperandType::cpu_label)) { - return this->instruction.getInstrIndexAsVram(); - } - - if (this->instruction.isBranch()) { - return this->instruction.getVram() + this->instruction.getBranchOffset(); - } - - assert(!"unreachable code"); - } - - void patchImmediate(int32_t newImmediate) { - this->patched = true; - this->patched_imms = newImmediate; - } - - int32_t getImmediate() const { - if (this->patched) { - return this->patched_imms; - } - - return this->instruction.getProcessedImmediate(); - } - - std::string disassemble() const { - char buffer[0x1000]; - int32_t imm; - - switch (this->instruction.getUniqueId()) { - case UniqueId_cpu_li: - imm = this->getImmediate(); - if (imm >= 0) { - sprintf(buffer, "li %s, 0x%X", RabbitizerRegister_getNameGpr((int)this->lila_dst_reg), - imm); - } else { - sprintf(buffer, "li %s, %i", RabbitizerRegister_getNameGpr((int)this->lila_dst_reg), imm); - } - return buffer; - - case UniqueId_cpu_la: - sprintf(buffer, "la %s, 0x%X", RabbitizerRegister_getNameGpr((int)this->lila_dst_reg), - this->getAddress()); - return buffer; - - default: - return this->instruction.disassembleInstruction(0); - } - } -}; - -struct Function { - vector returns; // points to delay slots - uint32_t end_addr; // address after end - uint32_t nargs; - uint32_t nret; - bool v0_in; - bool referenced_by_function_pointer; -}; - -bool conservative; - -const uint8_t* text_section; -uint32_t text_section_len; -uint32_t text_vaddr; - -const uint8_t* rodata_section; -uint32_t rodata_section_len; -uint32_t rodata_vaddr; - -const uint8_t* data_section; -uint32_t data_section_len; -uint32_t data_vaddr; - -uint32_t bss_section_len; -uint32_t bss_vaddr; - -vector insns; -set label_addresses; -vector got_globals; -vector got_locals; -uint32_t gp_value; -uint32_t gp_value_adj; - -map symbol_names; - -vector> data_function_pointers; -set la_function_pointers; -map functions; -uint32_t main_addr; -uint32_t mcount_addr; -uint32_t procedure_table_start; -uint32_t procedure_table_len; - -#define FLAG_NO_MEM 1 -#define FLAG_VARARG 2 - -/** - * Struct containing information on external functions that are called using the wrappers in `libc_impl.c`. - * - * name: function name - * params: first char is return type, subsequent chars are argument types. Key to chars used: - * - 'v' void - * - 'i' signed int (int32_t) - * - 'u' unsigned int (uint32_t) - * - 'p' pointer (uintptr_t) - * - 'f' float - * - 'd' double - * - 'l' signed long long (int64_t) - * - 'j' unsigned long long (uint64_t) - * - 't' trampoline - * - * flags: use defines above - */ -const struct ExternFunction { - const char* name; - const char* params; - int flags; -} extern_functions[] = { - { "exit", "vi", 0 }, // override exit from application - { "abort", "v", 0 }, - { "sbrk", "pi", 0 }, - { "malloc", "pu", 0 }, - { "calloc", "puu", 0 }, - { "realloc", "ppu", 0 }, - { "free", "vp", 0 }, - { "fscanf", "ipp", FLAG_VARARG }, - { "printf", "ip", FLAG_VARARG }, - { "sprintf", "ipp", FLAG_VARARG }, - { "fprintf", "ipp", FLAG_VARARG }, - { "_doprnt", "ippp", 0 }, - { "strlen", "up", 0 }, - { "open", "ipii", 0 }, - { "creat", "ipi", 0 }, - { "access", "ipi", 0 }, - { "rename", "ipp", 0 }, - { "utime", "ipp", 0 }, - { "flock", "iii", 0 }, - { "chmod", "ipu", 0 }, - { "umask", "ii", FLAG_NO_MEM }, - { "ecvt", "pdipp", 0 }, - { "fcvt", "pdipp", 0 }, - { "sqrt", "dd", FLAG_NO_MEM }, - { "sqrtf", "ff", FLAG_NO_MEM }, - { "atoi", "ip", 0 }, - { "atol", "ip", 0 }, - { "atof", "dp", 0 }, - { "strtol", "ippi", 0 }, - { "strtoul", "uppi", 0 }, - { "strtoll", "lppi", 0 }, - { "strtoull", "jppi", 0 }, - { "strtod", "dpp", 0 }, - { "strchr", "ppi", 0 }, - { "strrchr", "ppi", 0 }, - { "strcspn", "upp", 0 }, - { "strpbrk", "ppp", 0 }, - { "fstat", "iip", 0 }, - { "stat", "ipp", 0 }, - { "ftruncate", "iii", 0 }, - { "truncate", "ipi", 0}, - { "bcopy", "vppu", 0 }, - { "memcpy", "pppu", 0 }, - { "memccpy", "pppiu", 0 }, - { "read", "iipu", 0 }, - { "write", "iipu", 0 }, - { "fopen", "ppp", 0 }, - { "freopen", "pppp", 0 }, - { "fclose", "ip", 0 }, - { "ftell", "ip", 0 }, - { "rewind", "vp", 0 }, - { "fseek", "ipii", 0 }, - { "lseek", "iiii", 0 }, - { "fflush", "ip", 0 }, - { "fchown", "iiii", 0 }, - { "dup", "ii", 0 }, - { "dup2", "iii", 0 }, - { "pipe", "ip", 0 }, - { "perror", "vp", 0 }, - { "fdopen", "iip", 0 }, - { "memset", "ppiu", 0 }, - { "bcmp", "ippu", 0 }, - { "memcmp", "ippu", 0 }, - { "getpid", "i", FLAG_NO_MEM }, - { "getpgrp", "i", 0 }, - { "remove", "ip", 0 }, - { "unlink", "ip", 0 }, - { "close", "ii", 0 }, - { "strcmp", "ipp", 0 }, - { "strncmp", "ippu", 0 }, - { "strcpy", "ppp", 0 }, - { "strncpy", "pppu", 0 }, - { "strcat", "ppp", 0 }, - { "strncat", "pppu", 0 }, - { "strtok", "ppp", 0 }, - { "strstr", "ppp", 0 }, - { "strdup", "pp", 0 }, - { "toupper", "ii", FLAG_NO_MEM }, - { "tolower", "ii", FLAG_NO_MEM }, - { "gethostname", "ipu", 0 }, - { "isatty", "ii", 0 }, - { "strftime", "upupp", 0 }, - { "times", "ip", 0 }, - { "clock", "i", FLAG_NO_MEM }, - { "ctime", "pp", 0 }, - { "localtime", "pp", 0 }, - { "setvbuf", "ippiu", 0 }, - { "__semgetc", "ip", 0 }, - { "__semputc", "iip", 0 }, - { "fgetc", "ip", 0 }, - { "fgets", "ipip", 0 }, - { "__filbuf", "ip", 0 }, - { "__flsbuf", "iip", 0 }, - { "ungetc", "iip", 0 }, - { "gets", "pp", 0 }, - { "fread", "upuup", 0 }, - { "fwrite", "upuup", 0 }, - { "fputs", "ipp", 0 }, - { "puts", "ip", 0 }, - { "getcwd", "ppu", 0 }, - { "time", "ip", 0 }, - { "bzero", "vpu", 0 }, - { "fp_class_d", "id", FLAG_NO_MEM }, - { "ldexp", "ddi", FLAG_NO_MEM }, - { "__ll_mul", "lll", FLAG_NO_MEM }, - { "__ll_div", "lll", FLAG_NO_MEM }, - { "__ll_rem", "ljl", FLAG_NO_MEM }, - { "__ll_lshift", "llj", FLAG_NO_MEM }, - { "__ll_rshift", "llj", FLAG_NO_MEM }, - { "__ull_div", "jjj", FLAG_NO_MEM }, - { "__ull_rem", "jjj", FLAG_NO_MEM }, - { "__ull_rshift", "jjj", FLAG_NO_MEM }, - { "__d_to_ull", "jd", FLAG_NO_MEM }, - { "__d_to_ll", "ld", FLAG_NO_MEM }, - { "__f_to_ull", "jf", FLAG_NO_MEM }, - { "__f_to_ll", "lf", FLAG_NO_MEM }, - { "__ull_to_f", "fj", FLAG_NO_MEM }, - { "__ll_to_f", "fl", FLAG_NO_MEM }, - { "__ull_to_d", "dj", FLAG_NO_MEM }, - { "__ll_to_d", "dl", FLAG_NO_MEM }, - { "_exit", "vi", 0 }, - { "_cleanup", "v", 0 }, - { "_rld_new_interface", "pu", FLAG_VARARG }, - { "_exithandle", "v", 0 }, - { "_prctl", "ii", FLAG_VARARG }, - { "_atod", "dpii", 0 }, - { "pathconf", "ipi", 0 }, - { "getenv", "pp", 0 }, - { "gettxt", "ppp", 0 }, - { "setlocale", "pip", 0 }, - { "mmap", "ppuiiii", 0 }, - { "munmap", "ipu", 0 }, - { "mprotect", "ipui", 0 }, - { "sysconf", "ii", 0 }, - { "getpagesize", "i", 0 }, - { "strerror", "pi", 0 }, - { "ioctl", "iiu", FLAG_VARARG }, - { "fcntl", "iii", FLAG_VARARG }, - { "signal", "pit", 0 }, - { "sigset", "pit", 0 }, - { "get_fpc_csr", "i", 0 }, - { "set_fpc_csr", "ii", 0 }, - { "setjmp", "ip", 0 }, - { "longjmp", "vpi", 0 }, - { "tempnam", "ppp", 0 }, - { "tmpnam", "pp", 0 }, - { "mktemp", "pp", 0 }, - { "mkstemp", "ip", 0 }, - { "tmpfile", "p", 0 }, - { "wait", "ip", 0 }, - { "kill", "iii", 0 }, - { "execlp", "ip", FLAG_VARARG }, - { "execv", "ipp", 0 }, - { "execvp", "ipp", 0 }, - { "fork", "i", 0 }, - { "system", "ip", 0 }, - { "tsearch", "pppp", 0 }, - { "tfind", "pppp", 0 }, - { "qsort", "vpuut", 0 }, - { "regcmp", "pp", FLAG_VARARG }, - { "regex", "ppp", FLAG_VARARG }, - { "__assert", "vppi", 0 }, -}; - -void disassemble(void) { - uint32_t i; - - RabbitizerConfig_Cfg.misc.omit0XOnSmallImm = true; - RabbitizerConfig_Cfg.misc.opcodeLJust -= 8; - RabbitizerConfig_Cfg.misc.upperCaseImm = false; - insns.reserve(1 + text_section_len / sizeof(uint32_t)); // +1 for dummy instruction - - for (i = 0; i < text_section_len; i += sizeof(uint32_t)) { - uint32_t word = read_u32_be(&text_section[i]); - Insn insn(word, text_vaddr + i); - insns.push_back(insn); - } - - { - // Add dummy NOP instruction to avoid out of bounds - Insn insn(0x00000000, text_vaddr + i); - insn.no_following_successor = true; - insns.push_back(insn); - } -} - -void add_function(uint32_t addr) { - if (addr >= text_vaddr && addr < text_vaddr + text_section_len) { - functions[addr]; - } -} - -map::iterator find_function(uint32_t addr) { - if (functions.size() == 0) { - return functions.end(); - } - - auto it = functions.upper_bound(addr); - - if (it == functions.begin()) { - return functions.end(); - } - - --it; - return it; -} - -rabbitizer::Registers::Cpu::GprO32 get_dest_reg(const Insn& insn) { - switch (insn.instruction.getUniqueId()) { - case rabbitizer::InstrId::UniqueId::cpu_jalr: - // jalr technically modifies rd, so an empty case is here to avoid crashing - break; - - case UniqueId_cpu_li: - case UniqueId_cpu_la: - return insn.lila_dst_reg; - - default: - if (insn.instruction.modifiesRt()) { - return insn.instruction.GetO32_rt(); - } else if (insn.instruction.modifiesRd()) { - return insn.instruction.GetO32_rd(); - } - break; - } - - return rabbitizer::Registers::Cpu::GprO32::GPR_O32_zero; -} - -// try to find a matching LUI for a given register -void link_with_lui(int offset, rabbitizer::Registers::Cpu::GprO32 reg, int mem_imm) { -#define MAX_LOOKBACK 128 - // don't attempt to compute addresses for zero offset - // end search after some sane max number of instructions - int end_search = std::max(0, offset - MAX_LOOKBACK); - - for (int search = offset - 1; search >= end_search; search--) { - switch (insns[search].instruction.getUniqueId()) { - case rabbitizer::InstrId::UniqueId::cpu_lui: - if (reg == insns[search].instruction.GetO32_rt()) { - goto loop_end; - } - continue; - - case rabbitizer::InstrId::UniqueId::cpu_lw: - case rabbitizer::InstrId::UniqueId::cpu_ld: - case rabbitizer::InstrId::UniqueId::cpu_addiu: - case rabbitizer::InstrId::UniqueId::cpu_add: - case rabbitizer::InstrId::UniqueId::cpu_sub: - case rabbitizer::InstrId::UniqueId::cpu_subu: - if (reg == get_dest_reg(insns[search])) { - if ((insns[search].instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_lw) && - insns[search].instruction.GetO32_rs() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_gp) { - int mem_imm0 = insns[search].instruction.getProcessedImmediate(); - uint32_t got_entry = (mem_imm0 + gp_value_adj) / sizeof(uint32_t); - - if (got_entry < got_locals.size()) { - // used for static functions - uint32_t addr = got_locals[got_entry] + mem_imm; - insns[search].linked_insn = offset; - insns[search].linked_value = addr; - insns[offset].linked_insn = search; - insns[offset].linked_value = addr; - - // Patch instruction to contain full address - insns[search].lila_dst_reg = get_dest_reg(insns[search]); - insns[search].patchAddress(UniqueId_cpu_la, addr); - - // Patch instruction to have offset 0 - switch (insns[offset].instruction.getUniqueId()) { - case rabbitizer::InstrId::UniqueId::cpu_addiu: { - rabbitizer::Registers::Cpu::GprO32 dst_reg = insns[offset].instruction.GetO32_rt(); - insns[offset].patchInstruction(rabbitizer::InstrId::UniqueId::cpu_move); - // Patch the destination register too - insns[offset].instruction.Set_rd(dst_reg); - } - - if (addr >= text_vaddr && addr < text_vaddr + text_section_len) { - add_function(addr); - } - goto loop_end; - - case rabbitizer::InstrId::UniqueId::cpu_lb: - case rabbitizer::InstrId::UniqueId::cpu_lbu: - case rabbitizer::InstrId::UniqueId::cpu_sb: - case rabbitizer::InstrId::UniqueId::cpu_lh: - case rabbitizer::InstrId::UniqueId::cpu_lhu: - case rabbitizer::InstrId::UniqueId::cpu_sh: - case rabbitizer::InstrId::UniqueId::cpu_lw: - case rabbitizer::InstrId::UniqueId::cpu_sw: - case rabbitizer::InstrId::UniqueId::cpu_ldc1: - case rabbitizer::InstrId::UniqueId::cpu_lwc1: - case rabbitizer::InstrId::UniqueId::cpu_swc1: - insns[offset].patchImmediate(0); - goto loop_end; - - default: - assert(0 && "Unsupported instruction type"); - } - } - goto loop_end; - } else { - // ignore: reg is pointer, offset is probably struct data member - goto loop_end; - } - } - - continue; - - case rabbitizer::InstrId::UniqueId::cpu_jr: - if ((insns[search].instruction.GetO32_rs() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_ra) && - (offset - search >= 2)) { - // stop looking when previous `jr ra` is hit, - // but ignore if `offset` is branch delay slot for this `jr ra` - goto loop_end; - } - continue; - - default: - continue; - } - } -loop_end:; -} - -// for a given `jalr t9`, find the matching t9 load -void link_with_jalr(int offset) { - // end search after some sane max number of instructions - int end_search = std::max(0, offset - MAX_LOOKBACK); - - for (int search = offset - 1; search >= end_search; search--) { - if (get_dest_reg(insns[search]) == rabbitizer::Registers::Cpu::GprO32::GPR_O32_t9) { - // should be a switch with returns - switch (insns[search].instruction.getUniqueId()) { - case rabbitizer::InstrId::UniqueId::cpu_lw: - case UniqueId_cpu_la: - if (insns[search].is_global_got_memop || - (insns[search].instruction.getUniqueId() == UniqueId_cpu_la)) { - insns[search].linked_insn = offset; - insns[offset].linked_insn = search; - insns[offset].linked_value = insns[search].linked_value; - - insns[offset].patchAddress(rabbitizer::InstrId::UniqueId::cpu_jal, insns[search].linked_value); - - insns[search].patchInstruction(rabbitizer::InstrId::UniqueId::cpu_nop); - insns[search].is_global_got_memop = false; - - add_function(insns[search].linked_value); - } - return; - - case rabbitizer::InstrId::UniqueId::cpu_addiu: - if (insns[search].linked_insn != -1) { - uint32_t first = insns[search].linked_insn; - - // not describing as patched since instruction not edited - insns[search].linked_insn = offset; - insns[offset].linked_insn = first; - insns[offset].linked_value = insns[search].linked_value; - } - return; - - case rabbitizer::InstrId::UniqueId::cpu_ld: - case rabbitizer::InstrId::UniqueId::cpu_addu: - case rabbitizer::InstrId::UniqueId::cpu_add: - case rabbitizer::InstrId::UniqueId::cpu_sub: - case rabbitizer::InstrId::UniqueId::cpu_subu: - return; - - default: - break; - } - } else if ((insns[search].instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_jr) && - (insns[search].instruction.GetO32_rs() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_ra)) { - // stop looking when previous `jr ra` is hit - return; - } - } -} - -// TODO: uniformise use of insn vs insns[i] -void pass1(void) { - for (size_t i = 0; i < insns.size(); i++) { - Insn& insn = insns[i]; - - // TODO: replace with BAL. Or just fix properly - if (insn.instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_bal) { - insn.patchAddress(rabbitizer::InstrId::UniqueId::cpu_jal, - insn.instruction.getVram() + insn.instruction.getBranchOffset()); - } - - if (insn.instruction.isJump()) { - if (insn.instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_jal || - insn.instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_j) { - uint32_t target = insn.getAddress(); - - label_addresses.insert(target); - add_function(target); - } else if (insn.instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_jr) { - // sltiu $at, $ty, z - // sw $reg, offset($sp) (very seldom, one or more, usually in func entry) - // lw $gp, offset($sp) (if PIC, and very seldom) - // beqz $at, .L - // some other instruction (not always) - // lui $at, %hi(jtbl) - // sll $tx, $ty, 2 - // addu $at, $at, $tx - // lw $tx, %lo(jtbl)($at) - // nop (code compiled with 5.3) - // addu $tx, $tx, $gp (if PIC) - // jr $tx - - // IDO 7.1: - // lw at,offset(gp) - // andi t9,t8,0x3f - // sll t9,t9,0x2 - // addu at,at,t9 - // lw t9,offset(at) - // addu t9,t9,gp - // jr t9 - - // IDO 5.3: - // lw at,offset(gp) - // andi t3,t2,0x3f - // sll t3,t3,0x2 - // addu at,at,t3 - // something - // lw t3,offset(at) - // something - // addu t3,t3,gp - // jr t3 - if (i >= 7 && rodata_section != NULL) { - bool is_pic = - (insns[i - 1].instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_addu) && - (insns[i - 1].instruction.GetO32_rt() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_gp); - bool has_nop = - insns[i - is_pic - 1].instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_nop; - bool has_extra = insns[i - is_pic - has_nop - 5].instruction.getUniqueId() != - rabbitizer::InstrId::UniqueId::cpu_beqz; - int lw = i - (int)is_pic - (int)has_nop - 1; - - if (insns[lw].instruction.getUniqueId() != rabbitizer::InstrId::UniqueId::cpu_lw) { - --lw; - } - - if ((insns[lw].instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_lw) && - (insns[lw].linked_insn != -1)) { - int sltiu_index = -1; - int andi_index = -1; - uint32_t addu_index = lw - 1; - uint32_t num_cases; - bool found = false; - bool and_variant = false; - int end = 14; - - if (insns[addu_index].instruction.getUniqueId() != rabbitizer::InstrId::UniqueId::cpu_addu) { - --addu_index; - } - - if (insns[addu_index].instruction.getUniqueId() != rabbitizer::InstrId::UniqueId::cpu_addu) { - goto skip; - } - - if (insns[addu_index - 1].instruction.getUniqueId() != rabbitizer::InstrId::UniqueId::cpu_sll) { - goto skip; - } - - if (get_dest_reg(insns[addu_index - 1]) != insn.instruction.GetO32_rs()) { - goto skip; - } - - for (int j = 3; j <= 4; j++) { - if (insns[lw - j].instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_andi) { - andi_index = lw - j; - break; - } - } - - if (i == 368393) { - // In copt - end = 18; - } - - for (int j = 5; j <= end; j++) { - if ((insns[lw - has_extra - j].instruction.getUniqueId() == - rabbitizer::InstrId::UniqueId::cpu_sltiu) && - (insns[lw - has_extra - j].instruction.GetO32_rt() == - rabbitizer::Registers::Cpu::GprO32::GPR_O32_at)) { - sltiu_index = j; - break; - } - - if (insns[lw - has_extra - j].instruction.getUniqueId() == - rabbitizer::InstrId::UniqueId::cpu_jr) { - // Prevent going into a previous switch - break; - } - } - - if (sltiu_index != -1) { - andi_index = -1; - } - - if (sltiu_index != -1 && insns[lw - has_extra - sltiu_index].instruction.getUniqueId() == - rabbitizer::InstrId::UniqueId::cpu_sltiu) { - num_cases = insns[lw - has_extra - sltiu_index].instruction.getProcessedImmediate(); - found = true; - } else if (andi_index != -1) { - num_cases = insns[andi_index].instruction.getProcessedImmediate() + 1; - found = true; - and_variant = true; - } else if (i == 219382) { - // Special hard case in copt where the initial sltiu is in another basic block - found = true; - num_cases = 13; - } else if (i == 370995) { - // Special hard case in copt where the initial sltiu is in another basic block - found = true; - num_cases = 12; - } - - if (found) { - uint32_t jtbl_addr = insns[lw].linked_value; - - if (is_pic) { - insns[i - 1].patchInstruction(rabbitizer::InstrId::UniqueId::cpu_nop); - } - - insn.jtbl_addr = jtbl_addr; - insn.num_cases = num_cases; - insn.index_reg = insns[addu_index - 1].instruction.GetO32_rt(); - insns[lw].patchInstruction(rabbitizer::InstrId::UniqueId::cpu_nop); - - insns[addu_index].patchInstruction(rabbitizer::InstrId::UniqueId::cpu_nop); - - insns[addu_index - 1].patchInstruction(rabbitizer::InstrId::UniqueId::cpu_nop); - - if (!and_variant) { - insns[addu_index - 2].patchInstruction(rabbitizer::InstrId::UniqueId::cpu_nop); - } - - if (jtbl_addr < rodata_vaddr || - jtbl_addr + num_cases * sizeof(uint32_t) > rodata_vaddr + rodata_section_len) { - fprintf(stderr, "jump table outside rodata\n"); - exit(EXIT_FAILURE); - } - - for (uint32_t i = 0; i < num_cases; i++) { - uint32_t target_addr = - read_u32_be(rodata_section + (jtbl_addr - rodata_vaddr) + i * sizeof(uint32_t)); - - target_addr += gp_value; - // printf("%08X\n", target_addr); - label_addresses.insert(target_addr); - } - } - skip:; - } - } - } else if (insn.instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_jalr) { - // empty - } else { - assert(!"Unreachable code"); - } - } else if (insn.instruction.isBranch()) { - uint32_t target = insn.getAddress(); - - label_addresses.insert(target); - } - - switch (insns[i].instruction.getUniqueId()) { - // find floating point LI - case rabbitizer::InstrId::UniqueId::cpu_mtc1: { - rabbitizer::Registers::Cpu::GprO32 rt = insns[i].instruction.GetO32_rt(); - - for (int s = i - 1; s >= 0; s--) { - switch (insns[s].instruction.getUniqueId()) { - case rabbitizer::InstrId::UniqueId::cpu_lui: - if (insns[s].instruction.GetO32_rt() == rt) { - float f; - uint32_t lui_imm = insns[s].instruction.getProcessedImmediate() << 16; - - memcpy(&f, &lui_imm, sizeof(f)); - // link up the LUI with this instruction and the float - insns[s].linked_insn = i; - insns[s].linked_float = f; - // rewrite LUI instruction to be LI - insns[s].lila_dst_reg = get_dest_reg(insns[s]); - insns[s].patchInstruction(UniqueId_cpu_li); - insns[s].patchImmediate(lui_imm); - } - goto loop_end; - - case rabbitizer::InstrId::UniqueId::cpu_lw: - case rabbitizer::InstrId::UniqueId::cpu_ld: - case rabbitizer::InstrId::UniqueId::cpu_lh: - case rabbitizer::InstrId::UniqueId::cpu_lhu: - case rabbitizer::InstrId::UniqueId::cpu_lb: - case rabbitizer::InstrId::UniqueId::cpu_lbu: - case rabbitizer::InstrId::UniqueId::cpu_addiu: - if (rt == insns[s].instruction.GetO32_rt()) { - goto loop_end; - } - continue; - - case rabbitizer::InstrId::UniqueId::cpu_add: - case rabbitizer::InstrId::UniqueId::cpu_sub: - case rabbitizer::InstrId::UniqueId::cpu_subu: - if (rt == insns[s].instruction.GetO32_rd()) { - goto loop_end; - } - continue; - - case rabbitizer::InstrId::UniqueId::cpu_jr: - if (insns[s].instruction.GetO32_rs() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_ra) { - goto loop_end; - } - continue; - - default: - continue; - } - } - loop_end:; - } break; - - case rabbitizer::InstrId::UniqueId::cpu_sd: - case rabbitizer::InstrId::UniqueId::cpu_sw: - case rabbitizer::InstrId::UniqueId::cpu_sh: - case rabbitizer::InstrId::UniqueId::cpu_sb: - case rabbitizer::InstrId::UniqueId::cpu_lb: - case rabbitizer::InstrId::UniqueId::cpu_lbu: - case rabbitizer::InstrId::UniqueId::cpu_ld: - case rabbitizer::InstrId::UniqueId::cpu_ldl: - case rabbitizer::InstrId::UniqueId::cpu_ldr: - case rabbitizer::InstrId::UniqueId::cpu_lh: - case rabbitizer::InstrId::UniqueId::cpu_lhu: - case rabbitizer::InstrId::UniqueId::cpu_lw: - case rabbitizer::InstrId::UniqueId::cpu_lwu: - case rabbitizer::InstrId::UniqueId::cpu_ldc1: - case rabbitizer::InstrId::UniqueId::cpu_lwc1: - case rabbitizer::InstrId::UniqueId::cpu_lwc2: - case rabbitizer::InstrId::UniqueId::cpu_swc1: - case rabbitizer::InstrId::UniqueId::cpu_swc2: { - rabbitizer::Registers::Cpu::GprO32 mem_rs = insns[i].instruction.GetO32_rs(); - int32_t mem_imm = insns[i].instruction.getProcessedImmediate(); - - if (mem_rs == rabbitizer::Registers::Cpu::GprO32::GPR_O32_gp) { - unsigned int got_entry = (mem_imm + gp_value_adj) / sizeof(unsigned int); - - if (got_entry >= got_locals.size()) { - got_entry -= got_locals.size(); - if (got_entry < got_globals.size()) { - assert(insn.instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_lw); - unsigned int dest_vaddr = got_globals[got_entry]; - - insns[i].is_global_got_memop = true; - insns[i].linked_value = dest_vaddr; - - // patch to LA - insns[i].lila_dst_reg = get_dest_reg(insns[i]); - insns[i].patchAddress(UniqueId_cpu_la, dest_vaddr); - } - } - } else { - link_with_lui(i, mem_rs, mem_imm); - } - } break; - - case rabbitizer::InstrId::UniqueId::cpu_addiu: - case rabbitizer::InstrId::UniqueId::cpu_ori: { - // could be insn? - rabbitizer::Registers::Cpu::GprO32 rt = insns[i].instruction.GetO32_rt(); - rabbitizer::Registers::Cpu::GprO32 rs = insns[i].instruction.GetO32_rs(); - int32_t imm = insns[i].instruction.getProcessedImmediate(); - - if (rs == rabbitizer::Registers::Cpu::GprO32::GPR_O32_zero) { // becomes LI - insns[i].lila_dst_reg = get_dest_reg(insns[i]); - insns[i].patchInstruction(UniqueId_cpu_li); - insns[i].patchImmediate(imm); - } else if (rt != rabbitizer::Registers::Cpu::GprO32::GPR_O32_gp) { // only look for LUI if rt and rs are - // the same - link_with_lui(i, rs, imm); - } - } break; - - case rabbitizer::InstrId::UniqueId::cpu_jalr: { - rabbitizer::Registers::Cpu::GprO32 rs = insn.instruction.GetO32_rs(); - - if (rs == rabbitizer::Registers::Cpu::GprO32::GPR_O32_t9) { - link_with_jalr(i); - if (insn.linked_insn != -1) { - insn.patchAddress(rabbitizer::InstrId::UniqueId::cpu_jal, insn.linked_value); - - label_addresses.insert(insn.linked_value); - add_function(insn.linked_value); - } - } - } break; - - default: - break; - } - - if ((insn.instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_addu) && - (insn.instruction.GetO32_rd() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_gp) && - (insn.instruction.GetO32_rs() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_gp) && - (insn.instruction.GetO32_rt() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_t9) && i >= 2) { - for (size_t j = i - 2; j <= i; j++) { - insns[j].patchInstruction(rabbitizer::InstrId::UniqueId::cpu_nop); - } - } - } -} - -uint32_t addr_to_i(uint32_t addr) { - return (addr - text_vaddr) / 4; -} - -void pass2(void) { - // Find returns in each function - for (size_t i = 0; i < insns.size(); i++) { - uint32_t addr = text_vaddr + i * 4; - Insn& insn = insns[i]; - - if ((insn.instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_jr) && - (insn.instruction.GetO32_rs() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_ra)) { - auto it = find_function(addr); - assert(it != functions.end()); - - it->second.returns.push_back(addr + 4); - } - - if (insn.instruction.getUniqueId() == UniqueId_cpu_la) { - uint32_t faddr = insn.getAddress(); - - if ((text_vaddr <= faddr) && (faddr < text_vaddr + text_section_len)) { - la_function_pointers.insert(faddr); - functions[faddr].referenced_by_function_pointer = true; -#if INSPECT_FUNCTION_POINTERS - fprintf(stderr, "la function pointer: 0x%x at 0x%x\n", faddr, addr); -#endif - } - } - } - - for (auto it = functions.begin(); it != functions.end(); ++it) { - if (it->second.returns.size() == 0) { - uint32_t i = addr_to_i(it->first); - auto str_it = symbol_names.find(it->first); - - if (str_it != symbol_names.end() && str_it->second == "__start") { - - } else if (str_it != symbol_names.end() && str_it->second == "xmalloc") { - // orig 5.3: - /* - 496bf4: 3c1c0fb9 lui gp,0xfb9 - 496bf8: 279c366c addiu gp,gp,13932 - 496bfc: 0399e021 addu gp,gp,t9 - 496c00: 27bdffd8 addiu sp,sp,-40 - 496c04: 8f858de8 lw a1,-29208(gp) - 496c08: 10000006 b 496c24 - 496c0c: afbf0020 sw ra,32(sp) - */ - - // jal alloc_new - // lui $a1, malloc_scb - // jr $ra - // nop - uint32_t alloc_new_addr = text_vaddr + (i + 7) * 4; - - insns[i].patchAddress(rabbitizer::InstrId::UniqueId::cpu_jal, alloc_new_addr); - - assert(symbol_names.count(alloc_new_addr) && symbol_names[alloc_new_addr] == "alloc_new"); - i++; - - // LA - if (insns[i + 5].instruction.getUniqueId() == UniqueId_cpu_la) { - // 7.1 - insns[i] = insns[i + 5]; - } else { - // 5.3 - insns[i] = insns[i + 3]; - } - i++; - - // JR $RA - insns[i].patched = true; - insns[i].instruction = rabbitizer::InstructionCpu(0x03E00008, insns[i].instruction.getVram()); - it->second.returns.push_back(text_vaddr + i * 4 + 4); - i++; - - for (uint32_t j = 0; j < 4; j++) { - // NOP - insns[i].patched = true; - insns[i].instruction = rabbitizer::InstructionCpu(0, insns[i].instruction.getVram()); - i++; - } - } else if (str_it != symbol_names.end() && str_it->second == "xfree") { - // jal alloc_dispose - // lui $a1, malloc_scb - // jr $ra - // nop - uint32_t alloc_dispose_addr = text_vaddr + (i + 4) * 4; - - if (symbol_names.count(alloc_dispose_addr + 4) && - symbol_names[alloc_dispose_addr + 4] == "alloc_dispose") { - alloc_dispose_addr += 4; - } - - insns[i].patchAddress(rabbitizer::InstrId::UniqueId::cpu_jal, alloc_dispose_addr); - assert(symbol_names.count(alloc_dispose_addr) && symbol_names[alloc_dispose_addr] == "alloc_dispose"); - i++; - - insns[i] = insns[i + 2]; - i++; - - // JR $RA - insns[i].patched = true; - insns[i].instruction = rabbitizer::InstructionCpu(0x03E00008, insns[i].instruction.getVram()); - it->second.returns.push_back(text_vaddr + i * 4 + 4); - i++; - - // NOP - insns[i].patched = true; - insns[i].instruction = rabbitizer::InstructionCpu(0, insns[i].instruction.getVram()); - } else if ((insns[i].instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_lw) && - (insns[i + 1].instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_move) && - (insns[i + 2].instruction.getUniqueId() == rabbitizer::InstrId::UniqueId::cpu_jalr)) { - /* - 408f50: 8f998010 lw t9,-32752(gp) - 408f54: 03e07821 move t7,ra - 408f58: 0320f809 jalr t9 - */ - } else if (it->first > mcount_addr) { - fprintf(stderr, "no ret: 0x%x\n", it->first); - abort(); - } - } - - auto next = it; - - ++next; - if (next == functions.end()) { - it->second.end_addr = text_vaddr + text_section_len; - } else { - it->second.end_addr = next->first; - } - } -} - -void add_edge(uint32_t from, uint32_t to, bool function_entry = false, bool function_exit = false, - bool extern_function = false, bool function_pointer = false) { - Edge fe = Edge(), be = Edge(); - - fe.i = to; - be.i = from; - fe.function_entry = function_entry; - be.function_entry = function_entry; - fe.function_exit = function_exit; - be.function_exit = function_exit; - fe.extern_function = extern_function; - be.extern_function = extern_function; - fe.function_pointer = function_pointer; - be.function_pointer = function_pointer; - insns[from].successors.push_back(fe); - insns[to].predecessors.push_back(be); -} - -void pass3(void) { - // Build graph - for (size_t i = 0; i < insns.size(); i++) { - uint32_t addr = text_vaddr + i * 4; - Insn& insn = insns[i]; - - if (insn.no_following_successor) { - continue; - } - - switch (insn.instruction.getUniqueId()) { - case rabbitizer::InstrId::UniqueId::cpu_beq: - case rabbitizer::InstrId::UniqueId::cpu_bgez: - case rabbitizer::InstrId::UniqueId::cpu_bgtz: - case rabbitizer::InstrId::UniqueId::cpu_blez: - case rabbitizer::InstrId::UniqueId::cpu_bltz: - case rabbitizer::InstrId::UniqueId::cpu_bne: - case rabbitizer::InstrId::UniqueId::cpu_beqz: - case rabbitizer::InstrId::UniqueId::cpu_bnez: - case rabbitizer::InstrId::UniqueId::cpu_bc1f: - case rabbitizer::InstrId::UniqueId::cpu_bc1t: - add_edge(i, i + 1); - add_edge(i + 1, addr_to_i(insn.getAddress())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_beql: - case rabbitizer::InstrId::UniqueId::cpu_bgezl: - case rabbitizer::InstrId::UniqueId::cpu_bgtzl: - case rabbitizer::InstrId::UniqueId::cpu_blezl: - case rabbitizer::InstrId::UniqueId::cpu_bltzl: - case rabbitizer::InstrId::UniqueId::cpu_bnel: - case rabbitizer::InstrId::UniqueId::cpu_bc1fl: - case rabbitizer::InstrId::UniqueId::cpu_bc1tl: - add_edge(i, i + 1); - add_edge(i, i + 2); - add_edge(i + 1, addr_to_i(insn.getAddress())); - insns[i + 1].no_following_successor = true; // don't inspect delay slot - break; - - case rabbitizer::InstrId::UniqueId::cpu_b: - case rabbitizer::InstrId::UniqueId::cpu_j: - add_edge(i, i + 1); - add_edge(i + 1, addr_to_i(insn.getAddress())); - insns[i + 1].no_following_successor = true; // don't inspect delay slot - break; - - case rabbitizer::InstrId::UniqueId::cpu_jr: { - add_edge(i, i + 1); - - if (insn.jtbl_addr != 0) { - uint32_t jtbl_pos = insn.jtbl_addr - rodata_vaddr; - - assert(jtbl_pos < rodata_section_len && - jtbl_pos + insn.num_cases * sizeof(uint32_t) <= rodata_section_len); - - for (uint32_t j = 0; j < insn.num_cases; j++) { - uint32_t dest_addr = read_u32_be(rodata_section + jtbl_pos + j * sizeof(uint32_t)) + gp_value; - - add_edge(i + 1, addr_to_i(dest_addr)); - } - } else { - assert(insn.instruction.GetO32_rs() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_ra && - "jump to address in register not supported"); - } - - insns[i + 1].no_following_successor = true; // don't inspect delay slot - break; - } - - case rabbitizer::InstrId::UniqueId::cpu_jal: { - add_edge(i, i + 1); - - uint32_t dest = insn.getAddress(); - - if (dest > mcount_addr && dest >= text_vaddr && dest < text_vaddr + text_section_len) { - add_edge(i + 1, addr_to_i(dest), true); - - auto it = functions.find(dest); - assert(it != functions.end()); - - for (uint32_t ret_instr : it->second.returns) { - add_edge(addr_to_i(ret_instr), i + 2, false, true); - } - } else { - add_edge(i + 1, i + 2, false, false, true); - } - - insns[i + 1].no_following_successor = true; // don't inspect delay slot - break; - } - - case rabbitizer::InstrId::UniqueId::cpu_jalr: - // function pointer - add_edge(i, i + 1); - add_edge(i + 1, i + 2, false, false, false, true); - insns[i + 1].no_following_successor = true; // don't inspect delay slot - break; - - default: - add_edge(i, i + 1); - break; - } - } -} - -#define GPR_O32_hi (rabbitizer::Registers::Cpu::GprO32)((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_ra + 1) -#define GPR_O32_lo (rabbitizer::Registers::Cpu::GprO32)((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_ra + 2) - -uint64_t map_reg(rabbitizer::Registers::Cpu::GprO32 reg) { - return (uint64_t)1 << ((int)reg - (int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_zero + 1); -} - -uint64_t temporary_regs(void) { - // clang-format off - return - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_t0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_t1) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_t2) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_t3) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_t4) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_t5) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_t6) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_t7) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_t8) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_t9); - // clang-format on -} - -typedef enum { - /* 0 */ TYPE_NOP, // No arguments - /* 1 */ TYPE_S, // in - /* 2 */ TYPE_D, // 1 out - /* 3 */ TYPE_D_S, // out, in -} TYPE; - -TYPE insn_to_type(Insn& insn) { - switch (insn.instruction.getUniqueId()) { - case rabbitizer::InstrId::UniqueId::cpu_add_s: - case rabbitizer::InstrId::UniqueId::cpu_add_d: - return TYPE_NOP; - - case rabbitizer::InstrId::UniqueId::cpu_add: - case rabbitizer::InstrId::UniqueId::cpu_addu: - return TYPE_D_S; - - case rabbitizer::InstrId::UniqueId::cpu_addi: - case rabbitizer::InstrId::UniqueId::cpu_addiu: - case rabbitizer::InstrId::UniqueId::cpu_andi: - case rabbitizer::InstrId::UniqueId::cpu_ori: - case rabbitizer::InstrId::UniqueId::cpu_lb: - case rabbitizer::InstrId::UniqueId::cpu_lbu: - case rabbitizer::InstrId::UniqueId::cpu_lh: - case rabbitizer::InstrId::UniqueId::cpu_lhu: - case rabbitizer::InstrId::UniqueId::cpu_lw: - case rabbitizer::InstrId::UniqueId::cpu_lwl: - // case rabbitizer::InstrId::UniqueId::cpu_lwr: - case rabbitizer::InstrId::UniqueId::cpu_move: - case rabbitizer::InstrId::UniqueId::cpu_negu: - case rabbitizer::InstrId::UniqueId::cpu_not: - case rabbitizer::InstrId::UniqueId::cpu_sll: - case rabbitizer::InstrId::UniqueId::cpu_slti: - case rabbitizer::InstrId::UniqueId::cpu_sltiu: - case rabbitizer::InstrId::UniqueId::cpu_sra: - case rabbitizer::InstrId::UniqueId::cpu_srl: - case rabbitizer::InstrId::UniqueId::cpu_xori: - return TYPE_D_S; - - case rabbitizer::InstrId::UniqueId::cpu_mfhi: - return TYPE_D_S; - - case rabbitizer::InstrId::UniqueId::cpu_mflo: - return TYPE_D_S; - - case rabbitizer::InstrId::UniqueId::cpu_and: - case rabbitizer::InstrId::UniqueId::cpu_or: - case rabbitizer::InstrId::UniqueId::cpu_nor: - case rabbitizer::InstrId::UniqueId::cpu_sllv: - case rabbitizer::InstrId::UniqueId::cpu_slt: - case rabbitizer::InstrId::UniqueId::cpu_sltu: - case rabbitizer::InstrId::UniqueId::cpu_srav: - case rabbitizer::InstrId::UniqueId::cpu_srlv: - case rabbitizer::InstrId::UniqueId::cpu_subu: - case rabbitizer::InstrId::UniqueId::cpu_xor: - return TYPE_D_S; - - case rabbitizer::InstrId::UniqueId::cpu_cfc1: - case rabbitizer::InstrId::UniqueId::cpu_mfc1: - case UniqueId_cpu_li: - case UniqueId_cpu_la: - case rabbitizer::InstrId::UniqueId::cpu_lui: - return TYPE_D; - - case rabbitizer::InstrId::UniqueId::cpu_ctc1: - case rabbitizer::InstrId::UniqueId::cpu_bgez: - case rabbitizer::InstrId::UniqueId::cpu_bgezl: - case rabbitizer::InstrId::UniqueId::cpu_bgtz: - case rabbitizer::InstrId::UniqueId::cpu_bgtzl: - case rabbitizer::InstrId::UniqueId::cpu_blez: - case rabbitizer::InstrId::UniqueId::cpu_blezl: - case rabbitizer::InstrId::UniqueId::cpu_bltz: - case rabbitizer::InstrId::UniqueId::cpu_bltzl: - case rabbitizer::InstrId::UniqueId::cpu_beqz: - case rabbitizer::InstrId::UniqueId::cpu_bnez: - case rabbitizer::InstrId::UniqueId::cpu_mtc1: - return TYPE_S; - - case rabbitizer::InstrId::UniqueId::cpu_beq: - case rabbitizer::InstrId::UniqueId::cpu_beql: - case rabbitizer::InstrId::UniqueId::cpu_bne: - case rabbitizer::InstrId::UniqueId::cpu_bnel: - case rabbitizer::InstrId::UniqueId::cpu_sb: - case rabbitizer::InstrId::UniqueId::cpu_sh: - case rabbitizer::InstrId::UniqueId::cpu_sw: - case rabbitizer::InstrId::UniqueId::cpu_swl: - // case rabbitizer::InstrId::UniqueId::cpu_swr: - case rabbitizer::InstrId::UniqueId::cpu_tne: - case rabbitizer::InstrId::UniqueId::cpu_teq: - case rabbitizer::InstrId::UniqueId::cpu_tge: - case rabbitizer::InstrId::UniqueId::cpu_tgeu: - case rabbitizer::InstrId::UniqueId::cpu_tlt: - return TYPE_S; - - case rabbitizer::InstrId::UniqueId::cpu_div: - return TYPE_D_S; - - case rabbitizer::InstrId::UniqueId::cpu_div_s: - case rabbitizer::InstrId::UniqueId::cpu_div_d: - return TYPE_NOP; - - case rabbitizer::InstrId::UniqueId::cpu_divu: - case rabbitizer::InstrId::UniqueId::cpu_mult: - case rabbitizer::InstrId::UniqueId::cpu_multu: - return TYPE_D_S; - - case rabbitizer::InstrId::UniqueId::cpu_neg_s: - case rabbitizer::InstrId::UniqueId::cpu_neg_d: - return TYPE_NOP; - - case rabbitizer::InstrId::UniqueId::cpu_jalr: - return TYPE_S; - - case rabbitizer::InstrId::UniqueId::cpu_jr: - if (insn.jtbl_addr != 0) { - insn.instruction.Set_rs(insn.index_reg); - } - if (insn.instruction.GetO32_rs() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_ra) { - return TYPE_NOP; - } - return TYPE_S; - - case rabbitizer::InstrId::UniqueId::cpu_lwc1: - case rabbitizer::InstrId::UniqueId::cpu_ldc1: - case rabbitizer::InstrId::UniqueId::cpu_swc1: - case rabbitizer::InstrId::UniqueId::cpu_sdc1: - return TYPE_S; - - default: - return TYPE_NOP; - } -} - -uint64_t get_dest_reg_mask(const Insn& insn) { - switch (insn.instruction.getUniqueId()) { - case rabbitizer::InstrId::UniqueId::cpu_div: - case rabbitizer::InstrId::UniqueId::cpu_divu: - case rabbitizer::InstrId::UniqueId::cpu_mult: - case rabbitizer::InstrId::UniqueId::cpu_multu: - return map_reg(GPR_O32_lo) | map_reg(GPR_O32_hi); - - default: - return map_reg(get_dest_reg(insn)); - } -} - -uint64_t get_single_source_reg_mask(const rabbitizer::InstructionCpu& instr) { - switch (instr.getUniqueId()) { - case rabbitizer::InstrId::UniqueId::cpu_mflo: - return map_reg(GPR_O32_lo); - case rabbitizer::InstrId::UniqueId::cpu_mfhi: - return map_reg(GPR_O32_hi); - - default: - break; - } - if (instr.hasOperandAlias(rabbitizer::OperandType::cpu_rs)) { - return map_reg(instr.GetO32_rs()); - } else if (instr.hasOperandAlias(rabbitizer::OperandType::cpu_rt)) { - return map_reg(instr.GetO32_rt()); - } else { - return 0; - } -} - -uint64_t get_all_source_reg_mask(const rabbitizer::InstructionCpu& instr) { - uint64_t ret = 0; - - switch (instr.getUniqueId()) { - case rabbitizer::InstrId::UniqueId::cpu_mflo: - ret |= map_reg(GPR_O32_lo); - case rabbitizer::InstrId::UniqueId::cpu_mfhi: - ret |= map_reg(GPR_O32_hi); - - default: - break; - } - - if (instr.hasOperandAlias(rabbitizer::OperandType::cpu_rs)) { - ret |= map_reg(instr.GetO32_rs()); - } - if (instr.hasOperandAlias(rabbitizer::OperandType::cpu_rt) && !instr.modifiesRt()) { - ret |= map_reg(instr.GetO32_rt()); - } - return ret; -} - -void pass4(void) { - vector q; // TODO: Why is this called q? - uint64_t livein_func_start = 1U | map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a1) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_sp) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_zero); - - q.push_back(main_addr); - insns[addr_to_i(main_addr)].f_livein = livein_func_start; - - for (auto& it : data_function_pointers) { - q.push_back(it.second); - insns[addr_to_i(it.second)].f_livein = livein_func_start | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a2) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a3); - } - - for (auto& addr : la_function_pointers) { - q.push_back(addr); - insns[addr_to_i(addr)].f_livein = livein_func_start | map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a2) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a3); - } - - while (!q.empty()) { - uint32_t addr = q.back(); - q.pop_back(); - uint32_t i = addr_to_i(addr); - Insn& insn = insns[i]; - uint64_t live = insn.f_livein | 1U; - uint64_t src_regs_map; - - switch (insn_to_type(insn)) { - case TYPE_D: - live |= get_dest_reg_mask(insn); - break; - - case TYPE_D_S: - src_regs_map = get_all_source_reg_mask(insn.instruction); - if ((live & src_regs_map) == src_regs_map) { - live |= get_dest_reg_mask(insn); - } - break; - - case TYPE_S: - case TYPE_NOP: - break; - } - - if ((insn.f_liveout | live) == insn.f_liveout) { - // No new bits - continue; - } - - live |= insn.f_liveout; - insn.f_liveout = live; - - bool function_entry = false; - - for (Edge& e : insn.successors) { - uint64_t new_live = live; - - if (e.function_exit) { - new_live &= 1U | map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_zero); - } else if (e.function_entry) { - new_live &= 1U | map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a1) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a2) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a3) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_sp) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_zero); - function_entry = true; - } else if (e.extern_function) { - string_view name; - size_t extern_function_id; - uint32_t address = insns[i - 1].getAddress(); - - // TODO: Can this only ever be a J-type instruction? - auto it = symbol_names.find(address); - const ExternFunction* found_fn = nullptr; - - if (it != symbol_names.end()) { - name = it->second; - - for (auto& fn : extern_functions) { - if (name == fn.name) { - found_fn = &fn; - break; - } - } - - if (found_fn == nullptr) { - fprintf(stderr, "missing extern function: %s\n", string(name).c_str()); - } - } - - assert(found_fn); - - char ret_type = found_fn->params[0]; - - new_live &= ~(map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a1) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a2) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a3) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1) | temporary_regs()); - - switch (ret_type) { - case 'i': - case 'u': - case 'p': - new_live |= map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0); - break; - - case 'f': - break; - - case 'd': - break; - - case 'v': - break; - - case 'l': - case 'j': - new_live |= map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1); - break; - } - } else if (e.function_pointer) { - new_live &= ~(map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a1) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a2) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a3) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1) | temporary_regs()); - new_live |= map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1); - } - - if ((insns[e.i].f_livein | new_live) != insns[e.i].f_livein) { - insns[e.i].f_livein |= new_live; - q.push_back(text_vaddr + e.i * sizeof(uint32_t)); - } - } - - if (function_entry) { - // add one edge that skips the function call, for callee-saved register liveness propagation - live &= ~(map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a1) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a2) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a3) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1) | temporary_regs()); - - if ((insns[i + 1].f_livein | live) != insns[i + 1].f_livein) { - insns[i + 1].f_livein |= live; - q.push_back(text_vaddr + (i + 1) * sizeof(uint32_t)); - } - } - } -} - -void pass5(void) { - vector q; - - assert(functions.count(main_addr)); - - q = functions[main_addr].returns; - for (auto addr : q) { - insns[addr_to_i(addr)].b_liveout = 1U | map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0); - } - - for (auto& it : data_function_pointers) { - for (auto addr : functions[it.second].returns) { - q.push_back(addr); - insns[addr_to_i(addr)].b_liveout = 1U | map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1); - } - } - - for (auto& func_addr : la_function_pointers) { - for (auto addr : functions[func_addr].returns) { - q.push_back(addr); - insns[addr_to_i(addr)].b_liveout = 1U | map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1); - } - } - - for (auto& insn : insns) { - if (insn.f_livein != 0) { - q.push_back(insn.instruction.getVram()); - } - } - - while (!q.empty()) { - uint32_t addr = q.back(); - - q.pop_back(); - - uint32_t i = addr_to_i(addr); - Insn& insn = insns[i]; - uint64_t live = insn.b_liveout | 1; - - switch (insn_to_type(insn)) { - case TYPE_S: - live |= get_all_source_reg_mask(insn.instruction); - break; - - case TYPE_D: - live &= ~get_dest_reg_mask(insn); - break; - - case TYPE_D_S: - if (live & get_dest_reg_mask(insn)) { - live &= ~get_dest_reg_mask(insn); - live |= get_all_source_reg_mask(insn.instruction); - } - break; - - case TYPE_NOP: - break; - } - - if ((insn.b_livein | live) == insn.b_livein) { - // No new bits - continue; - } - - live |= insn.b_livein; - insn.b_livein = live; - - bool function_exit = false; - - for (Edge& e : insn.predecessors) { - uint64_t new_live = live; - - if (e.function_exit) { - new_live &= 1U | map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1); - function_exit = true; - } else if (e.function_entry) { - new_live &= 1U | map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a1) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a2) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a3) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_sp); - } else if (e.extern_function) { - string_view name; - size_t extern_function_id; - const ExternFunction* found_fn = nullptr; - uint32_t address = insns[i - 2].getAddress(); - // TODO: Can this only ever be a J-type instruction? - auto it = symbol_names.find(address); - - if (it != symbol_names.end()) { - name = it->second; - for (auto& fn : extern_functions) { - if (name == fn.name) { - found_fn = &fn; - break; - } - } - } - - assert(found_fn); - - uint64_t args = 1U; - - if (found_fn->flags & FLAG_VARARG) { - // Assume the worst, that all four registers are used - for (int j = 0; j < 4; j++) { - args |= map_reg((rabbitizer::Registers::Cpu::GprO32)( - (int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + j)); - } - } - - int pos = 0; - int pos_float = 0; - bool only_floats_so_far = true; - - for (const char* p = found_fn->params + 1; *p != '\0'; ++p) { - switch (*p) { - case 'i': - case 'u': - case 'p': - case 't': - only_floats_so_far = false; - if (pos < 4) { - args |= map_reg((rabbitizer::Registers::Cpu::GprO32)( - (int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + pos)); - } - ++pos; - break; - - case 'f': - if (only_floats_so_far && pos_float < 4) { - pos_float += 2; - } else if (pos < 4) { - args |= map_reg((rabbitizer::Registers::Cpu::GprO32)( - (int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + pos)); - } - ++pos; - break; - - case 'd': - // !!! - if (pos % 1 != 0) { - ++pos; - } - if (only_floats_so_far && pos_float < 4) { - pos_float += 2; - } else if (pos < 4) { - args |= map_reg((rabbitizer::Registers::Cpu::GprO32)( - (int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + pos)) | - map_reg((rabbitizer::Registers::Cpu::GprO32)( - (int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + pos + 1)); - } - pos += 2; - break; - - case 'l': - case 'j': - if (pos % 1 != 0) { - ++pos; - } - only_floats_so_far = false; - if (pos < 4) { - args |= map_reg((rabbitizer::Registers::Cpu::GprO32)( - (int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + pos)) | - map_reg((rabbitizer::Registers::Cpu::GprO32)( - (int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + pos + 1)); - } - pos += 2; - break; - } - } - args |= map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_sp); - new_live &= ~(map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a1) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a2) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a3) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1) | temporary_regs()); - new_live |= args; - } else if (e.function_pointer) { - new_live &= ~(map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a1) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a2) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a3) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1) | temporary_regs()); - new_live |= map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a1) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a2) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a3); - } - - if ((insns[e.i].b_liveout | new_live) != insns[e.i].b_liveout) { - insns[e.i].b_liveout |= new_live; - q.push_back(text_vaddr + e.i * sizeof(uint32_t)); - } - } - - if (function_exit) { - // add one edge that skips the function call, for callee-saved register liveness propagation - live &= ~(map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a1) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a2) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_a3) | - map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1) | temporary_regs()); - - if ((insns[i - 1].b_liveout | live) != insns[i - 1].b_liveout) { - insns[i - 1].b_liveout |= live; - q.push_back(text_vaddr + (i - 1) * sizeof(uint32_t)); - } - } - } -} - -void pass6(void) { - for (auto& it : functions) { - uint32_t addr = it.first; - Function& f = it.second; - - for (uint32_t ret : f.returns) { - Insn& i = insns[addr_to_i(ret)]; - - if (i.f_liveout & i.b_liveout & map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1)) { - f.nret = 2; - } else if ((i.f_liveout & i.b_liveout & map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0)) && - f.nret == 0) { - f.nret = 1; - } - } - - Insn& insn = insns.at(addr_to_i(addr)); - - for (int i = 0; i < 4; i++) { - if (insn.f_livein & insn.b_livein & - map_reg( - (rabbitizer::Registers::Cpu::GprO32)((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + i))) { - f.nargs = 1 + i; - } - } - f.v0_in = (insn.f_livein & insn.b_livein & map_reg(rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0)) != 0 && - !f.referenced_by_function_pointer; - } -} - -void dump(void) { - for (size_t i = 0; i < insns.size(); i++) { - Insn& insn = insns[i]; - uint32_t vaddr = text_vaddr + i * sizeof(uint32_t); - if (label_addresses.count(vaddr)) { - if (symbol_names.count(vaddr)) { - printf("L%08x: //%s\n", vaddr, symbol_names[vaddr].c_str()); - } else { - printf("L%08x:\n", vaddr); - } - } - - // TODO: construct an immediate override for the instructions - printf("\t%s", insn.disassemble().c_str()); - if (insn.patched) { - printf("\t[patched, immediate now 0x%X]", insn.patched_addr); - } - printf("\n"); - } -} - -const char* r(uint32_t reg) { - static const char* regs[] = { - /* */ "zero", "at", "v0", "v1", - /* */ "a0", "a1", "a2", "a3", - /* */ "t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7", - /* */ "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", - /* */ "t8", "t9", "k0", "k1", "gp", "sp", "fp", "ra", - }; - - assert(reg < std::size(regs)); - return regs[reg]; -} - -const char* wr(uint32_t reg) { - // clang-format off - static const char *regs[] = { - "f0.w[0]", "f0.w[1]", - "f2.w[0]", "f2.w[1]", - "f4.w[0]", "f4.w[1]", - "f6.w[0]", "f6.w[1]", - "f8.w[0]", "f8.w[1]", - "f10.w[0]", "f10.w[1]", - "f12.w[0]", "f12.w[1]", - "f14.w[0]", "f14.w[1]", - "f16.w[0]", "f16.w[1]", - "f18.w[0]", "f18.w[1]", - "f20.w[0]", "f20.w[1]", - "f22.w[0]", "f22.w[1]", - "f24.w[0]", "f24.w[1]", - "f26.w[0]", "f26.w[1]", - "f28.w[0]", "f28.w[1]", - "f30.w[0]", "f30.w[1]" - }; - // clang-format on - - size_t index = reg - (int)rabbitizer::Registers::Cpu::Cop1O32::COP1_O32_fv0; - - assert(index < std::size(regs)); - return regs[index]; -} - -const char* fr(uint32_t reg) { - // clang-format off - static const char *regs[] = { - "f0.f[0]", "f0.f[1]", - "f2.f[0]", "f2.f[1]", - "f4.f[0]", "f4.f[1]", - "f6.f[0]", "f6.f[1]", - "f8.f[0]", "f8.f[1]", - "f10.f[0]", "f10.f[1]", - "f12.f[0]", "f12.f[1]", - "f14.f[0]", "f14.f[1]", - "f16.f[0]", "f16.f[1]", - "f18.f[0]", "f18.f[1]", - "f20.f[0]", "f20.f[1]", - "f22.f[0]", "f22.f[1]", - "f24.f[0]", "f24.f[1]", - "f26.f[0]", "f26.f[1]", - "f28.f[0]", "f28.f[1]", - "f30.f[0]", "f30.f[1]", - }; - // clang-format on - - size_t index = reg - (int)rabbitizer::Registers::Cpu::Cop1O32::COP1_O32_fv0; - - assert(index < std::size(regs)); - return regs[index]; -} - -const char* dr(uint32_t reg) { - // clang-format off - static const char *regs[] = { - "f0", - "f2", - "f4", - "f6", - "f8", - "f10", - "f12", - "f14", - "f16", - "f18", - "f20", - "f22", - "f24", - "f26", - "f28", - "f30" - }; - // clang-format on - - size_t index = reg - (int)rabbitizer::Registers::Cpu::Cop1O32::COP1_O32_fv0; - - assert(index % 2 == 0); - index /= 2; - assert(index < std::size(regs)); - return regs[index]; -} - -void dump_instr(int i); - -void dump_cond_branch(int i, const char* lhs, const char* op, const char* rhs) { - Insn& insn = insns[i]; - const char* cast1 = ""; - const char* cast2 = ""; - - if (strcmp(op, "==") && strcmp(op, "!=")) { - cast1 = "(int)"; - if (strcmp(rhs, "0")) { - cast2 = "(int)"; - } - } - printf("if (%s%s %s %s%s) {\n", cast1, lhs, op, cast2, rhs); - dump_instr(i + 1); - - uint32_t addr = insn.getAddress(); - - printf("goto L%x;}\n", addr); -} - -void dump_cond_branch_likely(int i, const char* lhs, const char* op, const char* rhs) { - uint32_t target = text_vaddr + (i + 2) * sizeof(uint32_t); - - dump_cond_branch(i, lhs, op, rhs); - if (!TRACE) { - printf("else goto L%x;\n", target); - } else { - printf("else {printf(\"pc=0x%08x (ignored)\\n\"); goto L%x;}\n", text_vaddr + (i + 1) * 4, target); - } - label_addresses.insert(target); -} - -void dump_jal(int i, uint32_t imm) { - string_view name; - auto it = symbol_names.find(imm); - const ExternFunction* found_fn = nullptr; - - // Check for an external function at the address in the immediate. If it does not exist, function is internal - if (it != symbol_names.end()) { - name = it->second; - for (auto& fn : extern_functions) { - if (name == fn.name) { - found_fn = &fn; - break; - } - } - } - - dump_instr(i + 1); - - if (found_fn != nullptr) { - if (found_fn->flags & FLAG_VARARG) { - for (int j = 0; j < 4; j++) { - printf("MEM_U32(sp + %d) = %s;\n", j * 4, r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + j)); - } - } - - const char ret_type = found_fn->params[0]; - - switch (ret_type) { - case 'v': - break; - - case 'i': - case 'u': - case 'p': - printf("%s = ", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0)); - break; - - case 'f': - printf("%s = ", fr((int)rabbitizer::Registers::Cpu::Cop1O32::COP1_O32_fv0)); - break; - - case 'd': - printf("tempf64 = "); - break; - - case 'l': - case 'j': - printf("temp64 = "); - break; - } - - printf("wrapper_%s(", string(name).c_str()); - - bool first = true; - - if (!(found_fn->flags & FLAG_NO_MEM)) { - printf("mem"); - first = false; - } - - int pos = 0; - int pos_float = 0; - bool only_floats_so_far = true; - bool needs_sp = false; - - for (const char* p = &found_fn->params[1]; *p != '\0'; ++p) { - if (!first) { - printf(", "); - } - - first = false; - - switch (*p) { - case 't': - printf("trampoline, "); - needs_sp = true; - // fallthrough - case 'i': - case 'u': - case 'p': - only_floats_so_far = false; - if (pos < 4) { - printf("%s", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + pos)); - } else { - printf("MEM_%c32(sp + %d)", *p == 'i' ? 'S' : 'U', pos * 4); - } - ++pos; - break; - - case 'f': - if (only_floats_so_far && pos_float < 4) { - printf("%s", fr((int)rabbitizer::Registers::Cpu::Cop1O32::COP1_O32_fa0 + pos_float)); - pos_float += 2; - } else if (pos < 4) { - printf("BITCAST_U32_TO_F32(%s)", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + pos)); - } else { - printf("BITCAST_U32_TO_F32(MEM_U32(sp + %d))", pos * 4); - } - ++pos; - break; - - case 'd': - if (pos % 1 != 0) { - ++pos; - } - if (only_floats_so_far && pos_float < 4) { - printf("double_from_FloatReg(%s)", - dr((int)rabbitizer::Registers::Cpu::Cop1O32::COP1_O32_fa0 + pos_float)); - pos_float += 2; - } else if (pos < 4) { - printf("BITCAST_U64_TO_F64(((uint64_t)%s << 32) | (uint64_t)%s)", - r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + pos), - r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + pos + 1)); - } else { - printf("BITCAST_U64_TO_F64(((uint64_t)MEM_U32(sp + %d) << 32) | " - "(uint64_t)MEM_U32(sp + " - "%d))", - pos * 4, (pos + 1) * 4); - } - pos += 2; - break; - - case 'l': - case 'j': - if (pos % 1 != 0) { - ++pos; - } - only_floats_so_far = false; - if (*p == 'l') { - printf("(int64_t)"); - } - if (pos < 4) { - printf("(((uint64_t)%s << 32) | (uint64_t)%s)", - r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + pos), - r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + pos + 1)); - } else { - printf("(((uint64_t)MEM_U32(sp + %d) << 32) | (uint64_t)MEM_U32(sp + %d))", pos * 4, - (pos + 1) * 4); - } - pos += 2; - break; - } - } - - if ((found_fn->flags & FLAG_VARARG) || needs_sp) { - printf("%s%s", first ? "" : ", ", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_sp)); - } - - printf(");\n"); - - if (ret_type == 'l' || ret_type == 'j') { - printf("%s = (uint32_t)(temp64 >> 32);\n", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0)); - printf("%s = (uint32_t)temp64;\n", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1)); - } else if (ret_type == 'd') { - printf("%s = FloatReg_from_double(tempf64);\n", dr((int)rabbitizer::Registers::Cpu::Cop1O32::COP1_O32_fv0)); - } - } else { - Function& f = functions.find(imm)->second; - - if (f.nret == 1) { - printf("v0 = "); - } else if (f.nret == 2) { - printf("temp64 = "); - } - - if (!name.empty()) { - printf("f_%s", string(name).c_str()); - } else { - printf("func_%x", imm); - } - - printf("(mem, sp"); - - if (f.v0_in) { - printf(", %s", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0)); - } - - for (uint32_t i = 0; i < f.nargs; i++) { - printf(", %s", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + i)); - } - - printf(");\n"); - - if (f.nret == 2) { - printf("%s = (uint32_t)(temp64 >> 32);\n", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0)); - printf("%s = (uint32_t)temp64;\n", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1)); - } - } - - printf("goto L%x;\n", text_vaddr + (i + 2) * 4); - label_addresses.insert(text_vaddr + (i + 2) * 4); -} - -void dump_instr(int i) { - Insn& insn = insns[i]; - - const char* symbol_name = NULL; - if (symbol_names.count(text_vaddr + i * sizeof(uint32_t)) != 0) { - symbol_name = symbol_names[text_vaddr + i * sizeof(uint32_t)].c_str(); - printf("//%s:\n", symbol_name); - } - - if (TRACE) { - printf("++cnt; printf(\"pc=0x%08x%s%s\\n\"); ", text_vaddr + i * 4, symbol_name ? " " : "", - symbol_name ? symbol_name : ""); - } - - uint64_t src_regs_map; - if (!insn.instruction.isJump() && !insn.instruction.isBranch() && !conservative) { - switch (insn_to_type(insn)) { - case TYPE_S: - src_regs_map = get_all_source_reg_mask(insn.instruction); - if (!((insn.f_livein & src_regs_map) == src_regs_map)) { - printf("// fdead %llx ", (unsigned long long)insn.f_livein); - } - break; - - case TYPE_D_S: { - uint64_t reg_mask = get_all_source_reg_mask(insn.instruction); - - if ((insn.f_livein & reg_mask) != reg_mask) { - printf("// fdead %llx ", (unsigned long long)insn.f_livein); - break; - } - } - // fallthrough - case TYPE_D: - if (!(insn.b_liveout & get_dest_reg_mask(insn))) { -#if 0 - printf("// %i bdead %llx %llx ", i, (unsigned long long)insn.b_liveout, - (unsigned long long)get_dest_reg_mask(insn)); -#else - printf("// bdead %llx ", (unsigned long long)insn.b_liveout); -#endif - } - break; - - case TYPE_NOP: - break; - } - } - - int32_t imm; - char buf[0x100]; - switch (insn.instruction.getUniqueId()) { - case rabbitizer::InstrId::UniqueId::cpu_add: - case rabbitizer::InstrId::UniqueId::cpu_addu: - if (insn.instruction.GetO32_rs() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_zero) { - printf("%s = %s;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rt())); - } else if (insn.instruction.GetO32_rt() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_zero) { - printf("%s = %s;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rs())); - } else { - printf("%s = %s + %s;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt())); - } - break; - - case rabbitizer::InstrId::UniqueId::cpu_add_s: - printf("%s = %s + %s;\n", fr((int)insn.instruction.GetO32_fd()), fr((int)insn.instruction.GetO32_fs()), - fr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_add_d: - printf("%s = FloatReg_from_double(double_from_FloatReg(%s) + double_from_FloatReg(%s));\n", - dr((int)insn.instruction.GetO32_fd()), dr((int)insn.instruction.GetO32_fs()), - dr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_addi: - case rabbitizer::InstrId::UniqueId::cpu_addiu: - imm = insn.getImmediate(); - if (insn.instruction.GetO32_rs() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_zero) { - printf("%s = 0x%x;\n", r((int)insn.instruction.GetO32_rt()), imm); - } else { - printf("%s = %s + 0x%x;\n", r((int)insn.instruction.GetO32_rt()), r((int)insn.instruction.GetO32_rs()), - imm); - } - break; - - case rabbitizer::InstrId::UniqueId::cpu_and: - printf("%s = %s & %s;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_andi: - imm = insn.getImmediate(); - printf("%s = %s & 0x%x;\n", r((int)insn.instruction.GetO32_rt()), r((int)insn.instruction.GetO32_rs()), - imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_beq: - dump_cond_branch(i, r((int)insn.instruction.GetO32_rs()), "==", r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_beql: - dump_cond_branch_likely(i, r((int)insn.instruction.GetO32_rs()), - "==", r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_bgez: - dump_cond_branch(i, r((int)insn.instruction.GetO32_rs()), ">=", "0"); - break; - - case rabbitizer::InstrId::UniqueId::cpu_bgezl: - dump_cond_branch_likely(i, r((int)insn.instruction.GetO32_rs()), ">=", "0"); - break; - - case rabbitizer::InstrId::UniqueId::cpu_bgtz: - dump_cond_branch(i, r((int)insn.instruction.GetO32_rs()), ">", "0"); - break; - - case rabbitizer::InstrId::UniqueId::cpu_bgtzl: - dump_cond_branch_likely(i, r((int)insn.instruction.GetO32_rs()), ">", "0"); - break; - - case rabbitizer::InstrId::UniqueId::cpu_blez: - dump_cond_branch(i, r((int)insn.instruction.GetO32_rs()), "<=", "0"); - break; - - case rabbitizer::InstrId::UniqueId::cpu_blezl: - dump_cond_branch_likely(i, r((int)insn.instruction.GetO32_rs()), "<=", "0"); - break; - - case rabbitizer::InstrId::UniqueId::cpu_bltz: - dump_cond_branch(i, r((int)insn.instruction.GetO32_rs()), "<", "0"); - break; - - case rabbitizer::InstrId::UniqueId::cpu_bltzl: - dump_cond_branch_likely(i, r((int)insn.instruction.GetO32_rs()), "<", "0"); - break; - - case rabbitizer::InstrId::UniqueId::cpu_bne: - dump_cond_branch(i, r((int)insn.instruction.GetO32_rs()), "!=", r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_bnel: - dump_cond_branch_likely(i, r((int)insn.instruction.GetO32_rs()), - "!=", r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_break: - printf("abort();\n"); - break; - - case rabbitizer::InstrId::UniqueId::cpu_beqz: - dump_cond_branch(i, r((int)insn.instruction.GetO32_rs()), "==", "0"); - break; - - case rabbitizer::InstrId::UniqueId::cpu_b: - dump_instr(i + 1); - imm = insn.getAddress(); - printf("goto L%x;\n", imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_bc1f: - printf("if (!cf) {\n"); - dump_instr(i + 1); - imm = insn.getAddress(); - printf("goto L%x;}\n", imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_bc1t: - printf("if (cf) {\n"); - dump_instr(i + 1); - imm = insn.getAddress(); - printf("goto L%x;}\n", imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_bc1fl: { - uint32_t target = text_vaddr + (i + 2) * sizeof(uint32_t); - printf("if (!cf) {\n"); - dump_instr(i + 1); - imm = insn.getAddress(); - printf("goto L%x;}\n", imm); - if (!TRACE) { - printf("else goto L%x;\n", target); - } else { - printf("else {printf(\"pc=0x%08x (ignored)\\n\"); goto L%x;}\n", text_vaddr + (i + 1) * 4, target); - } - label_addresses.insert(target); - } break; - - case rabbitizer::InstrId::UniqueId::cpu_bc1tl: { - uint32_t target = text_vaddr + (i + 2) * sizeof(uint32_t); - printf("if (cf) {\n"); - dump_instr(i + 1); - imm = insn.getAddress(); - printf("goto L%x;}\n", imm); - if (!TRACE) { - printf("else goto L%x;\n", target); - } else { - printf("else {printf(\"pc=0x%08x (ignored)\\n\"); goto L%x;}\n", text_vaddr + (i + 1) * 4, target); - } - label_addresses.insert(target); - } break; - - case rabbitizer::InstrId::UniqueId::cpu_bnez: - dump_cond_branch(i, r((int)insn.instruction.GetO32_rs()), "!=", "0"); - break; - - case rabbitizer::InstrId::UniqueId::cpu_c_lt_s: - printf("cf = %s < %s;\n", fr((int)insn.instruction.GetO32_fs()), fr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_c_le_s: - printf("cf = %s <= %s;\n", fr((int)insn.instruction.GetO32_fs()), fr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_c_eq_s: - printf("cf = %s == %s;\n", fr((int)insn.instruction.GetO32_fs()), fr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_c_lt_d: - printf("cf = double_from_FloatReg(%s) < double_from_FloatReg(%s);\n", dr((int)insn.instruction.GetO32_fs()), - dr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_c_le_d: - printf("cf = double_from_FloatReg(%s) <= double_from_FloatReg(%s);\n", - dr((int)insn.instruction.GetO32_fs()), dr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_c_eq_d: - printf("cf = double_from_FloatReg(%s) == double_from_FloatReg(%s);\n", - dr((int)insn.instruction.GetO32_fs()), dr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_cvt_s_w: - printf("%s = (int)%s;\n", fr((int)insn.instruction.GetO32_fd()), wr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_cvt_d_w: - printf("%s = FloatReg_from_double((int)%s);\n", dr((int)insn.instruction.GetO32_fd()), - wr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_cvt_d_s: - printf("%s = FloatReg_from_double(%s);\n", dr((int)insn.instruction.GetO32_fd()), - fr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_cvt_s_d: - printf("%s = double_from_FloatReg(%s);\n", fr((int)insn.instruction.GetO32_fd()), - dr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_cvt_w_d: - printf("%s = cvt_w_d(double_from_FloatReg(%s));\n", wr((int)insn.instruction.GetO32_fd()), - dr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_cvt_w_s: - printf("%s = cvt_w_s(%s);\n", wr((int)insn.instruction.GetO32_fd()), fr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_cvt_l_d: - case rabbitizer::InstrId::UniqueId::cpu_cvt_l_s: - case rabbitizer::InstrId::UniqueId::cpu_cvt_s_l: - case rabbitizer::InstrId::UniqueId::cpu_cvt_d_l: - goto unimplemented; - - case rabbitizer::InstrId::UniqueId::cpu_cfc1: - assert(insn.instruction.Get_cop1cs() == rabbitizer::Registers::Cpu::Cop1Control::COP1_CONTROL_FpcCsr); - printf("%s = fcsr;\n", r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_ctc1: - assert(insn.instruction.Get_cop1cs() == rabbitizer::Registers::Cpu::Cop1Control::COP1_CONTROL_FpcCsr); - printf("fcsr = %s;\n", r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_div: - printf("lo = (int)%s / (int)%s; ", r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt())); - printf("hi = (int)%s %% (int)%s;\n", r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_divu: - printf("lo = %s / %s; ", r((int)insn.instruction.GetO32_rs()), r((int)insn.instruction.GetO32_rt())); - printf("hi = %s %% %s;\n", r((int)insn.instruction.GetO32_rs()), r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_div_s: - printf("%s = %s / %s;\n", fr((int)insn.instruction.GetO32_fd()), fr((int)insn.instruction.GetO32_fs()), - fr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_div_d: - printf("%s = FloatReg_from_double(double_from_FloatReg(%s) / double_from_FloatReg(%s));\n", - dr((int)insn.instruction.GetO32_fd()), dr((int)insn.instruction.GetO32_fs()), - dr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_mov_s: - printf("%s = %s;\n", fr((int)insn.instruction.GetO32_fd()), fr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_mov_d: - printf("%s = %s;\n", dr((int)insn.instruction.GetO32_fd()), dr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_mul_s: - printf("%s = %s * %s;\n", fr((int)insn.instruction.GetO32_fd()), fr((int)insn.instruction.GetO32_fs()), - fr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_mul_d: - printf("%s = FloatReg_from_double(double_from_FloatReg(%s) * double_from_FloatReg(%s));\n", - dr((int)insn.instruction.GetO32_fd()), dr((int)insn.instruction.GetO32_fs()), - dr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_negu: - printf("%s = -%s;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_neg_s: - printf("%s = -%s;\n", fr((int)insn.instruction.GetO32_fd()), fr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_neg_d: - printf("%s = FloatReg_from_double(-double_from_FloatReg(%s));\n", dr((int)insn.instruction.GetO32_fd()), - dr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_sub: - if (insn.instruction.GetO32_rs() == rabbitizer::Registers::Cpu::GprO32::GPR_O32_zero) { - printf("%s = -%s;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rt())); - break; - } else { - goto unimplemented; - } - - case rabbitizer::InstrId::UniqueId::cpu_sub_s: - printf("%s = %s - %s;\n", fr((int)insn.instruction.GetO32_fd()), fr((int)insn.instruction.GetO32_fs()), - fr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_sub_d: - printf("%s = FloatReg_from_double(double_from_FloatReg(%s) - double_from_FloatReg(%s));\n", - dr((int)insn.instruction.GetO32_fd()), dr((int)insn.instruction.GetO32_fs()), - dr((int)insn.instruction.GetO32_ft())); - break; - - // Jumps - - case rabbitizer::InstrId::UniqueId::cpu_j: - dump_instr(i + 1); - imm = insn.getAddress(); - printf("goto L%x;\n", imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_jal: - imm = insn.getAddress(); - dump_jal(i, imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_jalr: - printf("fp_dest = %s;\n", r((int)insn.instruction.GetO32_rs())); - dump_instr(i + 1); - printf("temp64 = trampoline(mem, sp, %s, %s, %s, %s, fp_dest);\n", - r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0), - r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a1), - r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a2), - r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a3)); - printf("%s = (uint32_t)(temp64 >> 32);\n", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0)); - printf("%s = (uint32_t)temp64;\n", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_v1)); - printf("goto L%x;\n", text_vaddr + (i + 2) * 4); - label_addresses.insert(text_vaddr + (i + 2) * 4); - break; - - case rabbitizer::InstrId::UniqueId::cpu_jr: - // TODO: understand why the switch version fails, and why only it needs the nop - if (insn.jtbl_addr != 0) { - uint32_t jtbl_pos = insn.jtbl_addr - rodata_vaddr; - - assert(jtbl_pos < rodata_section_len && - jtbl_pos + insn.num_cases * sizeof(uint32_t) <= rodata_section_len); -#if 1 - printf(";static void *const Lswitch%x[] = {\n", insn.jtbl_addr); - - for (uint32_t i = 0; i < insn.num_cases; i++) { - uint32_t dest_addr = read_u32_be(rodata_section + jtbl_pos + i * sizeof(uint32_t)) + gp_value; - printf("&&L%x,\n", dest_addr); - label_addresses.insert(dest_addr); - } - - printf("};\n"); - printf("dest = Lswitch%x[%s];\n", insn.jtbl_addr, r((int)insn.index_reg)); - dump_instr(i + 1); - printf("goto *dest;\n"); -#else - // This block produces a switch instead of an array of labels. - // It is not being used because currently it is a bit bugged. - // It has been keep as a reference and with the main intention to fix it - - assert(insns[i + 1].id == MIPS_INS_NOP); - printf("switch (%s) {\n", r(insn.index_reg)); - - for (uint32_t i = 0; i < insn.num_cases; i++) { - uint32_t dest_addr = read_u32_be(rodata_section + jtbl_pos + i * sizeof(uint32_t)) + gp_value; - printf("case %u: goto L%x;\n", i, dest_addr); - label_addresses.insert(dest_addr); - } - - printf("}\n"); -#endif - } else { - if (insn.instruction.GetO32_rs() != rabbitizer::Registers::Cpu::GprO32::GPR_O32_ra) { - printf("UNSUPPORTED JR %s (no jumptable available)\n", r((int)insn.instruction.GetO32_rs())); - } else { - dump_instr(i + 1); - switch (find_function(text_vaddr + i * sizeof(uint32_t))->second.nret) { - case 0: - printf("return;\n"); - break; - - case 1: - printf("return v0;\n"); - break; - - case 2: - printf("return ((uint64_t)v0 << 32) | v1;\n"); - break; - } - } - } - break; - - case rabbitizer::InstrId::UniqueId::cpu_lb: - imm = insn.getImmediate(); - printf("%s = MEM_S8(%s + %d);\n", r((int)insn.instruction.GetO32_rt()), - r((int)insn.instruction.GetO32_rs()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_lbu: - imm = insn.getImmediate(); - printf("%s = MEM_U8(%s + %d);\n", r((int)insn.instruction.GetO32_rt()), - r((int)insn.instruction.GetO32_rs()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_lh: - imm = insn.getImmediate(); - printf("%s = MEM_S16(%s + %d);\n", r((int)insn.instruction.GetO32_rt()), - r((int)insn.instruction.GetO32_rs()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_lhu: - imm = insn.getImmediate(); - printf("%s = MEM_U16(%s + %d);\n", r((int)insn.instruction.GetO32_rt()), - r((int)insn.instruction.GetO32_rs()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_lui: - imm = insn.getImmediate(); - printf("%s = 0x%x;\n", r((int)insn.instruction.GetO32_rt()), imm << 16); - break; - - case rabbitizer::InstrId::UniqueId::cpu_lw: - imm = insn.getImmediate(); - printf("%s = MEM_U32(%s + %d);\n", r((int)insn.instruction.GetO32_rt()), - r((int)insn.instruction.GetO32_rs()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_lwc1: - imm = insn.getImmediate(); - printf("%s = MEM_U32(%s + %d);\n", wr((int)insn.instruction.GetO32_ft()), - r((int)insn.instruction.GetO32_rs()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_ldc1: - imm = insn.getImmediate(); - assert(((int)insn.instruction.GetO32_ft() - (int)rabbitizer::Registers::Cpu::Cop1O32::COP1_O32_fv0) % 2 == - 0); - printf("%s = MEM_U32(%s + %d);\n", wr((int)insn.instruction.GetO32_ft() + 1), - r((int)insn.instruction.GetO32_rs()), imm); - printf("%s = MEM_U32(%s + %d + 4);\n", wr((int)insn.instruction.GetO32_ft()), - r((int)insn.instruction.GetO32_rs()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_lwl: { - const char* reg = r((int)insn.instruction.GetO32_rt()); - - imm = insn.getImmediate(); - - printf("%s = %s + %d; ", reg, r((int)insn.instruction.GetO32_rs()), imm); - printf("%s = ((uint32_t)MEM_U8(%s) << 24) | (MEM_U8(%s + 1) << 16) | (MEM_U8(%s + 2) << 8) | MEM_U8(%s + 3);\n", reg, - reg, reg, reg, reg); - } break; - - case rabbitizer::InstrId::UniqueId::cpu_lwr: - printf("//%s\n", insn.disassemble().c_str()); - break; - - case UniqueId_cpu_la: { - uint32_t addr = insn.getAddress(); - - printf("%s = 0x%x;", r((int)insn.lila_dst_reg), addr); - if ((text_vaddr <= addr) && (addr < text_vaddr + text_section_len)) { - printf(" // function pointer"); - label_addresses.insert(addr); - } - printf("\n"); - } break; - - case UniqueId_cpu_li: - imm = insn.getImmediate(); - - printf("%s = 0x%x;\n", r((int)insn.lila_dst_reg), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_mfc1: - printf("%s = %s;\n", r((int)insn.instruction.GetO32_rt()), wr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_mfhi: - printf("%s = hi;\n", r((int)insn.instruction.GetO32_rd())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_mflo: - printf("%s = lo;\n", r((int)insn.instruction.GetO32_rd())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_move: - printf("%s = %s;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_mtc1: - printf("%s = %s;\n", wr((int)insn.instruction.GetO32_fs()), r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_mult: - printf("lo = %s * %s;\n", r((int)insn.instruction.GetO32_rs()), r((int)insn.instruction.GetO32_rt())); - printf("hi = (uint32_t)((int64_t)(int)%s * (int64_t)(int)%s >> 32);\n", - r((int)insn.instruction.GetO32_rs()), r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_multu: - printf("lo = %s * %s;\n", r((int)insn.instruction.GetO32_rs()), r((int)insn.instruction.GetO32_rt())); - printf("hi = (uint32_t)((uint64_t)%s * (uint64_t)%s >> 32);\n", r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_sqrt_s: - printf("%s = sqrtf(%s);\n", fr((int)insn.instruction.GetO32_fd()), fr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_nor: - printf("%s = ~(%s | %s);\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_not: - printf("%s = ~%s;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_or: - printf("%s = %s | %s;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_ori: - imm = insn.getImmediate(); - printf("%s = %s | 0x%x;\n", r((int)insn.instruction.GetO32_rt()), r((int)insn.instruction.GetO32_rs()), - imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_sb: - imm = insn.getImmediate(); - printf("MEM_U8(%s + %d) = (uint8_t)%s;\n", r((int)insn.instruction.GetO32_rs()), imm, - r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_sh: - imm = insn.getImmediate(); - printf("MEM_U16(%s + %d) = (uint16_t)%s;\n", r((int)insn.instruction.GetO32_rs()), imm, - r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_sll: - printf("%s = %s << %d;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rt()), - insn.instruction.Get_sa()); - break; - - case rabbitizer::InstrId::UniqueId::cpu_sllv: - printf("%s = %s << (%s & 0x1f);\n", r((int)insn.instruction.GetO32_rd()), - r((int)insn.instruction.GetO32_rt()), r((int)insn.instruction.GetO32_rs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_slt: - printf("%s = (int)%s < (int)%s;\n", r((int)insn.instruction.GetO32_rd()), - r((int)insn.instruction.GetO32_rs()), r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_slti: - imm = insn.getImmediate(); - printf("%s = (int)%s < (int)0x%x;\n", r((int)insn.instruction.GetO32_rt()), - r((int)insn.instruction.GetO32_rs()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_sltiu: - imm = insn.getImmediate(); - printf("%s = %s < 0x%x;\n", r((int)insn.instruction.GetO32_rt()), r((int)insn.instruction.GetO32_rs()), - imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_sltu: - printf("%s = %s < %s;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_sra: - printf("%s = (int)%s >> %d;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rt()), - insn.instruction.Get_sa()); - break; - - case rabbitizer::InstrId::UniqueId::cpu_srav: - printf("%s = (int)%s >> (%s & 0x1f);\n", r((int)insn.instruction.GetO32_rd()), - r((int)insn.instruction.GetO32_rt()), r((int)insn.instruction.GetO32_rs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_srl: - printf("%s = %s >> %d;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rt()), - insn.instruction.Get_sa()); - break; - - case rabbitizer::InstrId::UniqueId::cpu_srlv: - printf("%s = %s >> (%s & 0x1f);\n", r((int)insn.instruction.GetO32_rd()), - r((int)insn.instruction.GetO32_rt()), r((int)insn.instruction.GetO32_rs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_subu: - printf("%s = %s - %s;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_sw: - imm = insn.getImmediate(); - printf("MEM_U32(%s + %d) = %s;\n", r((int)insn.instruction.GetO32_rs()), imm, - r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_swc1: - imm = insn.getImmediate(); - printf("MEM_U32(%s + %d) = %s;\n", r((int)insn.instruction.GetO32_rs()), imm, - wr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_sdc1: - assert(((int)insn.instruction.GetO32_ft() - (int)rabbitizer::Registers::Cpu::Cop1O32::COP1_O32_fv0) % 2 == - 0); - imm = insn.getImmediate(); - printf("MEM_U32(%s + %d) = %s;\n", r((int)insn.instruction.GetO32_rs()), imm, - wr((int)insn.instruction.GetO32_ft() + 1)); - printf("MEM_U32(%s + %d + 4) = %s;\n", r((int)insn.instruction.GetO32_rs()), imm, - wr((int)insn.instruction.GetO32_ft())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_swl: - imm = insn.getImmediate(); - for (int i = 0; i < 4; i++) { - printf("MEM_U8(%s + %d + %d) = (uint8_t)(%s >> %d);\n", r((int)insn.instruction.GetO32_rs()), imm, i, - r((int)insn.instruction.GetO32_rt()), (3 - i) * 8); - } - break; - - case rabbitizer::InstrId::UniqueId::cpu_swr: - printf("//%s\n", insn.disassemble().c_str()); - break; - - case rabbitizer::InstrId::UniqueId::cpu_trunc_w_s: - printf("%s = (int)%s;\n", wr((int)insn.instruction.GetO32_fd()), fr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_trunc_w_d: - printf("%s = (int)double_from_FloatReg(%s);\n", wr((int)insn.instruction.GetO32_fd()), - dr((int)insn.instruction.GetO32_fs())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_trunc_l_d: - case rabbitizer::InstrId::UniqueId::cpu_trunc_l_s: - goto unimplemented; - - case rabbitizer::InstrId::UniqueId::cpu_xor: - printf("%s = %s ^ %s;\n", r((int)insn.instruction.GetO32_rd()), r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt())); - break; - - case rabbitizer::InstrId::UniqueId::cpu_xori: - imm = insn.getImmediate(); - printf("%s = %s ^ 0x%x;\n", r((int)insn.instruction.GetO32_rt()), r((int)insn.instruction.GetO32_rs()), - imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_tne: - imm = insn.instruction.Get_code_lower(); - printf("assert(%s == %s && \"tne %d\");\n", r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_teq: - imm = insn.instruction.Get_code_lower(); - printf("assert(%s != %s && \"teq %d\");\n", r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_tge: - imm = insn.instruction.Get_code_lower(); - printf("assert((int)%s < (int)%s && \"tge %d\");\n", r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_tgeu: - imm = insn.instruction.Get_code_lower(); - printf("assert(%s < %s && \"tgeu %d\");\n", r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_tlt: - imm = insn.instruction.Get_code_lower(); - printf("assert((int)%s >= (int)%s && \"tlt %d\");\n", r((int)insn.instruction.GetO32_rs()), - r((int)insn.instruction.GetO32_rt()), imm); - break; - - case rabbitizer::InstrId::UniqueId::cpu_nop: - printf("//nop;\n"); - break; - - default: - unimplemented: - printf("UNIMPLEMENTED 0x%X : %s\n", insn.instruction.getRaw(), insn.disassemble().c_str()); - break; - } -} - -void inspect_data_function_pointers(vector>& ret, const uint8_t* section, - uint32_t section_vaddr, uint32_t len) { - for (uint32_t i = 0; i < len; i += 4) { - uint32_t addr = read_u32_be(section + i); - - if (addr == 0x430b00 || addr == 0x433b00) { - // in as1, not function pointers (normal integers) - continue; - } - - if (addr == 0x4a0000) { - // in copt - continue; - } - - if (section_vaddr + i >= procedure_table_start && - section_vaddr + i < procedure_table_start + procedure_table_len) { - // some linking table with a "all" functions, in as1 5.3 - continue; - } - - if ((addr >= text_vaddr) && (addr < text_vaddr + text_section_len) && ((addr % 4) == 0)) { -#if INSPECT_FUNCTION_POINTERS - fprintf(stderr, "assuming function pointer 0x%x at 0x%x\n", addr, section_vaddr + i); -#endif - ret.push_back(make_pair(section_vaddr + i, addr)); - label_addresses.insert(addr); - functions[addr].referenced_by_function_pointer = true; - } - } -} - -void dump_function_signature(Function& f, uint32_t vaddr) { - printf("static "); - switch (f.nret) { - case 0: - printf("void "); - break; - - case 1: - printf("uint32_t "); - break; - - case 2: - printf("uint64_t "); - break; - } - - auto name_it = symbol_names.find(vaddr); - - if (name_it != symbol_names.end()) { - printf("f_%s", name_it->second.c_str()); - } else { - printf("func_%x", vaddr); - } - - printf("(uint8_t *mem, uint32_t sp"); - - if (f.v0_in) { - printf(", uint32_t %s", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_v0)); - } - - for (uint32_t i = 0; i < f.nargs; i++) { - printf(", uint32_t %s", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + i)); - } - - printf(")"); -} - -void dump_c(void) { - map symbol_names_inv; - - for (auto& it : symbol_names) { - symbol_names_inv[it.second] = it.first; - } - - uint32_t min_addr = UINT32_MAX; - uint32_t max_addr = 0; - - if (data_section_len > 0) { - min_addr = std::min(min_addr, data_vaddr); - max_addr = std::max(max_addr, data_vaddr + data_section_len); - } - if (rodata_section_len > 0) { - min_addr = std::min(min_addr, rodata_vaddr); - max_addr = std::max(max_addr, rodata_vaddr + rodata_section_len); - } - if (bss_section_len) { - min_addr = std::min(min_addr, bss_vaddr); - max_addr = std::max(max_addr, bss_vaddr + bss_section_len); - } - - // 64 kB. Supposedly the worst-case smallest permitted page size, increase if necessary. - // Ensures the hardcoded min_addr and max_addr are sufficiently aligned for the machine running the - // recompiled binaries (and not just the one doing the original recomp build). - uint32_t page_size = 0x10000; - - min_addr = min_addr & ~(page_size - 1); - max_addr = (max_addr + (page_size - 1)) & ~(page_size - 1); - - uint32_t stack_bottom = min_addr; - min_addr -= 0x100000; // 1 MB stack - stack_bottom -= 0x10; // for main's stack frame - - printf("#include \"header.h\"\n"); - - if (conservative) { - printf("static uint32_t s0, s1, s2, s3, s4, s5, s6, s7, fp;\n"); - } - - printf("static const uint32_t rodata[] = {\n"); - - for (size_t i = 0; i < rodata_section_len; i += 4) { - printf("0x%x,%s", read_u32_be(rodata_section + i), i % 32 == 28 ? "\n" : ""); - } - - printf("};\n"); - printf("static const uint32_t data[] = {\n"); - - for (size_t i = 0; i < data_section_len; i += 4) { - printf("0x%x,%s", read_u32_be(data_section + i), i % 32 == 28 ? "\n" : ""); - } - - printf("};\n"); - - /* if (!data_function_pointers.empty()) { - printf("static const struct { uint32_t orig_addr; void *recompiled_addr; } data_function_pointers[] = {\n"); - for (auto item : data_function_pointers) { - printf("{0x%x, &&L%x},\n", item.first, item.second); - } - printf("};\n"); - } */ - - if (TRACE) { - printf("static unsigned long long int cnt = 0;\n"); - } - - for (auto& f_it : functions) { - uint32_t addr = f_it.first; - auto& ins = insns.at(addr_to_i(addr)); - - if (ins.f_livein != 0) { - // Function is used - dump_function_signature(f_it.second, addr); - printf(";\n"); - } - } - - if (!data_function_pointers.empty() || !la_function_pointers.empty()) { - printf("uint64_t trampoline(uint8_t *mem, uint32_t sp, uint32_t a0, uint32_t a1, uint32_t a2, uint32_t a3, " - "uint32_t fp_dest) {\n"); - printf("switch (fp_dest) {\n"); - - for (auto& it : functions) { - Function& f = it.second; - - if (f.referenced_by_function_pointer) { - printf("case 0x%x: ", it.first); - - if (f.nret == 1) { - printf("return (uint64_t)"); - } else if (f.nret == 2) { - printf("return "); - } - - auto name_it = symbol_names.find(it.first); - - if (name_it != symbol_names.end()) { - printf("f_%s", name_it->second.c_str()); - } else { - printf("func_%x", it.first); - } - - printf("(mem, sp"); - - for (unsigned int i = 0; i < f.nargs; i++) { - printf(", a%d", i); - } - - printf(")"); - - if (f.nret == 1) { - printf(" << 32"); - } - - printf(";"); - - if (f.nret == 0) { - printf(" return 0;"); - } - - printf("\n"); - } - } - - printf("default: abort();"); - printf("}\n"); - printf("}\n"); - } - - printf("int run(uint8_t *mem, int argc, char *argv[]) {\n"); - printf("mmap_initial_data_range(mem, 0x%x, 0x%x);\n", min_addr, max_addr); - - printf("memcpy(mem + 0x%x, rodata, 0x%x);\n", rodata_vaddr, rodata_section_len); - printf("memcpy(mem + 0x%x, data, 0x%x);\n", data_vaddr, data_section_len); - - /* if (!data_function_pointers.empty()) { - if (!LABELS_64_BIT) { - printf("for (int i = 0; i < %d; i++) MEM_U32(data_function_pointers[i].orig_addr) = - (uint32_t)(uintptr_t)data_function_pointers[i].recompiled_addr;\n", (int)data_function_pointers.size()); } else { - printf("for (int i = 0; i < %d; i++) MEM_U32(data_function_pointers[i].orig_addr) = - (uint32_t)((uintptr_t)data_function_pointers[i].recompiled_addr - (uintptr_t)&&Loffset);\n", - (int)data_function_pointers.size()); - } - } */ - - printf("MEM_S32(0x%x) = argc;\n", symbol_names_inv.at("__Argc")); - printf("MEM_S32(0x%x) = argc;\n", stack_bottom); - printf("uint32_t al = argc * 4; for (int i = 0; i < argc; i++) al += strlen(argv[i]) + 1;\n"); - printf("uint32_t arg_addr = wrapper_malloc(mem, al);\n"); - printf("MEM_U32(0x%x) = arg_addr;\n", symbol_names_inv.at("__Argv")); - printf("MEM_U32(0x%x) = arg_addr;\n", stack_bottom + 4); - printf("uint32_t arg_strpos = arg_addr + argc * 4;\n"); - printf("for (int i = 0; i < argc; i++) {MEM_U32(arg_addr + i * 4) = arg_strpos; uint32_t p = 0; do { " - "MEM_S8(arg_strpos) = argv[i][p]; ++arg_strpos; } while (argv[i][p++] != '\\0');}\n"); - - printf("setup_libc_data(mem);\n"); - - // printf("gp = 0x%x;\n", gp_value); // only to recreate the outcome when ugen reads uninitialized stack memory - - printf("int ret = f_main(mem, 0x%x", stack_bottom); - - Function& main_func = functions[main_addr]; - - if (main_func.nargs >= 1) { - printf(", argc"); - } - - if (main_func.nargs >= 2) { - printf(", arg_addr"); - } - - printf(");\n"); - - if (TRACE) { - printf("end: fprintf(stderr, \"cnt: %%llu\\n\", cnt);\n"); - } - - printf("return ret;\n"); - printf("}\n"); - - for (auto& f_it : functions) { - Function& f = f_it.second; - uint32_t start_addr = f_it.first; - uint32_t end_addr = f.end_addr; - - if (insns[addr_to_i(start_addr)].f_livein == 0) { - // Non-used function, skip - continue; - } - - printf("\n"); - dump_function_signature(f, start_addr); - printf(" {\n"); - printf("const uint32_t zero = 0;\n"); - - if (!conservative) { - printf("uint32_t at = 0, v1 = 0, t0 = 0, t1 = 0, t2 = 0,\n"); - printf("t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, s0 = 0, s1 = 0, s2 = 0, s3 = 0, s4 = 0, s5 = 0,\n"); - printf("s6 = 0, s7 = 0, t8 = 0, t9 = 0, gp = 0, fp = 0, s8 = 0, ra = 0;\n"); - } else { - printf("uint32_t at = 0, v1 = 0, t0 = 0, t1 = 0, t2 = 0,\n"); - printf("t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, t8 = 0, t9 = 0, gp = 0x10000, ra = 0x10000;\n"); - } - - printf("uint32_t lo = 0, hi = 0;\n"); - printf("int cf = 0;\n"); - printf("uint64_t temp64;\n"); - printf("double tempf64;\n"); - printf("uint32_t fp_dest;\n"); - printf("void *dest;\n"); - - if (!f.v0_in) { - printf("uint32_t v0 = 0;\n"); - } - - for (uint32_t j = f.nargs; j < 4; j++) { - printf("uint32_t %s = 0;\n", r((int)rabbitizer::Registers::Cpu::GprO32::GPR_O32_a0 + j)); - } - - for (size_t i = addr_to_i(start_addr), end_i = addr_to_i(end_addr); i < end_i; i++) { - Insn& insn = insns[i]; - uint32_t vaddr = text_vaddr + i * 4; - if (label_addresses.count(vaddr)) { - printf("L%x:\n", vaddr); - } -#if DUMP_INSTRUCTIONS - printf("// %s:\n", insn.disassemble().c_str()); -#endif - dump_instr(i); - } - - printf("}\n"); - } - /* for (size_t i = 0; i < insns.size(); i++) { - Insn& insn = insns[i]; - uint32_t vaddr = text_vaddr + i * 4; - auto fn_it = functions.find(vaddr); - - if (fn_it != functions.end()) { - Function& f = fn_it->second; - - printf("}\n\n"); - - switch (f.nret) { - case 0: - printf("void "); - break; - - case 1: - printf("uint32_t "); - break; - - case 2: - printf("uint64_t "); - break; - } - - auto name_it = symbol_names.find(vaddr); - - if (name_it != symbol_names.end()) { - printf("%s", name_it->second.c_str()); - } else { - printf("func_%x", vaddr); - } - - printf("(uint8_t *mem, uint32_t sp"); - - if (f.v0_in) { - printf(", uint32_t %s", r(MIPS_REG_V0)); - } - - for (uint32_t i = 0; i < f.nargs; i++) { - printf(", uint32_t %s", r(MIPS_REG_A0 + i)); - } - - printf(") {\n"); - printf("const uint32_t zero = 0;\n"); - printf("uint32_t at = 0, v1 = 0, t0 = 0, t1 = 0, t2 = 0,\n"); - printf("t3 = 0, t4 = 0, t5 = 0, t6 = 0, t7 = 0, s0 = 0, s1 = 0, s2 = 0, s3 = 0, s4 = 0, s5 = 0,\n"); - printf("s6 = 0, s7 = 0, t8 = 0, t9 = 0, gp = 0, fp = 0, s8 = 0, ra = 0;\n"); - printf("uint32_t lo = 0, hi = 0;\n"); - printf("int cf = 0;\n"); - - if (!f.v0_in) { - printf("uint32_t v0 = 0;\n"); - } - - for (uint32_t j = f.nargs; j < 4; j++) { - printf("uint32_t %s = 0;\n", r(MIPS_REG_A0 + j)); - } - } - - if (label_addresses.count(vaddr)) { - printf("L%x:\n", vaddr); - } - - dump_instr(i); - } */ -} - -void parse_elf(const uint8_t* data, size_t file_len) { - Elf32_Ehdr* ehdr; - Elf32_Shdr *shdr, *str_shdr, *sym_shdr = NULL, *dynsym_shdr, *dynamic_shdr, *reginfo_shdr, *got_shdr, - *sym_strtab = NULL, *sym_dynstr; - int text_section_index = -1; - int symtab_section_index = -1; - int dynsym_section_index = -1; - int reginfo_section_index = -1; - int dynamic_section_index = -1; - int got_section_index = -1; - int rodata_section_index = -1; - int data_section_index = -1; - int bss_section_index = -1; - uint32_t text_offset = 0; - uint32_t vaddr_adj = 0; - - if (file_len < 4 || data[0] != 0x7f || data[1] != 'E' || data[2] != 'L' || data[3] != 'F') { - fprintf(stderr, "Not an ELF file.\n"); - exit(EXIT_FAILURE); - } - - ehdr = (Elf32_Ehdr*)data; - if (ehdr->e_ident[EI_DATA] != 2 || u16be(ehdr->e_machine) != 8) { - fprintf(stderr, "Not big-endian MIPS.\n"); - exit(EXIT_FAILURE); - } - - if (u16be(ehdr->e_shstrndx) == 0) { - // (We could look at program headers instead in this case.) - fprintf(stderr, "Missing section headers; stripped binaries are not yet supported.\n"); - exit(EXIT_FAILURE); - } - -#define SECTION(index) (Elf32_Shdr*)(data + u32be(ehdr->e_shoff) + (index)*u16be(ehdr->e_shentsize)) -#define STR(strtab, offset) (const char*)(data + u32be(strtab->sh_offset) + offset) - - str_shdr = SECTION(u16be(ehdr->e_shstrndx)); - for (int i = 0; i < u16be(ehdr->e_shnum); i++) { - shdr = SECTION(i); - - const char* name = STR(str_shdr, u32be(shdr->sh_name)); - - if (strcmp(name, ".text") == 0) { - text_offset = u32be(shdr->sh_offset); - text_vaddr = u32be(shdr->sh_addr); - vaddr_adj = text_vaddr - u32be(shdr->sh_addr); - text_section_len = u32be(shdr->sh_size); - text_section = data + text_offset; - text_section_index = i; - } - - if (u32be(shdr->sh_type) == SHT_SYMTAB) { - symtab_section_index = i; - } - - if (u32be(shdr->sh_type) == SHT_DYNSYM) { - dynsym_section_index = i; - } - - if (u32be(shdr->sh_type) == SHT_MIPS_REGINFO) { - reginfo_section_index = i; - } - - if (u32be(shdr->sh_type) == SHT_DYNAMIC) { - dynamic_section_index = i; - } - - if (strcmp(name, ".got") == 0) { - got_section_index = i; - } - - if (strcmp(name, ".rodata") == 0) { - rodata_section_index = i; - } - - if (strcmp(name, ".data") == 0) { - data_section_index = i; - } - - if (strcmp(name, ".bss") == 0) { - bss_section_index = i; - } - } - - if (text_section_index == -1) { - fprintf(stderr, "Missing .text section.\n"); - exit(EXIT_FAILURE); - } - - if (symtab_section_index == -1 && dynsym_section_index == -1) { - fprintf(stderr, "Missing .symtab or .dynsym section.\n"); - exit(EXIT_FAILURE); - } - - if (dynsym_section_index != -1) { - if (reginfo_section_index == -1) { - fprintf(stderr, "Missing .reginfo section.\n"); - exit(EXIT_FAILURE); - } - - if (dynamic_section_index == -1) { - fprintf(stderr, "Missing .dynamic section.\n"); - exit(EXIT_FAILURE); - } - - if (got_section_index == -1) { - fprintf(stderr, "Missing .got section.\n"); - exit(EXIT_FAILURE); - } - } - - if (rodata_section_index != -1) { - shdr = SECTION(rodata_section_index); - uint32_t size = u32be(shdr->sh_size); - rodata_section = data + u32be(shdr->sh_offset); - rodata_section_len = size; - rodata_vaddr = u32be(shdr->sh_addr); - } - - if (data_section_index != -1) { - shdr = SECTION(data_section_index); - uint32_t size = u32be(shdr->sh_size); - data_section = data + u32be(shdr->sh_offset); - data_section_len = size; - data_vaddr = u32be(shdr->sh_addr); - } - - if (bss_section_index != -1) { - shdr = SECTION(bss_section_index); - uint32_t size = u32be(shdr->sh_size); - bss_section_len = size; - bss_vaddr = u32be(shdr->sh_addr); - } - - // add symbols - if (symtab_section_index != -1) { - sym_shdr = SECTION(symtab_section_index); - sym_strtab = SECTION(u32be(sym_shdr->sh_link)); - assert(0 && ".symtab not supported - use a program with .dynsym instead"); - - assert(u32be(sym_shdr->sh_entsize) == sizeof(Elf32_Sym)); - for (uint32_t i = 0; i < u32be(sym_shdr->sh_size); i += sizeof(Elf32_Sym)) { - Elf32_Sym* sym = (Elf32_Sym*)(data + u32be(sym_shdr->sh_offset) + i); - const char* name = STR(sym_strtab, u32be(sym->st_name)); - uint32_t addr = u32be(sym->st_value); - - if (u16be(sym->st_shndx) != text_section_index || name[0] == '.') { - continue; - } - - addr += vaddr_adj; - // disasm_label_add(state, name, addr, u32be(sym->st_size), true); - } - } - - if (dynsym_section_index != -1) { - dynsym_shdr = SECTION(dynsym_section_index); - sym_dynstr = SECTION(u32be(dynsym_shdr->sh_link)); - reginfo_shdr = SECTION(reginfo_section_index); - dynamic_shdr = SECTION(dynamic_section_index); - got_shdr = SECTION(got_section_index); - - Elf32_RegInfo* reg_info = (Elf32_RegInfo*)(data + u32be(reginfo_shdr->sh_offset)); - uint32_t gp_base = u32be(reg_info->ri_gp_value); // gp should have this value through the program run - uint32_t got_start = 0; - uint32_t local_got_no = 0; - uint32_t first_got_sym = 0; - uint32_t dynsym_no = 0; // section size can't be used due to alignment 16 padding - - assert(u32be(dynamic_shdr->sh_entsize) == sizeof(Elf32_Dyn)); - for (uint32_t i = 0; i < u32be(dynamic_shdr->sh_size); i += sizeof(Elf32_Dyn)) { - Elf32_Dyn* dyn = (Elf32_Dyn*)(data + u32be(dynamic_shdr->sh_offset) + i); - - if (u32be(dyn->d_tag) == DT_PLTGOT) { - got_start = u32be(dyn->d_un.d_ptr); - } - - if (u32be(dyn->d_tag) == DT_MIPS_LOCAL_GOTNO) { - local_got_no = u32be(dyn->d_un.d_val); - } - - if (u32be(dyn->d_tag) == DT_MIPS_GOTSYM) { - first_got_sym = u32be(dyn->d_un.d_val); - } - - if (u32be(dyn->d_tag) == DT_MIPS_SYMTABNO) { - dynsym_no = u32be(dyn->d_un.d_val); - } - } - - assert(got_start != 0); - - // value to add to asm gp offset, for example 32752, if -32752(gp) refers to the first entry in got. - uint32_t gp_adj = gp_base - got_start; - - assert(gp_adj < 0x10000); - - assert(u32be(dynsym_shdr->sh_entsize) == sizeof(Elf32_Sym)); - - uint32_t global_got_no = dynsym_no - first_got_sym; - // global_got_entry *global_entries = (global_got_entry *)calloc(global_got_no, sizeof(global_got_entry)); - - got_globals.resize(global_got_no); - - uint32_t common_start = ~0U; - vector common_order; - - for (uint32_t i = 0; i < dynsym_no; i++) { - Elf32_Sym* sym = (Elf32_Sym*)(data + u32be(dynsym_shdr->sh_offset) + i * sizeof(Elf32_Sym)); - const char* name = STR(sym_dynstr, u32be(sym->st_name)); - uint32_t addr = u32be(sym->st_value); - - addr += vaddr_adj; - - uint8_t type = ELF32_ST_TYPE(sym->st_info); - - if (!strcmp(name, "_procedure_table")) { - procedure_table_start = addr; - } else if (!strcmp(name, "_procedure_table_size")) { - procedure_table_len = 40 * u32be(sym->st_value); - } - - if ((u16be(sym->st_shndx) == SHN_MIPS_TEXT && type == STT_FUNC) || - (type == STT_OBJECT && - (u16be(sym->st_shndx) == SHN_MIPS_ACOMMON || u16be(sym->st_shndx) == SHN_MIPS_DATA))) { - // disasm_label_add(state, name, addr, u32be(sym->st_size), true); - if (type == STT_OBJECT) {} - - if (u16be(sym->st_shndx) == SHN_MIPS_ACOMMON) { - if (addr < common_start) { - common_start = addr; - } - - common_order.push_back(name); - } - - if (type == STT_FUNC) { - add_function(addr); - - if (strcmp(name, "main") == 0) { - main_addr = addr; - } - - if (strcmp(name, "_mcount") == 0) { - mcount_addr = addr; - } - - symbol_names[addr] = name; - } - } - - if (i >= first_got_sym) { - uint32_t got_value = u32be(*(uint32_t*)(data + u32be(got_shdr->sh_offset) + - (local_got_no + (i - first_got_sym)) * sizeof(uint32_t))); - - if (u16be(sym->st_shndx) == SHN_MIPS_TEXT && type == STT_FUNC) { - // got_globals[i - first_got_sym] = got_value; - // label_addresses.insert(got_value); - got_globals[i - first_got_sym] = addr; // to include the 3 instr gp header thing - label_addresses.insert(addr); - } else if (type == STT_OBJECT && - (u16be(sym->st_shndx) == SHN_UNDEF || u16be(sym->st_shndx) == SHN_COMMON)) { - // symbol defined externally (for example in libc) - got_globals[i - first_got_sym] = got_value; - } else { - got_globals[i - first_got_sym] = addr; - } - - symbol_names[got_globals[i - first_got_sym]] = name; - } - } - - uint32_t* local_entries = (uint32_t*)calloc(local_got_no, sizeof(uint32_t)); - got_locals.resize(local_got_no); - for (uint32_t i = 0; i < local_got_no; i++) { - uint32_t* entry = (uint32_t*)(data + u32be(got_shdr->sh_offset) + i * sizeof(uint32_t)); - got_locals[i] = u32be(*entry); - } - - gp_value = gp_base; - gp_value_adj = gp_adj; - - free(local_entries); - } - - // add relocations - for (int i = 0; i < u16be(ehdr->e_shnum); i++) { - Elf32_Rel* prevHi = NULL; - - shdr = SECTION(i); - if (u32be(shdr->sh_type) != SHT_REL || u32be(shdr->sh_info) != (uint32_t)text_section_index) - continue; - - if (sym_shdr == NULL) { - fprintf(stderr, "Relocations without .symtab section\n"); - exit(EXIT_FAILURE); - } - - assert(u32be(shdr->sh_link) == (uint32_t)symtab_section_index); - assert(u32be(shdr->sh_entsize) == sizeof(Elf32_Rel)); - - for (uint32_t i = 0; i < u32be(shdr->sh_size); i += sizeof(Elf32_Rel)) { - Elf32_Rel* rel = (Elf32_Rel*)(data + u32be(shdr->sh_offset) + i); - uint32_t offset = text_offset + u32be(rel->r_offset); - uint32_t symIndex = ELF32_R_SYM(u32be(rel->r_info)); - uint32_t rtype = ELF32_R_TYPE(u32be(rel->r_info)); - const char* symName = "0"; - - if (symIndex != STN_UNDEF) { - Elf32_Sym* sym = (Elf32_Sym*)(data + u32be(sym_shdr->sh_offset) + symIndex * sizeof(Elf32_Sym)); - - symName = STR(sym_strtab, u32be(sym->st_name)); - } - - if (rtype == R_MIPS_HI16) { - if (prevHi != NULL) { - fprintf(stderr, "Consecutive R_MIPS_HI16.\n"); - exit(EXIT_FAILURE); - } - - prevHi = rel; - continue; - } - - if (rtype == R_MIPS_LO16) { - int32_t addend = (int16_t)((data[offset + 2] << 8) + data[offset + 3]); - - if (prevHi != NULL) { - uint32_t offset2 = text_offset + u32be(prevHi->r_offset); - - addend += (uint32_t)((data[offset2 + 2] << 8) + data[offset2 + 3]) << 16; - // add_reloc(state, offset2, symName, addend, out_range.vaddr); - } - prevHi = NULL; - // add_reloc(state, offset, symName, addend, out_range.vaddr); - } else if (rtype == R_MIPS_26) { - int32_t addend = (u32be(*(uint32_t*)(data + offset)) & ((1 << 26) - 1)) << 2; - - if (addend >= (1 << 27)) { - addend -= 1 << 28; - } - // add_reloc(state, offset, symName, addend, out_range.vaddr); - } - - else { - fprintf(stderr, "Bad relocation type %d.\n", rtype); - exit(EXIT_FAILURE); - } - } - - if (prevHi != NULL) { - fprintf(stderr, "R_MIPS_HI16 without matching R_MIPS_LO16.\n"); - exit(EXIT_FAILURE); - } - } -} -#undef SECTION -#undef STR - -size_t read_file(const char* file_name, uint8_t** data) { - FILE* in; - uint8_t* in_buf = NULL; - long file_size; - long bytes_read; - - in = fopen(file_name, "rb"); - assert(in != nullptr); - - // allocate buffer to read from offset to end of file - fseek(in, 0, SEEK_END); - file_size = ftell(in); - assert(file_size != -1L); - - in_buf = (uint8_t*)malloc(file_size); - fseek(in, 0, SEEK_SET); - - // read bytes - bytes_read = fread(in_buf, 1, file_size, in); - assert(bytes_read == file_size); - - fclose(in); - *data = in_buf; - return bytes_read; -} - -#ifdef UNIX_PLATFORM -void crashHandler(int sig) { - void* array[4096]; - const size_t nMaxFrames = std::size(array); - size_t size = backtrace(array, nMaxFrames); - char** symbols = backtrace_symbols(array, nMaxFrames); - - fprintf(stderr, "\n recomp crashed. (Signal: %i)\n", sig); - - // Feel free to add more crash messages. - const char* crashEasterEgg[] = { - "\tIT'S A SECRET TO EVERYBODY. \n\tBut it shouldn't be, you'd better ask about it!", - "\tI AM ERROR.", - "\tGRUMBLE,GRUMBLE...", - "\tDODONGO DISLIKES SMOKE \n\tAnd recomp dislikes whatever you fed it.", - "\tMay the way of the Hero lead \n\tto the debugger.", - "\tTHE WIND FISH SLUMBERS LONG... \n\tTHE HERO'S LIFE GONE... ", - "\tSEA BEARS FOAM, SLEEP BEARS DREAMS. \n\tBOTH END IN THE SAME WAY CRASSSH!", - "\tYou've met with a terrible fate, haven't you?", - "\tMaster, I calculate a 100% probability that recomp has crashed. \n\tAdditionally, the " - "batteries in your Wii Remote are nearly depleted.", - "\t CONGRATURATIONS! \n" - "\tAll Pages are displayed.\n" - "\t THANK YOU! \n" - "\t You are great debugger!", - "\tRCP is HUNG UP!!\n" - "\tOh! MY GOD!!", - }; - - srand(time(nullptr)); - auto easterIndex = rand() % std::size(crashEasterEgg); - - fprintf(stderr, "\n%s\n\n", crashEasterEgg[easterIndex]); - - fprintf(stderr, "Traceback:\n"); - for (size_t i = 1; i < size; i++) { - Dl_info info; - uint32_t gotAddress = dladdr(array[i], &info); - std::string functionName(symbols[i]); - - if (gotAddress != 0 && info.dli_sname != nullptr) { - int32_t status; - char* demangled = abi::__cxa_demangle(info.dli_sname, nullptr, nullptr, &status); - const char* nameFound = info.dli_sname; - - if (status == 0) { - nameFound = demangled; - } - - { - char auxBuffer[0x8000]; - - snprintf(auxBuffer, std::size(auxBuffer), "%s (+0x%lX)", nameFound, - (char*)array[i] - (char*)info.dli_saddr); - functionName = auxBuffer; - } - free(demangled); - -#if FULL_TRACEBACK == 0 - fprintf(stderr, "%-3zd %s\n", i, functionName.c_str()); -#endif - } - -#if FULL_TRACEBACK != 0 - fprintf(stderr, "%-3zd %s\n", i, functionName.c_str()); -#endif - } - - fprintf(stderr, "\n"); - - free(symbols); - exit(1); -} -#endif - -int main(int argc, char* argv[]) { - const char* filename = argv[1]; - - if (strcmp(filename, "--conservative") == 0) { - conservative = true; - filename = argv[2]; - } - -#ifdef UNIX_PLATFORM - signal(SIGSEGV, crashHandler); - signal(SIGABRT, crashHandler); -#endif - - uint8_t* data; - size_t len = read_file(filename, &data); - - parse_elf(data, len); - disassemble(); - inspect_data_function_pointers(data_function_pointers, rodata_section, rodata_vaddr, rodata_section_len); - inspect_data_function_pointers(data_function_pointers, data_section, data_vaddr, data_section_len); - pass1(); - pass2(); - pass3(); - pass4(); - pass5(); - pass6(); - // dump(); - dump_c(); - free(data); - - return 0; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/.clang-format b/tools/ido-static-recomp/tools/rabbitizer/.clang-format deleted file mode 100644 index 414e3cff..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/.clang-format +++ /dev/null @@ -1,23 +0,0 @@ -IndentWidth: 4 -Language: Cpp -UseTab: Never -ColumnLimit: 160 -PointerAlignment: Right -BreakBeforeBraces: Attach -SpaceAfterCStyleCast: false -Cpp11BracedListStyle: false -IndentCaseLabels: true -BinPackArguments: true -BinPackParameters: true -AlignAfterOpenBracket: Align -AlignOperands: true -BreakBeforeTernaryOperators: true -BreakBeforeBinaryOperators: None -AllowShortBlocksOnASingleLine: true -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: false -AlignEscapedNewlines: Left -AlignTrailingComments: true -SortIncludes: false diff --git a/tools/ido-static-recomp/tools/rabbitizer/.clang-tidy b/tools/ido-static-recomp/tools/rabbitizer/.clang-tidy deleted file mode 100644 index 8534b8a6..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/.clang-tidy +++ /dev/null @@ -1,9 +0,0 @@ -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' -WarningsAsErrors: '' -HeaderFilterRegex: '(src|include)\/.*\.h$' -FormatStyle: 'file' -CheckOptions: - # Require argument names to match exactly (instead of allowing a name to be a prefix/suffix of another) - # Note: 'true' is expected by clang-tidy 12+ but '1' is used for compatibility with older versions - - key: readability-inconsistent-declaration-parameter-name.Strict - value: 1 diff --git a/tools/ido-static-recomp/tools/rabbitizer/.gitattributes b/tools/ido-static-recomp/tools/rabbitizer/.gitattributes deleted file mode 100644 index dfe07704..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto diff --git a/tools/ido-static-recomp/tools/rabbitizer/.github/workflows/ci.yml b/tools/ido-static-recomp/tools/rabbitizer/.github/workflows/ci.yml deleted file mode 100644 index 6baeb371..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/.github/workflows/ci.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Build and upload to PyPI - -# Build on every branch push, tag push, and pull request change: -on: [push, pull_request] - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-latest, macos-latest, windows-latest] - - steps: - - uses: actions/checkout@v2 - - - name: Build wheels - uses: pypa/cibuildwheel@v2.5.0 - env: - CIBW_ARCHS_WINDOWS: "auto" - CIBW_ARCHS_LINUX: "auto" - CIBW_ARCHS_MACOS: "all" - - - uses: actions/upload-artifact@v2 - with: - path: ./wheelhouse/*.whl - - build_sdist: - name: Build source distribution - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Build sdist - run: pipx run build --sdist - - - uses: actions/upload-artifact@v2 - with: - path: dist/*.tar.gz - - upload_pypi: - needs: [build_wheels, build_sdist] - runs-on: ubuntu-latest - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') - steps: - - uses: actions/download-artifact@v2 - with: - name: artifact - path: dist - - - uses: pypa/gh-action-pypi-publish@v1.4.2 - with: - user: __token__ - password: ${{ secrets.pypi_password }} diff --git a/tools/ido-static-recomp/tools/rabbitizer/.github/workflows/make.yml b/tools/ido-static-recomp/tools/rabbitizer/.github/workflows/make.yml deleted file mode 100644 index 3079d9e3..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/.github/workflows/make.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: make - -# Build on every branch push, tag push, and pull request change: -on: [push, pull_request] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: make - run: make WERROR=1 diff --git a/tools/ido-static-recomp/tools/rabbitizer/.gitignore b/tools/ido-static-recomp/tools/rabbitizer/.gitignore deleted file mode 100644 index e433d8d7..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/.gitignore +++ /dev/null @@ -1,215 +0,0 @@ -# https://raw.githubusercontent.com/github/gitignore/main/C.gitignore -# https://raw.githubusercontent.com/github/gitignore/main/Python.gitignore - -# Prerequisites -*.d - -# Object files -*.o -*.ko -*.obj -*.elf - -# Linker output -*.ilk -*.map -*.exp - -# Precompiled Headers -*.gch -*.pch - -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb - -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf - - - -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -#pdm.lock -# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it -# in version control. -# https://pdm.fming.dev/#use-with-ide -.pdm.toml - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - - -.vscode/ - diff --git a/tools/ido-static-recomp/tools/rabbitizer/.gitrepo b/tools/ido-static-recomp/tools/rabbitizer/.gitrepo deleted file mode 100644 index cbd77990..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/.gitrepo +++ /dev/null @@ -1,12 +0,0 @@ -; DO NOT EDIT (unless you know what you are doing) -; -; This subdirectory is a git "subrepo", and this file is maintained by the -; git-subrepo command. See https://github.com/git-commands/git-subrepo#readme -; -[subrepo] - remote = git@github.com:Decompollaborate/rabbitizer.git - branch = develop - commit = 72bf240f468d30286888212b5fb773fae94340f6 - parent = fa84f928c510147d6083b979efb28a5a07eefe10 - method = merge - cmdver = 0.4.3 diff --git a/tools/ido-static-recomp/tools/rabbitizer/LICENSE b/tools/ido-static-recomp/tools/rabbitizer/LICENSE deleted file mode 100644 index 10a2aa35..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Decompollaborate - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/tools/ido-static-recomp/tools/rabbitizer/MANIFEST.in b/tools/ido-static-recomp/tools/rabbitizer/MANIFEST.in deleted file mode 100644 index 1e60716c..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -include **/*.h -include **/**/*.h -graft include diff --git a/tools/ido-static-recomp/tools/rabbitizer/Makefile b/tools/ido-static-recomp/tools/rabbitizer/Makefile deleted file mode 100644 index e0b92c36..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/Makefile +++ /dev/null @@ -1,140 +0,0 @@ -# Build options can be changed by modifying the makefile or by building with 'make SETTING=value'. -DEBUG ?= 0 -WERROR ?= 0 -ASAN ?= 0 -EXPERIMENTAL ?= 0 -SANITY_CHECKS ?= 1 - -CC := clang -CXX := clang++ -AR := ar -IINC := -I include -IINC_XX := -I include -I cplusplus/include -CSTD := -std=c11 -CXXSTD := -std=c++17 -CFLAGS := -fPIC -CXXFLAGS := -fPIC -LDFLAGS := -Lbuild -lrabbitizer -LDXXFLAGS := -Lbuild -lrabbitizerpp -WARNINGS := -Wall -Wextra -Wpedantic -# WARNINGS := -Wall -Wextra -Wpedantic -Wpadded -WARNINGS += -Werror=vla -Werror=switch -Werror=implicit-fallthrough -Werror=unused-function -Werror=unused-parameter -Werror=shadow -WARNINGS_C := -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -WARNINGS_CXX := - -ifeq ($(CC),gcc) - WARNINGS += -Wno-cast-function-type -endif - -ifeq ($(DEBUG),0) - OPTFLAGS := -Os -g -else - OPTFLAGS := -O0 -g3 - CFLAGS += -DDEVELOPMENT=1 - CXXFLAGS += -DDEVELOPMENT=1 -endif - -ifneq ($(WERROR),0) - WARNINGS += -Werror -endif - -ifneq ($(ASAN),0) - CFLAGS += -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined - CXXFLAGS += -fsanitize=address -fsanitize=pointer-compare -fsanitize=pointer-subtract -fsanitize=undefined -endif - -ifneq ($(EXPERIMENTAL),0) - CFLAGS += -DEXPERIMENTAL - CXXFLAGS += -DEXPERIMENTAL -endif - -ifneq ($(SANITY_CHECKS),0) - CFLAGS += -DRAB_SANITY_CHECKS=1 - CXXFLAGS += -DRAB_SANITY_CHECKS=1 -endif - - -SRC_DIRS := $(shell find src -type d) -C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) -H_FILES := $(foreach dir,$(IINC),$(wildcard $(dir)/**/*.h)) -O_FILES := $(foreach f,$(C_FILES:.c=.o),build/$f) - -SRCXX_DIRS := $(shell find cplusplus/src -type d) -CXX_FILES := $(foreach dir,$(SRCXX_DIRS),$(wildcard $(dir)/*.cpp)) -HXX_FILES := $(foreach dir,$(IINC_XX),$(wildcard $(dir)/**/*.hpp)) -OXX_FILES := $(foreach f,$(CXX_FILES:.cpp=.o),build/$f) - -DEP_FILES := $(O_FILES:%.o=%.d) $(OXX_FILES:%.o=%.d) - -TESTS_DIRS := $(shell find tests -type d) - -STATIC_LIB := build/librabbitizer.a -DYNAMIC_LIB := build/librabbitizer.so - -STATIC_LIB_XX := build/librabbitizerpp.a -DYNAMIC_LIB_XX := build/librabbitizerpp.so - -# create build directories -$(shell mkdir -p $(foreach dir,$(SRC_DIRS) $(SRCXX_DIRS) $(TESTS_DIRS),build/$(dir))) - - -# Dependencies of libraries - -$(STATIC_LIB): $(O_FILES) -$(DYNAMIC_LIB): $(O_FILES) - -$(STATIC_LIB_XX): $(O_FILES) $(OXX_FILES) -$(DYNAMIC_LIB_XX): $(O_FILES) $(OXX_FILES) - - -#### Main Targets ### - -all: static tests - -static: $(STATIC_LIB) $(STATIC_LIB_XX) -dynamic: $(DYNAMIC_LIB) $(DYNAMIC_LIB_XX) - -clean: - $(RM) -rf build - -distclean: clean - $(RM) -rf dist rabbitizer.egg-info .mypy_cache - -format: - clang-format-11 -i -style=file $(C_FILES) - clang-format-11 -i -style=file $(CXX_FILES) - -tidy: - clang-tidy-11 -p . --fix --fix-errors $(C_FILES) $(H_FILES) -- $(CSTD) $(OPTFLAGS) $(IINC) $(WARNINGS) $(WARNINGS_C) $(CFLAGS) - -tests: build/test.elf build/rsptest.elf build/r5900test.elf build/registersTrackerTest.elf build/tests/cplusplus/test.elf - -.PHONY: all clean distclean format tidy tests -.DEFAULT_GOAL := all -.SECONDARY: - - -#### Various Recipes #### - -build/%.elf: %.c | $(STATIC_LIB) - $(CC) -MMD $(CSTD) $(OPTFLAGS) $(IINC) $(WARNINGS) $(WARNINGS_C) $(CFLAGS) -o $@ $^ $(LDFLAGS) - -build/%.elf: %.cpp | $(STATIC_LIB_XX) - $(CXX) -MMD $(CXXSTD) $(OPTFLAGS) $(IINC_XX) $(WARNINGS) $(WARNINGS_CXX) $(CXXFLAGS) -o $@ $^ $(LDXXFLAGS) - -build/%.a: - $(AR) rcs $@ $^ - -build/%.so: - $(CC) -shared -o $@ $^ - -build/%.o: %.c -# The -MMD flags additionaly creates a .d file with the same name as the .o file. - $(CC) -MMD -c $(CSTD) $(OPTFLAGS) $(IINC) $(WARNINGS) $(WARNINGS_C) $(CFLAGS) -o $@ $< - -build/%.o: %.cpp -# The -MMD flags additionaly creates a .d file with the same name as the .o file. - $(CXX) -MMD -c $(CXXSTD) $(OPTFLAGS) $(IINC_XX) $(WARNINGS) $(WARNINGS_CXX) $(CXXFLAGS) -o $@ $< - - --include $(DEP_FILES) diff --git a/tools/ido-static-recomp/tools/rabbitizer/README.md b/tools/ido-static-recomp/tools/rabbitizer/README.md deleted file mode 100644 index 18bc794c..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/README.md +++ /dev/null @@ -1,55 +0,0 @@ -# rabbitizer - -[![PyPI - Downloads](https://img.shields.io/pypi/dm/rabbitizer)](https://pypi.org/project/rabbitizer/) -![GitHub](https://img.shields.io/github/license/Decompollaborate/rabbitizer) -![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/Decompollaborate/rabbitizer) -![PyPI](https://img.shields.io/pypi/v/rabbitizer) -![GitHub contributors](https://img.shields.io/github/contributors/Decompollaborate/rabbitizer?logo=purple) - -A MIPS instruction decoder API. - -Currently supports all the CPU instructions for MIPS I, II, III and IV. - -## Installing - -The recommended way to install is using from the PyPi release, via `pip`: - -```bash -pip install rabbitizer -``` - -In case you want to mess with the latest development version without wanting to clone the repository, then you could use the following command: - -```bash -pip install git+https://github.com/Decompollaborate/rabbitizer.git@develop -``` - -NOTE: Installing the development version is not recommended. Proceed at your own risk. - -## Features - -- Should produces matching assembly. -- Fully written in C for fast decoding. -- Python bindings. - - The minimal Python version is 3.7, older versions are not guaranteed to work. -- Includes some minor tools to build your own pointer/symbol detection. -- Configurable, many features can be turned on and off. -- MIPS instructions features: - - Named registers for MIPS VR4300's coprocessors. - - Support for many pseudoinstructions. - - Properly handle move to/from coprocessor instructions. - - Support for numeric, o32, n32 and n64 ABI register names. -- Some workarounds for some specific compilers/assemblers: - - `SN64`: - - `div`/`divu` fix: tweaks a bit the produced `div`, `divu` and `break` instructions. -- N64 RSP instruction decoding support. - - RSP decoding has been tested to build back to matching assemblies with [armips](https://github.com/Kingcom/armips/). -- R5900 (PS2's Emotion Engine processor) decoding support. - -## References - -- R5900: - - EmotionEngine instruction decoding: - - Official documentation from Toshiba: - - VU instruction manual: - - GNU binutils: diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/analysis/LoPairingInfo.hpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/analysis/LoPairingInfo.hpp deleted file mode 100644 index 020761a5..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/analysis/LoPairingInfo.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_LO_PAIRING_INFO_HPP -#define RABBITIZER_LO_PAIRING_INFO_HPP -#pragma once - -#include "analysis/RabbitizerLoPairingInfo.h" - - -namespace rabbitizer { - class LoPairingInfo { - protected: - RabbitizerLoPairingInfo pairingInfo; - - public: - LoPairingInfo(); - LoPairingInfo(const RabbitizerLoPairingInfo &pairingInfo); - - /** - * Returns a pointer to the inner RabbitizerLoPairingInfo. - * It is recommended to not mess with it unless you know what you are doing. - */ - RabbitizerLoPairingInfo *getCPtr(); - const RabbitizerLoPairingInfo *getCPtr() const; - - int getInstrOffset() const; - int64_t getValue() const; - bool shouldProcess() const; - bool isGpRel() const; - bool isGpGot() const; - }; -}; - - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/analysis/RegistersTracker.hpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/analysis/RegistersTracker.hpp deleted file mode 100644 index d3e1cb9e..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/analysis/RegistersTracker.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_REGISTERS_TRACKER_HPP -#define RABBITIZER_REGISTERS_TRACKER_HPP -#pragma once - -#include "analysis/RabbitizerRegistersTracker.h" - -#include "analysis/LoPairingInfo.hpp" -#include "instructions/InstructionBase.hpp" - - -namespace rabbitizer { - class RegistersTracker { - protected: - RabbitizerRegistersTracker tracker; - - public: - RegistersTracker(); - RegistersTracker(const RegistersTracker &other); - virtual ~RegistersTracker(); - - /** - * Returns a pointer to the inner RabbitizerRegistersTracker. - * It is recommended to not mess with it unless you know what you are doing. - */ - RabbitizerRegistersTracker *getCPtr(); - const RabbitizerRegistersTracker *getCPtr() const; - - bool moveRegisters(const InstructionBase &instr); - void overwriteRegisters(const InstructionBase &instr, int instrOffset); - void unsetRegistersAfterFuncCall(const InstructionBase &instr, const InstructionBase &prevInstr); - bool getAddressIfCanSetType(const InstructionBase &instr, int instrOffset, uint32_t *dstAddress) const; - bool getJrInfo(const InstructionBase &instr, int *dstOffset, uint32_t *dstAddress) const; - - void processLui(const InstructionBase &instr, int instrOffset); - void processLui(const InstructionBase &instr, int instrOffset, const InstructionBase &prevInstr); - void processGpLoad(const InstructionBase &instr, int instrOffset); - bool getLuiOffsetForConstant(const InstructionBase &instr, int *dstOffset) const; - void processConstant(const InstructionBase &instr, uint32_t value, int offset); - LoPairingInfo preprocessLoAndGetInfo(const InstructionBase &instr, int instrOffset); - void processLo(const InstructionBase &instr, uint32_t value, int offset); - bool hasLoButNoHi(const InstructionBase &instr) const; - }; -}; - - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstrId.hpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstrId.hpp deleted file mode 100644 index 59bf46f5..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstrId.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_INSTRID_HPP -#define RABBITIZER_INSTRID_HPP -#pragma once - -#include - - -namespace rabbitizer { - namespace InstrId { - #define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) \ - prefix##_##name, - - #define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) \ - RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, __VA_ARGS__) - - enum class UniqueId { - #include "instructions/instr_id/RabbitizerInstrId_cpu.inc" - - #include "instructions/instr_id/RabbitizerInstrId_rsp.inc" - - #include "instructions/instr_id/RabbitizerInstrId_r5900.inc" - - ALL_MAX = RABBITIZER_DEF_INSTR_ID(r5900, , MAX, ) - }; - - #undef RABBITIZER_DEF_INSTR_ID - #undef RABBITIZER_DEF_INSTR_ID_ALTNAME - - - std::string getOpcodeName(UniqueId uniqueId); - }; -}; - - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstructionBase.hpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstructionBase.hpp deleted file mode 100644 index ced9901a..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstructionBase.hpp +++ /dev/null @@ -1,253 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_INSTRUCTION_BASE_HPP -#define RABBITIZER_INSTRUCTION_BASE_HPP -#pragma once - -#include -#include - -#include "instructions/RabbitizerInstruction.h" - -#include "instructions/Registers.hpp" -#include "instructions/OperandType.hpp" -#include "instructions/InstrId.hpp" - - -namespace rabbitizer { - class InstructionBase { - protected: - RabbitizerInstruction instr; - - InstructionBase() = default; - virtual ~InstructionBase() = default; - - public: - /** - * Returns a pointer to the inner RabbitizerInstruction. - * It is recommended to not mess with it unless you know what you are doing. - */ - RabbitizerInstruction *getCPtr(); - const RabbitizerInstruction *getCPtr() const; - - /* getters */ - - uint8_t Get_opcode() const; - uint8_t Get_sa() const; - uint8_t Get_function() const; - - Registers::Cpu::GprO32 GetO32_rs() const; - Registers::Cpu::GprO32 GetO32_rt() const; - Registers::Cpu::GprO32 GetO32_rd() const; - - Registers::Cpu::GprN32 GetN32_rs() const; - Registers::Cpu::GprN32 GetN32_rt() const; - Registers::Cpu::GprN32 GetN32_rd() const; - - Registers::Cpu::Cop0 Get_cop0d() const; - - uint32_t Get_instr_index() const; - uint16_t Get_immediate() const; - - Registers::Cpu::Cop1O32 GetO32_fs() const; - Registers::Cpu::Cop1O32 GetO32_ft() const; - Registers::Cpu::Cop1O32 GetO32_fd() const; - - Registers::Cpu::Cop1N32 GetN32_fs() const; - Registers::Cpu::Cop1N32 GetN32_ft() const; - Registers::Cpu::Cop1N32 GetN32_fd() const; - - Registers::Cpu::Cop1N64 GetN64_fs() const; - Registers::Cpu::Cop1N64 GetN64_ft() const; - Registers::Cpu::Cop1N64 GetN64_fd() const; - - Registers::Cpu::Cop1Control Get_cop1cs() const; - - Registers::Cpu::Cop2 Get_cop2t() const; - - uint8_t Get_op() const; - - uint32_t Get_code() const; - uint32_t Get_code_upper() const; - uint32_t Get_code_lower() const; - - uint32_t Get_copraw() const; - - uint8_t Get_fmt() const; - uint8_t Get_fc() const; - uint8_t Get_cond() const; - - uint8_t Get_tf() const; - uint8_t Get_nd() const; - uint8_t Get_bc_fmt() const; - - uint8_t Get_stype() const; - - /* getters */ - - - /* setters */ - - void Set_opcode(uint8_t val); - void Set_sa(uint8_t val); - void Set_function(uint8_t val); - - void Set_rs(Registers::Cpu::GprO32 val); - void Set_rt(Registers::Cpu::GprO32 val); - void Set_rd(Registers::Cpu::GprO32 val); - - void Set_rs(Registers::Cpu::GprN32 val); - void Set_rt(Registers::Cpu::GprN32 val); - void Set_rd(Registers::Cpu::GprN32 val); - - void Set_cop0d(Registers::Cpu::Cop0 val); - - void Set_instr_index(uint32_t val); - void Set_immediate(uint16_t val); - - void Set_fs(Registers::Cpu::Cop1O32 val); - void Set_ft(Registers::Cpu::Cop1O32 val); - void Set_fd(Registers::Cpu::Cop1O32 val); - - void Set_fs(Registers::Cpu::Cop1N32 val); - void Set_ft(Registers::Cpu::Cop1N32 val); - void Set_fd(Registers::Cpu::Cop1N32 val); - - void Set_fs(Registers::Cpu::Cop1N64 val); - void Set_ft(Registers::Cpu::Cop1N64 val); - void Set_fd(Registers::Cpu::Cop1N64 val); - - void Set_cop1cs(Registers::Cpu::Cop1Control val); - - void Set_cop2t(Registers::Cpu::Cop2 val); - - void Set_op(uint8_t val); - - void Set_code(uint32_t val); - void Set_code_upper(uint32_t val); - void Set_code_lower(uint32_t val); - - void Set_copraw(uint32_t val); - - void Set_fmt(uint8_t val); - void Set_fc(uint8_t val); - void Set_cond(uint8_t val); - - void Set_tf(uint8_t val); - void Set_nd(uint8_t val); - void Set_bc_fmt(uint8_t val); - - void Set_stype(uint8_t val); - - /* setters */ - - - /* more getters */ - - uint32_t getRaw() const; - - InstrId::UniqueId getUniqueId() const; - uint32_t getVram() const; - bool isInHandwrittenFunction() const; - - int32_t getProcessedImmediate() const; - uint32_t getInstrIndexAsVram() const; - - int32_t getBranchOffset() const; - int32_t getGenericBranchOffset(uint32_t currentVram) const; - - - std::string getOpcodeName() const; - - /* more getters */ - - - /* */ - - void blankOut(); - - - /* Instruction examination */ - - bool isImplemented() const; - bool isLikelyHandwritten() const; - bool isNop() const; - bool isUnconditionalBranch() const; - bool isJrRa() const; - bool isJrNotRa() const; - bool hasDelaySlot() const; - - std::string mapInstrToType() const; - - bool sameOpcode(const InstructionBase &other) const; - bool sameOpcodeButDifferentArguments(const InstructionBase &other) const; - - bool hasOperand(OperandType operand) const; - bool hasOperandAlias(OperandType operand) const; - - uint32_t getValidBits() const; - bool isValid() const; - - /* Instruction examination */ - - - /* Instruction descriptor */ - - bool isUnknownType() const; - bool isJType() const; - bool isIType() const; - bool isRType() const; - bool isRegimmType() const; - - // TODO - // RabbitizerInstrSuffix instrSuffix() const; - - bool isBranch() const; - bool isBranchLikely() const; - bool isJump() const; - bool isTrap() const; - - bool isFloat() const; - bool isDouble() const; - - bool isUnsigned() const; - - bool modifiesRt() const; - bool modifiesRd() const; - - bool notEmitedByCompilers() const; - - bool canBeHi() const; - bool canBeLo() const; - bool doesLink() const; - bool doesDereference() const; - bool doesLoad() const; - bool doesStore() const; - bool maybeIsMove() const; - - bool isPseudo() const; - - /* Instruction descriptor */ - - - /* Disassembly */ - - bool mustDisasmAsData() const; - - std::string disassembleOperands() const; - std::string disassembleOperands(std::string_view immOverride) const; - - std::string disassembleInstruction(int extraLJust) const; - std::string disassembleInstruction(int extraLJust, std::string_view immOverride) const; - - std::string disassembleAsData(int extraLJust) const; - - std::string disassemble(int extraLJust) const; - std::string disassemble(int extraLJust, std::string_view immOverride) const; - - /* Disassembly */ - }; -}; - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstructionCpu.hpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstructionCpu.hpp deleted file mode 100644 index ef2eec54..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstructionCpu.hpp +++ /dev/null @@ -1,20 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_INSTRUCTION_CPU_HPP -#define RABBITIZER_INSTRUCTION_CPU_HPP -#pragma once - -#include "InstructionBase.hpp" - - -namespace rabbitizer { - class InstructionCpu : public InstructionBase { - public: - InstructionCpu(uint32_t word, uint32_t vram); - virtual ~InstructionCpu(); - }; -}; - - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstructionR5900.hpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstructionR5900.hpp deleted file mode 100644 index 0be3a271..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstructionR5900.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_INSTRUCTION_R5900_HPP -#define RABBITIZER_INSTRUCTION_R5900_HPP -#pragma once - -#include "InstructionBase.hpp" - - -namespace rabbitizer { - class InstructionR5900 : public InstructionBase { - public: - InstructionR5900(uint32_t word, uint32_t vram); - virtual ~InstructionR5900(); - - Registers::R5900::VF GetR5900_vfs() const; - Registers::R5900::VF GetR5900_vft() const; - Registers::R5900::VF GetR5900_vfd() const; - - Registers::R5900::VI GetR5900_vis() const; - Registers::R5900::VI GetR5900_vit() const; - Registers::R5900::VI GetR5900_vid() const; - - uint8_t GetR5900_mmi_function() const; - uint8_t GetR5900_fhi_flo() const; - - uint8_t GetR5900_xyzw_x() const; - uint8_t GetR5900_xyzw_y() const; - uint8_t GetR5900_xyzw_z() const; - uint8_t GetR5900_xyzw_w() const; - uint8_t GetR5900_n() const; - uint8_t GetR5900_l() const; - uint8_t GetR5900_m() const; - - uint8_t GetR5900_imm5() const; - }; -}; - - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstructionRsp.hpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstructionRsp.hpp deleted file mode 100644 index f2d32a13..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/InstructionRsp.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_INSTRUCTION_RSP_HPP -#define RABBITIZER_INSTRUCTION_RSP_HPP -#pragma once - -#include "InstructionBase.hpp" - - -namespace rabbitizer { - class InstructionRsp : public InstructionBase { - public: - InstructionRsp(uint32_t word, uint32_t vram); - virtual ~InstructionRsp(); - - Registers::Rsp::Gpr GetRsp_rs() const; - Registers::Rsp::Gpr GetRsp_rt() const; - Registers::Rsp::Gpr GetRsp_rd() const; - - Registers::Rsp::Cop0 GetRsp_cop0d() const; - - Registers::Rsp::Cop2 GetRsp_cop2t() const; - - Registers::Rsp::Cop2Control GetRsp_cop2cd() const; - - Registers::Rsp::Vector GetRsp_vs() const; - Registers::Rsp::Vector GetRsp_vt() const; - Registers::Rsp::Vector GetRsp_vd() const; - - uint8_t GetRsp_elementhigh() const; - uint8_t GetRsp_elementlow() const; - - uint8_t GetRsp_index() const; - uint8_t GetRsp_de() const; - }; -}; - - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/OperandType.hpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/OperandType.hpp deleted file mode 100644 index abd728ad..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/OperandType.hpp +++ /dev/null @@ -1,27 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_OPERAND_TYPE_HPP -#define RABBITIZER_OPERAND_TYPE_HPP -#pragma once - - -namespace rabbitizer { - #define RAB_DEF_OPERAND(prefix, operand) \ - prefix##_##operand, - - enum class OperandType { - RAB_DEF_OPERAND(ALL, INVALID) - - #include "instructions/operands/RabbitizerOperandType_cpu.inc" - #include "instructions/operands/RabbitizerOperandType_rsp.inc" - #include "instructions/operands/RabbitizerOperandType_r5900.inc" - - RAB_DEF_OPERAND(ALL, MAX) - }; - - #undef RAB_DEF_OPERAND -}; - - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/Registers.hpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/Registers.hpp deleted file mode 100644 index ceddd8f8..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/instructions/Registers.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_REGISTER_HPP -#define RABBITIZER_REGISTER_HPP -#pragma once - - -namespace rabbitizer { - - namespace Registers { - #define RABBITIZER_DEF_REG(prefix, name, numeric) \ - prefix##_##name - - #define RABBITIZER_DEF_REG_NODOLLAR(prefix, name, numeric) \ - prefix##_##name - - namespace Cpu { - enum class GprO32 { - #include "instructions/registers/RabbitizerRegister_GprO32.inc" - }; - - enum class GprN32 { - #include "instructions/registers/RabbitizerRegister_GprN32.inc" - }; - - - enum class Cop0 { - #include "instructions/registers/RabbitizerRegister_Cop0.inc" - }; - - // Float registers - enum class Cop1O32 { - #include "instructions/registers/RabbitizerRegister_Cop1O32.inc" - }; - - enum class Cop1N32 { - #include "instructions/registers/RabbitizerRegister_Cop1N32.inc" - }; - - enum class Cop1N64 { - #include "instructions/registers/RabbitizerRegister_Cop1N64.inc" - }; - - enum class Cop1Control { - #include "instructions/registers/RabbitizerRegister_Cop1Control.inc" - }; - - enum class Cop2 { - #include "instructions/registers/RabbitizerRegister_Cop2.inc" - }; - }; - - - namespace Rsp { - enum class Gpr { - #include "instructions/registers/RabbitizerRegister_RspGpr.inc" - }; - - enum class Cop0 { - #include "instructions/registers/RabbitizerRegister_RspCop0.inc" - }; - - enum class Cop2 { - #include "instructions/registers/RabbitizerRegister_RspCop2.inc" - }; - - enum class Cop2Control { - #include "instructions/registers/RabbitizerRegister_RspCop2Control.inc" - }; - - enum class Vector { - #include "instructions/registers/RabbitizerRegister_RspVector.inc" - }; - }; - - - namespace R5900 { - enum class VF { - #include "instructions/registers/RabbitizerRegister_R5900VF.inc" - }; - - enum class VI { - #include "instructions/registers/RabbitizerRegister_R5900VI.inc" - }; - }; - - #undef RABBITIZER_DEF_REG - #undef RABBITIZER_DEF_REG_NODOLLAR - }; -}; - - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/rabbitizer.hpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/rabbitizer.hpp deleted file mode 100644 index 332101e8..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/include/rabbitizer.hpp +++ /dev/null @@ -1,26 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_HPP -#define RABBITIZER_HPP -#pragma once - - -#include "common/RabbitizerVersion.h" -#include "common/RabbitizerConfig.h" - -#include "instructions/OperandType.hpp" -#include "instructions/InstrId.hpp" -//#include "instructions/InstrSuffix.hpp" -//#include "instructions/InstrDescriptor.hpp" -#include "instructions/Registers.hpp" -#include "instructions/InstructionBase.hpp" -#include "instructions/InstructionCpu.hpp" -#include "instructions/InstructionRsp.hpp" -#include "instructions/InstructionR5900.hpp" - -#include "analysis/LoPairingInfo.hpp" -#include "analysis/RegistersTracker.hpp" - - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/analysis/LoPairingInfo.cpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/analysis/LoPairingInfo.cpp deleted file mode 100644 index d6fba253..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/analysis/LoPairingInfo.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "analysis/LoPairingInfo.hpp" - -using namespace rabbitizer; - -LoPairingInfo::LoPairingInfo() : pairingInfo{} { -} -LoPairingInfo::LoPairingInfo(const RabbitizerLoPairingInfo &newPairingInfo) : pairingInfo{ newPairingInfo } { -} - -RabbitizerLoPairingInfo *LoPairingInfo::getCPtr() { - return &this->pairingInfo; -} -const RabbitizerLoPairingInfo *LoPairingInfo::getCPtr() const { - return &this->pairingInfo; -} - -int LoPairingInfo::getInstrOffset() const { - return this->pairingInfo.instrOffset; -} -int64_t LoPairingInfo::getValue() const { - return this->pairingInfo.value; -} -bool LoPairingInfo::shouldProcess() const { - return this->pairingInfo.shouldProcess; -} -bool LoPairingInfo::isGpRel() const { - return this->pairingInfo.isGpRel; -} -bool LoPairingInfo::isGpGot() const { - return this->pairingInfo.isGpGot; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/analysis/RegistersTracker.cpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/analysis/RegistersTracker.cpp deleted file mode 100644 index 5294d58f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/analysis/RegistersTracker.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "analysis/RegistersTracker.hpp" - -using namespace rabbitizer; - -RegistersTracker::RegistersTracker() { - RabbitizerRegistersTracker_init(&this->tracker, NULL); -} -RegistersTracker::RegistersTracker(const RegistersTracker &other) { - RabbitizerRegistersTracker_init(&this->tracker, &other.tracker); -} -RegistersTracker::~RegistersTracker() { - RabbitizerRegistersTracker_destroy(&this->tracker); -} - -RabbitizerRegistersTracker *RegistersTracker::getCPtr() { - return &this->tracker; -} -const RabbitizerRegistersTracker *RegistersTracker::getCPtr() const { - return &this->tracker; -} - -bool RegistersTracker::moveRegisters(const InstructionBase &instr) { - return RabbitizerRegistersTracker_moveRegisters(&this->tracker, instr.getCPtr()); -} -void RegistersTracker::overwriteRegisters(const InstructionBase &instr, int instrOffset) { - RabbitizerRegistersTracker_overwriteRegisters(&this->tracker, instr.getCPtr(), instrOffset); -} -void RegistersTracker::unsetRegistersAfterFuncCall(const InstructionBase &instr, const InstructionBase &prevInstr) { - RabbitizerRegistersTracker_unsetRegistersAfterFuncCall(&this->tracker, instr.getCPtr(), prevInstr.getCPtr()); -} -bool RegistersTracker::getAddressIfCanSetType(const InstructionBase &instr, int instrOffset, uint32_t *dstAddress) const { - return RabbitizerRegistersTracker_getAddressIfCanSetType(&this->tracker, instr.getCPtr(), instrOffset, dstAddress); -} -bool RegistersTracker::getJrInfo(const InstructionBase &instr, int *dstOffset, uint32_t *dstAddress) const { - return RabbitizerRegistersTracker_getJrInfo(&this->tracker, instr.getCPtr(), dstOffset, dstAddress); -} - -void RegistersTracker::processLui(const InstructionBase &instr, int instrOffset) { - RabbitizerRegistersTracker_processLui(&this->tracker, instr.getCPtr(), instrOffset, NULL); -} -void RegistersTracker::processLui(const InstructionBase &instr, int instrOffset, const InstructionBase &prevInstr) { - RabbitizerRegistersTracker_processLui(&this->tracker, instr.getCPtr(), instrOffset, prevInstr.getCPtr()); -} -void RegistersTracker::processGpLoad(const InstructionBase &instr, int instrOffset) { - RabbitizerRegistersTracker_processGpLoad(&this->tracker, instr.getCPtr(), instrOffset); -} -bool RegistersTracker::getLuiOffsetForConstant(const InstructionBase &instr, int *dstOffset) const { - return RabbitizerRegistersTracker_getLuiOffsetForConstant(&this->tracker, instr.getCPtr(), dstOffset); -} -void RegistersTracker::processConstant(const InstructionBase &instr, uint32_t value, int offset) { - RabbitizerRegistersTracker_processConstant(&this->tracker, instr.getCPtr(), value, offset); -} -LoPairingInfo RegistersTracker::preprocessLoAndGetInfo(const InstructionBase &instr, int instrOffset) { - return RabbitizerRegistersTracker_preprocessLoAndGetInfo(&this->tracker, instr.getCPtr(), instrOffset); -} -void RegistersTracker::processLo(const InstructionBase &instr, uint32_t value, int offset) { - RabbitizerRegistersTracker_processLo(&this->tracker, instr.getCPtr(), value, offset); -} -bool RegistersTracker::hasLoButNoHi(const InstructionBase &instr) const { - return RabbitizerRegistersTracker_hasLoButNoHi(&this->tracker, instr.getCPtr()); -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstrId.cpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstrId.cpp deleted file mode 100644 index 03e28d01..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstrId.cpp +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/InstrId.hpp" - -#include "instructions/RabbitizerInstrId.h" - -using namespace rabbitizer; - -std::string InstrId::getOpcodeName(InstrId::UniqueId uniqueId) { - RabbitizerInstrId id = static_cast(uniqueId); - - return std::string(RabbitizerInstrId_getOpcodeName(id)); -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstructionBase.cpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstructionBase.cpp deleted file mode 100644 index 4f5ad5be..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstructionBase.cpp +++ /dev/null @@ -1,1036 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/InstructionBase.hpp" - -#include - -#include "instructions/RabbitizerInstruction.h" -#include "instructions/RabbitizerInstructionR5900.h" - -using namespace rabbitizer; - -RabbitizerInstruction *InstructionBase::getCPtr() { - return &this->instr; -} -const RabbitizerInstruction *InstructionBase::getCPtr() const { - return &this->instr; -} - -/* getters */ - -uint8_t InstructionBase::Get_opcode() const { - return RAB_INSTR_GET_opcode(&this->instr); -} -uint8_t InstructionBase::Get_sa() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_sa)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'sa' operand."); - } -#endif - - return RAB_INSTR_GET_sa(&this->instr); -} -uint8_t InstructionBase::Get_function() const { - /* - #ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_function)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'function' operand."); - } - #endif - */ - - return RAB_INSTR_GET_function(&this->instr); -} - -Registers::Cpu::GprO32 InstructionBase::GetO32_rs() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_rs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rs' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_rs(&this->instr)); -} -Registers::Cpu::GprO32 InstructionBase::GetO32_rt() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_rt)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rt' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_rt(&this->instr)); -} -Registers::Cpu::GprO32 InstructionBase::GetO32_rd() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_rd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rd' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_rd(&this->instr)); -} - -Registers::Cpu::GprN32 InstructionBase::GetN32_rs() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_rs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rs' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_rs(&this->instr)); -} -Registers::Cpu::GprN32 InstructionBase::GetN32_rt() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_rt)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rt' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_rt(&this->instr)); -} -Registers::Cpu::GprN32 InstructionBase::GetN32_rd() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_rd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rd' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_rd(&this->instr)); -} - -Registers::Cpu::Cop0 InstructionBase::Get_cop0d() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_cop0d)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'cop0d' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_cop0d(&this->instr)); -} - -uint32_t InstructionBase::Get_instr_index() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_label)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'label' operand."); - } -#endif - - return RAB_INSTR_GET_instr_index(&this->instr); -} -uint16_t InstructionBase::Get_immediate() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_immediate)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'immediate' operand."); - } -#endif - - return RAB_INSTR_GET_immediate(&this->instr); -} - -Registers::Cpu::Cop1O32 InstructionBase::GetO32_fs() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_fs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'fs' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_fs(&this->instr)); -} -Registers::Cpu::Cop1O32 InstructionBase::GetO32_ft() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_ft)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'ft' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_ft(&this->instr)); -} -Registers::Cpu::Cop1O32 InstructionBase::GetO32_fd() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_fd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'fd' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_fd(&this->instr)); -} - -Registers::Cpu::Cop1N32 InstructionBase::GetN32_fs() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_fs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'fs' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_fs(&this->instr)); -} -Registers::Cpu::Cop1N32 InstructionBase::GetN32_ft() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_ft)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'ft' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_ft(&this->instr)); -} -Registers::Cpu::Cop1N32 InstructionBase::GetN32_fd() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_fd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'fd' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_fd(&this->instr)); -} - -Registers::Cpu::Cop1N64 InstructionBase::GetN64_fs() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_fs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'fs' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_fs(&this->instr)); -} -Registers::Cpu::Cop1N64 InstructionBase::GetN64_ft() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_ft)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'ft' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_ft(&this->instr)); -} -Registers::Cpu::Cop1N64 InstructionBase::GetN64_fd() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_fd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'fd' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_fd(&this->instr)); -} - -Registers::Cpu::Cop1Control InstructionBase::Get_cop1cs() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_cop1cs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'cop1cs' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_cop1cs(&this->instr)); -} - -Registers::Cpu::Cop2 InstructionBase::Get_cop2t() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_cop2t)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'cop2t' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_cop2t(&this->instr)); -} - -uint8_t InstructionBase::Get_op() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_op)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'op' operand."); - } -#endif - - return RAB_INSTR_GET_op(&this->instr); -} - -uint32_t InstructionBase::Get_code() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_code)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'code' operand."); - } -#endif - - return RAB_INSTR_GET_code(&this->instr); -} -uint32_t InstructionBase::Get_code_upper() const { -#if 0 -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_code_upper)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'code_upper' operand."); - } -#endif -#endif - - return RAB_INSTR_GET_code_upper(&this->instr); -} -uint32_t InstructionBase::Get_code_lower() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_code_lower)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'code_lower' operand."); - } -#endif - - return RAB_INSTR_GET_code_lower(&this->instr); -} - -uint32_t InstructionBase::Get_copraw() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_copraw)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'copraw' operand."); - } -#endif - - return RAB_INSTR_GET_copraw(&this->instr); -} - -uint8_t InstructionBase::Get_fmt() const { - return RAB_INSTR_GET_fmt(&this->instr); -} -uint8_t InstructionBase::Get_fc() const { - return RAB_INSTR_GET_fc(&this->instr); -} -uint8_t InstructionBase::Get_cond() const { - return RAB_INSTR_GET_cond(&this->instr); -} - -uint8_t InstructionBase::Get_tf() const { - return RAB_INSTR_GET_tf(&this->instr); -} -uint8_t InstructionBase::Get_nd() const { - return RAB_INSTR_GET_nd(&this->instr); -} -uint8_t InstructionBase::Get_bc_fmt() const { - return RAB_INSTR_GET_bc_fmt(&this->instr); -} - -uint8_t InstructionBase::Get_stype() const { - return RAB_INSTR_GET_stype(&this->instr); -} - -/* getters */ - -/* setters */ - -void InstructionBase::Set_opcode(uint8_t val) { - this->instr.word = RAB_INSTR_PACK_opcode(this->instr.word, val); -} -void InstructionBase::Set_sa(uint8_t val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_sa)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'sa' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_sa(this->instr.word, val); -} -void InstructionBase::Set_function(uint8_t val) { - this->instr.word = RAB_INSTR_PACK_function(this->instr.word, val); -} - -void InstructionBase::Set_rs(Registers::Cpu::GprO32 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_rs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rs' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_rs(this->instr.word, static_cast(val)); -} -void InstructionBase::Set_rt(Registers::Cpu::GprO32 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_rt)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rt' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_rt(this->instr.word, static_cast(val)); -} -void InstructionBase::Set_rd(Registers::Cpu::GprO32 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_rd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rd' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_rd(this->instr.word, static_cast(val)); -} - -void InstructionBase::Set_rs(Registers::Cpu::GprN32 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_rs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rs' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_rs(this->instr.word, static_cast(val)); -} -void InstructionBase::Set_rt(Registers::Cpu::GprN32 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_rt)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rt' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_rt(this->instr.word, static_cast(val)); -} -void InstructionBase::Set_rd(Registers::Cpu::GprN32 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_rd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rd' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_rd(this->instr.word, static_cast(val)); -} - -void InstructionBase::Set_cop0d(Registers::Cpu::Cop0 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_cop0d)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'cop0d' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_cop0d(this->instr.word, static_cast(val)); -} - -void InstructionBase::Set_instr_index(uint32_t val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_label)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'label' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_instr_index(this->instr.word, val); -} -void InstructionBase::Set_immediate(uint16_t val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_immediate)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'immediate' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_immediate(this->instr.word, val); -} - -void InstructionBase::Set_fs(Registers::Cpu::Cop1O32 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_fs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'fs' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_fs(this->instr.word, static_cast(val)); -} -void InstructionBase::Set_ft(Registers::Cpu::Cop1O32 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_ft)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'ft' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_ft(this->instr.word, static_cast(val)); -} -void InstructionBase::Set_fd(Registers::Cpu::Cop1O32 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_fd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'fd' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_fd(this->instr.word, static_cast(val)); -} - -void InstructionBase::Set_fs(Registers::Cpu::Cop1N32 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_fs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'fs' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_fs(this->instr.word, static_cast(val)); -} -void InstructionBase::Set_ft(Registers::Cpu::Cop1N32 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_ft)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'ft' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_ft(this->instr.word, static_cast(val)); -} -void InstructionBase::Set_fd(Registers::Cpu::Cop1N32 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_fd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'fd' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_fd(this->instr.word, static_cast(val)); -} - -void InstructionBase::Set_fs(Registers::Cpu::Cop1N64 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_fs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'fs' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_fs(this->instr.word, static_cast(val)); -} -void InstructionBase::Set_ft(Registers::Cpu::Cop1N64 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_ft)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'ft' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_ft(this->instr.word, static_cast(val)); -} -void InstructionBase::Set_fd(Registers::Cpu::Cop1N64 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_fd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'fd' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_fd(this->instr.word, static_cast(val)); -} - -void InstructionBase::Set_cop1cs(Registers::Cpu::Cop1Control val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_cop1cs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'cop1cs' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_cop1cs(this->instr.word, static_cast(val)); -} - -void InstructionBase::Set_cop2t(Registers::Cpu::Cop2 val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_cop2t)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'cop2t' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_cop2t(this->instr.word, static_cast(val)); -} - -void InstructionBase::Set_op(uint8_t val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_op)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'op' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_op(this->instr.word, val); -} - -void InstructionBase::Set_code(uint32_t val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_code)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'code' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_code(this->instr.word, val); -} - -void InstructionBase::Set_code_upper(uint32_t val) { -#if 0 -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_code_upper)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'code_upper' operand."); - } -#endif -#endif - - this->instr.word = RAB_INSTR_PACK_code_upper(this->instr.word, val); -} - -void InstructionBase::Set_code_lower(uint32_t val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_code_lower)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'code_lower' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_code_lower(this->instr.word, val); -} - -void InstructionBase::Set_copraw(uint32_t val) { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_copraw)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'copraw' operand."); - } -#endif - - this->instr.word = RAB_INSTR_PACK_copraw(this->instr.word, val); -} - -void InstructionBase::Set_fmt(uint8_t val) { - this->instr.word = RAB_INSTR_PACK_fmt(this->instr.word, val); -} -void InstructionBase::Set_fc(uint8_t val) { - this->instr.word = RAB_INSTR_PACK_fc(this->instr.word, val); -} -void InstructionBase::Set_cond(uint8_t val) { - this->instr.word = RAB_INSTR_PACK_cond(this->instr.word, val); -} - -void InstructionBase::Set_tf(uint8_t val) { - this->instr.word = RAB_INSTR_PACK_tf(this->instr.word, val); -} -void InstructionBase::Set_nd(uint8_t val) { - this->instr.word = RAB_INSTR_PACK_nd(this->instr.word, val); -} -void InstructionBase::Set_bc_fmt(uint8_t val) { - this->instr.word = RAB_INSTR_PACK_bc_fmt(this->instr.word, val); -} - -void InstructionBase::Set_stype(uint8_t val) { - this->instr.word = RAB_INSTR_PACK_stype(this->instr.word, val); -} - -/* setters */ - -/* more getters */ - -uint32_t InstructionBase::getRaw() const { - return RabbitizerInstruction_getRaw(&this->instr); -} - -InstrId::UniqueId InstructionBase::getUniqueId() const { - return static_cast(this->instr.uniqueId); -} -uint32_t InstructionBase::getVram() const { - return this->instr.vram; -} -bool InstructionBase::isInHandwrittenFunction() const { - return this->instr.inHandwrittenFunction; -} - -int32_t InstructionBase::getProcessedImmediate() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_immediate)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'immediate' operand."); - } -#endif - - return RabbitizerInstruction_getProcessedImmediate(&this->instr); -} -uint32_t InstructionBase::getInstrIndexAsVram() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_label)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'label' operand."); - } -#endif - - return RabbitizerInstruction_getInstrIndexAsVram(&this->instr); -} - -int32_t InstructionBase::getBranchOffset() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_branch_target_label)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'branch_target_label' operand."); - } -#endif - - return RabbitizerInstruction_getBranchOffset(&this->instr); -} -int32_t InstructionBase::getGenericBranchOffset(uint32_t currentVram) const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::cpu_branch_target_label) && !hasOperandAlias(OperandType::cpu_label)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have either 'branch_target_label' or 'label' operands."); - } -#endif - - return RabbitizerInstruction_getGenericBranchOffset(&this->instr, currentVram); -} - -std::string InstructionBase::getOpcodeName() const { - return InstrId::getOpcodeName(getUniqueId()); -} - -/* more getters */ - -/* */ - -void InstructionBase::blankOut() { - RabbitizerInstruction_blankOut(&this->instr); -} - -/* Instruction examination */ - -bool InstructionBase::isImplemented() const { - return RabbitizerInstruction_isImplemented(&this->instr); -} -bool InstructionBase::isLikelyHandwritten() const { - return RabbitizerInstruction_isLikelyHandwritten(&this->instr); -} -bool InstructionBase::isNop() const { - return RabbitizerInstruction_isNop(&this->instr); -} -bool InstructionBase::isUnconditionalBranch() const { - return RabbitizerInstruction_isUnconditionalBranch(&this->instr); -} -bool InstructionBase::isJrRa() const { - return RabbitizerInstruction_isJrRa(&this->instr); -} -bool InstructionBase::isJrNotRa() const { - return RabbitizerInstruction_isJrNotRa(&this->instr); -} -bool InstructionBase::hasDelaySlot() const { - return RabbitizerInstruction_hasDelaySlot(&this->instr); -} - -std::string InstructionBase::mapInstrToType() const { - return std::string(RabbitizerInstruction_mapInstrToType(&this->instr)); -} - -bool InstructionBase::sameOpcode(const InstructionBase &other) const { - return RabbitizerInstruction_sameOpcode(&this->instr, &other.instr); -} -bool InstructionBase::sameOpcodeButDifferentArguments(const InstructionBase &other) const { - return RabbitizerInstruction_sameOpcodeButDifferentArguments(&this->instr, &other.instr); -} - -bool InstructionBase::hasOperand(OperandType operand) const { - return RabbitizerInstruction_hasOperand(&this->instr, static_cast(operand)); -} -bool InstructionBase::hasOperandAlias(OperandType operand) const { - return RabbitizerInstruction_hasOperandAlias(&this->instr, static_cast(operand)); -} - -uint32_t InstructionBase::getValidBits() const { - return RabbitizerInstruction_getValidBits(&this->instr); -} -bool InstructionBase::isValid() const { - return RabbitizerInstruction_isValid(&this->instr); -} - -/* Instruction examination */ - -/* Instruction descriptor */ - -bool InstructionBase::isUnknownType() const { - return RabbitizerInstrDescriptor_isUnknownType(this->instr.descriptor); -} -bool InstructionBase::isJType() const { - return RabbitizerInstrDescriptor_isJType(this->instr.descriptor); -} -bool InstructionBase::isIType() const { - return RabbitizerInstrDescriptor_isIType(this->instr.descriptor); -} -bool InstructionBase::isRType() const { - return RabbitizerInstrDescriptor_isRType(this->instr.descriptor); -} -bool InstructionBase::isRegimmType() const { - return RabbitizerInstrDescriptor_isRegimmType(this->instr.descriptor); -} - -// TODO -// RabbitizerInstrSuffix instrSuffix() const; - -bool InstructionBase::isBranch() const { - return RabbitizerInstrDescriptor_isBranch(this->instr.descriptor); -} -bool InstructionBase::isBranchLikely() const { - return RabbitizerInstrDescriptor_isBranchLikely(this->instr.descriptor); -} -bool InstructionBase::isJump() const { - return RabbitizerInstrDescriptor_isJump(this->instr.descriptor); -} -bool InstructionBase::isTrap() const { - return RabbitizerInstrDescriptor_isTrap(this->instr.descriptor); -} - -bool InstructionBase::isFloat() const { - return RabbitizerInstrDescriptor_isFloat(this->instr.descriptor); -} -bool InstructionBase::isDouble() const { - return RabbitizerInstrDescriptor_isDouble(this->instr.descriptor); -} - -bool InstructionBase::isUnsigned() const { - return RabbitizerInstrDescriptor_isUnsigned(this->instr.descriptor); -} - -bool InstructionBase::modifiesRt() const { - return RabbitizerInstrDescriptor_modifiesRt(this->instr.descriptor); -} -bool InstructionBase::modifiesRd() const { - return RabbitizerInstrDescriptor_modifiesRd(this->instr.descriptor); -} - -bool InstructionBase::notEmitedByCompilers() const { - return RabbitizerInstrDescriptor_notEmitedByCompilers(this->instr.descriptor); -} - -bool InstructionBase::canBeHi() const { - return RabbitizerInstrDescriptor_canBeHi(this->instr.descriptor); -} -bool InstructionBase::canBeLo() const { - return RabbitizerInstrDescriptor_canBeLo(this->instr.descriptor); -} -bool InstructionBase::doesLink() const { - return RabbitizerInstrDescriptor_doesLink(this->instr.descriptor); -} -bool InstructionBase::doesDereference() const { - return RabbitizerInstrDescriptor_doesDereference(this->instr.descriptor); -} -bool InstructionBase::doesLoad() const { - return RabbitizerInstrDescriptor_doesLoad(this->instr.descriptor); -} -bool InstructionBase::doesStore() const { - return RabbitizerInstrDescriptor_doesStore(this->instr.descriptor); -} -bool InstructionBase::maybeIsMove() const { - return RabbitizerInstrDescriptor_maybeIsMove(this->instr.descriptor); -} - -bool InstructionBase::isPseudo() const { - return RabbitizerInstrDescriptor_isPseudo(this->instr.descriptor); -} - -/* Instruction descriptor */ - -/* Disassembly */ - -bool InstructionBase::mustDisasmAsData() const { - return RabbitizerInstruction_mustDisasmAsData(&this->instr); -} - -std::string InstructionBase::disassembleOperands() const { - const char *immOverridePtr = NULL; - size_t immOverrideLength = 0; - size_t bufferSize; - size_t disassmbledSize; - char *buffer; - - bufferSize = RabbitizerInstruction_getSizeForBufferOperandsDisasm(&instr, immOverrideLength); - - buffer = (char *)malloc(bufferSize + 1); - if (buffer == NULL) { - throw std::runtime_error("buffer == NULL"); - } - - disassmbledSize = RabbitizerInstruction_disassembleOperands(&instr, buffer, immOverridePtr, immOverrideLength); - - std::string output(buffer); - free(buffer); - - if (disassmbledSize > bufferSize) { - throw std::runtime_error("disassmbledSize > bufferSize"); - } - - return output; -} -std::string InstructionBase::disassembleOperands(std::string_view immOverride) const { - const char *immOverridePtr = immOverride.data(); - size_t immOverrideLength = immOverride.size(); - size_t bufferSize; - size_t disassmbledSize; - char *buffer; - - bufferSize = RabbitizerInstruction_getSizeForBufferOperandsDisasm(&instr, immOverrideLength); - - buffer = (char *)malloc(bufferSize + 1); - if (buffer == NULL) { - throw std::runtime_error("buffer == NULL"); - } - - disassmbledSize = RabbitizerInstruction_disassembleOperands(&instr, buffer, immOverridePtr, immOverrideLength); - - std::string output(buffer); - free(buffer); - - if (disassmbledSize > bufferSize) { - throw std::runtime_error("disassmbledSize > bufferSize"); - } - - return output; -} - -std::string InstructionBase::disassembleInstruction(int extraLJust) const { - const char *immOverridePtr = NULL; - size_t immOverrideLength = 0; - size_t bufferSize; - size_t disassmbledSize; - char *buffer; - - bufferSize = RabbitizerInstruction_getSizeForBufferInstrDisasm(&instr, immOverrideLength, extraLJust); - - buffer = (char *)malloc(bufferSize + 1); - if (buffer == NULL) { - throw std::runtime_error("buffer == NULL"); - } - - disassmbledSize = RabbitizerInstruction_disassembleInstruction(&instr, buffer, immOverridePtr, immOverrideLength, extraLJust); - - std::string output(buffer); - free(buffer); - - if (disassmbledSize > bufferSize) { - throw std::runtime_error("disassmbledSize > bufferSize"); - } - - return output; -} -std::string InstructionBase::disassembleInstruction(int extraLJust, std::string_view immOverride) const { - const char *immOverridePtr = immOverride.data(); - size_t immOverrideLength = immOverride.size(); - size_t bufferSize; - size_t disassmbledSize; - char *buffer; - - bufferSize = RabbitizerInstruction_getSizeForBufferInstrDisasm(&instr, immOverrideLength, extraLJust); - - buffer = (char *)malloc(bufferSize + 1); - if (buffer == NULL) { - throw std::runtime_error("buffer == NULL"); - } - - disassmbledSize = RabbitizerInstruction_disassembleInstruction(&instr, buffer, immOverridePtr, immOverrideLength, extraLJust); - - std::string output(buffer); - free(buffer); - - if (disassmbledSize > bufferSize) { - throw std::runtime_error("disassmbledSize > bufferSize"); - } - - return output; -} - -std::string InstructionBase::disassembleAsData(int extraLJust) const { - size_t bufferSize; - size_t disassmbledSize; - char *buffer; - - bufferSize = RabbitizerInstruction_getSizeForBufferDataDisasm(&instr, extraLJust); - - buffer = (char *)malloc(bufferSize + 1); - if (buffer == NULL) { - throw std::runtime_error("buffer == NULL"); - } - - disassmbledSize = RabbitizerInstruction_disassembleAsData(&instr, buffer, extraLJust); - - std::string output(buffer); - free(buffer); - - if (disassmbledSize > bufferSize) { - throw std::runtime_error("disassmbledSize > bufferSize"); - } - - return output; -} - -std::string InstructionBase::disassemble(int extraLJust) const { - const char *immOverridePtr = NULL; - size_t immOverrideLength = 0; - size_t bufferSize; - size_t disassmbledSize; - char *buffer; - - bufferSize = RabbitizerInstruction_getSizeForBuffer(&instr, immOverrideLength, extraLJust); - - buffer = (char *)malloc(bufferSize + 1); - if (buffer == NULL) { - throw std::runtime_error("buffer == NULL"); - } - - disassmbledSize = RabbitizerInstruction_disassemble(&instr, buffer, immOverridePtr, immOverrideLength, extraLJust); - - std::string output(buffer); - free(buffer); - - if (disassmbledSize > bufferSize) { - throw std::runtime_error("disassmbledSize > bufferSize"); - } - - return output; -} - -std::string InstructionBase::disassemble(int extraLJust, std::string_view immOverride) const { - const char *immOverridePtr = immOverride.data(); - size_t immOverrideLength = immOverride.size(); - size_t bufferSize; - size_t disassmbledSize; - char *buffer; - - bufferSize = RabbitizerInstruction_getSizeForBuffer(&instr, immOverrideLength, extraLJust); - - buffer = (char *)malloc(bufferSize + 1); - if (buffer == NULL) { - throw std::runtime_error("buffer == NULL"); - } - - disassmbledSize = RabbitizerInstruction_disassemble(&instr, buffer, immOverridePtr, immOverrideLength, extraLJust); - - std::string output(buffer); - free(buffer); - - if (disassmbledSize > bufferSize) { - throw std::runtime_error("disassmbledSize > bufferSize"); - } - - return output; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstructionCpu.cpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstructionCpu.cpp deleted file mode 100644 index 9488b9a3..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstructionCpu.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/InstructionCpu.hpp" - -using namespace rabbitizer; - -InstructionCpu::InstructionCpu(uint32_t word, uint32_t vram) : InstructionBase() { - RabbitizerInstruction_init(&this->instr, word, vram); - RabbitizerInstruction_processUniqueId(&this->instr); -} - -InstructionCpu::~InstructionCpu() { - RabbitizerInstruction_destroy(&this->instr); -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstructionR5900.cpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstructionR5900.cpp deleted file mode 100644 index 0fe00630..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstructionR5900.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/InstructionR5900.hpp" - -#include - -#include "instructions/RabbitizerInstructionR5900.h" - -using namespace rabbitizer; - -InstructionR5900::InstructionR5900(uint32_t word, uint32_t vram) : InstructionBase() { - RabbitizerInstructionR5900_init(&this->instr, word, vram); - RabbitizerInstructionR5900_processUniqueId(&this->instr); -} - -InstructionR5900::~InstructionR5900() { - RabbitizerInstructionR5900_destroy(&this->instr); -} - -Registers::R5900::VF InstructionR5900::GetR5900_vfs() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_rs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'vfs' operand."); - } -#endif - - return static_cast(RAB_INSTR_R5900_GET_vfs(&this->instr)); -} - -Registers::R5900::VF InstructionR5900::GetR5900_vft() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_rt)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'vft' operand."); - } -#endif - - return static_cast(RAB_INSTR_R5900_GET_vft(&this->instr)); -} - -Registers::R5900::VF InstructionR5900::GetR5900_vfd() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_rd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'vfd' operand."); - } -#endif - - return static_cast(RAB_INSTR_R5900_GET_vfd(&this->instr)); -} - -Registers::R5900::VI InstructionR5900::GetR5900_vis() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_rs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'vis' operand."); - } -#endif - - return static_cast(RAB_INSTR_R5900_GET_vis(&this->instr)); -} - -Registers::R5900::VI InstructionR5900::GetR5900_vit() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_rt)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'vit' operand."); - } -#endif - - return static_cast(RAB_INSTR_R5900_GET_vit(&this->instr)); -} - -Registers::R5900::VI InstructionR5900::GetR5900_vid() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_rd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'vid' operand."); - } -#endif - - return static_cast(RAB_INSTR_R5900_GET_vid(&this->instr)); -} - -uint8_t InstructionR5900::GetR5900_mmi_function() const { - return RAB_INSTR_R5900_GET_mmi_function(&this->instr); -} -uint8_t InstructionR5900::GetR5900_fhi_flo() const { - return RAB_INSTR_R5900_GET_fhi_flo(&this->instr); -} - -uint8_t InstructionR5900::GetR5900_xyzw_x() const { - return RAB_INSTR_R5900_GET_xyzw_x(&this->instr); -} -uint8_t InstructionR5900::GetR5900_xyzw_y() const { - return RAB_INSTR_R5900_GET_xyzw_y(&this->instr); -} -uint8_t InstructionR5900::GetR5900_xyzw_z() const { - return RAB_INSTR_R5900_GET_xyzw_z(&this->instr); -} -uint8_t InstructionR5900::GetR5900_xyzw_w() const { - return RAB_INSTR_R5900_GET_xyzw_w(&this->instr); -} -uint8_t InstructionR5900::GetR5900_n() const { - return RAB_INSTR_R5900_GET_n(&this->instr); -} -uint8_t InstructionR5900::GetR5900_l() const { - return RAB_INSTR_R5900_GET_l(&this->instr); -} -uint8_t InstructionR5900::GetR5900_m() const { - return RAB_INSTR_R5900_GET_m(&this->instr); -} - -uint8_t InstructionR5900::GetR5900_imm5() const { - return RAB_INSTR_R5900_GET_imm5(&this->instr); -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstructionRsp.cpp b/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstructionRsp.cpp deleted file mode 100644 index 891a0351..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/cplusplus/src/instructions/InstructionRsp.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/InstructionRsp.hpp" - -#include - -#include "instructions/RabbitizerInstructionRsp.h" - -using namespace rabbitizer; - -InstructionRsp::InstructionRsp(uint32_t word, uint32_t vram) : InstructionBase() { - RabbitizerInstructionRsp_init(&this->instr, word, vram); - RabbitizerInstructionRsp_processUniqueId(&this->instr); -} - -InstructionRsp::~InstructionRsp() { - RabbitizerInstructionRsp_destroy(&this->instr); -} - -Registers::Rsp::Gpr InstructionRsp::GetRsp_rs() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_rs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rs' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_rs(&this->instr)); -} -Registers::Rsp::Gpr InstructionRsp::GetRsp_rt() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_rt)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rt' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_rt(&this->instr)); -} -Registers::Rsp::Gpr InstructionRsp::GetRsp_rd() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_rd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'rd' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_rd(&this->instr)); -} - -Registers::Rsp::Cop0 InstructionRsp::GetRsp_cop0d() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_cop0d)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'cop0d' operand."); - } -#endif - - return static_cast(RAB_INSTR_GET_cop0d(&this->instr)); -} - -Registers::Rsp::Cop2 InstructionRsp::GetRsp_cop2t() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_cop2t)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'cop2t' operand."); - } -#endif - - return static_cast(RAB_INSTR_RSP_GET_cop2t(&this->instr)); -} - -Registers::Rsp::Cop2Control InstructionRsp::GetRsp_cop2cd() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_cop2t)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'cop2cd' operand."); - } -#endif - - return static_cast(RAB_INSTR_RSP_GET_cop2cd(&this->instr)); -} - -Registers::Rsp::Vector InstructionRsp::GetRsp_vs() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_vs)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'vs' operand."); - } -#endif - - return static_cast(RAB_INSTR_RSP_GET_vs(&this->instr)); -} -Registers::Rsp::Vector InstructionRsp::GetRsp_vt() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_vt)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'vt' operand."); - } -#endif - - return static_cast(RAB_INSTR_RSP_GET_vt(&this->instr)); -} -Registers::Rsp::Vector InstructionRsp::GetRsp_vd() const { -#ifdef RAB_SANITY_CHECKS - if (!hasOperandAlias(OperandType::rsp_vd)) { - // TODO: make a rabbitizer exception class - throw std::runtime_error("Instruction '" + getOpcodeName() + "' does not have 'vd' operand."); - } -#endif - - return static_cast(RAB_INSTR_RSP_GET_vd(&this->instr)); -} - -uint8_t InstructionRsp::GetRsp_elementhigh() const { - return RAB_INSTR_RSP_GET_elementhigh(&this->instr); -} -uint8_t InstructionRsp::GetRsp_elementlow() const { - return RAB_INSTR_RSP_GET_elementlow(&this->instr); -} - -uint8_t InstructionRsp::GetRsp_index() const { - return RAB_INSTR_RSP_GET_index(&this->instr); -} -uint8_t InstructionRsp::GetRsp_de() const { - return RAB_INSTR_RSP_GET_de(&this->instr); -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/analysis/RabbitizerLoPairingInfo.h b/tools/ido-static-recomp/tools/rabbitizer/include/analysis/RabbitizerLoPairingInfo.h deleted file mode 100644 index b6a70ed2..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/analysis/RabbitizerLoPairingInfo.h +++ /dev/null @@ -1,34 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_LO_PAIRING_INFO_H -#define RABBITIZER_LO_PAIRING_INFO_H -#pragma once - -#include - -#include "common/Utils.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct RabbitizerLoPairingInfo { - int instrOffset; - int64_t value; // could be either an unsigned 32 bits number or a signed one, so use 64 bits to ensure it fits - bool shouldProcess; - bool isGpRel; - bool isGpGot; -} RabbitizerLoPairingInfo; - - -NON_NULL(1) -void RabbitizerLoPairingInfo_Init(RabbitizerLoPairingInfo *self); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/analysis/RabbitizerRegistersTracker.h b/tools/ido-static-recomp/tools/rabbitizer/include/analysis/RabbitizerRegistersTracker.h deleted file mode 100644 index 36ccbd56..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/analysis/RabbitizerRegistersTracker.h +++ /dev/null @@ -1,65 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_REGISTERS_TRACKER_H -#define RABBITIZER_REGISTERS_TRACKER_H -#pragma once - -#include "common/Utils.h" -#include "RabbitizerTrackedRegisterState.h" -#include "RabbitizerLoPairingInfo.h" -#include "instructions/RabbitizerInstruction.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define RAB_REGISTERS_COUNT 32 - - -typedef struct RabbitizerRegistersTracker { - RabbitizerTrackedRegisterState registers[RAB_REGISTERS_COUNT]; -} RabbitizerRegistersTracker; - -// TODO: Change functions which use parameters as a way to return values into actual structs returned by the functions - -NON_NULL(1) -void RabbitizerRegistersTracker_init(RabbitizerRegistersTracker *self, const RabbitizerRegistersTracker *other); -NON_NULL(1) -void RabbitizerRegistersTracker_destroy(RabbitizerRegistersTracker *self); - -NON_NULL(1, 2) -bool RabbitizerRegistersTracker_moveRegisters(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr); -NON_NULL(1, 2) -void RabbitizerRegistersTracker_overwriteRegisters(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset); -NON_NULL(1, 2, 3) -void RabbitizerRegistersTracker_unsetRegistersAfterFuncCall(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, const RabbitizerInstruction *prevInstr); -NON_NULL(1, 2, 4) -bool RabbitizerRegistersTracker_getAddressIfCanSetType(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset, uint32_t *dstAddress); -NON_NULL(1, 2, 3, 4) -bool RabbitizerRegistersTracker_getJrInfo(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int *dstOffset, uint32_t *dstAddress); - -// prevInstr can be NULL -NON_NULL(1, 2) -void RabbitizerRegistersTracker_processLui(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset, const RabbitizerInstruction *prevInstr); -NON_NULL(1, 2) -void RabbitizerRegistersTracker_processGpLoad(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset); -NON_NULL(1, 2, 3) -bool RabbitizerRegistersTracker_getLuiOffsetForConstant(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int *dstOffset); -NON_NULL(1, 2) -void RabbitizerRegistersTracker_processConstant(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, uint32_t value, int offset); -NON_NULL(1, 2, 4, 5) // deprecated -bool RabbitizerRegistersTracker_getLuiOffsetForLo(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset, int *dstOffset, bool *dstIsGp); -NODISCARD NON_NULL(1, 2) -RabbitizerLoPairingInfo RabbitizerRegistersTracker_preprocessLoAndGetInfo(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset); -NON_NULL(1, 2) -void RabbitizerRegistersTracker_processLo(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, uint32_t value, int offset); -NON_NULL(1, 2) -bool RabbitizerRegistersTracker_hasLoButNoHi(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/analysis/RabbitizerTrackedRegisterState.h b/tools/ido-static-recomp/tools/rabbitizer/include/analysis/RabbitizerTrackedRegisterState.h deleted file mode 100644 index daf4b2da..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/analysis/RabbitizerTrackedRegisterState.h +++ /dev/null @@ -1,80 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_TRACKED_REGISTER_STATE_H -#define RABBITIZER_TRACKED_REGISTER_STATE_H -#pragma once - -#include -#include -#include - -#include "common/Utils.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef struct RabbitizerTrackedRegisterState { - int registerNum; - - bool hasLuiValue; - int luiOffset; // The offset of last lui which set a value to this register - bool luiSetOnBranchLikely; - - bool hasGpGot; - int gpGotOffset; - - bool hasLoValue; - int loOffset; - bool dereferenced; - int dereferenceOffset; - - uint32_t value; -} RabbitizerTrackedRegisterState; - - -NON_NULL(1) -void RabbitizerTrackedRegisterState_init(RabbitizerTrackedRegisterState *self, int registerNum); -NON_NULL(1) -void RabbitizerTrackedRegisterState_destroy(RabbitizerTrackedRegisterState *self); - -NON_NULL(1) -void RabbitizerTrackedRegisterState_clear(RabbitizerTrackedRegisterState *self); -NON_NULL(1) -void RabbitizerTrackedRegisterState_clearHi(RabbitizerTrackedRegisterState *self); -NON_NULL(1) -void RabbitizerTrackedRegisterState_clearGp(RabbitizerTrackedRegisterState *self); -NON_NULL(1) -void RabbitizerTrackedRegisterState_clearLo(RabbitizerTrackedRegisterState *self); - -NON_NULL(1, 2) -void RabbitizerTrackedRegisterState_copyState(RabbitizerTrackedRegisterState *self, const RabbitizerTrackedRegisterState *other); - -NON_NULL(1) -void RabbitizerTrackedRegisterState_setHi(RabbitizerTrackedRegisterState *self, uint32_t value, int offset); -NON_NULL(1) -void RabbitizerTrackedRegisterState_setGpLoad(RabbitizerTrackedRegisterState *self, uint32_t value, int offset); -NON_NULL(1) -void RabbitizerTrackedRegisterState_setLo(RabbitizerTrackedRegisterState *self, uint32_t value, int offset); - -NON_NULL(1) -void RabbitizerTrackedRegisterState_deref(RabbitizerTrackedRegisterState *self, int offset); -NON_NULL(1, 2) -void RabbitizerTrackedRegisterState_dereferenceState(RabbitizerTrackedRegisterState *self, const RabbitizerTrackedRegisterState *other, int offset); - -NODISCARD NON_NULL(1) PURE -bool RabbitizerTrackedRegisterState_hasAnyValue(const RabbitizerTrackedRegisterState *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerTrackedRegisterState_wasSetInCurrentOffset(const RabbitizerTrackedRegisterState *self, int offset); - -NON_NULL(1) -void RabbitizerTrackedRegisterState_fprint(const RabbitizerTrackedRegisterState *self, FILE* outFile); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/common/Abi.inc b/tools/ido-static-recomp/tools/rabbitizer/include/common/Abi.inc deleted file mode 100644 index fa01d92f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/common/Abi.inc +++ /dev/null @@ -1,7 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -RABBITIZER_DEF_ABI(NUMERIC), -RABBITIZER_DEF_ABI(O32), -RABBITIZER_DEF_ABI(N32), -RABBITIZER_DEF_ABI(N64), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/common/RabbitizerConfig.h b/tools/ido-static-recomp/tools/rabbitizer/include/common/RabbitizerConfig.h deleted file mode 100644 index 8b9def78..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/common/RabbitizerConfig.h +++ /dev/null @@ -1,83 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_CONFIG_H -#define RABBITIZER_CONFIG_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -#define RABBITIZER_DEF_ABI(name) RABBITIZER_ABI_##name - -typedef enum RabbitizerAbi { - #include "Abi.inc" - - RABBITIZER_DEF_ABI(MAX), -} RabbitizerAbi; - -#undef RABBITIZER_DEF_ABI - -RabbitizerAbi RabbitizerAbi_fromStr(const char *name); - - -typedef struct RabbitizerConfig_RegisterNames { - bool namedRegisters; // Enables using named registers. This option takes precedence over the other named register options - RabbitizerAbi gprAbiNames; // The ABI names to be used for general purpose registers when disassembling the main processor's instructions - RabbitizerAbi fprAbiNames; // The ABI names to be used for floating point registers when disassembling the floating point (coprocessor 1) instructions - bool userFpcCsr; // Use FpcCsr as register $31 for the FP control/status register - bool vr4300Cop0NamedRegisters; // Use named registers for VR4300's coprocessor 0 registers - bool vr4300RspCop0NamedRegisters; // Use named registers for VR4300's RSP's coprocessor 0 registers -} RabbitizerConfig_RegisterNames; - -typedef struct RabbitizerConfig_PseudoInstr { - bool enablePseudos; // Produce pseudo instructions (like `move` or `b`) whenever those may match the desired original instruction - bool pseudoBeqz; - bool pseudoBnez; - bool pseudoB; - bool pseudoMove; - bool pseudoNot; - bool pseudoNegu; - bool pseudoBal; -} RabbitizerConfig_PseudoInstr; - -typedef struct RabbitizerConfig_ToolchainTweaks { - bool treatJAsUnconditionalBranch; //! @deprecated - /** - * Enables a few fixes for SN64's assembler related to div/divu instructions - * - * - SN64's assembler doesn't like assembling `div $0, a, b` with .set noat active. - * Removing the $0 fixes this issue (but not for handwritten asm) - * - * - SN64's assembler expands div to have break if dividing by zero - * However, the break it generates is different than the one it generates with `break N` - * So we replace break instrutions for SN64 with the exact word that the assembler generates when expanding div - */ - bool sn64DivFix; -} RabbitizerConfig_ToolchainTweaks; - -typedef struct RabbitizerConfig_Misc { - int opcodeLJust; // The minimal number of characters to left-align the opcode name - bool unknownInstrComment; // Generate a pseudo-disassembly comment when disassembling non implemented instructions - bool omit0XOnSmallImm; - bool upperCaseImm; -} RabbitizerConfig_Misc; - -typedef struct RabbitizerConfig { - RabbitizerConfig_RegisterNames regNames; - RabbitizerConfig_PseudoInstr pseudos; - RabbitizerConfig_ToolchainTweaks toolchainTweaks; - RabbitizerConfig_Misc misc; -} RabbitizerConfig; - -extern RabbitizerConfig RabbitizerConfig_Cfg; - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/common/RabbitizerVersion.h b/tools/ido-static-recomp/tools/rabbitizer/include/common/RabbitizerVersion.h deleted file mode 100644 index d59e716f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/common/RabbitizerVersion.h +++ /dev/null @@ -1,33 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_VERSION_H -#define RABBITIZER_VERSION_H - -#include "Utils.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -// Header version -#define RAB_VERSION_MAJOR 1 -#define RAB_VERSION_MINOR 2 -#define RAB_VERSION_PATCH 3 - -#define RAB_VERSION_STR RAB_STRINGIFY(RAB_VERSION_MAJOR) "." RAB_STRINGIFY(RAB_VERSION_MINOR) "." RAB_STRINGIFY(RAB_VERSION_PATCH) - -// Compiled library version -extern const int RabVersion_Major; -extern const int RabVersion_Minor; -extern const int RabVersion_Patch; - -extern const char RabVersion_Str[]; - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/common/Utils.h b/tools/ido-static-recomp/tools/rabbitizer/include/common/Utils.h deleted file mode 100644 index 6255a04a..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/common/Utils.h +++ /dev/null @@ -1,116 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_UTILS_H -#define RABBITIZER_UTILS_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -#if !defined(__GNUC__) && !defined(__clang__) -#define __attribute__(x) -#endif - -#if __STDC_VERSION__ >= 202000L -#define CONST [[gnu::const]] -#define DEPRECATED(reason) [[deprecated (reason)]] -#define FALLTHROUGH [[fallthrough]] -#define NODISCARD [[nodiscard]] -#define NORETURN [[noreturn]] -#define NON_NULL(...) [[gnu::nonnull (__VA_ARGS__)]] -#define PURE [[gnu::pure]] -#define RETURNS_NON_NULL [[gnu::returns_nonnull]] -#define UNUSED [[maybe_unused]] -#else -#define CONST __attribute__((const)) -#define DEPRECATED(reason) __attribute__((deprecated (reason))) -#define FALLTHROUGH __attribute__((fallthrough)) -#define NODISCARD __attribute__((warn_unused_result)) -#define NORETURN _Noreturn -#define NON_NULL(...) __attribute__((nonnull (__VA_ARGS__))) -#define PURE __attribute__((pure)) -#define RETURNS_NON_NULL __attribute__((returns_nonnull)) -#define UNUSED __attribute__((unused)) -#endif - - -#if defined(_MSC_VER) -# define UNREACHABLE __assume(0) -#elif defined(__GNUC__) || defined(__clang__) -# define UNREACHABLE __builtin_unreachable() -#else -# define UNREACHABLE -#endif - - -#define ARRAY_COUNT(arr) (sizeof(arr) / sizeof((arr)[0])) - -#define RAB_STRINGIFY(x) #x - -#define MASK(v, w) ((v) & ((1 << (w)) - 1)) - -/* - * the SHIFT macros take a value, a shift amount, and a width. - * - * For the left shift, the lower bits of the value are masked, - * then shifted left. - * - * For the right shift, the value is shifted right, then the lower bits - * are masked. - * - * (NOTE: SHIFTL(v, 0, 32) won't work, just use an assignment) - * - */ -#define SHIFTL(v, s, w) (MASK((v), (w)) << (s)) -#define SHIFTR(v, s, w) (MASK((v) >> (s), (w))) - -#define BITREPACK(fullword, v, s, w) ((SHIFTR((fullword), (s)+(w), 32-((s)+(w))) << ((s)+(w))) | SHIFTL((v), (s), (w)) | MASK((fullword), (s))) -#define BITREPACK_RIGHT(fullword, v, s, w) (SHIFTL((v), (s), (w)) | MASK((fullword), (s))) - - -#define RABUTILS_BUFFER_ADVANCE(buffer, totalSize, expression) \ - do { \ - size_t __tempSize = expression; \ - (buffer) += __tempSize; \ - (totalSize) += __tempSize; \ - } while (0) - -#define RABUTILS_BUFFER_WRITE_CHAR(buffer, totalSize, character) \ - do { \ - *(buffer) = (character); \ - RABUTILS_BUFFER_ADVANCE(buffer, totalSize, 1); \ - } while (0) - -#define RABUTILS_BUFFER_SPRINTF(buffer, totalSize, format, ...) \ - do { \ - int _len = sprintf(buffer, format, __VA_ARGS__); \ - assert(_len > 0); \ - RABUTILS_BUFFER_ADVANCE(buffer, totalSize, _len); \ - } while (0) - -#define RABUTILS_BUFFER_CPY(buffer, totalSize, string) \ - do { \ - size_t _tempSize = strlen(string); \ - memcpy(buffer, string, _tempSize); \ - RABUTILS_BUFFER_ADVANCE(buffer, totalSize, _tempSize); \ - } while (0) - - -CONST NODISCARD -int32_t RabbitizerUtils_From2Complement(uint32_t number, int bits); -NON_NULL(1) -size_t RabbitizerUtils_CharFill(char *dst, int count, char fillchar); -NON_NULL(1, 3) -size_t RabbitizerUtils_escapeString(char *dst, size_t dstSize, const char *src, size_t srcSize); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/InstrCategory.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/InstrCategory.inc deleted file mode 100644 index 9a6d85c1..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/InstrCategory.inc +++ /dev/null @@ -1,6 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -RABBITIZER_DEF_INSTR_CATEGORY(CPU), -RABBITIZER_DEF_INSTR_CATEGORY(RSP), // N64 -RABBITIZER_DEF_INSTR_CATEGORY(R5900), // PS2's Emotion Engine diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstrDescriptor.h b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstrDescriptor.h deleted file mode 100644 index e92f7971..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstrDescriptor.h +++ /dev/null @@ -1,141 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_INSTRDESCRIPTOR_H -#define RABBITIZER_INSTRDESCRIPTOR_H -#pragma once - -#include - -#include "common/Utils.h" -#include "RabbitizerOperandType.h" -#include "RabbitizerInstrId.h" -#include "RabbitizerInstrSuffix.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -typedef enum RabbitizerInstrType { - RABBITIZER_INSTR_TYPE_UNKNOWN, - RABBITIZER_INSTR_TYPE_J, - RABBITIZER_INSTR_TYPE_I, - RABBITIZER_INSTR_TYPE_R, - RABBITIZER_INSTR_TYPE_REGIMM, - RABBITIZER_INSTR_TYPE_MAX, -} RabbitizerInstrType; - -typedef enum RabbitizerArchitectureVersion { - RABBITIZER_ARCHVERSION_INVALID=-1, - RABBITIZER_ARCHVERSION_UNKNOWN, - RABBITIZER_ARCHVERSION_MIPS_I, - RABBITIZER_ARCHVERSION_MIPS_II, - RABBITIZER_ARCHVERSION_MIPS_III, - RABBITIZER_ARCHVERSION_MIPS_IV -} RabbitizerArchitectureVersion; - -typedef struct RabbitizerInstrDescriptor { - RabbitizerOperandType operands[4]; - RabbitizerInstrType instrType; - - RabbitizerInstrSuffix instrSuffix; - - bool isBranch; - bool isBranchLikely; - bool isJump; - bool isTrap; - - bool isFloat; - bool isDouble; - - bool isUnsigned; - - bool modifiesRt; - bool modifiesRd; - - bool notEmitedByCompilers; - - bool canBeHi; - bool canBeLo; - bool doesLink; // "and link" family of instructions - bool doesDereference; - bool doesLoad; // loads data from memory - bool doesStore; // stores data to memory - bool maybeIsMove; - - bool isPseudo; - - RabbitizerArchitectureVersion architectureVersion; // TODO: consider removing -} RabbitizerInstrDescriptor; - -// TODO: less redundant name -extern const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[]; - - -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isUnknownType(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isJType(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isIType(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isRType(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isRegimmType(const RabbitizerInstrDescriptor *self); - -NODISCARD NON_NULL(1) PURE -RabbitizerInstrSuffix RabbitizerInstrDescriptor_instrSuffix(const RabbitizerInstrDescriptor *self); - -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isBranch(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isBranchLikely(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isJump(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isTrap(const RabbitizerInstrDescriptor *self); - -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isFloat(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isDouble(const RabbitizerInstrDescriptor *self); - -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isUnsigned(const RabbitizerInstrDescriptor *self); - -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_modifiesRt(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_modifiesRd(const RabbitizerInstrDescriptor *self); - -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_notEmitedByCompilers(const RabbitizerInstrDescriptor *self); - -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_canBeHi(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_canBeLo(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_doesLink(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_doesDereference(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_doesLoad(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_doesStore(const RabbitizerInstrDescriptor *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_maybeIsMove(const RabbitizerInstrDescriptor *self); - -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstrDescriptor_isPseudo(const RabbitizerInstrDescriptor *self); - -NODISCARD NON_NULL(1) PURE -RabbitizerArchitectureVersion RabbitizerInstrDescriptor_getArchitectureVersion(const RabbitizerInstrDescriptor *self); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstrId.h b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstrId.h deleted file mode 100644 index c3838211..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstrId.h +++ /dev/null @@ -1,46 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_INSTRID_H -#define RABBITIZER_INSTRID_H -#pragma once - -#include "common/Utils.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) \ - RABBITIZER_INSTR_ID_##prefix##_##name, - -#define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) \ - RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, __VA_ARGS__) - -typedef enum RabbitizerInstrId { - #include "instructions/instr_id/RabbitizerInstrId_cpu.inc" - - #include "instructions/instr_id/RabbitizerInstrId_rsp.inc" - - #include "instructions/instr_id/RabbitizerInstrId_r5900.inc" - - RABBITIZER_INSTR_ID_ALL_MAX = RABBITIZER_DEF_INSTR_ID(r5900, , MAX, ) -} RabbitizerInstrId; - -#undef RABBITIZER_DEF_INSTR_ID -#undef RABBITIZER_DEF_INSTR_ID_ALTNAME - - -extern const char *RabbitizerInstrId_Names[]; - - -CONST NODISCARD RETURNS_NON_NULL -const char *RabbitizerInstrId_getOpcodeName(RabbitizerInstrId uniqueId); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstrSuffix.h b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstrSuffix.h deleted file mode 100644 index 7c59e334..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstrSuffix.h +++ /dev/null @@ -1,36 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_INSTRSUFFIX_H -#define RABBITIZER_INSTRSUFFIX_H -#pragma once - -#include "common/Utils.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -struct RabbitizerInstruction; - -typedef enum RabbitizerInstrSuffix { - RABINSTRSUFFIX_NONE, - - RABINSTRSUFFIX_R5900_xyzw, - - RABINSTRSUFFIX_MAX -} RabbitizerInstrSuffix; - -CONST NODISCARD NON_NULL(1) -size_t RabbitizerInstrSuffix_getSizeForBuffer(const struct RabbitizerInstruction *self, RabbitizerInstrSuffix instrSuffix); - -CONST NODISCARD NON_NULL(1, 2) -size_t RabbitizerInstrSuffix_processSuffix(const struct RabbitizerInstruction *self, char *dst, RabbitizerInstrSuffix instrSuffix); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstruction.h b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstruction.h deleted file mode 100644 index 17e3bab9..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstruction.h +++ /dev/null @@ -1,263 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_INSTRUCTION_H -#define RABBITIZER_INSTRUCTION_H -#pragma once - -#include -#include -#include - -#include "common/Utils.h" - -#include "RabbitizerInstrId.h" -#include "RabbitizerInstrDescriptor.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#define RABBITIZER_DEF_INSTR_CATEGORY(name) RABBITIZER_INSTRCAT_##name - -typedef enum RabbitizerInstrCategory { - #include "instructions/InstrCategory.inc" - - RABBITIZER_DEF_INSTR_CATEGORY(MAX), -} RabbitizerInstrCategory; - -#undef RABBITIZER_DEF_INSTR_CATEGORY - - -typedef struct RabbitizerInstruction { - uint32_t word; - uint32_t _mandatorybits; - - RabbitizerInstrId uniqueId; - const RabbitizerInstrDescriptor *descriptor; - - uint32_t vram; - bool _handwrittenCategory; - bool inHandwrittenFunction; - RabbitizerInstrCategory category; -} RabbitizerInstruction; - - -#define RAB_INSTR_GET_opcode(self) (SHIFTR((self)->word, 26, 6)) -#define RAB_INSTR_GET_rs(self) (SHIFTR((self)->word, 21, 5)) -#define RAB_INSTR_GET_rt(self) (SHIFTR((self)->word, 16, 5)) -#define RAB_INSTR_GET_rd(self) (SHIFTR((self)->word, 11, 5)) -#define RAB_INSTR_GET_sa(self) (SHIFTR((self)->word, 6, 5)) -#define RAB_INSTR_GET_function(self) (SHIFTR((self)->word, 0, 6)) - -#define RAB_INSTR_GET_cop0d(self) (SHIFTR((self)->word, 11, 5)) - -#define RAB_INSTR_GET_instr_index(self) (SHIFTR((self)->word, 0, 26)) -#define RAB_INSTR_GET_immediate(self) (SHIFTR((self)->word, 0, 16)) - -#define RAB_INSTR_GET_fs(self) (SHIFTR((self)->word, 11, 5)) -#define RAB_INSTR_GET_ft(self) (SHIFTR((self)->word, 16, 5)) -#define RAB_INSTR_GET_fd(self) (SHIFTR((self)->word, 6, 5)) -#define RAB_INSTR_GET_cop1cs(self) (SHIFTR((self)->word, 11, 5)) - -#define RAB_INSTR_GET_op(self) (SHIFTR((self)->word, 16, 5)) - -#define RAB_INSTR_GET_code(self) (SHIFTR((self)->word, 6, 20)) -#define RAB_INSTR_GET_code_upper(self) (SHIFTR((self)->word, 16, 10)) -#define RAB_INSTR_GET_code_lower(self) (SHIFTR((self)->word, 6, 10)) - -#define RAB_INSTR_GET_copraw(self) (SHIFTR((self)->word, 0, 25)) - -#define RAB_INSTR_GET_fmt(self) (SHIFTR((self)->word, 21, 5)) -#define RAB_INSTR_GET_fc(self) (SHIFTR((self)->word, 4, 2)) -#define RAB_INSTR_GET_cond(self) (SHIFTR((self)->word, 0, 4)) - -#define RAB_INSTR_GET_cop2t(self) (SHIFTR((self)->word, 16, 5)) - -#define RAB_INSTR_GET_tf(self) (SHIFTR((self)->word, 16, 1)) -#define RAB_INSTR_GET_nd(self) (SHIFTR((self)->word, 17, 1)) -#define RAB_INSTR_GET_bc_fmt(self) (SHIFTR((self)->word, 16, 5)) - -#define RAB_INSTR_GET_stype(self) (SHIFTR((self)->word, 6, 5)) - - -#define RAB_INSTR_PACK_opcode(word, value) (BITREPACK_RIGHT((word), (value), 26, 6)) -#define RAB_INSTR_PACK_rs(word, value) (BITREPACK((word), (value), 21, 5)) -#define RAB_INSTR_PACK_rt(word, value) (BITREPACK((word), (value), 16, 5)) -#define RAB_INSTR_PACK_rd(word, value) (BITREPACK((word), (value), 11, 5)) -#define RAB_INSTR_PACK_sa(word, value) (BITREPACK((word), (value), 6, 5)) -#define RAB_INSTR_PACK_function(word, value) (BITREPACK((word), (value), 0, 6)) - -#define RAB_INSTR_PACK_cop0d(word, value) (BITREPACK((word), (value), 11, 5)) - -#define RAB_INSTR_PACK_instr_index(word, value) (BITREPACK((word), (value), 0, 26)) -#define RAB_INSTR_PACK_immediate(word, value) (BITREPACK((word), (value), 0, 16)) - -#define RAB_INSTR_PACK_code(word, value) (BITREPACK((word), (value), 6, 20)) -#define RAB_INSTR_PACK_code_upper(word, value) (BITREPACK((word), (value), 16, 10)) -#define RAB_INSTR_PACK_code_lower(word, value) (BITREPACK((word), (value), 6, 10)) - -#define RAB_INSTR_PACK_copraw(word, value) (BITREPACK((word), (value), 0, 25)) - -#define RAB_INSTR_PACK_fmt(word, value) (BITREPACK((word), (value), 21, 5)) -#define RAB_INSTR_PACK_fc(word, value) (BITREPACK((word), (value), 4, 2)) -#define RAB_INSTR_PACK_cond(word, value) (BITREPACK((word), (value), 0, 4)) - -#define RAB_INSTR_PACK_fs(word, value) (BITREPACK((word), (value), 11, 5)) -#define RAB_INSTR_PACK_ft(word, value) (BITREPACK((word), (value), 16, 5)) -#define RAB_INSTR_PACK_fd(word, value) (BITREPACK((word), (value), 6, 5)) -#define RAB_INSTR_PACK_cop1cs(word, value) (BITREPACK((word), (value), 11, 5)) - -#define RAB_INSTR_PACK_op(word, value) (BITREPACK((word), (value), 16, 5)) - -#define RAB_INSTR_PACK_cop2t(word, value) (BITREPACK((word), (value), 16, 5)) - -#define RAB_INSTR_PACK_tf(word, value) (BITREPACK((word), (value), 16, 1)) -#define RAB_INSTR_PACK_nd(word, value) (BITREPACK((word), (value), 17, 1)) -#define RAB_INSTR_PACK_bc_fmt(word, value) (BITREPACK((word), (value), 16, 5)) - -#define RAB_INSTR_PACK_stype(word, value) (BITREPACK((word), (value), 6, 5)) - - -NON_NULL(1) -void RabbitizerInstruction_init(RabbitizerInstruction *self, uint32_t word, uint32_t vram); -NON_NULL(1) -void RabbitizerInstruction_destroy(RabbitizerInstruction* self); - - -/* Process uniqueId */ - -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Normal(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Special(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Regimm(RabbitizerInstruction *self); - -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Coprocessor0_BC0(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Coprocessor0_Tlb(RabbitizerInstruction *self); - -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Coprocessor0(RabbitizerInstruction *self); - -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Coprocessor1_BC1(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Coprocessor1_FpuS(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Coprocessor1_FpuD(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Coprocessor1_FpuW(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Coprocessor1_FpuL(RabbitizerInstruction *self); - -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Coprocessor1(RabbitizerInstruction *self); - -NON_NULL(1) -void RabbitizerInstruction_processUniqueId_Coprocessor2(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstruction_processUniqueId(RabbitizerInstruction *self); - -/* Process uniqueId */ - - -/* General getters */ - -NODISCARD NON_NULL(1) PURE -uint32_t RabbitizerInstruction_getRaw(const RabbitizerInstruction *self); - -NODISCARD NON_NULL(1) PURE -uint32_t RabbitizerInstruction_getImmediate(const RabbitizerInstruction *self); -NODISCARD NON_NULL(1) PURE -int32_t RabbitizerInstruction_getProcessedImmediate(const RabbitizerInstruction *self); -NODISCARD NON_NULL(1) PURE -uint32_t RabbitizerInstruction_getInstrIndex(const RabbitizerInstruction *self); -NODISCARD NON_NULL(1) PURE -uint32_t RabbitizerInstruction_getInstrIndexAsVram(const RabbitizerInstruction *self); - -NODISCARD NON_NULL(1) PURE -int32_t RabbitizerInstruction_getBranchOffset(const RabbitizerInstruction *self); -NODISCARD NON_NULL(1) PURE -int32_t RabbitizerInstruction_getGenericBranchOffset(const RabbitizerInstruction *self, uint32_t currentVram); - -/* General getters */ - -NON_NULL(1) -void RabbitizerInstruction_blankOut(RabbitizerInstruction *self); - - -/* Instruction examination */ - -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstruction_isImplemented(const RabbitizerInstruction *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstruction_isLikelyHandwritten(const RabbitizerInstruction *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstruction_isNop(const RabbitizerInstruction *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstruction_isUnconditionalBranch(const RabbitizerInstruction *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstruction_isJrRa(const RabbitizerInstruction *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstruction_isJrNotRa(const RabbitizerInstruction *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstruction_hasDelaySlot(const RabbitizerInstruction *self); - -NODISCARD NON_NULL(1) PURE -const char *RabbitizerInstruction_mapInstrToType(const RabbitizerInstruction *self); - -NODISCARD NON_NULL(1, 2) PURE -bool RabbitizerInstruction_sameOpcode(const RabbitizerInstruction *self, const RabbitizerInstruction *other); -NODISCARD NON_NULL(1, 2) PURE -bool RabbitizerInstruction_sameOpcodeButDifferentArguments(const RabbitizerInstruction *self, const RabbitizerInstruction *other); - -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstruction_hasOperand(const RabbitizerInstruction *self, RabbitizerOperandType operand); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstruction_hasOperandAlias(const RabbitizerInstruction *self, RabbitizerOperandType operand); - -NODISCARD NON_NULL(1) PURE -uint32_t RabbitizerInstruction_getValidBits(const RabbitizerInstruction *self); -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstruction_isValid(const RabbitizerInstruction *self); - -/* Instruction examination */ - - -/* Disassembly */ - -NODISCARD NON_NULL(1) PURE -bool RabbitizerInstruction_mustDisasmAsData(const RabbitizerInstruction *self); - -NODISCARD NON_NULL(1) PURE -size_t RabbitizerInstruction_getSizeForBufferOperandsDisasm(const RabbitizerInstruction *self, size_t immOverrideLength); -NON_NULL(1, 2) -size_t RabbitizerInstruction_disassembleOperands(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); - -NODISCARD NON_NULL(1) PURE -size_t RabbitizerInstruction_getSizeForBufferInstrDisasm(const RabbitizerInstruction *self, size_t immOverrideLength, int extraLJust); -NON_NULL(1, 2) -size_t RabbitizerInstruction_disassembleInstruction(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength, int extraLJust); - -NODISCARD NON_NULL(1) PURE -size_t RabbitizerInstruction_getSizeForBufferDataDisasm(const RabbitizerInstruction *self, int extraLJust); -NON_NULL(1, 2) -size_t RabbitizerInstruction_disassembleAsData(const RabbitizerInstruction *self, char *dst, int extraLJust); - -NODISCARD NON_NULL(1) PURE -size_t RabbitizerInstruction_getSizeForBuffer(const RabbitizerInstruction *self, size_t immOverrideLength, int extraLJust); -NON_NULL(1, 2) -size_t RabbitizerInstruction_disassemble(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength, int extraLJust); - -/* Disassembly */ - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstructionR5900.h b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstructionR5900.h deleted file mode 100644 index af5e809e..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstructionR5900.h +++ /dev/null @@ -1,87 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_INSTRUCTION_R5900_H -#define RABBITIZER_INSTRUCTION_R5900_H -#pragma once - -#include "RabbitizerInstruction.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#define RAB_INSTR_R5900_GET_mmi_function(self) (SHIFTR((self)->word, 6, 5)) -#define RAB_INSTR_R5900_GET_fhi_flo(self) ((SHIFTR((self)->word, 6, 5) << 2) | SHIFTR((self)->word, 0, 2)) - -#define RAB_INSTR_R5900_GET_vfs(self) (SHIFTR((self)->word, 11, 5)) -#define RAB_INSTR_R5900_GET_vft(self) (SHIFTR((self)->word, 16, 5)) -#define RAB_INSTR_R5900_GET_vfd(self) (SHIFTR((self)->word, 6, 5)) - -#define RAB_INSTR_R5900_GET_xyzw_x(self) (SHIFTR((self)->word, 24, 1)) -#define RAB_INSTR_R5900_GET_xyzw_y(self) (SHIFTR((self)->word, 23, 1)) -#define RAB_INSTR_R5900_GET_xyzw_z(self) (SHIFTR((self)->word, 22, 1)) -#define RAB_INSTR_R5900_GET_xyzw_w(self) (SHIFTR((self)->word, 21, 1)) -#define RAB_INSTR_R5900_GET_n(self) (SHIFTR((self)->word, 0, 2)) -#define RAB_INSTR_R5900_GET_l(self) (SHIFTR((self)->word, 21, 2)) -#define RAB_INSTR_R5900_GET_m(self) (SHIFTR((self)->word, 23, 2)) - -#define RAB_INSTR_R5900_GET_vis(self) (SHIFTR((self)->word, 11, 5)) -#define RAB_INSTR_R5900_GET_vit(self) (SHIFTR((self)->word, 16, 5)) -#define RAB_INSTR_R5900_GET_vid(self) (SHIFTR((self)->word, 6, 5)) - -#define RAB_INSTR_R5900_GET_imm5(self) (SHIFTR((self)->word, 6, 5)) - - -#define RAB_INSTR_R5900_PACK_mmi_function(word, value) (BITREPACK((word), (value), 6, 5)) -#define RAB_INSTR_R5900_PACK_fhi_flo(word, value) (BITREPACK(BITREPACK((word), (value) >> 2, 6, 5), (value), 0, 2)) - -#define RAB_INSTR_R5900_PACK_vfs(word, value) (BITREPACK((word), (value), 11, 5)) -#define RAB_INSTR_R5900_PACK_vft(word, value) (BITREPACK((word), (value), 16, 5)) -#define RAB_INSTR_R5900_PACK_vfd(word, value) (BITREPACK((word), (value), 6, 5)) - -#define RAB_INSTR_R5900_PACK_xyzw_x(word, value) (BITREPACK((word), (value), 24, 1)) -#define RAB_INSTR_R5900_PACK_xyzw_y(word, value) (BITREPACK((word), (value), 23, 1)) -#define RAB_INSTR_R5900_PACK_xyzw_z(word, value) (BITREPACK((word), (value), 22, 1)) -#define RAB_INSTR_R5900_PACK_xyzw_w(word, value) (BITREPACK((word), (value), 21, 1)) -#define RAB_INSTR_R5900_PACK_n(word, value) (BITREPACK((word), (value), 0, 2)) -#define RAB_INSTR_R5900_PACK_l(word, value) (BITREPACK((word), (value), 21, 2)) -#define RAB_INSTR_R5900_PACK_m(word, value) (BITREPACK((word), (value), 23, 2)) - -#define RAB_INSTR_R5900_PACK_vis(word, value) (BITREPACK((word), (value), 11, 5)) -#define RAB_INSTR_R5900_PACK_vit(word, value) (BITREPACK((word), (value), 16, 5)) -#define RAB_INSTR_R5900_PACK_vid(word, value) (BITREPACK((word), (value), 6, 5)) - -#define RAB_INSTR_R5900_PACK_imm5(word, value) (BITREPACK((word), (value), 6, 5)) - - -NON_NULL(1) -void RabbitizerInstructionR5900_init(RabbitizerInstruction *self, uint32_t word, uint32_t vram); -NON_NULL(1) -void RabbitizerInstructionR5900_destroy(RabbitizerInstruction *self); - -NON_NULL(1) -void RabbitizerInstructionR5900_processUniqueId_Normal(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstructionR5900_processUniqueId_Special(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstructionR5900_processUniqueId_Regimm(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstructionR5900_processUniqueId_Coprocessor0(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstructionR5900_processUniqueId_Coprocessor1(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstructionR5900_processUniqueId_Coprocessor2(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstructionR5900_processUniqueId_MMI(RabbitizerInstruction *self); - -NON_NULL(1) -void RabbitizerInstructionR5900_processUniqueId(RabbitizerInstruction *self); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstructionRsp.h b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstructionRsp.h deleted file mode 100644 index b2fb40d5..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerInstructionRsp.h +++ /dev/null @@ -1,70 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_INSTRUCTION_RSP_H -#define RABBITIZER_INSTRUCTION_RSP_H -#pragma once - -#include "RabbitizerInstruction.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#define RAB_INSTR_RSP_GET_cop2t(self) (SHIFTR((self)->word, 16, 5)) -#define RAB_INSTR_RSP_GET_cop2cd(self) (SHIFTR((self)->word, 11, 5)) - -#define RAB_INSTR_RSP_GET_vs(self) (SHIFTR((self)->word, 11, 5)) -#define RAB_INSTR_RSP_GET_vt(self) (SHIFTR((self)->word, 16, 5)) -#define RAB_INSTR_RSP_GET_vd(self) (SHIFTR((self)->word, 6, 5)) - -#define RAB_INSTR_RSP_GET_elementhigh(self) (SHIFTR((self)->word, 21, 4)) -#define RAB_INSTR_RSP_GET_elementlow(self) (SHIFTR((self)->word, 7, 4)) -#define RAB_INSTR_RSP_GET_OFFSET_VECTOR_RAW(self) (SHIFTR((self)->word, 0, 7)) - -#define RAB_INSTR_RSP_GET_index(self) (SHIFTR((self)->word, 7, 4)) -#define RAB_INSTR_RSP_GET_de(self) (SHIFTR((self)->word, 11, 5)) - - -#define RAB_INSTR_RSP_PACK_cop2t(word, value) (BITREPACK((word), value, 16, 5)) -#define RAB_INSTR_RSP_PACK_cop2cd(word, value) (BITREPACK((word), value, 11, 5)) - -#define RAB_INSTR_RSP_PACK_vs(word, value) (BITREPACK((word), value, 11, 5)) -#define RAB_INSTR_RSP_PACK_vt(word, value) (BITREPACK((word), value, 16, 5)) -#define RAB_INSTR_RSP_PACK_vd(word, value) (BITREPACK((word), value, 6, 5)) - -#define RAB_INSTR_RSP_PACK_elementhigh(word, value) (BITREPACK((word), value, 21, 4)) -#define RAB_INSTR_RSP_PACK_elementlow(word, value) (BITREPACK((word), value, 7, 4)) - -#define RAB_INSTR_RSP_PACK_index(word, value) (BITREPACK((word), value, 7, 4)) -#define RAB_INSTR_RSP_PACK_offset(word, value) (BITREPACK((word), value, 0, 7)) -#define RAB_INSTR_RSP_PACK_de(word, value) (BITREPACK((word), value, 11, 5)) - - -NON_NULL(1) -void RabbitizerInstructionRsp_init(RabbitizerInstruction *self, uint32_t word, uint32_t vram); -NON_NULL(1) -void RabbitizerInstructionRsp_destroy(RabbitizerInstruction *self); - - -NON_NULL(1) -void RabbitizerInstructionRsp_processUniqueId_Normal(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstructionRsp_processUniqueId_Special(RabbitizerInstruction *self); -NON_NULL(1) -void RabbitizerInstructionRsp_processUniqueId_Regimm(RabbitizerInstruction *self); - -NON_NULL(1) -void RabbitizerInstructionRsp_processUniqueId(RabbitizerInstruction *self); - - -NODISCARD NON_NULL(1) PURE -uint16_t RabbitizerInstructionRsp_GetOffsetVector(const RabbitizerInstruction *self); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerOperandType.h b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerOperandType.h deleted file mode 100644 index 58c26594..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerOperandType.h +++ /dev/null @@ -1,33 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_OPERAND_TYPE_H -#define RABBITIZER_OPERAND_TYPE_H -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - - -#define RAB_DEF_OPERAND(prefix, operand) \ - RAB_OPERAND_##prefix##_##operand, - -typedef enum RabbitizerOperandType { - RAB_DEF_OPERAND(ALL, INVALID) - -#include "operands/RabbitizerOperandType_cpu.inc" -#include "operands/RabbitizerOperandType_rsp.inc" -#include "operands/RabbitizerOperandType_r5900.inc" - - RAB_DEF_OPERAND(ALL, MAX) -} RabbitizerOperandType; - -#undef RAB_DEF_OPERAND - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerRegister.h b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerRegister.h deleted file mode 100644 index 1c6421cd..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/RabbitizerRegister.h +++ /dev/null @@ -1,143 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_REGISTER_H -#define RABBITIZER_REGISTER_H -#pragma once - -#include - -#include "common/Utils.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#define RABBITIZER_DEF_REG(prefix, name, numeric) \ - RABBITIZER_REG_##prefix##_##name - -#define RABBITIZER_DEF_REG_NODOLLAR(prefix, name, numeric) \ - RABBITIZER_REG_##prefix##_##name - - -typedef enum RabbitizerRegister_GprO32 { - #include "instructions/registers/RabbitizerRegister_GprO32.inc" -} RabbitizerRegister_GprO32; - -typedef enum RabbitizerRegister_GprN32 { - #include "instructions/registers/RabbitizerRegister_GprN32.inc" -} RabbitizerRegister_GprN32; - -typedef enum RabbitizerRegister_Cop0 { - #include "instructions/registers/RabbitizerRegister_Cop0.inc" -} RabbitizerRegister_Cop0; - -// Float registers -typedef enum RabbitizerRegister_Cop1O32 { - #include "instructions/registers/RabbitizerRegister_Cop1O32.inc" -} RabbitizerRegister_Cop1O32; - -typedef enum RabbitizerRegister_Cop1N32 { - #include "instructions/registers/RabbitizerRegister_Cop1N32.inc" -} RabbitizerRegister_Cop1N32; - -typedef enum RabbitizerRegister_Cop1N64 { - #include "instructions/registers/RabbitizerRegister_Cop1N64.inc" -} RabbitizerRegister_Cop1N64; - -typedef enum RabbitizerRegister_Cop1Control { - #include "instructions/registers/RabbitizerRegister_Cop1Control.inc" -} RabbitizerRegister_Cop1Control; - -typedef enum RabbitizerRegister_Cop2 { - #include "instructions/registers/RabbitizerRegister_Cop2.inc" -} RabbitizerRegister_Cop2; - - -/* RSP */ - -typedef enum RabbitizerRegister_RspGpr { - #include "instructions/registers/RabbitizerRegister_RspGpr.inc" -} RabbitizerRegister_RspGpr; - -typedef enum RabbitizerRegister_RspCop0 { - #include "instructions/registers/RabbitizerRegister_RspCop0.inc" -} RabbitizerRegister_RspCop0; - -typedef enum RabbitizerRegister_RspCop2 { - #include "instructions/registers/RabbitizerRegister_RspCop2.inc" -} RabbitizerRegister_RspCop2; - -typedef enum RabbitizerRegister_RspCop2Control { - #include "instructions/registers/RabbitizerRegister_RspCop2Control.inc" -} RabbitizerRegister_RspCop2Control; - -typedef enum RabbitizerRegister_RspVector { - #include "instructions/registers/RabbitizerRegister_RspVector.inc" -} RabbitizerRegister_RspVector; - -/* RSP */ - -/* R5900 */ - -typedef enum RabbitizerRegister_R5900VF { - #include "instructions/registers/RabbitizerRegister_R5900VF.inc" -} RabbitizerRegister_R5900VF; - -typedef enum RabbitizerRegister_R5900VI { - #include "instructions/registers/RabbitizerRegister_R5900VI.inc" -} RabbitizerRegister_R5900VI; - -/* R5900 */ - - -#undef RABBITIZER_DEF_REG -#undef RABBITIZER_DEF_REG_NODOLLAR - - -extern const char *RabbitizerRegister_GprO32_Names[][2]; -extern const char *RabbitizerRegister_GprN32_Names[][2]; -extern const char *RabbitizerRegister_Cop0_Names[][2]; -extern const char *RabbitizerRegister_Cop1O32_Names[][2]; -extern const char *RabbitizerRegister_Cop1N32_Names[][2]; -extern const char *RabbitizerRegister_Cop1N64_Names[][2]; -extern const char *RabbitizerRegister_Cop2_Names[][2]; -extern const char *RabbitizerRegister_RspGpr_Names[][2]; -extern const char *RabbitizerRegister_RspCop0_Names[][2]; -extern const char *RabbitizerRegister_RspVector_Names[][2]; - - -NODISCARD PURE RETURNS_NON_NULL -const char *RabbitizerRegister_getNameGpr(uint8_t regValue); -NODISCARD PURE RETURNS_NON_NULL -const char *RabbitizerRegister_getNameCop0(uint8_t regValue); -NODISCARD PURE RETURNS_NON_NULL -const char *RabbitizerRegister_getNameCop1(uint8_t regValue); -NODISCARD PURE RETURNS_NON_NULL -const char *RabbitizerRegister_getNameCop1Control(uint8_t regValue); -NODISCARD PURE RETURNS_NON_NULL -const char *RabbitizerRegister_getNameCop2(uint8_t regValue); - -NODISCARD PURE RETURNS_NON_NULL -const char *RabbitizerRegister_getNameRspGpr(uint8_t regValue); -NODISCARD PURE RETURNS_NON_NULL -const char *RabbitizerRegister_getNameRspCop0(uint8_t regValue); -NODISCARD PURE RETURNS_NON_NULL -const char *RabbitizerRegister_getNameRspCop2(uint8_t regValue); -NODISCARD PURE RETURNS_NON_NULL -const char *RabbitizerRegister_getNameRspCop2Control(uint8_t regValue); -NODISCARD PURE RETURNS_NON_NULL -const char *RabbitizerRegister_getNameRspVector(uint8_t regValue); - -NODISCARD PURE RETURNS_NON_NULL -const char *RabbitizerRegister_getNameR5900VF(uint8_t regValue); -NODISCARD PURE RETURNS_NON_NULL -const char *RabbitizerRegister_getNameR5900VI(uint8_t regValue); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/RabbitizerInstrId_cpu.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/RabbitizerInstrId_cpu.inc deleted file mode 100644 index dbbb9818..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/RabbitizerInstrId_cpu.inc +++ /dev/null @@ -1,40 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -RABBITIZER_DEF_INSTR_ID(cpu, , INVALID, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate}) - -#include "instructions/instr_id/cpu/cpu_normal.inc" -#include "instructions/instr_id/cpu/cpu_special.inc" -#include "instructions/instr_id/cpu/cpu_regimm.inc" -#include "instructions/instr_id/cpu/cpu_cop0.inc" -#include "instructions/instr_id/cpu/cpu_cop0_bc0.inc" -#include "instructions/instr_id/cpu/cpu_cop0_tlb.inc" -#include "instructions/instr_id/cpu/cpu_cop1.inc" -#include "instructions/instr_id/cpu/cpu_cop1_bc1.inc" -#include "instructions/instr_id/cpu/cpu_cop1_fpu_s.inc" -#include "instructions/instr_id/cpu/cpu_cop1_fpu_d.inc" -#include "instructions/instr_id/cpu/cpu_cop1_fpu_w.inc" -#include "instructions/instr_id/cpu/cpu_cop1_fpu_l.inc" - -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_00, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_01, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_02, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_03, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_04, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_05, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_06, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_07, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_08, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_09, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_10, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_11, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_12, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_13, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_14, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_15, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_16, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_17, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_18, .operands={0}) -RABBITIZER_DEF_INSTR_ID(cpu, , USERDEF_19, .operands={0}) - -RABBITIZER_DEF_INSTR_ID(cpu, , MAX, .operands={0}) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/RabbitizerInstrId_r5900.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/RabbitizerInstrId_r5900.inc deleted file mode 100644 index 10f11126..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/RabbitizerInstrId_r5900.inc +++ /dev/null @@ -1,46 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -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) - -#include "instructions/instr_id/r5900/r5900_normal.inc" -#include "instructions/instr_id/r5900/r5900_special.inc" -#include "instructions/instr_id/r5900/r5900_regimm.inc" - -#include "instructions/instr_id/r5900/r5900_mmi.inc" -#include "instructions/instr_id/r5900/r5900_mmi_0.inc" -#include "instructions/instr_id/r5900/r5900_mmi_1.inc" -#include "instructions/instr_id/r5900/r5900_mmi_2.inc" -#include "instructions/instr_id/r5900/r5900_mmi_3.inc" - -#include "instructions/instr_id/r5900/r5900_cop0_tlb.inc" - -#include "instructions/instr_id/r5900/r5900_cop1_fpu_s.inc" - -#include "instructions/instr_id/r5900/r5900_cop2.inc" -#include "instructions/instr_id/r5900/r5900_cop2_bc2.inc" -#include "instructions/instr_id/r5900/r5900_cop2_special1.inc" -#include "instructions/instr_id/r5900/r5900_cop2_special2.inc" - -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_00, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_01, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_02, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_03, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_04, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_05, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_06, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_07, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_08, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_09, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_10, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_11, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_12, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_13, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_14, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_15, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_16, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_17, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_18, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, , USERDEF_19, .operands={0}) - -RABBITIZER_DEF_INSTR_ID(r5900, , MAX, .operands={0}) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/RabbitizerInstrId_rsp.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/RabbitizerInstrId_rsp.inc deleted file mode 100644 index 2fcaa854..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/RabbitizerInstrId_rsp.inc +++ /dev/null @@ -1,41 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// RSP instructions -RABBITIZER_DEF_INSTR_ID(rsp, , INVALID, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) - -#include "instructions/instr_id/rsp/rsp_cop2.inc" -#include "instructions/instr_id/rsp/rsp_cop2_vu.inc" - -#include "instructions/instr_id/rsp/rsp_normal_lwc2.inc" -#include "instructions/instr_id/rsp/rsp_normal_swc2.inc" - -// CPU instructions but with rsp registers - -#include "instructions/instr_id/rsp/rsp_normal.inc" -#include "instructions/instr_id/rsp/rsp_special.inc" -#include "instructions/instr_id/rsp/rsp_regimm.inc" -#include "instructions/instr_id/rsp/rsp_cop0.inc" - -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_00, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_01, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_02, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_03, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_04, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_05, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_06, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_07, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_08, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_09, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_10, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_11, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_12, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_13, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_14, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_15, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_16, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_17, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_18, .operands={0}) -RABBITIZER_DEF_INSTR_ID(rsp, , USERDEF_19, .operands={0}) - -RABBITIZER_DEF_INSTR_ID(rsp, , MAX, .operands={0}) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop0.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop0.inc deleted file mode 100644 index 0aa3df49..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop0.inc +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP rt, cop0d -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 -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 -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 -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 -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 -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 diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop0_bc0.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop0_bc0.inc deleted file mode 100644 index 0165039b..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop0_bc0.inc +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP IMM -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 -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 -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 -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 diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop0_tlb.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop0_tlb.inc deleted file mode 100644 index 65b808e3..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop0_tlb.inc +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP -RABBITIZER_DEF_INSTR_ID(cpu, 0x01, tlbr, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmitedByCompilers=true) // Read Indexed TLB Entry -RABBITIZER_DEF_INSTR_ID(cpu, 0x02, tlbwi, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmitedByCompilers=true) // Write Indexed TLB Entry - -RABBITIZER_DEF_INSTR_ID(cpu, 0x06, tlbwr, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN) // Write Random TLB Entry - -RABBITIZER_DEF_INSTR_ID(cpu, 0x08, tlbp, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmitedByCompilers=true) // Probe TLB for Matching Entry - -RABBITIZER_DEF_INSTR_ID(cpu, 0x18, eret, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .notEmitedByCompilers=true) // Return from Exception diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1.inc deleted file mode 100644 index e6defc81..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1.inc +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP rt, fs -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 -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 -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 -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 - -// OP rt, cop1cs -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 -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 diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_bc1.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_bc1.inc deleted file mode 100644 index e339cd4d..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_bc1.inc +++ /dev/null @@ -1,8 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP IMM -RABBITIZER_DEF_INSTR_ID(cpu, 0x00, bc1f, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isBranch=true) -RABBITIZER_DEF_INSTR_ID(cpu, 0x01, bc1t, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isBranch=true) -RABBITIZER_DEF_INSTR_ID(cpu, 0x02, bc1fl, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isBranch=true, .isBranchLikely=true) -RABBITIZER_DEF_INSTR_ID(cpu, 0x03, bc1tl, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isBranch=true, .isBranchLikely=true) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_d.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_d.inc deleted file mode 100644 index a512496c..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_d.inc +++ /dev/null @@ -1,48 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP fd, fs, ft -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x00, add_d, add.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Add -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x01, sub_d, sub.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Sub -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x02, mul_d, mul.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Multiply -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x03, div_d, div.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Divide - -// OP fd, fs -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x04, sqrt_d, sqrt.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Square Root -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x05, abs_d, abs.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Absolute Value -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x06, mov_d, mov.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Move -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x07, neg_d, neg.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Negate - -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x08, round_l_d, round.l.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Round to Long Fixed-Point -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x09, trunc_l_d, trunc.l.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Truncate to Long Fixed-Point -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x0A, ceil_l_d, ceil.l.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Ceiling Convert to Long Fixed-Point -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x0B, floor_l_d, floor.l.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Floor Convert to Long Fixed-Point - -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x0C, round_w_d, round.w.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Round to Word Fixed-Point -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x0D, trunc_w_d, trunc.w.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Truncate to Word Fixed-Point -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x0E, ceil_w_d, ceil.w.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Ceiling Convert to Word Fixed-Point -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x0F, floor_w_d, floor.w.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Floor Convert to Word Fixed-Point - -// OP fd, fs -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x20, cvt_s_d, cvt.s.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .isDouble=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x24, cvt_w_d, cvt.w.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .isDouble=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x25, cvt_l_d, cvt.l.d, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .isDouble=true) - -// OP fs, ft -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x30, c_f_d, c.f.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x31, c_un_d, c.un.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x32, c_eq_d, c.eq.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x33, c_ueq_d, c.ueq.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x34, c_olt_d, c.olt.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x35, c_ult_d, c.ult.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x36, c_ole_d, c.ole.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x37, c_ule_d, c.ule.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) - -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x38, c_df_d, c.df.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x39, c_ngle_d, c.ngle.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x3A, c_deq_d, c.deq.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x3B, c_ngl_d, c.ngl.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x3C, c_lt_d, c.lt.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x3D, c_nge_d, c.nge.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x3E, c_le_d, c.le.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x3F, c_ngt_d, c.ngt.d, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_l.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_l.inc deleted file mode 100644 index 48eea054..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_l.inc +++ /dev/null @@ -1,6 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP fd, fs -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) -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) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_s.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_s.inc deleted file mode 100644 index 4271429b..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_s.inc +++ /dev/null @@ -1,48 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP fd, fs, ft -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x00, add_s, add.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Add -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x01, sub_s, sub.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Sub -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x02, mul_s, mul.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Multiply -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x03, div_s, div.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Divide - -// OP fd, fs -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x04, sqrt_s, sqrt.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Square Root -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x05, abs_s, abs.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Absolute Value -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x06, mov_s, mov.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Move -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x07, neg_s, neg.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Negate - -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x08, round_l_s, round.l.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Round to Long Fixed-Point -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x09, trunc_l_s, trunc.l.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Truncate to Long Fixed-Point -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x0A, ceil_l_s, ceil.l.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Ceiling Convert to Long Fixed-Point -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x0B, floor_l_s, floor.l.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Floor Convert to Long Fixed-Point - -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x0C, round_w_s, round.w.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Round to Word Fixed-Point -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x0D, trunc_w_s, trunc.w.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Truncate to Word Fixed-Point -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x0E, ceil_w_s, ceil.w.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Ceiling Convert to Word Fixed-Point -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x0F, floor_w_s, floor.w.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) // Floating-Point Floor Convert to Word Fixed-Point - -// OP fd, fs -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x21, cvt_d_s, cvt.d.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true, .isDouble=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x24, cvt_w_s, cvt.w.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x25, cvt_l_s, cvt.l.s, .operands={RAB_OPERAND_cpu_fd, RAB_OPERAND_cpu_fs}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) - -// OP fs, ft -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x30, c_f_s, c.f.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x31, c_un_s, c.un.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x32, c_eq_s, c.eq.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x33, c_ueq_s, c.ueq.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x34, c_olt_s, c.olt.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x35, c_ult_s, c.ult.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x36, c_ole_s, c.ole.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x37, c_ule_s, c.ule.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) - -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x38, c_sf_s, c.sf.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x39, c_ngle_s, c.ngle.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x3A, c_seq_s, c.seq.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x3B, c_ngl_s, c.ngl.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x3C, c_lt_s, c.lt.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x3D, c_nge_s, c.nge.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x3E, c_le_s, c.le.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, 0x3F, c_ngt_s, c.ngt.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .instrType=RABBITIZER_INSTR_TYPE_UNKNOWN, .isFloat=true) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_w.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_w.inc deleted file mode 100644 index 9d07b6dc..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_cop1_fpu_w.inc +++ /dev/null @@ -1,6 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP fd, fs -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) -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) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_normal.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_normal.inc deleted file mode 100644 index cc93fa5c..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_normal.inc +++ /dev/null @@ -1,83 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP LABEL -RABBITIZER_DEF_INSTR_ID(cpu, 0x02, j, .operands={RAB_OPERAND_cpu_label}, .instrType=RABBITIZER_INSTR_TYPE_J, .isJump=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Jump -RABBITIZER_DEF_INSTR_ID(cpu, 0x03, jal, .operands={RAB_OPERAND_cpu_label}, .instrType=RABBITIZER_INSTR_TYPE_J, .isJump=true, .doesLink=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Jump And Link - -// OP rs, rt, IMM -RABBITIZER_DEF_INSTR_ID(cpu, 0x04, beq, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_I, .isBranch=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Branch on EQual -RABBITIZER_DEF_INSTR_ID(cpu, 0x05, bne, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_I, .isBranch=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Branch on Not Equal -RABBITIZER_DEF_INSTR_ID(cpu, 0x14, beql, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_I, .isBranch=true, .isBranchLikely=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Branch on EQual Likely -RABBITIZER_DEF_INSTR_ID(cpu, 0x15, bnel, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_I, .isBranch=true, .isBranchLikely=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Branch on Not Equal Likely - -// OP rs, IMM -RABBITIZER_DEF_INSTR_ID(cpu, 0x06, blez, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_I, .isBranch=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Branch on Less than or Equal to Zero -RABBITIZER_DEF_INSTR_ID(cpu, 0x16, blezl, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_I, .isBranch=true, .isBranchLikely=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Branch on Less than or Equal to Zero Likely -RABBITIZER_DEF_INSTR_ID(cpu, 0x07, bgtz, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_I, .isBranch=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Branch on Greater Than Zero -RABBITIZER_DEF_INSTR_ID(cpu, 0x17, bgtzl, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_I, .isBranch=true, .isBranchLikely=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Branch on Greater Than Zero Likely - -// OP rt, rs, IMM -RABBITIZER_DEF_INSTR_ID(cpu, 0x08, addi, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .notEmitedByCompilers=true, .canBeLo=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Add Immediate -RABBITIZER_DEF_INSTR_ID(cpu, 0x09, addiu, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Add Immediate Unsigned Word -RABBITIZER_DEF_INSTR_ID(cpu, 0x0A, slti, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Set on Less Than Immediate -RABBITIZER_DEF_INSTR_ID(cpu, 0x0B, sltiu, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Set on Less Than Immediate Unsigned -RABBITIZER_DEF_INSTR_ID(cpu, 0x0C, andi, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .isUnsigned=true, .modifiesRt=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // And Immediate -RABBITIZER_DEF_INSTR_ID(cpu, 0x0D, ori, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .isUnsigned=true, .modifiesRt=true, .canBeLo=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Or Immediate -RABBITIZER_DEF_INSTR_ID(cpu, 0x0E, xori, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .isUnsigned=true, .modifiesRt=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // eXclusive OR Immediate -RABBITIZER_DEF_INSTR_ID(cpu, 0x18, daddi, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword add Immediate -RABBITIZER_DEF_INSTR_ID(cpu, 0x19, daddiu, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword add Immediate Unsigned - -// OP rt, IMM -RABBITIZER_DEF_INSTR_ID(cpu, 0x0F, lui, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .isUnsigned=true, .modifiesRt=true, .canBeHi=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Upper Immediate - -// OP rt, IMM(base) -RABBITIZER_DEF_INSTR_ID(cpu, 0x1A, ldl, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Load Doubleword Left -RABBITIZER_DEF_INSTR_ID(cpu, 0x1B, ldr, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Load Doubleword Right -RABBITIZER_DEF_INSTR_ID(cpu, 0x20, lb, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Byte -RABBITIZER_DEF_INSTR_ID(cpu, 0x21, lh, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Halfword -RABBITIZER_DEF_INSTR_ID(cpu, 0x22, lwl, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Word Left -RABBITIZER_DEF_INSTR_ID(cpu, 0x23, lw, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Word -RABBITIZER_DEF_INSTR_ID(cpu, 0x24, lbu, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Byte Insigned -RABBITIZER_DEF_INSTR_ID(cpu, 0x25, lhu, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Halfword Unsigned -RABBITIZER_DEF_INSTR_ID(cpu, 0x26, lwr, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Word Right -RABBITIZER_DEF_INSTR_ID(cpu, 0x27, lwu, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Load Word Unsigned -RABBITIZER_DEF_INSTR_ID(cpu, 0x28, sb, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Store Byte -RABBITIZER_DEF_INSTR_ID(cpu, 0x29, sh, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Store Halfword -RABBITIZER_DEF_INSTR_ID(cpu, 0x2A, swl, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Store Word Left -RABBITIZER_DEF_INSTR_ID(cpu, 0x2B, sw, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Store Word -RABBITIZER_DEF_INSTR_ID(cpu, 0x2C, sdl, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Store Doubleword Left -RABBITIZER_DEF_INSTR_ID(cpu, 0x2D, sdr, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Store Doubleword Right -RABBITIZER_DEF_INSTR_ID(cpu, 0x2E, swr, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Store Word Right -RABBITIZER_DEF_INSTR_ID(cpu, 0x30, ll, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Load Linked word -RABBITIZER_DEF_INSTR_ID(cpu, 0x33, pref, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_IV) // Prefetch -RABBITIZER_DEF_INSTR_ID(cpu, 0x34, lld, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Load Linked Doubleword -RABBITIZER_DEF_INSTR_ID(cpu, 0x37, ld, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Load Doubleword -RABBITIZER_DEF_INSTR_ID(cpu, 0x38, sc, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Store Conditional word -RABBITIZER_DEF_INSTR_ID(cpu, 0x3C, scd, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Store Conditional Doubleword -RABBITIZER_DEF_INSTR_ID(cpu, 0x3F, sd, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Store Doubleword - -// OP op, IMM(base) -RABBITIZER_DEF_INSTR_ID(cpu, 0x2F, cache, .operands={RAB_OPERAND_cpu_op, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .notEmitedByCompilers=true) // Cache - -// OP ft, IMM(base) -RABBITIZER_DEF_INSTR_ID(cpu, 0x31, lwc1, .operands={RAB_OPERAND_cpu_ft, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .isFloat=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Word to Coprocessor z -RABBITIZER_DEF_INSTR_ID(cpu, 0x35, ldc1, .operands={RAB_OPERAND_cpu_ft, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .isFloat=true, .isDouble=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Load Doubleword to Coprocessor z -RABBITIZER_DEF_INSTR_ID(cpu, 0x39, swc1, .operands={RAB_OPERAND_cpu_ft, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .isFloat=true, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Store Word from Coprocessor z -RABBITIZER_DEF_INSTR_ID(cpu, 0x3D, sdc1, .operands={RAB_OPERAND_cpu_ft, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .isFloat=true, .isDouble=true, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Store Doubleword from Coprocessor z - -// OP cop2t, IMM(base) -RABBITIZER_DEF_INSTR_ID(cpu, 0x32, lwc2, .operands={RAB_OPERAND_cpu_cop2t, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Word to Coprocessor z -RABBITIZER_DEF_INSTR_ID(cpu, 0x36, ldc2, .operands={RAB_OPERAND_cpu_cop2t, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Load Doubleword to Coprocessor z -RABBITIZER_DEF_INSTR_ID(cpu, 0x3A, swc2, .operands={RAB_OPERAND_cpu_cop2t, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Store Word from Coprocessor z -RABBITIZER_DEF_INSTR_ID(cpu, 0x3E, sdc2, .operands={RAB_OPERAND_cpu_cop2t, RAB_OPERAND_cpu_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Store Doubleword from Coprocessor z - - -// Pseudo-Instruction Unique IDs - -// OP IMM -RABBITIZER_DEF_INSTR_ID(cpu, -0x03, b, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_I, .isBranch=true, .isPseudo=true) // Branch (unconditional) - -// OP rs, IMM -RABBITIZER_DEF_INSTR_ID(cpu, -0x04, beqz, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_I, .isBranch=true, .isPseudo=true) // Branch on EQual Zero -RABBITIZER_DEF_INSTR_ID(cpu, -0x05, bnez, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_I, .isBranch=true, .isPseudo=true) // Branch on Not Equal Zero diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_regimm.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_regimm.inc deleted file mode 100644 index 4d47123b..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_regimm.inc +++ /dev/null @@ -1,25 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP rs, IMM -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 -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 -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 -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 - -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) -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) -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) -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) -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) -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) - -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 -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 -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 -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 - - -// Pseudo-Instruction Unique IDs - -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 diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_special.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_special.inc deleted file mode 100644 index 1adb970a..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/cpu/cpu_special.inc +++ /dev/null @@ -1,93 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP rd, rt, sa -RABBITIZER_DEF_INSTR_ID(cpu, 0x00, sll, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Shift word Left Logical -RABBITIZER_DEF_INSTR_ID(cpu, 0x02, srl, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Shift word Right Logical -RABBITIZER_DEF_INSTR_ID(cpu, 0x03, sra, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Shift word Right Arithmetic -RABBITIZER_DEF_INSTR_ID(cpu, 0x38, dsll, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword Shift Left Logical -RABBITIZER_DEF_INSTR_ID(cpu, 0x3A, dsrl, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword Shift Right Logical -RABBITIZER_DEF_INSTR_ID(cpu, 0x3B, dsra, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword Shift Right Arithmetic -RABBITIZER_DEF_INSTR_ID(cpu, 0x3C, dsll32, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword Shift Left Logical plus 32 -RABBITIZER_DEF_INSTR_ID(cpu, 0x3E, dsrl32, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword Shift Right Logical plus 32 -RABBITIZER_DEF_INSTR_ID(cpu, 0x3F, dsra32, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword Shift Right Arithmetic plus 32 - -// OP rd, rt, rs -RABBITIZER_DEF_INSTR_ID(cpu, 0x14, dsllv, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword Shift Left Logical Variable -RABBITIZER_DEF_INSTR_ID(cpu, 0x16, dsrlv, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword Shift Right Logical Variable -RABBITIZER_DEF_INSTR_ID(cpu, 0x17, dsrav, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword Shift Right Arithmetic Variable -RABBITIZER_DEF_INSTR_ID(cpu, 0x04, sllv, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Shift word Left Logical Variable -RABBITIZER_DEF_INSTR_ID(cpu, 0x06, srlv, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Shift word Right Logical Variable -RABBITIZER_DEF_INSTR_ID(cpu, 0x07, srav, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Shift word Right Arithmetic Variable - -// OP rs -RABBITIZER_DEF_INSTR_ID(cpu, 0x11, mthi, .operands={RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Move To HI register -RABBITIZER_DEF_INSTR_ID(cpu, 0x13, mtlo, .operands={RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Move To LO register -RABBITIZER_DEF_INSTR_ID(cpu, 0x08, jr, .operands={RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .isJump=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Jump Register -RABBITIZER_DEF_INSTR_ID(cpu, 0x09, jalr, .operands={RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .isJump=true, .modifiesRd=true, .doesLink=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Jump And Link Register - -// OP rd, rs -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, -0x09, jalr_rd, jalr, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .isJump=true, .modifiesRd=true, .doesLink=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Jump And Link Register // Special case for rd != 31 - -// OP rd -RABBITIZER_DEF_INSTR_ID(cpu, 0x10, mfhi, .operands={RAB_OPERAND_cpu_rd}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Move From HI register -RABBITIZER_DEF_INSTR_ID(cpu, 0x12, mflo, .operands={RAB_OPERAND_cpu_rd}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Move From LO register - -// OP rd, rs, rt -RABBITIZER_DEF_INSTR_ID(cpu, 0x0A, movz, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_IV) // MOVe conditional on Zero -RABBITIZER_DEF_INSTR_ID(cpu, 0x0B, movn, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_IV) // MOVe conditional on Not zero -RABBITIZER_DEF_INSTR_ID(cpu, 0x1A, div, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // DIVide word -RABBITIZER_DEF_INSTR_ID(cpu, 0x1B, divu, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // DIVide Unsigned word - -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, -0x1A, sn64_div, div, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // DIVide word -RABBITIZER_DEF_INSTR_ID_ALTNAME(cpu, -0x1B, sn64_divu, divu, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // DIVide Unsigned word - -RABBITIZER_DEF_INSTR_ID(cpu, 0x1E, ddiv, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword DIVide -RABBITIZER_DEF_INSTR_ID(cpu, 0x1F, ddivu, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword DIVide Unsigned -// RABBITIZER_DEF_INSTR_ID(cpu, , ddiv, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) -// RABBITIZER_DEF_INSTR_ID(cpu, , ddivu, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) -RABBITIZER_DEF_INSTR_ID(cpu, 0x20, add, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .notEmitedByCompilers=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // ADD word -RABBITIZER_DEF_INSTR_ID(cpu, 0x21, addu, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .maybeIsMove=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // ADD Unsigned word -RABBITIZER_DEF_INSTR_ID(cpu, 0x22, sub, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Subtract word -RABBITIZER_DEF_INSTR_ID(cpu, 0x23, subu, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // SUBtract Unsigned word -RABBITIZER_DEF_INSTR_ID(cpu, 0x24, and, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // AND -RABBITIZER_DEF_INSTR_ID(cpu, 0x25, or, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .maybeIsMove=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // OR -RABBITIZER_DEF_INSTR_ID(cpu, 0x26, xor, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // eXclusive OR -RABBITIZER_DEF_INSTR_ID(cpu, 0x27, nor, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Not OR -RABBITIZER_DEF_INSTR_ID(cpu, 0x2A, slt, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Set on Less Than -RABBITIZER_DEF_INSTR_ID(cpu, 0x2B, sltu, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Set on Less Than Unsigned -RABBITIZER_DEF_INSTR_ID(cpu, 0x2C, dadd, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword Add -RABBITIZER_DEF_INSTR_ID(cpu, 0x2D, daddu, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .maybeIsMove=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword Add Unsigned -RABBITIZER_DEF_INSTR_ID(cpu, 0x2E, dsub, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword SUBtract -RABBITIZER_DEF_INSTR_ID(cpu, 0x2F, dsubu, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword SUBtract Unsigned - -// OP code -RABBITIZER_DEF_INSTR_ID(cpu, 0x0C, syscall, .operands={RAB_OPERAND_cpu_code}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // SYStem CALL -RABBITIZER_DEF_INSTR_ID(cpu, 0x0D, break, .operands={RAB_OPERAND_cpu_code}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Break -RABBITIZER_DEF_INSTR_ID(cpu, 0x0F, sync, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Sync - -// OP rs, rt -RABBITIZER_DEF_INSTR_ID(cpu, 0x18, mult, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // MULTtiply word -RABBITIZER_DEF_INSTR_ID(cpu, 0x19, multu, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // MULTtiply Unsigned word -RABBITIZER_DEF_INSTR_ID(cpu, 0x1C, dmult, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword MULTiply -RABBITIZER_DEF_INSTR_ID(cpu, 0x1D, dmultu, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_III) // Doubleword MULTiply Unsigned - -RABBITIZER_DEF_INSTR_ID(cpu, 0x30, tge, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_code_lower}, .instrType=RABBITIZER_INSTR_TYPE_R, .isTrap=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Trap if Greater or Equal -RABBITIZER_DEF_INSTR_ID(cpu, 0x31, tgeu, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_code_lower}, .instrType=RABBITIZER_INSTR_TYPE_R, .isTrap=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Trap if Greater or Equal Unsigned -RABBITIZER_DEF_INSTR_ID(cpu, 0x32, tlt, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_code_lower}, .instrType=RABBITIZER_INSTR_TYPE_R, .isTrap=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Trap if Less Than -RABBITIZER_DEF_INSTR_ID(cpu, 0x33, tltu, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_code_lower}, .instrType=RABBITIZER_INSTR_TYPE_R, .isTrap=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Trap if Less Than Unsigned -RABBITIZER_DEF_INSTR_ID(cpu, 0x34, teq, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_code_lower}, .instrType=RABBITIZER_INSTR_TYPE_R, .isTrap=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Trap if EQual -RABBITIZER_DEF_INSTR_ID(cpu, 0x36, tne, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_code_lower}, .instrType=RABBITIZER_INSTR_TYPE_R, .isTrap=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Trap if Not Equal - - -// Pseudo-Instruction Unique IDs - -// OP -RABBITIZER_DEF_INSTR_ID(cpu, -0x01, nop, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_R, .isPseudo=true) // No OPeration - -// OP rd, rs -RABBITIZER_DEF_INSTR_ID(cpu, -0x25, move, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .maybeIsMove=true, .isPseudo=true) // Move -RABBITIZER_DEF_INSTR_ID(cpu, -0x27, not, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .isPseudo=true) // Not - -// OP rd, rt -RABBITIZER_DEF_INSTR_ID(cpu, -0x23, negu, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .isPseudo=true) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop0_tlb.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop0_tlb.inc deleted file mode 100644 index 5173361a..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop0_tlb.inc +++ /dev/null @@ -1,23 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31--------26-25------21--------------------------------5--------0 - | = COP0 | TLB | | fmt | - ------6----------5----------------------------------------------- - |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo -000 | --- | TLBR | TLBWI | --- | --- | --- | TLBWR | --- | -001 | TLBP | --- | --- | --- | --- | --- | --- | --- | -010 | --- | --- | --- | --- | --- | --- | --- | --- | -011 | ERET | --- | --- | --- | --- | --- | --- | --- | -100 | --- | --- | --- | --- | --- | --- | --- | --- | -101 | --- | --- | --- | --- | --- | --- | --- | --- | -110 | --- | --- | --- | --- | --- | --- | --- | --- | -111 | EI | DI | --- | --- | --- | --- | --- | --- | - hi |-------|-------|-------|-------|-------|-------|-------|-------| -*/ - -// The other instructions are implemented using the main CPU table - -RABBITIZER_DEF_INSTR_ID(r5900, 0x38, ei, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, 0x39, di, .operands={0}) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop1_fpu_s.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop1_fpu_s.inc deleted file mode 100644 index 730e7e91..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop1_fpu_s.inc +++ /dev/null @@ -1,46 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31--------26-25------21 -------------------------------5--------0 - | = COP1 | = S | | function| - ------6----------5-----------------------------------------6----- - |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo -000 | ADD.S | SUB.S | MUL.S | DIV.S | SQRT.S| ABS.S | MOV.S | NEG.S | -001 | --- | --- | --- | --- | --- | --- | --- | --- | -010 | --- | --- | --- | --- | --- | --- |RSQRT.S| --- | -011 | ADDA.S| SUBA.S| MULA.S| --- | MADD.S| MSUB.S|MADDA.S|MSUBA.S| -100 | --- | --- | --- | --- | CVT.W | --- | --- | --- | -101 | MAX.S | MIN.S | --- | --- | --- | --- | --- | --- | -110 | C.F | --- | C.EQ | --- | C.LT | --- | C.LE | --- | -111 | --- | --- | --- | --- | --- | --- | --- | --- | - hi |-------|-------|-------|-------|-------|-------|-------|-------| -*/ - -// The other instructions are implemented using the main CPU table - -RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x04, c1__sqrt_s, c1, .operands={RAB_OPERAND_cpu_copraw}) - -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 - -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 -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 -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 - -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 -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 -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 -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 - -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 -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 - -// 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. -// 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. -// Here's some reading about the binutils rationale: -// https://sourceware.org/legacy-ml/binutils/2012-11/msg00360.html -// https://sourceware.org/pipermail/binutils/2013-January/079863.html -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 - -RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x34, c_lt_s, c.lt.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) -RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, 0x36, c_le_s, c.le.s, .operands={RAB_OPERAND_cpu_fs, RAB_OPERAND_cpu_ft}, .isFloat=true) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2.inc deleted file mode 100644 index fae81904..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2.inc +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31--------26-25------21 ----------------------------------------0 - | = COP2 | fmt | | - ------6----------5----------------------------------------------- - |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo - 00 | --- | QMFC2 | CFC2 | --- | --- | QMTC2 | CTC2 | --- | - 01 | *1 | --- | --- | --- | --- | --- | --- | --- | - 10 | *2 | *2 | *2 | *2 | *2 | *2 | *2 | *2 | - 11 | *2 | *2 | *2 | *2 | *2 | *2 | *2 | *2 | - hi |-------|-------|-------|-------|-------|-------|-------|-------| - *1 = BC instructions, see BC2 list *2 =see special1 table -*/ - -// TODO: properties -RABBITIZER_DEF_INSTR_ID(r5900, 0x01, qmfc2, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_r5900_vfs}) -RABBITIZER_DEF_INSTR_ID(r5900, 0x02, cfc2, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_r5900_vis}) -RABBITIZER_DEF_INSTR_ID(r5900, 0x05, qmtc2, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_r5900_vfs}) -RABBITIZER_DEF_INSTR_ID(r5900, 0x06, ctc2, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_r5900_vis}) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2_bc2.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2_bc2.inc deleted file mode 100644 index 734e0d4f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2_bc2.inc +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31--------26-25------21-20------16------------------------------0 - | = COP0 | BC2 | fmt | | - ------6----------5----------5------------------------------------ - |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo - 00 | BC2F | BC2T | BC2FL | BC2TL | --- | --- | --- | --- | - 01 | --- | --- | --- | --- | --- | --- | --- | --- | - 10 | --- | --- | --- | --- | --- | --- | --- | --- | - 11 | --- | --- | --- | --- | --- | --- | --- | --- | - hi |-------|-------|-------|-------|-------|-------|-------|-------| -*/ - -// TODO: operands and properties - -RABBITIZER_DEF_INSTR_ID(r5900, 0x00, bc2f, .operands={RAB_OPERAND_cpu_branch_target_label}, .isBranch=true) -RABBITIZER_DEF_INSTR_ID(r5900, 0x01, bc2t, .operands={RAB_OPERAND_cpu_branch_target_label}, .isBranch=true) -RABBITIZER_DEF_INSTR_ID(r5900, 0x02, bc2fl, .operands={RAB_OPERAND_cpu_branch_target_label}, .isBranch=true, .isBranchLikely=true) -RABBITIZER_DEF_INSTR_ID(r5900, 0x03, bc2tl, .operands={RAB_OPERAND_cpu_branch_target_label}, .isBranch=true, .isBranchLikely=true) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2_special1.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2_special1.inc deleted file mode 100644 index 043c911f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2_special1.inc +++ /dev/null @@ -1,82 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31---------26-25-----21-20-----------------------------5--------0 - | =COP2 | Special1 | |function| - ------6----------5------------------------------------------6---- - |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo -000 |VADDx |VADDy |VADDz |VADDw |VSUBx |VSUBy |VSUBz |VSUBw | -001 |VMADDx |VMADDy |VMADDz |VMADDw |VMSUBx |VMSUBy |VMSUBz |VMSUBw | -010 |VMAXx |VMAXy |VMAXz |VMAXw |VMINIx |VMINIy |VMINIz |VMINIw | -011 |VMULx |VMULy |VMULz |VMULw |VMULq |VMAXi |VMULi |VMINIi | -100 |VADDq |VMADDq |VADDi |VMADDi |VSUBq |VMSUBq |VSUbi |VMSUBi | -101 |VADD |VMADD |VMUL |VMAX |VSUB |VMSUB |VOPMSUB|VMINI | -110 |VIADD |VISUB |VIADDI | --- |VIAND |VIOR | --- | --- | -111 |VCALLMS|VCALLMSR| --- | --- | *1 | *1 | *1 | *1 | - hi |-------|-------|-------|-------|-------|-------|-------|-------| - *1=see special2 table -*/ - -// TODO: properties - -RABBITIZER_DEF_INSTR_ID(r5900, 0x00, vaddx, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // ADD broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x01, vaddy, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // ADD broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x02, vaddz, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // ADD broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x03, vaddw, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // ADD broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x04, vsubx, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // SUBtract broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x05, vsuby, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // SUBtract broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x06, vsubz, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // SUBtract broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x07, vsubw, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // SUBtract broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x08, vmaddx, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-ADD broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x09, vmaddy, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-ADD broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x0A, vmaddz, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-ADD broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x0B, vmaddw, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-ADD broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x0C, vmsubx, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-SUBtract broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x0D, vmsuby, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-SUBtract broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x0E, vmsubz, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-SUBtract broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x0F, vmsubw, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-SUBtract broadcast - -RABBITIZER_DEF_INSTR_ID(r5900, 0x10, vmaxx, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MAXimum broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x11, vmaxy, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MAXimum broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x12, vmaxz, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MAXimum broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x13, vmaxw, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MAXimum broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x14, vminix, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MINimum broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x15, vminiy, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MINimum broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x16, vminiz, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MINimum broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x17, vminiw, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MINimum broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x18, vmulx, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MULtiply broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x19, vmuly, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MULtiply broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x1A, vmulz, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MULtiply broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x1B, vmulw, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MULtiply broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x1C, vmulq, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_Q}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MULtiply Q -RABBITIZER_DEF_INSTR_ID(r5900, 0x1D, vmaxi, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_I}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MAXimum I -RABBITIZER_DEF_INSTR_ID(r5900, 0x1E, vmuli, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_I}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MULtiply I -RABBITIZER_DEF_INSTR_ID(r5900, 0x1F, vminii, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_I}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MINImum I - -RABBITIZER_DEF_INSTR_ID(r5900, 0x20, vaddq, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_Q}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // ADD Q -RABBITIZER_DEF_INSTR_ID(r5900, 0x21, vmaddq, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_Q}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-ADD Q -RABBITIZER_DEF_INSTR_ID(r5900, 0x22, vaddi, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_I}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // ADD I -RABBITIZER_DEF_INSTR_ID(r5900, 0x23, vmaddi, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_I}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-ADD I -RABBITIZER_DEF_INSTR_ID(r5900, 0x24, vsubq, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_Q}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // SUBtract Q -RABBITIZER_DEF_INSTR_ID(r5900, 0x25, vmsubq, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_Q}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-SUBtract Q -RABBITIZER_DEF_INSTR_ID(r5900, 0x26, vsubi, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_I}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // SUBtract I -RABBITIZER_DEF_INSTR_ID(r5900, 0x27, vmsubi, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_I}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-SUBtract I -RABBITIZER_DEF_INSTR_ID(r5900, 0x28, vadd, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // ADD -RABBITIZER_DEF_INSTR_ID(r5900, 0x29, vmadd, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-ADD -RABBITIZER_DEF_INSTR_ID(r5900, 0x2A, vmul, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MULtiply -RABBITIZER_DEF_INSTR_ID(r5900, 0x2B, vmax, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MAXimum -RABBITIZER_DEF_INSTR_ID(r5900, 0x2C, vsub, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // SUBtract -RABBITIZER_DEF_INSTR_ID(r5900, 0x2D, vmsub, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply-SUBtract -RABBITIZER_DEF_INSTR_ID(r5900, 0x2E, vopmsub, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Outer product post decrement -RABBITIZER_DEF_INSTR_ID(r5900, 0x2F, vmini, .operands={RAB_OPERAND_r5900_vfdxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // MINImum - -RABBITIZER_DEF_INSTR_ID(r5900, 0x30, viadd, .operands={RAB_OPERAND_r5900_vid, RAB_OPERAND_r5900_vis, RAB_OPERAND_r5900_vit}) // Integer ADD -RABBITIZER_DEF_INSTR_ID(r5900, 0x31, visub, .operands={RAB_OPERAND_r5900_vid, RAB_OPERAND_r5900_vis, RAB_OPERAND_r5900_vit}) // Integer SUBtract -RABBITIZER_DEF_INSTR_ID(r5900, 0x32, viaddi, .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis, RAB_OPERAND_r5900_immediate5}) // Integer ADD Immediate -RABBITIZER_DEF_INSTR_ID(r5900, 0x34, viand, .operands={RAB_OPERAND_r5900_vid, RAB_OPERAND_r5900_vis, RAB_OPERAND_r5900_vit}) // Integer AND -RABBITIZER_DEF_INSTR_ID(r5900, 0x35, vior, .operands={RAB_OPERAND_r5900_vid, RAB_OPERAND_r5900_vis, RAB_OPERAND_r5900_vit}) // Integer OR - -// TODO: operands and properties -RABBITIZER_DEF_INSTR_ID(r5900, 0x38, vcallms, .operands={0}) -RABBITIZER_DEF_INSTR_ID(r5900, 0x39, vcallmsr, .operands={RAB_OPERAND_r5900_vis}) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2_special2.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2_special2.inc deleted file mode 100644 index 6558540f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_cop2_special2.inc +++ /dev/null @@ -1,125 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31---------26-25-----21-20------------------11-10------6-5-2-1--0 - | =COP2 | Special2 | | fhi |1111|flo| - ------6----------5----------------------------------------------- -Note: opcode is flo | (fhi * 4). - |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo -0000 |VADDAx |VADDAy |VADDAz |VADDAw |VSUBAx |VSUBAy |VSUBAz |VSUBAw | -0001 |VMADDAx|VMADDAy|VMADDAz|VMADDAw|VMSUBAx|VMSUBAy|VMSUBAz|VMSUBAw| -0010 |VITOF0 |VITOF4 |VITOF12|VITOF15|VFTOI0 |VFTOI4 |VFTOI12|VFTOI15| -0011 |VMULAx |VMULAy |VMULAz |VMULAw |VMULAq |VABS |VMULAi |VCLIPw | -0100 |VADDAq |VMADDAq|VADDAi |VMADDAi|VSUBAq |VMSUBAq|VSUBAi |VMSUBAi| -0101 |VADDA |VMADDA |VMULA | --- |VSUBA |VMSUBA |VOPMULA|VNOP | -0110 |VMOVE |VMR32 | --- | --- |VLQI |VSQI |VLQD |VSQD | -0111 |VDIV |VSQRT |VRSQRT |VWAITQ |VMTIR |VMFIR |VILWR |VISWR | -1000 |VRNEXT |VRGET |VRINIT |VRXOR | --- | --- | --- | --- | -1001 | --- | --- | --- | --- | --- | --- | --- | --- | -1010 | --- | --- | --- | --- | --- | --- | --- | --- | -1011 | --- | --- | --- | --- | --- | --- | --- | --- | -1100 | --- | --- | --- | --- | --- | --- | --- | --- | -1101 | --- | --- | --- | --- | --- | --- | --- | --- | -1110 | --- | --- | --- | --- | --- | --- | --- | --- | -1111 | --- | --- | --- | --- | --- | --- | --- | --- | - hi |-------|-------|-------|-------|-------|-------|-------|-------| -*/ - -// TODO: operands and properties - -RABBITIZER_DEF_INSTR_ID(r5900, 0x00, vaddax, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Add accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x01, vadday, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Add accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x02, vaddaz, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Add accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x03, vaddaw, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Add accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x04, vsubax, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and substract accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x05, vsubay, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and substract accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x06, vsubaz, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and substract accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x07, vsubaw, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and substract accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x08, vmaddax, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw) // Multiply and add accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x09, vmadday, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw) // Multiply and add accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x0A, vmaddaz, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw) // Multiply and add accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x0B, vmaddaw, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw) // Multiply and add accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x0C, vmsubax, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and substract accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x0D, vmsubay, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and substract accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x0E, vmsubaz, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and substract accumulator broadcast -RABBITIZER_DEF_INSTR_ID(r5900, 0x0F, vmsubaw, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and substract accumulator broadcast - -RABBITIZER_DEF_INSTR_ID(r5900, 0x10, vitof0, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Integer to floating point -RABBITIZER_DEF_INSTR_ID(r5900, 0x11, vitof4, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Integer to floating point -RABBITIZER_DEF_INSTR_ID(r5900, 0x12, vitof12, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Integer to floating point -RABBITIZER_DEF_INSTR_ID(r5900, 0x13, vitof15, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Integer to floating point -RABBITIZER_DEF_INSTR_ID(r5900, 0x14, vftoi0, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Floating to integer -RABBITIZER_DEF_INSTR_ID(r5900, 0x15, vftoi4, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Floating to integer -RABBITIZER_DEF_INSTR_ID(r5900, 0x16, vftoi12, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Floating to integer -RABBITIZER_DEF_INSTR_ID(r5900, 0x17, vftoi15, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Floating to integer - -RABBITIZER_DEF_INSTR_ID(r5900, 0x18, vmulax, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw) -RABBITIZER_DEF_INSTR_ID(r5900, 0x19, vmulay, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw) -RABBITIZER_DEF_INSTR_ID(r5900, 0x1A, vmulaz, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw) -RABBITIZER_DEF_INSTR_ID(r5900, 0x1B, vmulaw, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw) -// TODO -RABBITIZER_DEF_INSTR_ID(r5900, 0x1C, vmulaq, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_Q}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw) - -RABBITIZER_DEF_INSTR_ID(r5900, 0x1D, vabs, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Absolute - -// TODO -RABBITIZER_DEF_INSTR_ID(r5900, 0x1E, vmulai, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_I}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw) - -RABBITIZER_DEF_INSTR_ID(r5900, 0x1F, vclipw, .operands={RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftn}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Clip - -RABBITIZER_DEF_INSTR_ID(r5900, 0x20, vaddaq, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_Q}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Add accumulator Q -RABBITIZER_DEF_INSTR_ID(r5900, 0x21, vmaddaq, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_Q}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and add accumulator Q -RABBITIZER_DEF_INSTR_ID(r5900, 0x22, vaddai, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_I}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Add accumulator I -RABBITIZER_DEF_INSTR_ID(r5900, 0x23, vmaddai, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_I}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and add accumulator I -RABBITIZER_DEF_INSTR_ID(r5900, 0x24, vsubaq, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_Q}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Subtract accumulator Q -RABBITIZER_DEF_INSTR_ID(r5900, 0x25, vmsubaq, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_Q}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and Subtract accumulator Q -RABBITIZER_DEF_INSTR_ID(r5900, 0x26, vsubai, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_I}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Subtract accumulator I -RABBITIZER_DEF_INSTR_ID(r5900, 0x27, vmsubai, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_I}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and Subtract accumulator I -RABBITIZER_DEF_INSTR_ID(r5900, 0x28, vadda, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Add accumulator -RABBITIZER_DEF_INSTR_ID(r5900, 0x29, vmadda, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and add accumulator - -// TODO -RABBITIZER_DEF_INSTR_ID(r5900, 0x2A, vmula, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw) - -RABBITIZER_DEF_INSTR_ID(r5900, 0x2C, vsuba, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) -RABBITIZER_DEF_INSTR_ID(r5900, 0x2D, vmsuba, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Multiply and substract accumulator -RABBITIZER_DEF_INSTR_ID(r5900, 0x2E, vopmula, .operands={RAB_OPERAND_r5900_ACCxyzw, RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vftxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Outer product pre increment -RABBITIZER_DEF_INSTR_ID(r5900, 0x2F, vnop, .operands={0}) // No operation - -RABBITIZER_DEF_INSTR_ID(r5900, 0x30, vmove, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Move floating point registers -RABBITIZER_DEF_INSTR_ID(r5900, 0x31, vmr32, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vfsxyzw}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Move and rotate per word -RABBITIZER_DEF_INSTR_ID(r5900, 0x34, vlqi, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vis_postincr}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Load quadraword post increment -RABBITIZER_DEF_INSTR_ID(r5900, 0x35, vsqi, .operands={RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vit_postincr}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Store quadraword post increment -RABBITIZER_DEF_INSTR_ID(r5900, 0x36, vlqd, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vis_predecr}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Load quadraword pre decrement -RABBITIZER_DEF_INSTR_ID(r5900, 0x37, vsqd, .operands={RAB_OPERAND_r5900_vfsxyzw, RAB_OPERAND_r5900_vit_predecr}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Store quadraword pre decrement - -RABBITIZER_DEF_INSTR_ID(r5900, 0x38, vdiv, .operands={RAB_OPERAND_r5900_Q, RAB_OPERAND_r5900_vfsl, RAB_OPERAND_r5900_vftm}) -RABBITIZER_DEF_INSTR_ID(r5900, 0x39, vsqrt, .operands={RAB_OPERAND_r5900_Q, RAB_OPERAND_r5900_vftm}) -RABBITIZER_DEF_INSTR_ID(r5900, 0x3A, vrsqrt, .operands={RAB_OPERAND_r5900_Q, RAB_OPERAND_r5900_vfsl,RAB_OPERAND_r5900_vftm}) - -RABBITIZER_DEF_INSTR_ID(r5900, 0x3B, vwaitq, .operands={0}) // Wait Q operation - -RABBITIZER_DEF_INSTR_ID(r5900, 0x3C, vmtir, .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vfsl}) - -RABBITIZER_DEF_INSTR_ID(r5900, 0x3D, vmfir, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_vis}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // Move from integer register - -RABBITIZER_DEF_INSTR_ID(r5900, 0x3E, vilwr, .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis}, .isFloat=true, .doesDereference=true, .doesLoad=true) // Integer load word register -RABBITIZER_DEF_INSTR_ID(r5900, 0x3F, viswr, .operands={RAB_OPERAND_r5900_vit, RAB_OPERAND_r5900_vis}, .isFloat=true, .doesDereference=true, .doesStore=true) // Integer store word register -/* -"vilwr.w", RAB_OPERAND_r5900_vit,(RAB_OPERAND_r5900_vis) -"vilwr.x", RAB_OPERAND_r5900_vit,(RAB_OPERAND_r5900_vis) -"vilwr.y", RAB_OPERAND_r5900_vit,(RAB_OPERAND_r5900_vis) -"vilwr.z", RAB_OPERAND_r5900_vit,(RAB_OPERAND_r5900_vis) -"viswr.w", RAB_OPERAND_r5900_vit,(RAB_OPERAND_r5900_vis) -"viswr.x", RAB_OPERAND_r5900_vit,(RAB_OPERAND_r5900_vis) -"viswr.y", RAB_OPERAND_r5900_vit,(RAB_OPERAND_r5900_vis) -"viswr.z", RAB_OPERAND_r5900_vit,(RAB_OPERAND_r5900_vis) -*/ - -RABBITIZER_DEF_INSTR_ID(r5900, 0x40, vrnext, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_R}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // R next -RABBITIZER_DEF_INSTR_ID(r5900, 0x41, vrget, .operands={RAB_OPERAND_r5900_vftxyzw, RAB_OPERAND_r5900_R}, .instrSuffix=RABINSTRSUFFIX_R5900_xyzw, .isFloat=true) // R move - -// TODO -RABBITIZER_DEF_INSTR_ID(r5900, 0x42, vrinit, .operands={RAB_OPERAND_r5900_R, RAB_OPERAND_r5900_vfsl}) -RABBITIZER_DEF_INSTR_ID(r5900, 0x43, vrxor, .operands={RAB_OPERAND_r5900_R, RAB_OPERAND_r5900_vfsl}) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi.inc deleted file mode 100644 index 1cc9bf5c..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi.inc +++ /dev/null @@ -1,49 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31---------26------------------------------------------5--------0 - | = MMI | | function| - ------6----------------------------------------------------6----- - |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo -000 | MADD | MADDU | --- | --- | PLZCW | --- | --- | --- | -001 | *1 | *2 | --- | --- | --- | --- | --- | --- | -010 | MFHI1 | MTHI1 | MFLO1 | MTLO1 | --- | --- | --- | --- | -011 | MULT1 | MULTU1| DIV1 | DIVU1 | --- | --- | --- | --- | -100 | MADD1 | MADDU1| --- | --- | --- | --- | --- | --- | -101 | *3 | *4 | --- | --- | --- | --- | --- | --- | -110 | PMFHL | PMTHL | --- | --- | PSLLH | --- | PSRLH | PSRAH | -111 | --- | --- | --- | --- | PSLLW | --- | PSRLW | PSRAW | - hi |-------|-------|-------|-------|-------|-------|-------|-------| - *1 = MMI0 list *2 = MMI2 list - *3 = MMI1 list *4 = MMI3 list -*/ - -RABBITIZER_DEF_INSTR_ID(r5900, 0x00, madd, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Multiply-ADD word -RABBITIZER_DEF_INSTR_ID(r5900, 0x01, maddu, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Multiply-ADD Unsigned word -RABBITIZER_DEF_INSTR_ID(r5900, 0x04, plzcw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs}, .modifiesRd=true) // Parallel Leading Zero or one Count Word - -RABBITIZER_DEF_INSTR_ID(r5900, 0x10, mfhi1, .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true) // Move From HI1 register -RABBITIZER_DEF_INSTR_ID(r5900, 0x11, mthi1, .operands={RAB_OPERAND_cpu_rs}) // Move To HI1 register -RABBITIZER_DEF_INSTR_ID(r5900, 0x12, mflo1, .operands={RAB_OPERAND_cpu_rd}) // Move From LO1 register -RABBITIZER_DEF_INSTR_ID(r5900, 0x13, mtlo1, .operands={RAB_OPERAND_cpu_rs}) // Move To LO1 register - -RABBITIZER_DEF_INSTR_ID(r5900, 0x18, mult1, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // MULTiply word pipeline 1 -RABBITIZER_DEF_INSTR_ID(r5900, 0x19, multu1, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // MULTiply Unsigned word pipeline 1 -RABBITIZER_DEF_INSTR_ID(r5900, 0x1A, div1, .operands={RAB_OPERAND_cpu_zero, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}) // DIVide word pipeline 1 -RABBITIZER_DEF_INSTR_ID(r5900, 0x1B, divu1, .operands={RAB_OPERAND_cpu_zero, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}) // DIVide Unsigned word pipeline 1 - -RABBITIZER_DEF_INSTR_ID(r5900, 0x20, madd1, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Multiply-ADD word pipeline 1 -RABBITIZER_DEF_INSTR_ID(r5900, 0x21, maddu1, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Multiply-ADD Unsigned word pipeline 1 - -// TODO: check this two instruction, it is supposed to have an extra .fmt -RABBITIZER_DEF_INSTR_ID(r5900, 0x30, pmfhl, .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true) // Parallel Move From Hi/Lo register -RABBITIZER_DEF_INSTR_ID(r5900, 0x31, pmthl, .operands={RAB_OPERAND_cpu_rs}) // Parallel Move To Hi/Lo register - -RABBITIZER_DEF_INSTR_ID(r5900, 0x34, psllh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .modifiesRd=true) // Parallel Shift Left Logical Halfword -RABBITIZER_DEF_INSTR_ID(r5900, 0x36, psrlh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .modifiesRd=true) // Parallel Shift Right Logical Halfword -RABBITIZER_DEF_INSTR_ID(r5900, 0x37, psrah, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .modifiesRd=true) // Parallel Shift Right Arithmetic Halfword - -RABBITIZER_DEF_INSTR_ID(r5900, 0x3C, psllw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .modifiesRd=true) // Parallel Shift Left Logical Word -RABBITIZER_DEF_INSTR_ID(r5900, 0x3E, psrlw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .modifiesRd=true) // Parallel Shift Right Logical Word -RABBITIZER_DEF_INSTR_ID(r5900, 0x3F, psraw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt, RAB_OPERAND_cpu_sa}, .modifiesRd=true) // Parallel Shift Right Arithmetic Word diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_0.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_0.inc deleted file mode 100644 index d9203e52..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_0.inc +++ /dev/null @@ -1,50 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31---------26------------------------------10--------6-5--------0 - | | |function | MMI0 | - ------6----------------------------------------------------6----- - |---00--|---01--|---10--|---11--| lo -000 |PADDW | PSUBW | PCGTW | PMAXW | -001 |PADDH | PSUBH | PCGTH | PMAXH | -010 |PADDB | PSUBB | PCGTB | --- | -011 | --- | --- | --- | --- | -100 |PADDSW |PSUBSW |PEXTLW | PPACW | -101 |PADDSH |PSUBSH |PEXTLH | PPACH | -110 |PADDSB |PSUBSB |PEXTLB | PPACB | -111 | --- | --- | PEXT5 | PPAC5 | - hi |-------|-------|-------|-------| -*/ - -RABBITIZER_DEF_INSTR_ID(r5900, 0x00, paddw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ADD Word -RABBITIZER_DEF_INSTR_ID(r5900, 0x01, psubw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel SUBtract Word -RABBITIZER_DEF_INSTR_ID(r5900, 0x02, pcgtw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Compare for Greater Than Word -RABBITIZER_DEF_INSTR_ID(r5900, 0x03, pmaxw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel MAXimum Word - -RABBITIZER_DEF_INSTR_ID(r5900, 0x04, paddh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ADD Halfword -RABBITIZER_DEF_INSTR_ID(r5900, 0x05, psubh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel SUBtract Halfword -RABBITIZER_DEF_INSTR_ID(r5900, 0x06, pcgth, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Compare for Greater Than Halfword -RABBITIZER_DEF_INSTR_ID(r5900, 0x07, pmaxh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel MAXimum Halfword - -RABBITIZER_DEF_INSTR_ID(r5900, 0x08, paddb, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ADD Byte -RABBITIZER_DEF_INSTR_ID(r5900, 0x09, psubb, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel SUBtract Byte -RABBITIZER_DEF_INSTR_ID(r5900, 0x0A, pcgtb, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel Compare for Greater Than Byte - -RABBITIZER_DEF_INSTR_ID(r5900, 0x10, paddsw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ADD with Signed saturation Word -RABBITIZER_DEF_INSTR_ID(r5900, 0x11, psubsw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel SUBtract with Signed saturation Word -RABBITIZER_DEF_INSTR_ID(r5900, 0x12, pextlw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXTend Lower from Word -RABBITIZER_DEF_INSTR_ID(r5900, 0x13, ppacw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel PACk to Word - -RABBITIZER_DEF_INSTR_ID(r5900, 0x14, paddsh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ADD with Signed saturation Halfword -RABBITIZER_DEF_INSTR_ID(r5900, 0x15, psubsh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel SUBtract with Signed saturation Halfword -RABBITIZER_DEF_INSTR_ID(r5900, 0x16, pextlh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXTend Lower from Halfword -RABBITIZER_DEF_INSTR_ID(r5900, 0x17, ppach, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel PACk to Halfword - -RABBITIZER_DEF_INSTR_ID(r5900, 0x18, paddsb, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ADD with Signed saturation Bytes -RABBITIZER_DEF_INSTR_ID(r5900, 0x19, psubsb, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel SUBtract with Signed saturation Bytes -RABBITIZER_DEF_INSTR_ID(r5900, 0x1A, pextlb, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXTend Lower from Bytes -RABBITIZER_DEF_INSTR_ID(r5900, 0x1B, ppacb, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel PACk to Bytes - -RABBITIZER_DEF_INSTR_ID(r5900, 0x1E, pext5, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXTend from 5-bits -RABBITIZER_DEF_INSTR_ID(r5900, 0x1F, ppac5, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel PACk to 5-bits diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_1.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_1.inc deleted file mode 100644 index 64573223..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_1.inc +++ /dev/null @@ -1,43 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31---------26------------------------------------------5--------0 - | | |function | MMI1 | - ------6----------------------------------------------------6----- - |---00--|---01--|---10--|---11--| lo -000 | --- | PABSW | PCEQW | PMINW | -001 |PADSBH | PABSH | PCEQH | PMINH | -010 | --- | --- | PCEQB | --- | -011 | --- | --- | --- | --- | -100 |PADDUW |PSUBUW |PEXTUW | --- | -101 |PADDUH |PSUBUH |PEXTUH | --- | -110 |PADDUB |PSUBUB |PEXTUB | QFSRV | -111 | --- | --- | --- | --- | - hi |-------|-------|-------|-------| -*/ - -// TODO: operands and properties -RABBITIZER_DEF_INSTR_ID(r5900, 0x01, pabsw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ABSolute Word -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 -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 - -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 -RABBITIZER_DEF_INSTR_ID(r5900, 0x05, pabsh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ABSolute Halfword -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 -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 - -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 - -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 -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 -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 - -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 -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 -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 - -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 -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 -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 -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 diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_2.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_2.inc deleted file mode 100644 index a7cd357f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_2.inc +++ /dev/null @@ -1,48 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31---------26------------------------------------------5--------0 - | | |function | MMI2 | - ------6----------------------------------------------------6----- - |---00--|---01--|---10--|---11--| lo -000 |PMADDW | --- |PSLLVW |PSRLVW | -001 |PMSUBW | --- | --- | --- | -010 |PMFHI |PMFLO |PINTH | --- | -011 |PMULTW |PDIVW |PCPYLD | --- | -100 |PMADDH |PHMADH | PAND | PXOR | -101 |PMSUBH |PHMSBH | --- | --- | -110 | --- | --- | PEXEH | PREVH | -111 |PMULTH |PDIVBW | PEXEW |PROT3W | - hi |-------|-------|-------|-------| -*/ - -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 -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 -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 - -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 - -RABBITIZER_DEF_INSTR_ID(r5900, 0x08, pmfhi, .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true) // Parallel Move From HI register -RABBITIZER_DEF_INSTR_ID(r5900, 0x09, pmflo, .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true) // Parallel Move From LO register -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 - -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 -RABBITIZER_DEF_INSTR_ID(r5900, 0x0D, pdivw, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}) // Parallel DIVide Word -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 - -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 -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 -RABBITIZER_DEF_INSTR_ID(r5900, 0x12, pand, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel AND -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 - -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 -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 - -RABBITIZER_DEF_INSTR_ID(r5900, 0x1A, pexeh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXchange Even Halfword -RABBITIZER_DEF_INSTR_ID(r5900, 0x1B, prevh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel REVerse Halfword - -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 -RABBITIZER_DEF_INSTR_ID(r5900, 0x1D, pdivbw, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel DIVide Broadcast Word -RABBITIZER_DEF_INSTR_ID(r5900, 0x1E, pexew, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXchange Even Word -RABBITIZER_DEF_INSTR_ID(r5900, 0x1F, prot3w, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel ROTate 3 Words left diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_3.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_3.inc deleted file mode 100644 index 21edadd5..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_mmi_3.inc +++ /dev/null @@ -1,37 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31---------26------------------------------------------5--------0 - | | |function | MMI3 | - ------6----------------------------------------------------6----- - |---00--|---01--|---10--|---11--| lo -000 |PMADDUW| --- | --- |PSRAVW | -001 | --- | --- | --- | --- | -010 |PMTHI | PMTLO |PINTEH | --- | -011 |PMULTUW| PDIVUW|PCPYUD | --- | -100 | --- | --- | POR | PNOR | -101 | --- | --- | --- | --- | -110 | --- | --- | PEXCH | PCPYH | -111 | --- | --- | PEXCW | --- | - hi |-------|-------|-------|-------| -*/ - -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 -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 - -RABBITIZER_DEF_INSTR_ID(r5900, 0x08, pmthi, .operands={RAB_OPERAND_cpu_rs}) // Parallel Move To HI register -RABBITIZER_DEF_INSTR_ID(r5900, 0x09, pmtlo, .operands={RAB_OPERAND_cpu_rs}) // Parallel Move To LO register -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 - -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 -RABBITIZER_DEF_INSTR_ID(r5900, 0x0D, pdivuw, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}) // Prallel DIVide Unsigned Word -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 - -RABBITIZER_DEF_INSTR_ID(r5900, 0x12, por, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel OR -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 - -RABBITIZER_DEF_INSTR_ID(r5900, 0x1A, pexch, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXchange Center Halfword -RABBITIZER_DEF_INSTR_ID(r5900, 0x1B, pcpyh, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel CoPY Halfword - -RABBITIZER_DEF_INSTR_ID(r5900, 0x1E, pexcw, .operands={RAB_OPERAND_cpu_rd, RAB_OPERAND_cpu_rt}, .modifiesRd=true) // Parallel EXchange Center Word diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_normal.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_normal.inc deleted file mode 100644 index d5bd5c23..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_normal.inc +++ /dev/null @@ -1,31 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31---------26---------------------------------------------------0 - | opcode | | - ------6---------------------------------------------------------- - |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo -000 | *1 | *2 | J | JAL | BEQ | BNE | BLEZ | BGTZ | -001 | ADDI | ADDIU | SLTI | SLTIU | ANDI | ORI | XORI | LUI | -010 | *3 | *4 | *5 | --- | BEQL | BNEL | BLEZL | BGTZL | -011 | DADDI |DADDIU | LDL | LDR | *6 | --- | LQ | SQ | -100 | LB | LH | LWL | LW | LBU | LHU | LWR | LWU | -101 | SB | SH | SWL | SW | SDL | SDR | SWR | CACHE | -110 | --- | LWC1 | --- | PREF | --- | --- | LQC2 | LD | -111 | --- | SWC1 | --- | --- | --- | --- | SQC2 | SD | - hi |-------|-------|-------|-------|-------|-------|-------|-------| - *1 = SPECIAL, see SPECIAL list *2 = REGIMM, see REGIMM list - *3 = COP0 *4 = COP1 - *5 = COP2 *6 = MMI table -*/ - -// The other instructions are implemented using the main CPU table - - -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 -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 - -RABBITIZER_DEF_INSTR_ID(r5900, 0x36, lqc2, .operands={RAB_OPERAND_r5900_vft, RAB_OPERAND_cpu_immediate_base}, .canBeLo=true, .doesDereference=true, .doesLoad=true) - -RABBITIZER_DEF_INSTR_ID(r5900, 0x3E, sqc2, .operands={RAB_OPERAND_r5900_vft, RAB_OPERAND_cpu_immediate_base}, .canBeLo=true, .doesDereference=true, .doesStore=true) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_regimm.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_regimm.inc deleted file mode 100644 index c1f27a2a..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_regimm.inc +++ /dev/null @@ -1,20 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31---------26----------20-------16------------------------------0 - | = REGIMM | | rt | | - ------6---------------------5------------------------------------ - |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo - 00 | BLTZ | BGEZ | BLTZL | BGEZL | --- | --- | --- | --- | - 01 | TGEI | TGEIU | TLTI | TLTIU | TEQI | --- | TNEI | --- | - 10 | BLTZAL| BGEZAL|BLTZALL|BGEZALL| --- | --- | --- | --- | - 11 | MTSAB | MTSAH | --- | --- | --- | --- | --- | --- | - hi |-------|-------|-------|-------|-------|-------|-------|-------| -*/ - -// The other instructions are implemented using the main CPU table - -// OP rs, IMM -RABBITIZER_DEF_INSTR_ID(r5900, 0x18, mtsab, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM) -RABBITIZER_DEF_INSTR_ID(r5900, 0x19, mtsah, .operands={RAB_OPERAND_cpu_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_special.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_special.inc deleted file mode 100644 index 22e1bb73..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/r5900/r5900_special.inc +++ /dev/null @@ -1,27 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/* - 31---------26------------------------------------------5--------0 - | = SPECIAL | | function| - ------6----------------------------------------------------6----- - |--000--|--001--|--010--|--011--|--100--|--101--|--110--|--111--| lo -000 | SLL | --- | SRL | SRA | SLLV | --- | SRLV | SRAV | -001 | JR | JALR | MOVZ | MOVN |SYSCALL| BREAK | --- | SYNC | -010 | MFHI | MTHI | MFLO | MTLO | DSLLV | --- | DSRLV | DSRAV | -011 | MULT | MULTU | DIV | DIVU | ---- | --- | ---- | ----- | -100 | ADD | ADDU | SUB | SUBU | AND | OR | XOR | NOR | -101 | MFSA | MTSA | SLT | SLTU | DADD | DADDU | DSUB | DSUBU | -110 | TGE | TGEU | TLT | TLTU | TEQ | --- | TNE | --- | -111 | DSLL | --- | DSRL | DSRA |DSLL32 | --- |DSRL32 |DSRA32 | - hi |-------|-------|-------|-------|-------|-------|-------|-------| -*/ - -// The other instructions are implemented using the main CPU table - -RABBITIZER_DEF_INSTR_ID_ALTNAME(r5900, -0x0F, sync_p, sync.p, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_R, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_II) // Sync - -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 - -RABBITIZER_DEF_INSTR_ID(r5900, 0x28, mfsa, .operands={RAB_OPERAND_cpu_rd}, .modifiesRd=true) // Move From Shift Amount register -RABBITIZER_DEF_INSTR_ID(r5900, 0x29, mtsa, .operands={RAB_OPERAND_cpu_rs}) // Move To Shift Amount register diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_cop0.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_cop0.inc deleted file mode 100644 index c6c7d0ea..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_cop0.inc +++ /dev/null @@ -1,6 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP rt, cop0d -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 -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 diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_cop2.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_cop2.inc deleted file mode 100644 index 344891db..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_cop2.inc +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP cop2t, vd[index] -RABBITIZER_DEF_INSTR_ID(rsp, 0x00, mfc2, .operands={RAB_OPERAND_rsp_cop2t, RAB_OPERAND_rsp_vs_index}, .modifiesRt=true) -RABBITIZER_DEF_INSTR_ID(rsp, 0x04, mtc2, .operands={RAB_OPERAND_rsp_cop2t, RAB_OPERAND_rsp_vs_index}) - -// OP rt, cop2cd -RABBITIZER_DEF_INSTR_ID(rsp, 0x02, cfc2, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_rsp_cop2cd}, .modifiesRt=true) -RABBITIZER_DEF_INSTR_ID(rsp, 0x06, ctc2, .operands={RAB_OPERAND_cpu_rt, RAB_OPERAND_rsp_cop2cd}) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_cop2_vu.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_cop2_vu.inc deleted file mode 100644 index 4a927a59..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_cop2_vu.inc +++ /dev/null @@ -1,53 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP vd, vs, vt[elementhigh] -RABBITIZER_DEF_INSTR_ID(rsp, 0x00, vmulf, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x01, vmulu, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x02, vrndp, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x03, vmulq, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x04, vmudl, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x05, vmudm, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x06, vmudn, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x07, vmudh, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x08, vmacf, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x09, vmacu, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x0A, vrndn, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x0B, vmacq, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x0C, vmadl, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x0D, vmadm, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x0E, vmadn, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x0F, vmadh, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x10, vadd, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x11, vsub, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x13, vabs, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x14, vaddc, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x15, vsubc, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x1D, vsar, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x28, vand, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x29, vnand, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x2A, vor, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x2B, vnor, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x2C, vxor, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x2D, vnxor, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) - -RABBITIZER_DEF_INSTR_ID(rsp, 0x20, vlt, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x21, veq, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x22, vne, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x23, vge, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x24, vcl, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x25, vch, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x26, vcr, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x27, vmrg, .operands={RAB_OPERAND_rsp_vd, RAB_OPERAND_rsp_vs, RAB_OPERAND_rsp_vt_elementhigh}) - -// OP vd[de], vt[elementhigh] -RABBITIZER_DEF_INSTR_ID(rsp, 0x30, vrcp, .operands={RAB_OPERAND_rsp_vd_de, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x31, vrcpl, .operands={RAB_OPERAND_rsp_vd_de, RAB_OPERAND_rsp_vt_elementhigh}) // operands may be wrong -RABBITIZER_DEF_INSTR_ID(rsp, 0x32, vrcph, .operands={RAB_OPERAND_rsp_vd_de, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x33, vmov, .operands={RAB_OPERAND_rsp_vd_de, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x34, vrsq, .operands={RAB_OPERAND_rsp_vd_de, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x35, vrsql, .operands={RAB_OPERAND_rsp_vd_de, RAB_OPERAND_rsp_vt_elementhigh}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x36, vrsqh, .operands={RAB_OPERAND_rsp_vd_de, RAB_OPERAND_rsp_vt_elementhigh}) - -// OP -RABBITIZER_DEF_INSTR_ID(rsp, 0x37, vnop, .operands={0}) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_normal.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_normal.inc deleted file mode 100644 index be73f5a0..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_normal.inc +++ /dev/null @@ -1,53 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP LABEL -RABBITIZER_DEF_INSTR_ID(rsp, 0x02, j, .operands={RAB_OPERAND_cpu_label}, .instrType=RABBITIZER_INSTR_TYPE_J, .isJump=true) // Jump -RABBITIZER_DEF_INSTR_ID(rsp, 0x03, jal, .operands={RAB_OPERAND_cpu_label}, .instrType=RABBITIZER_INSTR_TYPE_J, .isJump=true, .doesLink=true) // Jump And Link - -// OP rs, rt, IMM -RABBITIZER_DEF_INSTR_ID(rsp, 0x04, beq, .operands={RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true) // Branch on EQual -RABBITIZER_DEF_INSTR_ID(rsp, 0x05, bne, .operands={RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true) // Branch on Not Equal - -// OP rs, IMM -RABBITIZER_DEF_INSTR_ID(rsp, 0x06, blez, .operands={RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true) // Branch on Less than or Equal to Zero -RABBITIZER_DEF_INSTR_ID(rsp, 0x07, bgtz, .operands={RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true) // Branch on Greater Than Zero - -// OP rt, rs, IMM -RABBITIZER_DEF_INSTR_ID(rsp, 0x08, addi, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .notEmitedByCompilers=true, .canBeLo=true) // Add Immediate -RABBITIZER_DEF_INSTR_ID(rsp, 0x09, addiu, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true) // Add Immediate Unsigned Word -RABBITIZER_DEF_INSTR_ID(rsp, 0x0A, slti, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true) // Set on Less Than Immediate -RABBITIZER_DEF_INSTR_ID(rsp, 0x0B, sltiu, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true) // Set on Less Than Immediate Unsigned -RABBITIZER_DEF_INSTR_ID(rsp, 0x0C, andi, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .isUnsigned=true, .modifiesRt=true) // And Immediate -RABBITIZER_DEF_INSTR_ID(rsp, 0x0D, ori, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .isUnsigned=true, .modifiesRt=true, .canBeLo=true) // Or Immediate -RABBITIZER_DEF_INSTR_ID(rsp, 0x0E, xori, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .isUnsigned=true, .modifiesRt=true) // eXclusive OR Immediate - -// OP rt, IMM -RABBITIZER_DEF_INSTR_ID(rsp, 0x0F, lui, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_cpu_immediate}, .instrType=RABBITIZER_INSTR_TYPE_I, .isUnsigned=true, .modifiesRt=true, .canBeHi=true) // Load Upper Immediate - -// OP rt, IMM(base) -RABBITIZER_DEF_INSTR_ID(rsp, 0x20, lb, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Byte -RABBITIZER_DEF_INSTR_ID(rsp, 0x21, lh, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Halfword -RABBITIZER_DEF_INSTR_ID(rsp, 0x23, lw, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Word -RABBITIZER_DEF_INSTR_ID(rsp, 0x24, lbu, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Byte Insigned -RABBITIZER_DEF_INSTR_ID(rsp, 0x25, lhu, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Halfword Unsigned -RABBITIZER_DEF_INSTR_ID(rsp, 0x28, sb, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Store Byte -RABBITIZER_DEF_INSTR_ID(rsp, 0x29, sh, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Store Halfword -RABBITIZER_DEF_INSTR_ID(rsp, 0x2B, sw, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Store Word -RABBITIZER_DEF_INSTR_ID(rsp, 0x33, pref, .operands={RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .modifiesRt=true, .canBeLo=true, .doesDereference=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_IV) // Prefetch - -RABBITIZER_DEF_INSTR_ID(rsp, 0x2F, cache, .operands={RAB_OPERAND_cpu_op, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .notEmitedByCompilers=true) // Cache - -// OP ft, IMM(base) -RABBITIZER_DEF_INSTR_ID(rsp, 0x31, lwc1, .operands={RAB_OPERAND_cpu_ft, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .isFloat=true, .canBeLo=true, .doesDereference=true, .doesLoad=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Load Word to Coprocessor z -RABBITIZER_DEF_INSTR_ID(rsp, 0x39, swc1, .operands={RAB_OPERAND_cpu_ft, RAB_OPERAND_rsp_immediate_base}, .instrType=RABBITIZER_INSTR_TYPE_I, .isFloat=true, .canBeLo=true, .doesDereference=true, .doesStore=true, .architectureVersion=RABBITIZER_ARCHVERSION_MIPS_I) // Store Word from Coprocessor z - - -// Pseudo-Instruction Unique IDs - -// OP IMM -RABBITIZER_DEF_INSTR_ID(rsp, -0x03, b, .operands={RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true) // Branch (unconditional) - -// OP rs, IMM -RABBITIZER_DEF_INSTR_ID(rsp, -0x04, beqz, .operands={RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true) // Branch on EQual Zero -RABBITIZER_DEF_INSTR_ID(rsp, -0x05, bnez, .operands={RAB_OPERAND_rsp_rs, RAB_OPERAND_cpu_branch_target_label}, .instrType=RABBITIZER_INSTR_TYPE_REGIMM, .isBranch=true) // Branch on Not Equal Zero diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_normal_lwc2.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_normal_lwc2.inc deleted file mode 100644 index 4440fb09..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_normal_lwc2.inc +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP vt[elementlow], offset(vs) -RABBITIZER_DEF_INSTR_ID(rsp, 0x00, lbv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x01, lsv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x02, llv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x03, ldv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x04, lqv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x05, lrv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x06, lpv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x07, luv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x08, lhv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x09, lfv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x0B, ltv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_normal_swc2.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_normal_swc2.inc deleted file mode 100644 index 996c69f2..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_normal_swc2.inc +++ /dev/null @@ -1,17 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP vt[elementlow], offset(vs) -RABBITIZER_DEF_INSTR_ID(rsp, 0x00, sbv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x01, ssv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x02, slv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x03, sdv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x04, sqv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x05, srv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x06, spv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x07, suv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x08, shv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x09, sfv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) -RABBITIZER_DEF_INSTR_ID(rsp, 0x0B, stv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) - -RABBITIZER_DEF_INSTR_ID(rsp, -0x07, swv, .operands={RAB_OPERAND_rsp_vt_elementlow, RAB_OPERAND_rsp_offset_rs}) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_regimm.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_regimm.inc deleted file mode 100644 index c2132f94..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_regimm.inc +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP rs, IMM -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 -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 - -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 -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 - - -// Pseudo-Instruction Unique IDs - -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 diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_special.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_special.inc deleted file mode 100644 index 9f12212d..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/instr_id/rsp/rsp_special.inc +++ /dev/null @@ -1,49 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -// OP rd, rt, sa -RABBITIZER_DEF_INSTR_ID(rsp, 0x00, sll, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rt, RAB_OPERAND_cpu_sa}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // Shift word Left Logical -RABBITIZER_DEF_INSTR_ID(rsp, 0x02, srl, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rt, RAB_OPERAND_cpu_sa}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // Shift word Right Logical -RABBITIZER_DEF_INSTR_ID(rsp, 0x03, sra, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rt, RAB_OPERAND_cpu_sa}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // Shift word Right Arithmetic - -// OP rd, rt, rs -RABBITIZER_DEF_INSTR_ID(rsp, 0x04, sllv, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // Shift word Left Logical Variable -RABBITIZER_DEF_INSTR_ID(rsp, 0x06, srlv, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // Shift word Right Logical Variable -RABBITIZER_DEF_INSTR_ID(rsp, 0x07, srav, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rt, RAB_OPERAND_rsp_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // Shift word Right Arithmetic Variable - -// OP rs -RABBITIZER_DEF_INSTR_ID(rsp, 0x08, jr, .operands={RAB_OPERAND_rsp_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .isJump=true) // Jump Register -RABBITIZER_DEF_INSTR_ID(rsp, 0x09, jalr, .operands={RAB_OPERAND_rsp_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .isJump=true, .modifiesRd=true, .doesLink=true) // Jump And Link Register - -// OP rd, rs -RABBITIZER_DEF_INSTR_ID_ALTNAME(rsp, -0x09, jalr_rd, jalr, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .isJump=true, .modifiesRd=true, .doesLink=true) // Jump And Link Register // Special case for rd != 31 - -// OP rd, rs, rt -RABBITIZER_DEF_INSTR_ID(rsp, 0x0A, movz, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // MOVe conditional on Zero -RABBITIZER_DEF_INSTR_ID(rsp, 0x0B, movn, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // MOVe conditional on Not zero - -RABBITIZER_DEF_INSTR_ID(rsp, 0x20, add, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true, .notEmitedByCompilers=true) // ADD word -RABBITIZER_DEF_INSTR_ID(rsp, 0x21, addu, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // ADD Unsigned word -RABBITIZER_DEF_INSTR_ID(rsp, 0x22, sub, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // Subtract word -RABBITIZER_DEF_INSTR_ID(rsp, 0x23, subu, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // SUBtract Unsigned word -RABBITIZER_DEF_INSTR_ID(rsp, 0x24, and, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // AND -RABBITIZER_DEF_INSTR_ID(rsp, 0x25, or, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // OR -RABBITIZER_DEF_INSTR_ID(rsp, 0x26, xor, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // eXclusive OR -RABBITIZER_DEF_INSTR_ID(rsp, 0x27, nor, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // Not OR -RABBITIZER_DEF_INSTR_ID(rsp, 0x2A, slt, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // Set on Less Than -RABBITIZER_DEF_INSTR_ID(rsp, 0x2B, sltu, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // Set on Less Than Unsigned - -// OP code -RABBITIZER_DEF_INSTR_ID(rsp, 0x0D, break, .operands={RAB_OPERAND_cpu_code}, .instrType=RABBITIZER_INSTR_TYPE_R) // Break - - -// Pseudo-Instruction Unique IDs -// OP -RABBITIZER_DEF_INSTR_ID(rsp, -0x01, nop, .operands={0}, .instrType=RABBITIZER_INSTR_TYPE_R) // No OPeration - -// OP rd, rs -RABBITIZER_DEF_INSTR_ID(rsp, -0x25, move, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // Move -RABBITIZER_DEF_INSTR_ID(rsp, -0x27, not, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rs}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) // Not - -// OP rd, rt -RABBITIZER_DEF_INSTR_ID(rsp, -0x23, negu, .operands={RAB_OPERAND_rsp_rd, RAB_OPERAND_rsp_rt}, .instrType=RABBITIZER_INSTR_TYPE_R, .modifiesRd=true) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/operands/RabbitizerOperandType_cpu.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/operands/RabbitizerOperandType_cpu.inc deleted file mode 100644 index bb863366..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/operands/RabbitizerOperandType_cpu.inc +++ /dev/null @@ -1,25 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -RAB_DEF_OPERAND(cpu, rs) -RAB_DEF_OPERAND(cpu, rt) -RAB_DEF_OPERAND(cpu, rd) -RAB_DEF_OPERAND(cpu, sa) -RAB_DEF_OPERAND(cpu, zero) // $zero -// RAB_DEF_OPERAND(cpu, function) -RAB_DEF_OPERAND(cpu, cop0d) -RAB_DEF_OPERAND(cpu, fs) -RAB_DEF_OPERAND(cpu, ft) -RAB_DEF_OPERAND(cpu, fd) -RAB_DEF_OPERAND(cpu, cop1cs) // Coprocessor 1 control fs -RAB_DEF_OPERAND(cpu, cop2t) -RAB_DEF_OPERAND(cpu, op) -RAB_DEF_OPERAND(cpu, code) -RAB_DEF_OPERAND(cpu, code_lower) -RAB_DEF_OPERAND(cpu, copraw) -RAB_DEF_OPERAND(cpu, label) -RAB_DEF_OPERAND(cpu, immediate) -RAB_DEF_OPERAND(cpu, branch_target_label) - -// composed/aliased operands -RAB_DEF_OPERAND(cpu, immediate_base) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/operands/RabbitizerOperandType_r5900.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/operands/RabbitizerOperandType_r5900.inc deleted file mode 100644 index 36cb6efc..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/operands/RabbitizerOperandType_r5900.inc +++ /dev/null @@ -1,33 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -RAB_DEF_OPERAND(r5900, I) -RAB_DEF_OPERAND(r5900, Q) -RAB_DEF_OPERAND(r5900, R) -RAB_DEF_OPERAND(r5900, ACC) -RAB_DEF_OPERAND(r5900, ACCxyzw) -RAB_DEF_OPERAND(r5900, vfs) -RAB_DEF_OPERAND(r5900, vft) -RAB_DEF_OPERAND(r5900, vfd) -RAB_DEF_OPERAND(r5900, vfsxyzw) -RAB_DEF_OPERAND(r5900, vftxyzw) -RAB_DEF_OPERAND(r5900, vfdxyzw) -RAB_DEF_OPERAND(r5900, vfsn) -RAB_DEF_OPERAND(r5900, vftn) -RAB_DEF_OPERAND(r5900, vfdn) -RAB_DEF_OPERAND(r5900, vfsl) -RAB_DEF_OPERAND(r5900, vftl) -RAB_DEF_OPERAND(r5900, vfdl) -RAB_DEF_OPERAND(r5900, vfsm) -RAB_DEF_OPERAND(r5900, vftm) -RAB_DEF_OPERAND(r5900, vfdm) -RAB_DEF_OPERAND(r5900, vis) -RAB_DEF_OPERAND(r5900, vit) -RAB_DEF_OPERAND(r5900, vid) -RAB_DEF_OPERAND(r5900, vis_predecr) -RAB_DEF_OPERAND(r5900, vit_predecr) -RAB_DEF_OPERAND(r5900, vid_predecr) -RAB_DEF_OPERAND(r5900, vis_postincr) -RAB_DEF_OPERAND(r5900, vit_postincr) -RAB_DEF_OPERAND(r5900, vid_postincr) -RAB_DEF_OPERAND(r5900, immediate5) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/operands/RabbitizerOperandType_rsp.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/operands/RabbitizerOperandType_rsp.inc deleted file mode 100644 index 7bae435d..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/operands/RabbitizerOperandType_rsp.inc +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -RAB_DEF_OPERAND(rsp, rs) -RAB_DEF_OPERAND(rsp, rt) -RAB_DEF_OPERAND(rsp, rd) -RAB_DEF_OPERAND(rsp, cop0d) -RAB_DEF_OPERAND(rsp, cop2t) -RAB_DEF_OPERAND(rsp, cop2cd) // Coprocessor 2 control rd -RAB_DEF_OPERAND(rsp, vs) -RAB_DEF_OPERAND(rsp, vt) -RAB_DEF_OPERAND(rsp, vd) -// RAB_DEF_OPERAND(rsp, elementhigh) -// RAB_DEF_OPERAND(rsp, elementlow) -// RAB_DEF_OPERAND(rsp, index) -// RAB_DEF_OPERAND(rsp, offset) - -// composed/aliased operands -RAB_DEF_OPERAND(rsp, vt_elementhigh) -RAB_DEF_OPERAND(rsp, vt_elementlow) -RAB_DEF_OPERAND(rsp, vd_de) -RAB_DEF_OPERAND(rsp, vs_index) -RAB_DEF_OPERAND(rsp, offset_rs) -RAB_DEF_OPERAND(rsp, immediate_base) diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop0.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop0.inc deleted file mode 100644 index 9d3d63d2..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop0.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG_NODOLLAR(COP0, Index, 0), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Random, 1), - RABBITIZER_DEF_REG_NODOLLAR(COP0, EntryLo0, 2), - RABBITIZER_DEF_REG_NODOLLAR(COP0, EntryLo1, 3), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Context, 4), - RABBITIZER_DEF_REG_NODOLLAR(COP0, PageMask, 5), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Wired, 6), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved07, 7), - RABBITIZER_DEF_REG_NODOLLAR(COP0, BadVaddr, 8), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Count, 9), - RABBITIZER_DEF_REG_NODOLLAR(COP0, EntryHi, 10), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Compare, 11), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Status, 12), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Cause, 13), - RABBITIZER_DEF_REG_NODOLLAR(COP0, EPC, 14), - RABBITIZER_DEF_REG_NODOLLAR(COP0, PRevID, 15), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Config, 16), - RABBITIZER_DEF_REG_NODOLLAR(COP0, LLAddr, 17), - RABBITIZER_DEF_REG_NODOLLAR(COP0, WatchLo, 18), - RABBITIZER_DEF_REG_NODOLLAR(COP0, WatchHi, 19), - RABBITIZER_DEF_REG_NODOLLAR(COP0, XContext, 20), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved21, 21), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved22, 22), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved23, 23), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved24, 24), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved25, 25), - RABBITIZER_DEF_REG_NODOLLAR(COP0, PErr, 26), - RABBITIZER_DEF_REG_NODOLLAR(COP0, CacheErr, 27), - RABBITIZER_DEF_REG_NODOLLAR(COP0, TagLo, 28), - RABBITIZER_DEF_REG_NODOLLAR(COP0, TagHi, 29), - RABBITIZER_DEF_REG_NODOLLAR(COP0, ErrorEPC, 30), - RABBITIZER_DEF_REG_NODOLLAR(COP0, Reserved31, 31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1Control.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1Control.inc deleted file mode 100644 index cad6bde5..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1Control.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG(COP1_CONTROL, 0, 0), - RABBITIZER_DEF_REG(COP1_CONTROL, 1, 1), - RABBITIZER_DEF_REG(COP1_CONTROL, 2, 2), - RABBITIZER_DEF_REG(COP1_CONTROL, 3, 3), - RABBITIZER_DEF_REG(COP1_CONTROL, 4, 4), - RABBITIZER_DEF_REG(COP1_CONTROL, 5, 5), - RABBITIZER_DEF_REG(COP1_CONTROL, 6, 6), - RABBITIZER_DEF_REG(COP1_CONTROL, 7, 7), - RABBITIZER_DEF_REG(COP1_CONTROL, 8, 8), - RABBITIZER_DEF_REG(COP1_CONTROL, 9, 9), - RABBITIZER_DEF_REG(COP1_CONTROL, 10, 10), - RABBITIZER_DEF_REG(COP1_CONTROL, 11, 11), - RABBITIZER_DEF_REG(COP1_CONTROL, 12, 12), - RABBITIZER_DEF_REG(COP1_CONTROL, 13, 13), - RABBITIZER_DEF_REG(COP1_CONTROL, 14, 14), - RABBITIZER_DEF_REG(COP1_CONTROL, 15, 15), - RABBITIZER_DEF_REG(COP1_CONTROL, 16, 16), - RABBITIZER_DEF_REG(COP1_CONTROL, 17, 17), - RABBITIZER_DEF_REG(COP1_CONTROL, 18, 18), - RABBITIZER_DEF_REG(COP1_CONTROL, 19, 19), - RABBITIZER_DEF_REG(COP1_CONTROL, 20, 20), - RABBITIZER_DEF_REG(COP1_CONTROL, 21, 21), - RABBITIZER_DEF_REG(COP1_CONTROL, 22, 22), - RABBITIZER_DEF_REG(COP1_CONTROL, 23, 23), - RABBITIZER_DEF_REG(COP1_CONTROL, 24, 24), - RABBITIZER_DEF_REG(COP1_CONTROL, 25, 25), - RABBITIZER_DEF_REG(COP1_CONTROL, 26, 26), - RABBITIZER_DEF_REG(COP1_CONTROL, 27, 27), - RABBITIZER_DEF_REG(COP1_CONTROL, 28, 28), - RABBITIZER_DEF_REG(COP1_CONTROL, 29, 29), - RABBITIZER_DEF_REG(COP1_CONTROL, 30, 30), - RABBITIZER_DEF_REG(COP1_CONTROL, FpcCsr, 31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1N32.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1N32.inc deleted file mode 100644 index affe4948..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1N32.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG(COP1_N32, fv0, f0), - RABBITIZER_DEF_REG(COP1_N32, ft14, f1), - RABBITIZER_DEF_REG(COP1_N32, fv1, f2), - RABBITIZER_DEF_REG(COP1_N32, ft15, f3), - RABBITIZER_DEF_REG(COP1_N32, ft0, f4), - RABBITIZER_DEF_REG(COP1_N32, ft1, f5), - RABBITIZER_DEF_REG(COP1_N32, ft2, f6), - RABBITIZER_DEF_REG(COP1_N32, ft3, f7), - RABBITIZER_DEF_REG(COP1_N32, ft4, f8), - RABBITIZER_DEF_REG(COP1_N32, ft5, f9), - RABBITIZER_DEF_REG(COP1_N32, ft6, f10), - RABBITIZER_DEF_REG(COP1_N32, ft7, f11), - RABBITIZER_DEF_REG(COP1_N32, fa0, f12), - RABBITIZER_DEF_REG(COP1_N32, fa1, f13), - RABBITIZER_DEF_REG(COP1_N32, fa2, f14), - RABBITIZER_DEF_REG(COP1_N32, fa3, f15), - RABBITIZER_DEF_REG(COP1_N32, fa4, f16), - RABBITIZER_DEF_REG(COP1_N32, fa5, f17), - RABBITIZER_DEF_REG(COP1_N32, fa6, f18), - RABBITIZER_DEF_REG(COP1_N32, fa7, f19), - RABBITIZER_DEF_REG(COP1_N32, fs0, f20), - RABBITIZER_DEF_REG(COP1_N32, ft8, f21), - RABBITIZER_DEF_REG(COP1_N32, fs1, f22), - RABBITIZER_DEF_REG(COP1_N32, ft9, f23), - RABBITIZER_DEF_REG(COP1_N32, fs2, f24), - RABBITIZER_DEF_REG(COP1_N32, ft10, f25), - RABBITIZER_DEF_REG(COP1_N32, fs3, f26), - RABBITIZER_DEF_REG(COP1_N32, ft11, f27), - RABBITIZER_DEF_REG(COP1_N32, fs4, f28), - RABBITIZER_DEF_REG(COP1_N32, ft12, f29), - RABBITIZER_DEF_REG(COP1_N32, fs5, f30), - RABBITIZER_DEF_REG(COP1_N32, ft13, f31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1N64.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1N64.inc deleted file mode 100644 index 1388c93d..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1N64.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG(COP1_N64, fv0, f0), - RABBITIZER_DEF_REG(COP1_N64, ft12, f1), - RABBITIZER_DEF_REG(COP1_N64, fv1, f2), - RABBITIZER_DEF_REG(COP1_N64, ft13, f3), - RABBITIZER_DEF_REG(COP1_N64, ft0, f4), - RABBITIZER_DEF_REG(COP1_N64, ft1, f5), - RABBITIZER_DEF_REG(COP1_N64, ft2, f6), - RABBITIZER_DEF_REG(COP1_N64, ft3, f7), - RABBITIZER_DEF_REG(COP1_N64, ft4, f8), - RABBITIZER_DEF_REG(COP1_N64, ft5, f9), - RABBITIZER_DEF_REG(COP1_N64, ft6, f10), - RABBITIZER_DEF_REG(COP1_N64, ft7, f11), - RABBITIZER_DEF_REG(COP1_N64, fa0, f12), - RABBITIZER_DEF_REG(COP1_N64, fa1, f13), - RABBITIZER_DEF_REG(COP1_N64, fa2, f14), - RABBITIZER_DEF_REG(COP1_N64, fa3, f15), - RABBITIZER_DEF_REG(COP1_N64, fa4, f16), - RABBITIZER_DEF_REG(COP1_N64, fa5, f17), - RABBITIZER_DEF_REG(COP1_N64, fa6, f18), - RABBITIZER_DEF_REG(COP1_N64, fa7, f19), - RABBITIZER_DEF_REG(COP1_N64, ft8, f20), - RABBITIZER_DEF_REG(COP1_N64, ft9, f21), - RABBITIZER_DEF_REG(COP1_N64, ft10, f22), - RABBITIZER_DEF_REG(COP1_N64, ft11, f23), - RABBITIZER_DEF_REG(COP1_N64, fs0, f24), - RABBITIZER_DEF_REG(COP1_N64, fs1, f25), - RABBITIZER_DEF_REG(COP1_N64, fs2, f26), - RABBITIZER_DEF_REG(COP1_N64, fs3, f27), - RABBITIZER_DEF_REG(COP1_N64, fs4, f28), - RABBITIZER_DEF_REG(COP1_N64, fs5, f29), - RABBITIZER_DEF_REG(COP1_N64, fs6, f30), - RABBITIZER_DEF_REG(COP1_N64, fs7, f31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1O32.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1O32.inc deleted file mode 100644 index 44ba53e1..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop1O32.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG(COP1_O32, fv0, f0), - RABBITIZER_DEF_REG(COP1_O32, fv0f, f1), - RABBITIZER_DEF_REG(COP1_O32, fv1, f2), - RABBITIZER_DEF_REG(COP1_O32, fv1f, f3), - RABBITIZER_DEF_REG(COP1_O32, ft0, f4), - RABBITIZER_DEF_REG(COP1_O32, ft0f, f5), - RABBITIZER_DEF_REG(COP1_O32, ft1, f6), - RABBITIZER_DEF_REG(COP1_O32, ft1f, f7), - RABBITIZER_DEF_REG(COP1_O32, ft2, f8), - RABBITIZER_DEF_REG(COP1_O32, ft2f, f9), - RABBITIZER_DEF_REG(COP1_O32, ft3, f10), - RABBITIZER_DEF_REG(COP1_O32, ft3f, f11), - RABBITIZER_DEF_REG(COP1_O32, fa0, f12), - RABBITIZER_DEF_REG(COP1_O32, fa0f, f13), - RABBITIZER_DEF_REG(COP1_O32, fa1, f14), - RABBITIZER_DEF_REG(COP1_O32, fa1f, f15), - RABBITIZER_DEF_REG(COP1_O32, ft4, f16), - RABBITIZER_DEF_REG(COP1_O32, ft4f, f17), - RABBITIZER_DEF_REG(COP1_O32, ft5, f18), - RABBITIZER_DEF_REG(COP1_O32, ft5f, f19), - RABBITIZER_DEF_REG(COP1_O32, fs0, f20), - RABBITIZER_DEF_REG(COP1_O32, fs0f, f21), - RABBITIZER_DEF_REG(COP1_O32, fs1, f22), - RABBITIZER_DEF_REG(COP1_O32, fs1f, f23), - RABBITIZER_DEF_REG(COP1_O32, fs2, f24), - RABBITIZER_DEF_REG(COP1_O32, fs2f, f25), - RABBITIZER_DEF_REG(COP1_O32, fs3, f26), - RABBITIZER_DEF_REG(COP1_O32, fs3f, f27), - RABBITIZER_DEF_REG(COP1_O32, fs4, f28), - RABBITIZER_DEF_REG(COP1_O32, fs4f, f29), - RABBITIZER_DEF_REG(COP1_O32, fs5, f30), - RABBITIZER_DEF_REG(COP1_O32, fs5f, f31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop2.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop2.inc deleted file mode 100644 index 84e40f32..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_Cop2.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG(COP2, 0, 0), - RABBITIZER_DEF_REG(COP2, 1, 1), - RABBITIZER_DEF_REG(COP2, 2, 2), - RABBITIZER_DEF_REG(COP2, 3, 3), - RABBITIZER_DEF_REG(COP2, 4, 4), - RABBITIZER_DEF_REG(COP2, 5, 5), - RABBITIZER_DEF_REG(COP2, 6, 6), - RABBITIZER_DEF_REG(COP2, 7, 7), - RABBITIZER_DEF_REG(COP2, 8, 8), - RABBITIZER_DEF_REG(COP2, 9, 9), - RABBITIZER_DEF_REG(COP2, 10, 10), - RABBITIZER_DEF_REG(COP2, 11, 11), - RABBITIZER_DEF_REG(COP2, 12, 12), - RABBITIZER_DEF_REG(COP2, 13, 13), - RABBITIZER_DEF_REG(COP2, 14, 14), - RABBITIZER_DEF_REG(COP2, 15, 15), - RABBITIZER_DEF_REG(COP2, 16, 16), - RABBITIZER_DEF_REG(COP2, 17, 17), - RABBITIZER_DEF_REG(COP2, 18, 18), - RABBITIZER_DEF_REG(COP2, 19, 19), - RABBITIZER_DEF_REG(COP2, 20, 20), - RABBITIZER_DEF_REG(COP2, 21, 21), - RABBITIZER_DEF_REG(COP2, 22, 22), - RABBITIZER_DEF_REG(COP2, 23, 23), - RABBITIZER_DEF_REG(COP2, 24, 24), - RABBITIZER_DEF_REG(COP2, 25, 25), - RABBITIZER_DEF_REG(COP2, 26, 26), - RABBITIZER_DEF_REG(COP2, 27, 27), - RABBITIZER_DEF_REG(COP2, 28, 28), - RABBITIZER_DEF_REG(COP2, 29, 29), - RABBITIZER_DEF_REG(COP2, 30, 30), - RABBITIZER_DEF_REG(COP2, 31, 31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_GprN32.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_GprN32.inc deleted file mode 100644 index a937136b..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_GprN32.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG(GPR_N32, zero, 0), - RABBITIZER_DEF_REG(GPR_N32, at, 1), - RABBITIZER_DEF_REG(GPR_N32, v0, 2), - RABBITIZER_DEF_REG(GPR_N32, v1, 3), - RABBITIZER_DEF_REG(GPR_N32, a0, 4), - RABBITIZER_DEF_REG(GPR_N32, a1, 5), - RABBITIZER_DEF_REG(GPR_N32, a2, 6), - RABBITIZER_DEF_REG(GPR_N32, a3, 7), - RABBITIZER_DEF_REG(GPR_N32, a4, 8), - RABBITIZER_DEF_REG(GPR_N32, a5, 9), - RABBITIZER_DEF_REG(GPR_N32, a6, 10), - RABBITIZER_DEF_REG(GPR_N32, a7, 11), - RABBITIZER_DEF_REG(GPR_N32, t0, 12), - RABBITIZER_DEF_REG(GPR_N32, t1, 13), - RABBITIZER_DEF_REG(GPR_N32, t2, 14), - RABBITIZER_DEF_REG(GPR_N32, t3, 15), - RABBITIZER_DEF_REG(GPR_N32, s0, 16), - RABBITIZER_DEF_REG(GPR_N32, s1, 17), - RABBITIZER_DEF_REG(GPR_N32, s2, 18), - RABBITIZER_DEF_REG(GPR_N32, s3, 19), - RABBITIZER_DEF_REG(GPR_N32, s4, 20), - RABBITIZER_DEF_REG(GPR_N32, s5, 21), - RABBITIZER_DEF_REG(GPR_N32, s6, 22), - RABBITIZER_DEF_REG(GPR_N32, s7, 23), - RABBITIZER_DEF_REG(GPR_N32, t8, 24), - RABBITIZER_DEF_REG(GPR_N32, t9, 25), - RABBITIZER_DEF_REG(GPR_N32, k0, 26), - RABBITIZER_DEF_REG(GPR_N32, k1, 27), - RABBITIZER_DEF_REG(GPR_N32, gp, 28), - RABBITIZER_DEF_REG(GPR_N32, sp, 29), - RABBITIZER_DEF_REG(GPR_N32, fp, 30), - RABBITIZER_DEF_REG(GPR_N32, ra, 31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_GprO32.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_GprO32.inc deleted file mode 100644 index 26685fe5..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_GprO32.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG(GPR_O32, zero, 0), - RABBITIZER_DEF_REG(GPR_O32, at, 1), - RABBITIZER_DEF_REG(GPR_O32, v0, 2), - RABBITIZER_DEF_REG(GPR_O32, v1, 3), - RABBITIZER_DEF_REG(GPR_O32, a0, 4), - RABBITIZER_DEF_REG(GPR_O32, a1, 5), - RABBITIZER_DEF_REG(GPR_O32, a2, 6), - RABBITIZER_DEF_REG(GPR_O32, a3, 7), - RABBITIZER_DEF_REG(GPR_O32, t0, 8), - RABBITIZER_DEF_REG(GPR_O32, t1, 9), - RABBITIZER_DEF_REG(GPR_O32, t2, 10), - RABBITIZER_DEF_REG(GPR_O32, t3, 11), - RABBITIZER_DEF_REG(GPR_O32, t4, 12), - RABBITIZER_DEF_REG(GPR_O32, t5, 13), - RABBITIZER_DEF_REG(GPR_O32, t6, 14), - RABBITIZER_DEF_REG(GPR_O32, t7, 15), - RABBITIZER_DEF_REG(GPR_O32, s0, 16), - RABBITIZER_DEF_REG(GPR_O32, s1, 17), - RABBITIZER_DEF_REG(GPR_O32, s2, 18), - RABBITIZER_DEF_REG(GPR_O32, s3, 19), - RABBITIZER_DEF_REG(GPR_O32, s4, 20), - RABBITIZER_DEF_REG(GPR_O32, s5, 21), - RABBITIZER_DEF_REG(GPR_O32, s6, 22), - RABBITIZER_DEF_REG(GPR_O32, s7, 23), - RABBITIZER_DEF_REG(GPR_O32, t8, 24), - RABBITIZER_DEF_REG(GPR_O32, t9, 25), - RABBITIZER_DEF_REG(GPR_O32, k0, 26), - RABBITIZER_DEF_REG(GPR_O32, k1, 27), - RABBITIZER_DEF_REG(GPR_O32, gp, 28), - RABBITIZER_DEF_REG(GPR_O32, sp, 29), - RABBITIZER_DEF_REG(GPR_O32, fp, 30), - RABBITIZER_DEF_REG(GPR_O32, ra, 31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_R5900VF.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_R5900VF.inc deleted file mode 100644 index afb88dd5..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_R5900VF.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -RABBITIZER_DEF_REG(R5900_VF, vf0, 0), -RABBITIZER_DEF_REG(R5900_VF, vf1, 1), -RABBITIZER_DEF_REG(R5900_VF, vf2, 2), -RABBITIZER_DEF_REG(R5900_VF, vf3, 3), -RABBITIZER_DEF_REG(R5900_VF, vf4, 4), -RABBITIZER_DEF_REG(R5900_VF, vf5, 5), -RABBITIZER_DEF_REG(R5900_VF, vf6, 6), -RABBITIZER_DEF_REG(R5900_VF, vf7, 7), -RABBITIZER_DEF_REG(R5900_VF, vf8, 8), -RABBITIZER_DEF_REG(R5900_VF, vf9, 9), -RABBITIZER_DEF_REG(R5900_VF, vf10, 10), -RABBITIZER_DEF_REG(R5900_VF, vf11, 11), -RABBITIZER_DEF_REG(R5900_VF, vf12, 12), -RABBITIZER_DEF_REG(R5900_VF, vf13, 13), -RABBITIZER_DEF_REG(R5900_VF, vf14, 14), -RABBITIZER_DEF_REG(R5900_VF, vf15, 15), -RABBITIZER_DEF_REG(R5900_VF, vf16, 16), -RABBITIZER_DEF_REG(R5900_VF, vf17, 17), -RABBITIZER_DEF_REG(R5900_VF, vf18, 18), -RABBITIZER_DEF_REG(R5900_VF, vf19, 19), -RABBITIZER_DEF_REG(R5900_VF, vf20, 20), -RABBITIZER_DEF_REG(R5900_VF, vf21, 21), -RABBITIZER_DEF_REG(R5900_VF, vf22, 22), -RABBITIZER_DEF_REG(R5900_VF, vf23, 23), -RABBITIZER_DEF_REG(R5900_VF, vf24, 24), -RABBITIZER_DEF_REG(R5900_VF, vf25, 25), -RABBITIZER_DEF_REG(R5900_VF, vf26, 26), -RABBITIZER_DEF_REG(R5900_VF, vf27, 27), -RABBITIZER_DEF_REG(R5900_VF, vf28, 28), -RABBITIZER_DEF_REG(R5900_VF, vf29, 29), -RABBITIZER_DEF_REG(R5900_VF, vf30, 30), -RABBITIZER_DEF_REG(R5900_VF, vf31, 31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_R5900VI.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_R5900VI.inc deleted file mode 100644 index 3e8e9f82..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_R5900VI.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -RABBITIZER_DEF_REG(R5900_VI, vi0, 0), -RABBITIZER_DEF_REG(R5900_VI, vi1, 1), -RABBITIZER_DEF_REG(R5900_VI, vi2, 2), -RABBITIZER_DEF_REG(R5900_VI, vi3, 3), -RABBITIZER_DEF_REG(R5900_VI, vi4, 4), -RABBITIZER_DEF_REG(R5900_VI, vi5, 5), -RABBITIZER_DEF_REG(R5900_VI, vi6, 6), -RABBITIZER_DEF_REG(R5900_VI, vi7, 7), -RABBITIZER_DEF_REG(R5900_VI, vi8, 8), -RABBITIZER_DEF_REG(R5900_VI, vi9, 9), -RABBITIZER_DEF_REG(R5900_VI, vi10, 10), -RABBITIZER_DEF_REG(R5900_VI, vi11, 11), -RABBITIZER_DEF_REG(R5900_VI, vi12, 12), -RABBITIZER_DEF_REG(R5900_VI, vi13, 13), -RABBITIZER_DEF_REG(R5900_VI, vi14, 14), -RABBITIZER_DEF_REG(R5900_VI, vi15, 15), -RABBITIZER_DEF_REG(R5900_VI, vi16, 16), -RABBITIZER_DEF_REG(R5900_VI, vi17, 17), -RABBITIZER_DEF_REG(R5900_VI, vi18, 18), -RABBITIZER_DEF_REG(R5900_VI, vi19, 19), -RABBITIZER_DEF_REG(R5900_VI, vi20, 20), -RABBITIZER_DEF_REG(R5900_VI, vi21, 21), -RABBITIZER_DEF_REG(R5900_VI, vi22, 22), -RABBITIZER_DEF_REG(R5900_VI, vi23, 23), -RABBITIZER_DEF_REG(R5900_VI, vi24, 24), -RABBITIZER_DEF_REG(R5900_VI, vi25, 25), -RABBITIZER_DEF_REG(R5900_VI, vi26, 26), -RABBITIZER_DEF_REG(R5900_VI, vi27, 27), -RABBITIZER_DEF_REG(R5900_VI, vi28, 28), -RABBITIZER_DEF_REG(R5900_VI, vi29, 29), -RABBITIZER_DEF_REG(R5900_VI, vi30, 30), -RABBITIZER_DEF_REG(R5900_VI, vi31, 31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspCop0.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspCop0.inc deleted file mode 100644 index fdac94d1..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspCop0.inc +++ /dev/null @@ -1,19 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_MEM_ADDR, 0), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_DRAM_ADDR, 1), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_RD_LEN, 2), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_WR_LEN, 3), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_STATUS, 4), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_DMA_FULL, 5), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_DMA_BUSY, 6), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, SP_SEMAPHORE, 7), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_START, 8), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_END, 9), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_CURRENT, 10), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_STATUS, 11), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_CLOCK, 12), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_BUFBUSY, 13), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_PIPEBUSY, 14), - RABBITIZER_DEF_REG_NODOLLAR(RSP_COP0, DPC_TMEM, 15), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspCop2.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspCop2.inc deleted file mode 100644 index d22b673f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspCop2.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG(RSP_COP2, 0, 0), - RABBITIZER_DEF_REG(RSP_COP2, 1, 1), - RABBITIZER_DEF_REG(RSP_COP2, 2, 2), - RABBITIZER_DEF_REG(RSP_COP2, 3, 3), - RABBITIZER_DEF_REG(RSP_COP2, 4, 4), - RABBITIZER_DEF_REG(RSP_COP2, 5, 5), - RABBITIZER_DEF_REG(RSP_COP2, 6, 6), - RABBITIZER_DEF_REG(RSP_COP2, 7, 7), - RABBITIZER_DEF_REG(RSP_COP2, 8, 8), - RABBITIZER_DEF_REG(RSP_COP2, 9, 9), - RABBITIZER_DEF_REG(RSP_COP2, 10, 10), - RABBITIZER_DEF_REG(RSP_COP2, 11, 11), - RABBITIZER_DEF_REG(RSP_COP2, 12, 12), - RABBITIZER_DEF_REG(RSP_COP2, 13, 13), - RABBITIZER_DEF_REG(RSP_COP2, 14, 14), - RABBITIZER_DEF_REG(RSP_COP2, 15, 15), - RABBITIZER_DEF_REG(RSP_COP2, 16, 16), - RABBITIZER_DEF_REG(RSP_COP2, 17, 17), - RABBITIZER_DEF_REG(RSP_COP2, 18, 18), - RABBITIZER_DEF_REG(RSP_COP2, 19, 19), - RABBITIZER_DEF_REG(RSP_COP2, 20, 20), - RABBITIZER_DEF_REG(RSP_COP2, 21, 21), - RABBITIZER_DEF_REG(RSP_COP2, 22, 22), - RABBITIZER_DEF_REG(RSP_COP2, 23, 23), - RABBITIZER_DEF_REG(RSP_COP2, 24, 24), - RABBITIZER_DEF_REG(RSP_COP2, 25, 25), - RABBITIZER_DEF_REG(RSP_COP2, 26, 26), - RABBITIZER_DEF_REG(RSP_COP2, 27, 27), - RABBITIZER_DEF_REG(RSP_COP2, 28, 28), - RABBITIZER_DEF_REG(RSP_COP2, 29, 29), - RABBITIZER_DEF_REG(RSP_COP2, 30, 30), - RABBITIZER_DEF_REG(RSP_COP2, 31, 31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspCop2Control.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspCop2Control.inc deleted file mode 100644 index 0f730f31..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspCop2Control.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 0, 0), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 1, 1), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 2, 2), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 3, 3), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 4, 4), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 5, 5), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 6, 6), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 7, 7), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 8, 8), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 9, 9), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 10, 10), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 11, 11), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 12, 12), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 13, 13), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 14, 14), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 15, 15), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 16, 16), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 17, 17), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 18, 18), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 19, 19), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 20, 20), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 21, 21), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 22, 22), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 23, 23), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 24, 24), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 25, 25), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 26, 26), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 27, 27), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 28, 28), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 29, 29), - RABBITIZER_DEF_REG(RSP_COP2_CONTROL, 30, 30), - RABBITIZER_DEF_REG(COP1_CONTROL, 31, 31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspGpr.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspGpr.inc deleted file mode 100644 index 490926cd..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspGpr.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG(RSP_GPR, zero, 0), - RABBITIZER_DEF_REG(RSP_GPR, 1, 1), - RABBITIZER_DEF_REG(RSP_GPR, 2, 2), - RABBITIZER_DEF_REG(RSP_GPR, 3, 3), - RABBITIZER_DEF_REG(RSP_GPR, 4, 4), - RABBITIZER_DEF_REG(RSP_GPR, 5, 5), - RABBITIZER_DEF_REG(RSP_GPR, 6, 6), - RABBITIZER_DEF_REG(RSP_GPR, 7, 7), - RABBITIZER_DEF_REG(RSP_GPR, 8, 8), - RABBITIZER_DEF_REG(RSP_GPR, 9, 9), - RABBITIZER_DEF_REG(RSP_GPR, 10, 10), - RABBITIZER_DEF_REG(RSP_GPR, 11, 11), - RABBITIZER_DEF_REG(RSP_GPR, 12, 12), - RABBITIZER_DEF_REG(RSP_GPR, 13, 13), - RABBITIZER_DEF_REG(RSP_GPR, 14, 14), - RABBITIZER_DEF_REG(RSP_GPR, 15, 15), - RABBITIZER_DEF_REG(RSP_GPR, 16, 16), - RABBITIZER_DEF_REG(RSP_GPR, 17, 17), - RABBITIZER_DEF_REG(RSP_GPR, 18, 18), - RABBITIZER_DEF_REG(RSP_GPR, 19, 19), - RABBITIZER_DEF_REG(RSP_GPR, 20, 20), - RABBITIZER_DEF_REG(RSP_GPR, 21, 21), - RABBITIZER_DEF_REG(RSP_GPR, 22, 22), - RABBITIZER_DEF_REG(RSP_GPR, 23, 23), - RABBITIZER_DEF_REG(RSP_GPR, 24, 24), - RABBITIZER_DEF_REG(RSP_GPR, 25, 25), - RABBITIZER_DEF_REG(RSP_GPR, 26, 26), - RABBITIZER_DEF_REG(RSP_GPR, 27, 27), - RABBITIZER_DEF_REG(RSP_GPR, 28, 28), - RABBITIZER_DEF_REG(RSP_GPR, 29, 29), - RABBITIZER_DEF_REG(RSP_GPR, 30, 30), - RABBITIZER_DEF_REG(RSP_GPR, ra, 31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspVector.inc b/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspVector.inc deleted file mode 100644 index c2676d91..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/instructions/registers/RabbitizerRegister_RspVector.inc +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - - RABBITIZER_DEF_REG(RSP_VECTOR, v0, 0), - RABBITIZER_DEF_REG(RSP_VECTOR, v1, 1), - RABBITIZER_DEF_REG(RSP_VECTOR, v2, 2), - RABBITIZER_DEF_REG(RSP_VECTOR, v3, 3), - RABBITIZER_DEF_REG(RSP_VECTOR, v4, 4), - RABBITIZER_DEF_REG(RSP_VECTOR, v5, 5), - RABBITIZER_DEF_REG(RSP_VECTOR, v6, 6), - RABBITIZER_DEF_REG(RSP_VECTOR, v7, 7), - RABBITIZER_DEF_REG(RSP_VECTOR, v8, 8), - RABBITIZER_DEF_REG(RSP_VECTOR, v9, 9), - RABBITIZER_DEF_REG(RSP_VECTOR, v10, 10), - RABBITIZER_DEF_REG(RSP_VECTOR, v11, 11), - RABBITIZER_DEF_REG(RSP_VECTOR, v12, 12), - RABBITIZER_DEF_REG(RSP_VECTOR, v13, 13), - RABBITIZER_DEF_REG(RSP_VECTOR, v14, 14), - RABBITIZER_DEF_REG(RSP_VECTOR, v15, 15), - RABBITIZER_DEF_REG(RSP_VECTOR, v16, 16), - RABBITIZER_DEF_REG(RSP_VECTOR, v17, 17), - RABBITIZER_DEF_REG(RSP_VECTOR, v18, 18), - RABBITIZER_DEF_REG(RSP_VECTOR, v19, 19), - RABBITIZER_DEF_REG(RSP_VECTOR, v20, 20), - RABBITIZER_DEF_REG(RSP_VECTOR, v21, 21), - RABBITIZER_DEF_REG(RSP_VECTOR, v22, 22), - RABBITIZER_DEF_REG(RSP_VECTOR, v23, 23), - RABBITIZER_DEF_REG(RSP_VECTOR, v24, 24), - RABBITIZER_DEF_REG(RSP_VECTOR, v25, 25), - RABBITIZER_DEF_REG(RSP_VECTOR, v26, 26), - RABBITIZER_DEF_REG(RSP_VECTOR, v27, 27), - RABBITIZER_DEF_REG(RSP_VECTOR, v28, 28), - RABBITIZER_DEF_REG(RSP_VECTOR, v29, 29), - RABBITIZER_DEF_REG(RSP_VECTOR, v30, 30), - RABBITIZER_DEF_REG(RSP_VECTOR, v31, 31), diff --git a/tools/ido-static-recomp/tools/rabbitizer/include/rabbitizer.h b/tools/ido-static-recomp/tools/rabbitizer/include/rabbitizer.h deleted file mode 100644 index 5bae2d58..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/include/rabbitizer.h +++ /dev/null @@ -1,25 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_H -#define RABBITIZER_H -#pragma once - -#include "common/Utils.h" -#include "common/RabbitizerVersion.h" -#include "common/RabbitizerConfig.h" - -#include "instructions/RabbitizerOperandType.h" -#include "instructions/RabbitizerInstrId.h" -#include "instructions/RabbitizerInstrSuffix.h" -#include "instructions/RabbitizerInstrDescriptor.h" -#include "instructions/RabbitizerRegister.h" -#include "instructions/RabbitizerInstruction.h" -#include "instructions/RabbitizerInstructionRsp.h" -#include "instructions/RabbitizerInstructionR5900.h" - -#include "analysis/RabbitizerTrackedRegisterState.h" -#include "analysis/RabbitizerLoPairingInfo.h" -#include "analysis/RabbitizerRegistersTracker.h" - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/pyproject.toml b/tools/ido-static-recomp/tools/rabbitizer/pyproject.toml deleted file mode 100644 index 35a5cb29..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/pyproject.toml +++ /dev/null @@ -1,9 +0,0 @@ -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -[build-system] -requires = ["setuptools>=61.0", "wheel"] -build-backend = "setuptools.build_meta" - -[tool.cibuildwheel] -skip = ["cp36-*"] diff --git a/tools/ido-static-recomp/tools/rabbitizer/r5900test.c b/tools/ido-static-recomp/tools/rabbitizer/r5900test.c deleted file mode 100644 index bc83f4db..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/r5900test.c +++ /dev/null @@ -1,47 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstructionR5900.h" - -#include -#include -#include -#include - - -int main() { - uint32_t word; - RabbitizerInstruction instr; - char *buffer; - int extraLJust = 5; -#if 1 - uint32_t validbits; -#endif - - word = 0x4BE1634B; - - RabbitizerInstructionR5900_init(&instr, word, 0x00100000); - - RabbitizerInstructionR5900_processUniqueId(&instr); - - buffer = malloc(RabbitizerInstruction_getSizeForBuffer(&instr, 0, extraLJust) + 1); - assert(buffer != NULL); - - RabbitizerInstruction_disassemble(&instr, buffer, NULL, 0, extraLJust); - - printf("%08X: %s\n", word, buffer); - -#if 1 - validbits = RabbitizerInstruction_getValidBits(&instr); - - printf("word: %08X\n", instr.word); - printf("mandatory bits: %08X\n", instr._mandatorybits); - printf("valid bits: %08X\n", validbits); - printf("invalid bits: %08X\n", (~validbits) & instr.word); -#endif - - free(buffer); - RabbitizerInstructionR5900_destroy(&instr); - - return 0; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/Config.pyi b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/Config.pyi deleted file mode 100644 index c639b4f1..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/Config.pyi +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from __future__ import annotations - -from .Enum import Enum - - -class Abi: - NUMERIC: Enum - O32: Enum - N32: Enum - N64: Enum - - @staticmethod - def fromStr(name: str | None) -> Enum: ... - - -class _RabbitizerConfig: - regNames_namedRegisters: bool = True - regNames_gprAbiNames: Enum = Abi.O32 - regNames_fprAbiNames: Enum = Abi.NUMERIC - regNames_userFpcCsr: bool = True - regNames_vr4300Cop0NamedRegisters: bool = True - regNames_vr4300RspCop0NamedRegisters: bool = True - - pseudos_enablePseudos: bool = True - pseudos_pseudoBeqz: bool = True - pseudos_pseudoBnez: bool = True - pseudos_pseudoB: bool = True - pseudos_pseudoMove: bool = True - pseudos_pseudoNot: bool = True - pseudos_pseudoNegu: bool = True - pseudos_pseudoBal: bool = True - - toolchainTweaks_sn64DivFix: bool = False - toolchainTweaks_treatJAsUnconditionalBranch: bool = False - - misc_opcodeLJust: int = 11 - misc_unknownInstrComment: bool = True - misc_omit0XOnSmallImm: bool = False - misc_upperCaseImm: bool = True - -config: _RabbitizerConfig diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/Enum.pyi b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/Enum.pyi deleted file mode 100644 index afa18969..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/Enum.pyi +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from __future__ import annotations - - -class Enum: - name: str - value: int - - def __init__(self, enumType: str, name: str, value: int) -> None: ... - - def __reduce__(self) -> tuple: ... - - def __lt__(self, __o: object) -> bool: ... - def __le__(self, __o: object) -> bool: ... - def __eq__(self, __o: object) -> bool: ... - def __gt__(self, __o: object) -> bool: ... - def __ge__(self, __o: object) -> bool: ... - - def __repr__(self) -> str: ... - def __str__(self) -> str: ... diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/InstrCategory.pyi b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/InstrCategory.pyi deleted file mode 100644 index 7d4b7e56..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/InstrCategory.pyi +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from __future__ import annotations - -from .Enum import Enum - - -class InstrCategory: - CPU: Enum - RSP: Enum - R5900: Enum - MAX: Enum diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/InstrId.pyi b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/InstrId.pyi deleted file mode 100644 index 87e87bf3..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/InstrId.pyi +++ /dev/null @@ -1,631 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from __future__ import annotations - -from .Enum import Enum - - -class InstrId: - cpu_INVALID: Enum - cpu_mthi: Enum - cpu_mtlo: Enum - cpu_jr: Enum - cpu_jalr: Enum - cpu_jalr_rd: Enum - cpu_mfhi: Enum - cpu_mflo: Enum - cpu_mult: Enum - cpu_multu: Enum - cpu_dmult: Enum - cpu_dmultu: Enum - cpu_tge: Enum - cpu_tgeu: Enum - cpu_tlt: Enum - cpu_tltu: Enum - cpu_teq: Enum - cpu_tne: Enum - cpu_movz: Enum - cpu_movn: Enum - cpu_div: Enum - cpu_divu: Enum - cpu_sn64_div: Enum - cpu_sn64_divu: Enum - cpu_ddiv: Enum - cpu_ddivu: Enum - cpu_add: Enum - cpu_addu: Enum - cpu_sub: Enum - cpu_subu: Enum - cpu_and: Enum - cpu_or: Enum - cpu_xor: Enum - cpu_nor: Enum - cpu_slt: Enum - cpu_sltu: Enum - cpu_dadd: Enum - cpu_daddu: Enum - cpu_dsub: Enum - cpu_dsubu: Enum - cpu_syscall: Enum - cpu_break: Enum - cpu_sync: Enum - cpu_dsllv: Enum - cpu_dsrlv: Enum - cpu_dsrav: Enum - cpu_sllv: Enum - cpu_srlv: Enum - cpu_srav: Enum - cpu_sll: Enum - cpu_srl: Enum - cpu_sra: Enum - cpu_dsll: Enum - cpu_dsrl: Enum - cpu_dsra: Enum - cpu_dsll32: Enum - cpu_dsrl32: Enum - cpu_dsra32: Enum - cpu_bltz: Enum - cpu_bgez: Enum - cpu_bltzl: Enum - cpu_bgezl: Enum - cpu_tgei: Enum - cpu_tgeiu: Enum - cpu_tlti: Enum - cpu_tltiu: Enum - cpu_bltzal: Enum - cpu_bgezal: Enum - cpu_bltzall: Enum - cpu_bgezall: Enum - cpu_bal: Enum - cpu_teqi: Enum - cpu_tnei: Enum - cpu_j: Enum - cpu_jal: Enum - cpu_beq: Enum - cpu_bne: Enum - cpu_beql: Enum - cpu_bnel: Enum - cpu_blez: Enum - cpu_bgtz: Enum - cpu_blezl: Enum - cpu_bgtzl: Enum - cpu_lui: Enum - cpu_andi: Enum - cpu_ori: Enum - cpu_xori: Enum - cpu_addi: Enum - cpu_addiu: Enum - cpu_daddi: Enum - cpu_daddiu: Enum - cpu_slti: Enum - cpu_sltiu: Enum - cpu_ldl: Enum - cpu_ldr: Enum - cpu_lb: Enum - cpu_lh: Enum - cpu_lwl: Enum - cpu_lw: Enum - cpu_lbu: Enum - cpu_lhu: Enum - cpu_lwr: Enum - cpu_lwu: Enum - cpu_sb: Enum - cpu_sh: Enum - cpu_swl: Enum - cpu_sw: Enum - cpu_sdl: Enum - cpu_sdr: Enum - cpu_swr: Enum - cpu_ll: Enum - cpu_pref: Enum - cpu_lld: Enum - cpu_ld: Enum - cpu_sc: Enum - cpu_scd: Enum - cpu_sd: Enum - cpu_lwc1: Enum - cpu_ldc1: Enum - cpu_swc1: Enum - cpu_sdc1: Enum - cpu_lwc2: Enum - cpu_ldc2: Enum - cpu_swc2: Enum - cpu_sdc2: Enum - cpu_mfc0: Enum - cpu_dmfc0: Enum - cpu_cfc0: Enum - cpu_mtc0: Enum - cpu_dmtc0: Enum - cpu_ctc0: Enum - cpu_tlbr: Enum - cpu_tlbwi: Enum - cpu_tlbwr: Enum - cpu_tlbp: Enum - cpu_eret: Enum - cpu_bc0t: Enum - cpu_bc0f: Enum - cpu_bc0tl: Enum - cpu_bc0fl: Enum - cpu_mfc1: Enum - cpu_dmfc1: Enum - cpu_mtc1: Enum - cpu_dmtc1: Enum - cpu_cfc1: Enum - cpu_ctc1: Enum - cpu_bc1f: Enum - cpu_bc1t: Enum - cpu_bc1fl: Enum - cpu_bc1tl: Enum - cpu_add_s: Enum - cpu_sub_s: Enum - cpu_mul_s: Enum - cpu_div_s: Enum - cpu_add_d: Enum - cpu_sub_d: Enum - cpu_mul_d: Enum - cpu_div_d: Enum - cpu_sqrt_s: Enum - cpu_abs_s: Enum - cpu_mov_s: Enum - cpu_neg_s: Enum - cpu_sqrt_d: Enum - cpu_abs_d: Enum - cpu_mov_d: Enum - cpu_neg_d: Enum - cpu_round_l_s: Enum - cpu_trunc_l_s: Enum - cpu_ceil_l_s: Enum - cpu_floor_l_s: Enum - cpu_round_l_d: Enum - cpu_trunc_l_d: Enum - cpu_ceil_l_d: Enum - cpu_floor_l_d: Enum - cpu_round_w_s: Enum - cpu_trunc_w_s: Enum - cpu_ceil_w_s: Enum - cpu_floor_w_s: Enum - cpu_round_w_d: Enum - cpu_trunc_w_d: Enum - cpu_ceil_w_d: Enum - cpu_floor_w_d: Enum - cpu_c_f_s: Enum - cpu_c_un_s: Enum - cpu_c_eq_s: Enum - cpu_c_ueq_s: Enum - cpu_c_olt_s: Enum - cpu_c_ult_s: Enum - cpu_c_ole_s: Enum - cpu_c_ule_s: Enum - cpu_c_f_d: Enum - cpu_c_un_d: Enum - cpu_c_eq_d: Enum - cpu_c_ueq_d: Enum - cpu_c_olt_d: Enum - cpu_c_ult_d: Enum - cpu_c_ole_d: Enum - cpu_c_ule_d: Enum - cpu_c_sf_s: Enum - cpu_c_ngle_s: Enum - cpu_c_seq_s: Enum - cpu_c_ngl_s: Enum - cpu_c_lt_s: Enum - cpu_c_nge_s: Enum - cpu_c_le_s: Enum - cpu_c_ngt_s: Enum - cpu_c_sf_d: Enum - cpu_c_ngle_d: Enum - cpu_c_seq_d: Enum - cpu_c_ngl_d: Enum - cpu_c_lt_d: Enum - cpu_c_nge_d: Enum - cpu_c_le_d: Enum - cpu_c_ngt_d: Enum - cpu_cvt_s_d: Enum - cpu_cvt_s_w: Enum - cpu_cvt_s_l: Enum - cpu_cvt_d_s: Enum - cpu_cvt_d_w: Enum - cpu_cvt_d_l: Enum - cpu_cvt_w_s: Enum - cpu_cvt_w_d: Enum - cpu_cvt_l_s: Enum - cpu_cvt_l_d: Enum - cpu_nop: Enum - cpu_beqz: Enum - cpu_bnez: Enum - cpu_b: Enum - cpu_move: Enum - cpu_not: Enum - cpu_negu: Enum - cpu_MAX: Enum - - rsp_INVALID: Enum - rsp_vmulf: Enum - rsp_vmulu: Enum - rsp_vrndp: Enum - rsp_vmulq: Enum - rsp_vmudl: Enum - rsp_vmudm: Enum - rsp_vmudn: Enum - rsp_vmudh: Enum - rsp_vmacf: Enum - rsp_vmacu: Enum - rsp_vrndn: Enum - rsp_vmacq: Enum - rsp_vmadl: Enum - rsp_vmadm: Enum - rsp_vmadn: Enum - rsp_vmadh: Enum - rsp_vadd: Enum - rsp_vsub: Enum - rsp_vabs: Enum - rsp_vaddc: Enum - rsp_vsubc: Enum - rsp_vsar: Enum - rsp_vand: Enum - rsp_vnand: Enum - rsp_vor: Enum - rsp_vnor: Enum - rsp_vxor: Enum - rsp_vnxor: Enum - rsp_vlt: Enum - rsp_veq: Enum - rsp_vne: Enum - rsp_vge: Enum - rsp_vcl: Enum - rsp_vch: Enum - rsp_vcr: Enum - rsp_vmrg: Enum - rsp_vrcp: Enum - rsp_vrcpl: Enum - rsp_vrcph: Enum - rsp_vmov: Enum - rsp_vrsq: Enum - rsp_vrsql: Enum - rsp_vrsqh: Enum - rsp_vnop: Enum - rsp_mfc2: Enum - rsp_mtc2: Enum - rsp_cfc2: Enum - rsp_ctc2: Enum - rsp_sbv: Enum - rsp_ssv: Enum - rsp_slv: Enum - rsp_sdv: Enum - rsp_sqv: Enum - rsp_srv: Enum - rsp_spv: Enum - rsp_suv: Enum - rsp_swv: Enum - rsp_shv: Enum - rsp_sfv: Enum - rsp_stv: Enum - rsp_lbv: Enum - rsp_lsv: Enum - rsp_llv: Enum - rsp_ldv: Enum - rsp_lqv: Enum - rsp_lrv: Enum - rsp_lpv: Enum - rsp_luv: Enum - rsp_lhv: Enum - rsp_lfv: Enum - rsp_ltv: Enum - rsp_jr: Enum - rsp_jalr: Enum - rsp_jalr_rd: Enum - rsp_movz: Enum - rsp_movn: Enum - rsp_add: Enum - rsp_addu: Enum - rsp_sub: Enum - rsp_subu: Enum - rsp_and: Enum - rsp_or: Enum - rsp_xor: Enum - rsp_nor: Enum - rsp_slt: Enum - rsp_sltu: Enum - rsp_break: Enum - rsp_sllv: Enum - rsp_srlv: Enum - rsp_srav: Enum - rsp_sll: Enum - rsp_srl: Enum - rsp_sra: Enum - rsp_bltz: Enum - rsp_bgez: Enum - rsp_bltzal: Enum - rsp_bgezal: Enum - rsp_bal: Enum - rsp_j: Enum - rsp_jal: Enum - rsp_beq: Enum - rsp_bne: Enum - rsp_blez: Enum - rsp_bgtz: Enum - rsp_lui: Enum - rsp_andi: Enum - rsp_ori: Enum - rsp_xori: Enum - rsp_addi: Enum - rsp_addiu: Enum - rsp_slti: Enum - rsp_sltiu: Enum - rsp_lb: Enum - rsp_lh: Enum - rsp_lw: Enum - rsp_lbu: Enum - rsp_lhu: Enum - rsp_sb: Enum - rsp_sh: Enum - rsp_sw: Enum - rsp_pref: Enum - rsp_lwc1: Enum - rsp_swc1: Enum - rsp_mfc0: Enum - rsp_mtc0: Enum - rsp_nop: Enum - rsp_beqz: Enum - rsp_bnez: Enum - rsp_b: Enum - rsp_move: Enum - rsp_not: Enum - rsp_negu: Enum - rsp_MAX: Enum - - r5900_INVALID: Enum - r5900_lq: Enum - r5900_sq: Enum - r5900_lqc2: Enum - r5900_sqc2: Enum - r5900_sync_p: Enum - r5900_mfsa: Enum - r5900_mtsa: Enum - r5900_mtsab: Enum - r5900_mtsah: Enum - r5900_madd: Enum - r5900_maddu: Enum - r5900_plzcw: Enum - r5900_mfhi1: Enum - r5900_mthi1: Enum - r5900_mflo1: Enum - r5900_mtlo1: Enum - r5900_mult1: Enum - r5900_multu1: Enum - r5900_div1: Enum - r5900_divu1: Enum - r5900_madd1: Enum - r5900_maddu1: Enum - r5900_pmfhl: Enum - r5900_pmthl: Enum - r5900_psllh: Enum - r5900_psrlh: Enum - r5900_psrah: Enum - r5900_psllw: Enum - r5900_psrlw: Enum - r5900_psraw: Enum - r5900_paddw: Enum - r5900_psubw: Enum - r5900_pcgtw: Enum - r5900_pmaxw: Enum - r5900_paddh: Enum - r5900_psubh: Enum - r5900_pcgth: Enum - r5900_pmaxh: Enum - r5900_paddb: Enum - r5900_psubb: Enum - r5900_pcgtb: Enum - r5900_paddsw: Enum - r5900_psubsw: Enum - r5900_pextlw: Enum - r5900_ppacw: Enum - r5900_paddsh: Enum - r5900_psubsh: Enum - r5900_pextlh: Enum - r5900_ppach: Enum - r5900_paddsb: Enum - r5900_psubsb: Enum - r5900_pextlb: Enum - r5900_ppacb: Enum - r5900_pext5: Enum - r5900_ppac5: Enum - r5900_pabsw: Enum - r5900_pceqw: Enum - r5900_pminw: Enum - r5900_padsbh: Enum - r5900_pabsh: Enum - r5900_pceqh: Enum - r5900_pminh: Enum - r5900_pceqb: Enum - r5900_padduw: Enum - r5900_psubuw: Enum - r5900_pextuw: Enum - r5900_padduh: Enum - r5900_psubuh: Enum - r5900_pextuh: Enum - r5900_paddub: Enum - r5900_psubub: Enum - r5900_pextub: Enum - r5900_qfsrv: Enum - r5900_pmaddw: Enum - r5900_psllvw: Enum - r5900_psrlvw: Enum - r5900_pmsubw: Enum - r5900_pmfhi: Enum - r5900_pmflo: Enum - r5900_pinth: Enum - r5900_pmultw: Enum - r5900_pdivw: Enum - r5900_pcpyld: Enum - r5900_pmaddh: Enum - r5900_phmadh: Enum - r5900_pand: Enum - r5900_pxor: Enum - r5900_pmsubh: Enum - r5900_phmsbh: Enum - r5900_pexeh: Enum - r5900_prevh: Enum - r5900_pmulth: Enum - r5900_pdivbw: Enum - r5900_pexew: Enum - r5900_prot3w: Enum - r5900_pmadduw: Enum - r5900_psravw: Enum - r5900_pmthi: Enum - r5900_pmtlo: Enum - r5900_pinteh: Enum - r5900_pmultuw: Enum - r5900_pdivuw: Enum - r5900_pcpyud: Enum - r5900_por: Enum - r5900_pnor: Enum - r5900_pexch: Enum - r5900_pcpyh: Enum - r5900_pexcw: Enum - r5900_ei: Enum - r5900_di: Enum - r5900_rsqrt_s: Enum - r5900_adda_s: Enum - r5900_suba_s: Enum - r5900_mula_s: Enum - r5900_madd_s: Enum - r5900_msub_s: Enum - r5900_madda_s: Enum - r5900_msuba_s: Enum - r5900_max_s: Enum - r5900_min_s: Enum - r5900_qmfc2: Enum - r5900_cfc2: Enum - r5900_qmtc2: Enum - r5900_ctc2: Enum - r5900_bc2f: Enum - r5900_bc2t: Enum - r5900_bc2fl: Enum - r5900_bc2tl: Enum - r5900_vaddx: Enum - r5900_vaddy: Enum - r5900_vaddz: Enum - r5900_vaddw: Enum - r5900_vsubx: Enum - r5900_vsuby: Enum - r5900_vsubz: Enum - r5900_vsubw: Enum - r5900_vmaddx: Enum - r5900_vmaddy: Enum - r5900_vmaddz: Enum - r5900_vmaddw: Enum - r5900_vmsubx: Enum - r5900_vmsuby: Enum - r5900_vmsubz: Enum - r5900_vmsubw: Enum - r5900_vmaxx: Enum - r5900_vmaxy: Enum - r5900_vmaxz: Enum - r5900_vmaxw: Enum - r5900_vminix: Enum - r5900_vminiy: Enum - r5900_vminiz: Enum - r5900_vminiw: Enum - r5900_vmulx: Enum - r5900_vmuly: Enum - r5900_vmulz: Enum - r5900_vmulw: Enum - r5900_vmulq: Enum - r5900_vmaxi: Enum - r5900_vmuli: Enum - r5900_vminii: Enum - r5900_vaddq: Enum - r5900_vmaddq: Enum - r5900_vaddi: Enum - r5900_vmaddi: Enum - r5900_vsubq: Enum - r5900_vmsubq: Enum - r5900_vsubi: Enum - r5900_vmsubi: Enum - r5900_vadd: Enum - r5900_vmadd: Enum - r5900_vmul: Enum - r5900_vmax: Enum - r5900_vsub: Enum - r5900_vmsub: Enum - r5900_vopmsub: Enum - r5900_vmini: Enum - r5900_viadd: Enum - r5900_visub: Enum - r5900_viaddi: Enum - r5900_viand: Enum - r5900_vior: Enum - r5900_vcallms: Enum - r5900_callmsr: Enum - r5900_vaddax: Enum - r5900_vadday: Enum - r5900_vaddaz: Enum - r5900_vaddaw: Enum - r5900_vsubax: Enum - r5900_vsubay: Enum - r5900_vsubaz: Enum - r5900_vsubaw: Enum - r5900_vvmaddx: Enum - r5900_vvmaddy: Enum - r5900_vvmaddz: Enum - r5900_vvmaddw: Enum - r5900_vmsubax: Enum - r5900_vmsubay: Enum - r5900_vmsubaz: Enum - r5900_vmsubaw: Enum - r5900_vitof0: Enum - r5900_vitof4: Enum - r5900_vitof12: Enum - r5900_vitof15: Enum - r5900_vftoi0: Enum - r5900_vftoi4: Enum - r5900_vftoi12: Enum - r5900_vftoi15: Enum - r5900_vmulax: Enum - r5900_vmulay: Enum - r5900_vmulaz: Enum - r5900_vmulaw: Enum - r5900_vmulaq: Enum - r5900_vabs: Enum - r5900_vmulai: Enum - r5900_vclipw: Enum - r5900_vaddaq: Enum - r5900_vmaddaq: Enum - r5900_vaddai: Enum - r5900_vmaddai: Enum - r5900_vsubaq: Enum - r5900_vmsubaq: Enum - r5900_vsubai: Enum - r5900_vmsubai: Enum - r5900_vadda: Enum - r5900_vmadda: Enum - r5900_vmula: Enum - r5900_vsuba: Enum - r5900_vmsuba: Enum - r5900_vopmula: Enum - r5900_vnop: Enum - r5900_vmove: Enum - r5900_vmr32: Enum - r5900_vlqi: Enum - r5900_vsqi: Enum - r5900_vlqd: Enum - r5900_vsqd: Enum - r5900_vdiv: Enum - r5900_vsqrt: Enum - r5900_vrsqrt: Enum - r5900_vwaitq: Enum - r5900_vmtir: Enum - r5900_vmfir: Enum - r5900_vilwr: Enum - r5900_viswr: Enum - r5900_vrnext: Enum - r5900_vrget: Enum - r5900_vrinit: Enum - r5900_vrxor: Enum - r5900_MAX: Enum - - ALL_MAX: Enum diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/LoPairingInfo.pyi b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/LoPairingInfo.pyi deleted file mode 100644 index 70e2a1b7..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/LoPairingInfo.pyi +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from __future__ import annotations - - -class LoPairingInfo: - instrOffset: int - value: int - shouldProcess: bool - isGpRel: bool - isGpGot: bool - - def __init__(self): ... diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/RegGprN32.pyi b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/RegGprN32.pyi deleted file mode 100644 index 54443526..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/RegGprN32.pyi +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from __future__ import annotations - -from .Enum import Enum - - -class RegGprN32: - zero: Enum - at: Enum - v0: Enum - v1: Enum - a0: Enum - a1: Enum - a2: Enum - a3: Enum - a4: Enum - a5: Enum - a6: Enum - a7: Enum - t0: Enum - t1: Enum - t2: Enum - t3: Enum - s0: Enum - s1: Enum - s2: Enum - s3: Enum - s4: Enum - s5: Enum - s6: Enum - s7: Enum - t8: Enum - t9: Enum - k0: Enum - k1: Enum - gp: Enum - sp: Enum - fp: Enum - ra: Enum diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/RegGprO32.pyi b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/RegGprO32.pyi deleted file mode 100644 index f145ca3d..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/RegGprO32.pyi +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from __future__ import annotations - -from .Enum import Enum - - -class RegGprO32: - zero: Enum - at: Enum - v0: Enum - v1: Enum - a0: Enum - a1: Enum - a2: Enum - a3: Enum - t0: Enum - t1: Enum - t2: Enum - t3: Enum - t4: Enum - t5: Enum - t6: Enum - t7: Enum - s0: Enum - s1: Enum - s2: Enum - s3: Enum - s4: Enum - s5: Enum - s6: Enum - s7: Enum - t8: Enum - t9: Enum - k0: Enum - k1: Enum - gp: Enum - sp: Enum - fp: Enum - ra: Enum diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/RegistersTracker.pyi b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/RegistersTracker.pyi deleted file mode 100644 index 967ba493..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/RegistersTracker.pyi +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from __future__ import annotations - -from .rabbitizer import Instruction -from .LoPairingInfo import LoPairingInfo - - -class RegistersTracker: - def __init__(self, other: RegistersTracker|None=None): ... - - def moveRegisters(self, instr: Instruction) -> bool: ... - def overwriteRegisters(self, instr: Instruction, instructionOffset: int) -> None: ... - def unsetRegistersAfterFuncCall(self, instr: Instruction, prevInstr: Instruction) -> None: ... - def getAddressIfCanSetType(self, instr: Instruction, instrOffset: int) -> int|None: ... - def getJrInfo(self, instr: Instruction) -> tuple[int, int]|None: ... - - def processLui(self, instr: Instruction, instrOffset: int, prevInstr: Instruction|None=None) -> None: ... - def processGpLoad(self, instr: Instruction, instrOffset: int) -> None: ... - def getLuiOffsetForConstant(self, instr: Instruction) -> int|None: ... - def processConstant(self, instr: Instruction, value: int, offset: int) -> None: ... - def getLuiOffsetForLo(self, instr: Instruction, instrOffset: int) -> tuple[int, bool, bool]: ... #! deprecated - def preprocessLoAndGetInfo(self, instr: Instruction, instrOffset: int) -> LoPairingInfo: ... - def processLo(self, instr: Instruction, value: int, offset: int) -> None: ... - def hasLoButNoHi(self, instr: Instruction) -> bool: ... diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/TrackedRegisterState.pyi b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/TrackedRegisterState.pyi deleted file mode 100644 index 36ba693e..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/TrackedRegisterState.pyi +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from __future__ import annotations - - -class RegistersTracker: - registerNum: int - - hasLuiValue: bool - luiOffset: int # The offset of last lui which set a value to this register - luiSetOnBranchLikely: bool - - hasGpGot: bool - gpGotOffset: int - - hasLoValue: bool - loOffset: int - dereferenced: bool - dereferenceOffset: int - - value: int diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/Utils.pyi b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/Utils.pyi deleted file mode 100644 index 7215556f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/Utils.pyi +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from __future__ import annotations - - -class Utils: - @staticmethod - def from2Complement(number: int, bits: int) -> int: ... - - @staticmethod - def escapeString(src: str) -> str: ... diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/__init__.pyi b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/__init__.pyi deleted file mode 100644 index 1bc27a7f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/__init__.pyi +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from __future__ import annotations - -from .Utils import * - -from .Enum import * -from .InstrCategory import * -from .InstrId import * - -from .RegGprO32 import * -from .RegGprN32 import * - -from .Config import * - -from .rabbitizer import * - -from .RegistersTracker import * diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/enums_utils.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/enums_utils.c deleted file mode 100644 index 081dcdaf..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/enums_utils.c +++ /dev/null @@ -1,38 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "enums_utils.h" - - -int rabbitizer_EnumMetadata_Initialize(PyObject *submodule, RabbitizerEnumMetadata *enumValues) { - for (size_t i = 0; enumValues[i].enumType != 0; i++) { - PyObject *args; - - args = Py_BuildValue("ssi", enumValues[i].enumType, enumValues[i].name, enumValues[i].value); - if (args == NULL) { - goto error; - } - - enumValues[i].instance = PyObject_CallObject((PyObject*)&rabbitizer_type_Enum_TypeObject, args); - Py_DECREF(args); - if (enumValues[i].instance == NULL) { - goto error; - } - - enumValues[i].isInstanced = true; - if (PyModule_AddObject(submodule, enumValues[i].name, enumValues[i].instance) < 0) { - goto error; - } - } - return 0; - -error: - for (size_t i = 0; enumValues[i].enumType != 0; i++) { - if (enumValues[i].isInstanced) { - Py_DECREF(enumValues[i].instance); - } - enumValues[i].isInstanced = false; - } - - return -1; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/enums_utils.h b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/enums_utils.h deleted file mode 100644 index 6cb8604f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/enums_utils.h +++ /dev/null @@ -1,85 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_ENUMS_UTILS_H -#define RABBITIZER_ENUMS_UTILS_H -#pragma once - - -#define PY_SSIZE_T_CLEAN -#include -#include "structmember.h" - -#include - - -extern PyTypeObject rabbitizer_type_Enum_TypeObject; - - -typedef struct PyRabbitizerEnum { - PyObject_HEAD - PyObject *enumType; - PyObject *name; - int value; -} PyRabbitizerEnum; - -typedef struct RabbitizerEnumMetadata { - const char *enumType; - const char *name; - int value; - bool isInstanced; - PyObject *instance; -} RabbitizerEnumMetadata; - - -int rabbitizer_EnumMetadata_Initialize(PyObject *submodule, RabbitizerEnumMetadata *enumValues); - - -#define DECL_ENUM(enumName) \ - extern RabbitizerEnumMetadata rabbitizer_enum_##enumName##_enumvalues[]; \ - PyObject *rabbitizer_enum_##enumName##_Init(void); \ - /* Return true if o is of this enum type */ \ - int rabbitizer_enum_##enumName##_Check(PyObject *o); - -#define DEF_ENUM(enumName, docs) \ - static PyModuleDef rabbitizer_enum_##enumName##_module = { \ - PyModuleDef_HEAD_INIT, \ - .m_name = "rabbitizer." #enumName, \ - .m_doc = PyDoc_STR(docs), \ - .m_size = -1, \ - .m_methods = rabbitizer_enum_##enumName##_methods, \ - }; \ - PyObject *rabbitizer_enum_##enumName##_Init(void) { \ - PyObject *submodule; \ - if (PyType_Ready(&rabbitizer_type_Enum_TypeObject) < 0) { \ - return NULL; \ - } \ - submodule = PyModule_Create(&rabbitizer_enum_##enumName##_module); \ - if (submodule == NULL) { \ - return NULL; \ - } \ - if (rabbitizer_EnumMetadata_Initialize(submodule, rabbitizer_enum_##enumName##_enumvalues) < 0) { \ - Py_DECREF(submodule); \ - return NULL; \ - } \ - return submodule; \ - } \ - /* Return true if o is of this enum type */ \ - int rabbitizer_enum_##enumName##_Check(PyObject *o) { \ - int isInstance = PyObject_IsInstance(o, (PyObject*)&rabbitizer_type_Enum_TypeObject); \ - int enumTypeCmp; \ - if (isInstance < 0) { \ - /* An error happened */ \ - /* PyObject_IsInstance already sets an exception, so nothing else to do here */ \ - return -1; \ - } \ - if (isInstance == 0) { \ - /* `other` isn't an instance of the Enum type */ \ - return 0; \ - } \ - /* Check if both enums have the same `enumType` */ \ - enumTypeCmp = PyUnicode_CompareWithASCIIString(((PyRabbitizerEnum*)o)->enumType, #enumName); \ - return enumTypeCmp == 0; \ - } - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/rabbitizer_enum_Abi.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/rabbitizer_enum_Abi.c deleted file mode 100644 index a0d5fb09..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/rabbitizer_enum_Abi.c +++ /dev/null @@ -1,48 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "enums_utils.h" -#include "common/RabbitizerConfig.h" -#include "common/Utils.h" - - -#define RABBITIZER_DEF_ABI(name) { "Abi", #name, RABBITIZER_ABI_##name, false, NULL } - -RabbitizerEnumMetadata rabbitizer_enum_Abi_enumvalues[] = { - #include "common/Abi.inc" - RABBITIZER_DEF_ABI(MAX), - - { 0 }, -}; - -#undef RABBITIZER_DEF_ABI - - -static PyObject *rabbitizer_enum_Abi_fromStr(UNUSED PyObject *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "name", NULL }; - const char *name = NULL; - RabbitizerAbi abi; - PyObject *ret; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "z", kwlist, &name)) { - return NULL; - } - - abi = RabbitizerAbi_fromStr(name); - - ret = rabbitizer_enum_Abi_enumvalues[abi].instance; - Py_INCREF(ret); - return ret; -} - - -#define METHOD_NO_ARGS(name, docs) { #name, (PyCFunction) rabbitizer_enum_Abi_##name, METH_NOARGS, PyDoc_STR(docs) } -#define METHOD_ARGS(name, docs) { #name, (PyCFunction) rabbitizer_enum_Abi_##name, METH_VARARGS | METH_KEYWORDS, PyDoc_STR(docs) } - -static PyMethodDef rabbitizer_enum_Abi_methods[] = { - METHOD_ARGS(fromStr, ""), - - { 0 }, -}; - -DEF_ENUM(Abi, "") diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/rabbitizer_enum_InstrCategory.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/rabbitizer_enum_InstrCategory.c deleted file mode 100644 index fbc94dda..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/rabbitizer_enum_InstrCategory.c +++ /dev/null @@ -1,23 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "enums_utils.h" -#include "instructions/RabbitizerInstruction.h" - - -#define RABBITIZER_DEF_INSTR_CATEGORY(name) { "InstrCategory", #name, RABBITIZER_INSTRCAT_##name, false, NULL } - -RabbitizerEnumMetadata rabbitizer_enum_InstrCategory_enumvalues[] = { - #include "instructions/InstrCategory.inc" - RABBITIZER_DEF_INSTR_CATEGORY(MAX), - - { 0 }, -}; - -#undef RABBITIZER_DEF_INSTR_CATEGORY - -static PyMethodDef rabbitizer_enum_InstrCategory_methods[] = { - { 0 }, -}; - -DEF_ENUM(InstrCategory, "") diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/rabbitizer_enum_InstrId.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/rabbitizer_enum_InstrId.c deleted file mode 100644 index fabf612d..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/rabbitizer_enum_InstrId.c +++ /dev/null @@ -1,29 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "enums_utils.h" -#include "instructions/RabbitizerInstrId.h" - - -#define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) { "InstrId", #prefix "_" #name, RABBITIZER_INSTR_ID_##prefix##_##name, false, NULL }, -#define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, __VA_ARGS__) - -RabbitizerEnumMetadata rabbitizer_enum_InstrId_enumvalues[] = { - #include "instructions/instr_id/RabbitizerInstrId_cpu.inc" - - #include "instructions/instr_id/RabbitizerInstrId_rsp.inc" - - #include "instructions/instr_id/RabbitizerInstrId_r5900.inc" - - RABBITIZER_DEF_INSTR_ID(ALL, , MAX, ) - { 0 }, -}; - -#undef RABBITIZER_DEF_INSTR_ID -#undef RABBITIZER_DEF_INSTR_ID_ALTNAME - -static PyMethodDef rabbitizer_enum_InstrId_methods[] = { - { 0 }, -}; - -DEF_ENUM(InstrId, "") diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/rabbitizer_type_Enum.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/rabbitizer_type_Enum.c deleted file mode 100644 index 299fb386..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/rabbitizer_type_Enum.c +++ /dev/null @@ -1,211 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "rabbitizer_module.h" -#include "enums_utils.h" -#include "common/Utils.h" - - -static void rabbitizer_type_Enum_dealloc(PyRabbitizerEnum *self) { - Py_XDECREF(self->enumType); - Py_XDECREF(self->name); - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static PyObject *rabbitizer_type_Enum_new(PyTypeObject *type, UNUSED PyObject *args, UNUSED PyObject *kwds) { - PyRabbitizerEnum *self = (PyRabbitizerEnum *) type->tp_alloc(type, 0); - - if (self == NULL) { - return NULL; - } - - self->enumType = PyUnicode_FromString(""); - if (self->enumType == NULL) { - Py_DECREF(self); - return NULL; - } - self->name = PyUnicode_FromString(""); - if (self->name == NULL) { - Py_DECREF(self); - return NULL; - } - self->value = 0; - - return (PyObject *) self; -} - -static int rabbitizer_type_Enum_init(PyRabbitizerEnum *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "enumType", "name", "value", NULL }; - PyObject *enumType = NULL; - PyObject *name = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "UUi", kwlist, &enumType, &name, &self->value)) { - return -1; - } - - if (enumType != NULL) { - PyObject *tmp = NULL; - - tmp = self->enumType; - Py_INCREF(enumType); - self->enumType = enumType; - Py_DECREF(tmp); - } - if (name) { - PyObject *tmp = NULL; - - tmp = self->name; - Py_INCREF(name); - self->name = name; - Py_DECREF(tmp); - } - - return 0; -} - - -#define DEF_MEMBER_GET_INT(name) \ - static PyObject *rabbitizer_type_Enum_member_get_##name(PyRabbitizerEnum *self, PyObject *Py_UNUSED(ignored)) { \ - return PyLong_FromLong(self->name); \ - } - -#define DEF_MEMBER_GET_OBJREF(name) \ - static PyObject *rabbitizer_type_Enum_member_get_##name(PyRabbitizerEnum *self, PyObject *Py_UNUSED(ignored)) { \ - Py_INCREF(self->name); \ - return self->name; \ - } - -DEF_MEMBER_GET_OBJREF(name) -DEF_MEMBER_GET_INT(value) - - -#define MEMBER_GET(name, docs, closure) { #name, (getter) rabbitizer_type_Enum_member_get_##name, (setter) NULL, PyDoc_STR(docs), closure } -#define MEMBER_SET(name, docs, closure) { #name, (getter) NULL, (setter) rabbitizer_type_Enum_member_set_##name, PyDoc_STR(docs), closure } -#define MEMBER_GET_SET(name, docs, closure) { #name, (getter) rabbitizer_type_Enum_member_get_##name, (setter) rabbitizer_type_Enum_member_set_##name, PyDoc_STR(docs), closure } - -static PyGetSetDef rabbitizer_type_Enum_getsetters[] = { - MEMBER_GET(name, "", NULL), - MEMBER_GET(value, "", NULL), - - { 0 }, -}; - - -// Crappy hash -Py_hash_t rabbitizer_type_Enum_hash(PyRabbitizerEnum *self) { - Py_hash_t hash = PyObject_Hash(self->enumType); - - if (hash == -1) { - return -1; - } - - return hash + self->value; -} - -// Checks for the 6 basic comparisons (==, !=, <, <=, >, >=) -PyObject *rabbitizer_type_Enum_richcompare(PyRabbitizerEnum *self, PyObject *other, int op) { - int isInstance = PyObject_IsInstance(other, (PyObject*)&rabbitizer_type_Enum_TypeObject); - int enumTypeCmp; - int otherValue; - - if (isInstance < 0) { - // An error happened - // PyObject_IsInstance already sets an exception, so nothing else to do here - return NULL; - } - - if (isInstance == 0) { - // `other` isn't an instance of the Enum type - Py_RETURN_FALSE; - } - - // Check if both enums have the same `enumType` - enumTypeCmp = PyUnicode_Compare(self->enumType, ((PyRabbitizerEnum*)other)->enumType); - if (enumTypeCmp < 0) { - // Negative could mean it isn't equal or an error occurred, so we need to check for errors - if (PyErr_Occurred() != NULL) { - return NULL; - } - Py_RETURN_FALSE; - } - if (enumTypeCmp != 0) { - Py_RETURN_FALSE; - } - - otherValue = ((PyRabbitizerEnum*)other)->value; - - // Fails to build on ci builds for some reason - // Py_RETURN_RICHCOMPARE(self->value, ((PyRabbitizerEnum*)other)->value, op); - - switch (op) { - case Py_EQ: if ((self->value) == (otherValue)) Py_RETURN_TRUE; Py_RETURN_FALSE; - case Py_NE: if ((self->value) != (otherValue)) Py_RETURN_TRUE; Py_RETURN_FALSE; - case Py_LT: if ((self->value) < (otherValue)) Py_RETURN_TRUE; Py_RETURN_FALSE; - case Py_GT: if ((self->value) > (otherValue)) Py_RETURN_TRUE; Py_RETURN_FALSE; - case Py_LE: if ((self->value) <= (otherValue)) Py_RETURN_TRUE; Py_RETURN_FALSE; - case Py_GE: if ((self->value) >= (otherValue)) Py_RETURN_TRUE; Py_RETURN_FALSE; - default: - //Py_UNREACHABLE(); - UNREACHABLE; - } -} - - -// To allow piclking the object -static PyObject *rabbitizer_type_Enum___reduce__(PyRabbitizerEnum *self, UNUSED PyObject *closure) { - PyObject *args; - PyObject *enumType; - PyObject *name; - PyObject *value; - - enumType = self->enumType; - Py_INCREF(enumType); - name = self->name; - Py_INCREF(name); - value = PyLong_FromLong(self->value); - - - args = PyTuple_Pack(3, enumType, name, value); - - return PyTuple_Pack(2, (PyObject*)&rabbitizer_type_Enum_TypeObject, args); -} - - -#define METHOD_NO_ARGS(name, docs) { #name, (PyCFunction)rabbitizer_type_Enum_##name, METH_NOARGS, PyDoc_STR(docs) } -#define METHOD_ARGS(name, docs) { #name, (PyCFunction)rabbitizer_type_Enum_##name, METH_VARARGS | METH_KEYWORDS, PyDoc_STR(docs) } - - -static PyMethodDef rabbitizer_type_Enum_methods[] = { - METHOD_ARGS(__reduce__, ""), - - { 0 }, -}; - -static PyObject *rabbitizer_type_Enum_repr(PyRabbitizerEnum *self) { - return PyUnicode_FromFormat("<%U: %U (%i)>", self->enumType, self->name, self->value); -} - -static PyObject *rabbitizer_type_Enum_str(PyRabbitizerEnum *self) { - return rabbitizer_type_Enum_repr(self); -} - -// TODO: implement hash and int - -PyTypeObject rabbitizer_type_Enum_TypeObject = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "rabbitizer.Enum", - .tp_doc = PyDoc_STR("Enum"), - .tp_basicsize = sizeof(PyRabbitizerEnum), - .tp_itemsize = 0, - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .tp_new = rabbitizer_type_Enum_new, - .tp_init = (initproc) rabbitizer_type_Enum_init, - .tp_dealloc = (destructor) rabbitizer_type_Enum_dealloc, - .tp_hash = (hashfunc) rabbitizer_type_Enum_hash, - .tp_richcompare = (richcmpfunc) rabbitizer_type_Enum_richcompare, - .tp_repr = (reprfunc) rabbitizer_type_Enum_repr, - .tp_str = (reprfunc) rabbitizer_type_Enum_str, - //.tp_members = rabbitizer_type_Enum_members, - .tp_methods = rabbitizer_type_Enum_methods, - .tp_getset = rabbitizer_type_Enum_getsetters, -}; diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/registers/rabbitizer_enum_GprN32.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/registers/rabbitizer_enum_GprN32.c deleted file mode 100644 index 6027d78f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/registers/rabbitizer_enum_GprN32.c +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "enums/enums_utils.h" -#include "instructions/RabbitizerRegister.h" - - -#define RABBITIZER_DEF_REG(prefix, name, numeric) \ - { "RegGprN32", #name, RABBITIZER_REG_##prefix##_##name, false, NULL } - -#define RABBITIZER_DEF_REG_NODOLLAR(prefix, name, numeric) \ - { "RegGprN32", #name, RABBITIZER_REG_##prefix##_##name, false, NULL } - -RabbitizerEnumMetadata rabbitizer_enum_RegGprN32_enumvalues[] = { - #include "instructions/registers/RabbitizerRegister_GprN32.inc" - - { 0 }, -}; - -#undef RABBITIZER_DEF_REG -#undef RABBITIZER_DEF_REG_NODOLLAR - - -static PyMethodDef rabbitizer_enum_RegGprN32_methods[] = { - { 0 }, -}; - -DEF_ENUM(RegGprN32, "") diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/registers/rabbitizer_enum_GprO32.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/registers/rabbitizer_enum_GprO32.c deleted file mode 100644 index 50cdabe7..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/enums/registers/rabbitizer_enum_GprO32.c +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "enums/enums_utils.h" -#include "instructions/RabbitizerRegister.h" - - -#define RABBITIZER_DEF_REG(prefix, name, numeric) \ - { "RegGprO32", #name, RABBITIZER_REG_##prefix##_##name, false, NULL } - -#define RABBITIZER_DEF_REG_NODOLLAR(prefix, name, numeric) \ - { "RegGprO32", #name, RABBITIZER_REG_##prefix##_##name, false, NULL } - -RabbitizerEnumMetadata rabbitizer_enum_RegGprO32_enumvalues[] = { - #include "instructions/registers/RabbitizerRegister_GprO32.inc" - - { 0 }, -}; - -#undef RABBITIZER_DEF_REG -#undef RABBITIZER_DEF_REG_NODOLLAR - - -static PyMethodDef rabbitizer_enum_RegGprO32_methods[] = { - { 0 }, -}; - -DEF_ENUM(RegGprO32, "") diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/py.typed b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/py.typed deleted file mode 100644 index e69de29b..00000000 diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer.pyi b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer.pyi deleted file mode 100644 index 0ff63fac..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer.pyi +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env python3 - -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from __future__ import annotations - -from .Enum import Enum -from .InstrCategory import InstrCategory - - -class Instruction: - rs: Enum - """The value of the `rs` register for this instruction. - The type of this attribute will be either a `RegGprO32` or a `RegGprN32` depending on the current `config.regNames_gprAbiNames` value. - If the current instruction does not use the `rs` register, then a Runtime exception will be raised. - Read-only.""" - rt: Enum - """The value of the `rt` register for this instruction. - The type of this attribute will be either a `RegGprO32` or a `RegGprN32` depending on the current `config.regNames_gprAbiNames` value. - If the current instruction does not use the `rt` register, then a Runtime exception will be raised. - Read-only.""" - rd: Enum - """The value of the `rd` register for this instruction. - The type of this attribute will be either a `RegGprO32` or a `RegGprN32` depending on the current `config.regNames_gprAbiNames` value. - If the current instruction does not use the `rd` register, then a Runtime exception will be raised. - Read-only.""" - sa: int - """The value of the `sa` field for this instruction. - If the current instruction does not have a `sa` field, then a Runtime exception will be raised. - Read-only.""" - - uniqueId: Enum - """An unique identificator for the opcode of this instruction. - The type is an `InstrId` enum. - Read-only.""" - - vram: int = 0 - """The vram (virtual ram) address for this instruction""" - inHandwrittenFunction: bool = False - """Boolean value indicating if the current instruction is used on a handwritten function. This is intended to be determined by the user.""" - - - def __init__(self, word: int, vram: int=0, category: Enum=InstrCategory.CPU) -> None: ... - - def getRaw(self) -> int: ... - def getImmediate(self) -> int: ... - def getProcessedImmediate(self) -> int: ... - def getInstrIndexAsVram(self) -> int: ... - def getBranchOffset(self) -> int: ... - def getGenericBranchOffset(self, currentVram: int) -> int: ... - def getOpcodeName(self) -> str: ... - - def blankOut(self) -> None: ... - - def isImplemented(self) -> bool: ... - def isLikelyHandwritten(self) -> bool: ... - def isNop(self) -> bool: ... - def isUnconditionalBranch(self) -> bool: ... - def isJrRa(self) -> bool: ... - def isJrNotRa(self) -> bool: ... - def hasDelaySlot(self) -> bool: ... - def mapInstrToType(self) -> str|None: ... - - def sameOpcode(self, other: Instruction) -> bool: ... - def sameOpcodeButDifferentArguments(self, other: Instruction) -> bool: ... - - def isValid(self) -> bool: ... - - def isUnknownType(self) -> bool: ... - def isJType(self) -> bool: ... - def isIType(self) -> bool: ... - def isRType(self) -> bool: ... - def isRegimmType(self) -> bool: ... - def isBranch(self) -> bool: ... - def isBranchLikely(self) -> bool: ... - def isJump(self) -> bool: ... - def isTrap(self) -> bool: ... - def isFloat(self) -> bool: ... - def isDouble(self) -> bool: ... - def isUnsigned(self) -> bool: ... - def modifiesRt(self) -> bool: ... - def modifiesRd(self) -> bool: ... - def notEmitedByCompilers(self) -> bool: ... - def canBeHi(self) -> bool: ... - def canBeLo(self) -> bool: ... - def doesLink(self) -> bool: ... - def doesDereference(self) -> bool: ... - def doesLoad(self) -> bool: ... - def doesStore(self) -> bool: ... - def maybeIsMove(self) -> bool: ... - def isPseudo(self) -> bool: ... - - def disassemble(self, immOverride: str|None=None, extraLJust: int=0) -> str: ... - - def __reduce__(self) -> tuple: ... - - def __repr__(self) -> str: ... - def __str__(self) -> str: ... diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_global_config.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_global_config.c deleted file mode 100644 index d02fce37..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_global_config.c +++ /dev/null @@ -1,165 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -/** - * Wrapper to expose rabbitizer's global configuration - */ - -#include "rabbitizer_module.h" -#include "common/RabbitizerConfig.h" -#include "common/Utils.h" - - -#define DEF_MEMBER_GET_BOOL(category, name) \ - static PyObject *rabbitizer_global_config_get_##category##_##name(UNUSED PyObject *self, UNUSED PyObject *closure) { \ - if (RabbitizerConfig_Cfg.category.name) { \ - Py_RETURN_TRUE; \ - } \ - Py_RETURN_FALSE; \ - } -#define DEF_MEMBER_SET_BOOL(category, name) \ - static int rabbitizer_global_config_set_##category##_##name(UNUSED PyObject *self, PyObject *value, UNUSED void *closure) { \ - if (value == NULL) { \ - PyErr_SetString(PyExc_TypeError, "Cannot delete '" #category "." #name "' attribute"); \ - return -1; \ - } \ - RabbitizerConfig_Cfg.category.name = PyObject_IsTrue(value); \ - return 0; \ - } - -#define DEF_MEMBER_GET_SET_BOOL(category, name) \ - DEF_MEMBER_GET_BOOL(category, name) \ - DEF_MEMBER_SET_BOOL(category, name) - - -#define DEF_MEMBER_GET_INT(category, name) \ - static PyObject *rabbitizer_global_config_get_##category##_##name(UNUSED PyObject *self, UNUSED PyObject *closure) { \ - return PyLong_FromLong(RabbitizerConfig_Cfg.category.name); \ - } -#define DEF_MEMBER_SET_INT(category, name, rangeCheck, minVal, maxVal) \ - static int rabbitizer_global_config_set_##category##_##name(UNUSED PyObject *self, PyObject *value, UNUSED void *closure) { \ - long val; \ - if (value == NULL) { \ - PyErr_SetString(PyExc_TypeError, "Cannot delete '" #category "_" #name "' attribute"); \ - return -1; \ - } \ - val = PyLong_AsLong(value); \ - if (val == -1) { \ - PyObject *err = PyErr_Occurred(); \ - if (err != NULL) { \ - return -1; \ - } \ - } \ - if (rangeCheck && (val < minVal || val > maxVal)) { \ - PyErr_SetString(PyExc_ValueError, "Invalid value for '" #category "_" #name "' attribute"); \ - return -1; \ - } \ - RabbitizerConfig_Cfg.category.name = val;\ - return 0; \ - } - -#define DEF_MEMBER_GET_SET_INT(category, name, rangeCheck, minVal, maxVal) \ - DEF_MEMBER_GET_INT(category, name) \ - DEF_MEMBER_SET_INT(category, name, rangeCheck, minVal, maxVal) - -#define DEF_MEMBER_GET_ABI(category, name) \ - static PyObject *rabbitizer_global_config_get_##category##_##name(UNUSED PyObject *self, UNUSED PyObject *ignored) { \ - PyObject *enumInstance = rabbitizer_enum_Abi_enumvalues[RabbitizerConfig_Cfg.category.name].instance; \ - if (enumInstance == NULL) { \ - PyErr_SetString(PyExc_RuntimeError, "Internal error: invalid enum value for '" #category "_" #name "'"); \ - return NULL; \ - } \ - Py_INCREF(enumInstance); \ - return enumInstance; \ - } -#define DEF_MEMBER_SET_ABI(category, name) \ - static int rabbitizer_global_config_set_##category##_##name(UNUSED PyObject *self, PyObject *value, UNUSED void *closure) { \ - int enumCheck; \ - if (value == NULL) { \ - PyErr_SetString(PyExc_TypeError, "Cannot delete '" #category "_" #name "' attribute"); \ - return -1; \ - } \ - enumCheck = rabbitizer_enum_Abi_Check(value); \ - if (enumCheck <= 0) { \ - if (enumCheck == 0) { \ - PyErr_SetString(PyExc_ValueError, "Invalid value for '" #category "_" #name "' attribute"); \ - } \ - return -1; \ - } \ - RabbitizerConfig_Cfg.category.name = ((PyRabbitizerEnum*)value)->value; \ - return 0; \ - } - -#define DEF_MEMBER_GET_SET_ABI(category, name) \ - DEF_MEMBER_GET_ABI(category, name) \ - DEF_MEMBER_SET_ABI(category, name) - - -#define MEMBER_GET(category, name, docs, closure) { #category "_" #name, (getter) rabbitizer_global_config_get_##category##_##name, (setter) NULL, PyDoc_STR(docs), closure } -#define MEMBER_SET(category, name, docs, closure) { #category "_" #name, (getter) NULL, (setter) rabbitizer_global_config_set_##category##_##name, PyDoc_STR(docs), closure } -#define MEMBER_GET_SET(category, name, docs, closure) { #category "_" #name, (getter) rabbitizer_global_config_get_##category##_##name, (setter) rabbitizer_global_config_set_##category##_##name, PyDoc_STR(docs), closure } - - -DEF_MEMBER_GET_SET_BOOL(regNames, namedRegisters) -DEF_MEMBER_GET_SET_ABI(regNames, gprAbiNames) -DEF_MEMBER_GET_SET_ABI(regNames, fprAbiNames) -DEF_MEMBER_GET_SET_BOOL(regNames, userFpcCsr) -DEF_MEMBER_GET_SET_BOOL(regNames, vr4300Cop0NamedRegisters) -DEF_MEMBER_GET_SET_BOOL(regNames, vr4300RspCop0NamedRegisters) - -DEF_MEMBER_GET_SET_BOOL(pseudos, enablePseudos) -DEF_MEMBER_GET_SET_BOOL(pseudos, pseudoBeqz) -DEF_MEMBER_GET_SET_BOOL(pseudos, pseudoBnez) -DEF_MEMBER_GET_SET_BOOL(pseudos, pseudoB) -DEF_MEMBER_GET_SET_BOOL(pseudos, pseudoMove) -DEF_MEMBER_GET_SET_BOOL(pseudos, pseudoNot) -DEF_MEMBER_GET_SET_BOOL(pseudos, pseudoNegu) -DEF_MEMBER_GET_SET_BOOL(pseudos, pseudoBal) - -DEF_MEMBER_GET_SET_BOOL(toolchainTweaks, treatJAsUnconditionalBranch) -DEF_MEMBER_GET_SET_BOOL(toolchainTweaks, sn64DivFix) - -DEF_MEMBER_GET_SET_INT(misc, opcodeLJust, false, 0, 0) -DEF_MEMBER_GET_SET_BOOL(misc, unknownInstrComment) -DEF_MEMBER_GET_SET_BOOL(misc, omit0XOnSmallImm) -DEF_MEMBER_GET_SET_BOOL(misc, upperCaseImm) - - -static PyGetSetDef rabbitizer_global_config_GetSets[] = { - MEMBER_GET_SET(regNames, namedRegisters, "", NULL), - MEMBER_GET_SET(regNames, gprAbiNames, "", NULL), - MEMBER_GET_SET(regNames, fprAbiNames, "", NULL), - MEMBER_GET_SET(regNames, userFpcCsr, "", NULL), - MEMBER_GET_SET(regNames, vr4300Cop0NamedRegisters, "", NULL), - MEMBER_GET_SET(regNames, vr4300RspCop0NamedRegisters, "", NULL), - - MEMBER_GET_SET(pseudos, enablePseudos, "", NULL), - MEMBER_GET_SET(pseudos, pseudoBeqz, "", NULL), - MEMBER_GET_SET(pseudos, pseudoBnez, "", NULL), - MEMBER_GET_SET(pseudos, pseudoB, "", NULL), - MEMBER_GET_SET(pseudos, pseudoMove, "", NULL), - MEMBER_GET_SET(pseudos, pseudoNot, "", NULL), - MEMBER_GET_SET(pseudos, pseudoNegu, "", NULL), - MEMBER_GET_SET(pseudos, pseudoBal, "", NULL), - - MEMBER_GET_SET(toolchainTweaks, treatJAsUnconditionalBranch, "", NULL), - MEMBER_GET_SET(toolchainTweaks, sn64DivFix, "", NULL), - - MEMBER_GET_SET(misc, opcodeLJust, "", NULL), - MEMBER_GET_SET(misc, unknownInstrComment, "", NULL), - MEMBER_GET_SET(misc, omit0XOnSmallImm, "", NULL), - MEMBER_GET_SET(misc, upperCaseImm, "", NULL), - - { 0 }, -}; - -PyTypeObject rabbitizer_global_config_TypeObject = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "rabbitizer.config", - .tp_doc = PyDoc_STR(""), - .tp_basicsize = sizeof(PyObject), - .tp_itemsize = 0, - .tp_flags = Py_TPFLAGS_DEFAULT, - .tp_new = PyType_GenericNew, - .tp_getset = rabbitizer_global_config_GetSets, -}; diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_module.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_module.c deleted file mode 100644 index 66dec777..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_module.c +++ /dev/null @@ -1,142 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "rabbitizer_module.h" - -#include - -#include "common/Utils.h" -#include "instructions/RabbitizerInstrId.h" - - -typedef enum ModuleAttributeCategory { - MODULE_ATTRIBUTE_CAT_TYPE, - MODULE_ATTRIBUTE_CAT_INIT, // submodules - MODULE_ATTRIBUTE_CAT_GLOBAL, -} ModuleAttributeCategory; - -typedef struct ModuleAttribute { - union { - PyTypeObject *type; - PyObject *(*init)(void); - PyTypeObject *global; - }; - ModuleAttributeCategory cat; - const char *name; - bool isInstanced; - PyObject *instance; -} ModuleAttributes; - -#define MODULE_ATTRIBUTE_TYPE(name) { {.type = &rabbitizer_type_##name##_TypeObject}, MODULE_ATTRIBUTE_CAT_TYPE, #name, false, NULL } -#define MODULE_ATTRIBUTE_INIT(name) { {.init = rabbitizer_submodule_##name##_Init}, MODULE_ATTRIBUTE_CAT_INIT, #name, false, NULL } -#define MODULE_ATTRIBUTE_ENUM(name) { {.init = rabbitizer_enum_##name##_Init}, MODULE_ATTRIBUTE_CAT_INIT, #name, false, NULL } -#define MODULE_ATTRIBUTE_GLOBAL(name) { {.global = &rabbitizer_global_##name##_TypeObject}, MODULE_ATTRIBUTE_CAT_GLOBAL, #name, false, NULL } - -static ModuleAttributes rabbitizer_module_attributes[] = { - MODULE_ATTRIBUTE_INIT(Utils), - MODULE_ATTRIBUTE_GLOBAL(config), - MODULE_ATTRIBUTE_TYPE(Enum), - MODULE_ATTRIBUTE_ENUM(Abi), - MODULE_ATTRIBUTE_ENUM(InstrCategory), - MODULE_ATTRIBUTE_ENUM(InstrId), - MODULE_ATTRIBUTE_ENUM(RegGprO32), - MODULE_ATTRIBUTE_ENUM(RegGprN32), - MODULE_ATTRIBUTE_TYPE(Instruction), - MODULE_ATTRIBUTE_TYPE(LoPairingInfo), - MODULE_ATTRIBUTE_TYPE(TrackedRegisterState), - MODULE_ATTRIBUTE_TYPE(RegistersTracker), -}; - -static int rabbitizer_module_attributes_Ready(void) { - // Sanity checks and PyType_Ready - for (size_t i = 0; i < ARRAY_COUNT(rabbitizer_module_attributes); i++) { - if (rabbitizer_module_attributes[i].global == NULL || rabbitizer_module_attributes[i].name == NULL) { - return -1; - } - switch (rabbitizer_module_attributes[i].cat) { - case MODULE_ATTRIBUTE_CAT_TYPE: - case MODULE_ATTRIBUTE_CAT_GLOBAL: - if (PyType_Ready(rabbitizer_module_attributes[i].type) < 0) { - return -1; - } - break; - - case MODULE_ATTRIBUTE_CAT_INIT: - break; - - default: - return -1; - } - } - - return 0; -} - -static int rabbitizer_module_attributes_Initialize(PyObject *module) { - for (size_t i = 0; i < ARRAY_COUNT(rabbitizer_module_attributes); i++) { - switch (rabbitizer_module_attributes[i].cat) { - case MODULE_ATTRIBUTE_CAT_TYPE: - rabbitizer_module_attributes[i].instance = (PyObject*) rabbitizer_module_attributes[i].type; - Py_INCREF(rabbitizer_module_attributes[i].instance); - break; - - case MODULE_ATTRIBUTE_CAT_INIT: - rabbitizer_module_attributes[i].instance = rabbitizer_module_attributes[i].init(); - if (rabbitizer_module_attributes[i].instance == NULL) { - goto error; - } - break; - - case MODULE_ATTRIBUTE_CAT_GLOBAL: - rabbitizer_module_attributes[i].instance = PyObject_CallObject((PyObject*)rabbitizer_module_attributes[i].global, NULL); - if (rabbitizer_module_attributes[i].instance == NULL) { - goto error; - } - break; - } - - rabbitizer_module_attributes[i].isInstanced = true; - if (PyModule_AddObject(module, rabbitizer_module_attributes[i].name, rabbitizer_module_attributes[i].instance) < 0) { - goto error; - } - } - - return 0; - -error: - for (size_t i = 0; i < ARRAY_COUNT(rabbitizer_module_attributes); i++) { - if (rabbitizer_module_attributes[i].isInstanced) { - Py_DECREF(rabbitizer_module_attributes[i].instance); - } - rabbitizer_module_attributes[i].isInstanced = false; - } - return -1; -} - - -static PyModuleDef rabbitizer_module = { - PyModuleDef_HEAD_INIT, - .m_name = "rabbitizer", - .m_doc = "", - .m_size = -1, -}; - -PyMODINIT_FUNC PyInit_rabbitizer(void) { - PyObject *module; - - if (rabbitizer_module_attributes_Ready() < 0) { - return NULL; - } - - module = PyModule_Create(&rabbitizer_module); - if (module == NULL) { - return NULL; - } - - if (rabbitizer_module_attributes_Initialize(module) < 0) { - Py_DECREF(module); - return NULL; - } - - return module; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_module.h b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_module.h deleted file mode 100644 index 051ea67d..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_module.h +++ /dev/null @@ -1,54 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#ifndef RABBITIZER_MODULE_H -#define RABBITIZER_MODULE_H -#pragma once - -#define PY_SSIZE_T_CLEAN -#include -#include "structmember.h" - -#include "enums/enums_utils.h" - -#include "instructions/RabbitizerInstruction.h" -#include "analysis/RabbitizerTrackedRegisterState.h" -#include "analysis/RabbitizerLoPairingInfo.h" - -// TODO: clean up this... - - -typedef struct PyRabbitizerInstruction { - PyObject_HEAD - RabbitizerInstruction instr; -} PyRabbitizerInstruction; - -typedef struct PyRabbitizerTrackedRegisterState { - PyObject_HEAD - RabbitizerTrackedRegisterState registerState; -} PyRabbitizerTrackedRegisterState; - -typedef struct PyRabbitizerLoPairingInfo { - PyObject_HEAD - RabbitizerLoPairingInfo pairingInfo; -} PyRabbitizerLoPairingInfo; - - -PyObject *rabbitizer_submodule_Utils_Init(void); - -extern PyTypeObject rabbitizer_global_config_TypeObject; - -extern PyTypeObject rabbitizer_type_Enum_TypeObject; -extern PyTypeObject rabbitizer_type_Instruction_TypeObject; -extern PyTypeObject rabbitizer_type_LoPairingInfo_TypeObject; -extern PyTypeObject rabbitizer_type_TrackedRegisterState_TypeObject; -extern PyTypeObject rabbitizer_type_RegistersTracker_TypeObject; - -DECL_ENUM(Abi) -DECL_ENUM(InstrCategory) -DECL_ENUM(InstrId) - -DECL_ENUM(RegGprO32) -DECL_ENUM(RegGprN32) - -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_submodule_Utils.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_submodule_Utils.c deleted file mode 100644 index 31b844a8..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_submodule_Utils.c +++ /dev/null @@ -1,81 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "rabbitizer_module.h" - -#include "common/Utils.h" - - -static PyObject *rabbitizer_submodule_Utils_from2Complement(UNUSED PyObject *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "number", "bits", NULL }; - uint32_t number = 0; - int bits = 0; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "Ii", kwlist, &number, &bits)) { - return NULL; - } - - return PyLong_FromLong(RabbitizerUtils_From2Complement(number, bits)); -} - -static PyObject *rabbitizer_submodule_Utils_escapeString(UNUSED PyObject *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "src", NULL }; - const char *src = NULL; - Py_ssize_t srcSize = 0; - char *dst; - size_t dstSize; - size_t wroteBytes; - PyObject *ret; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "s#", kwlist, &src, &srcSize)) { - return NULL; - } - - dstSize = 2 * srcSize; - dst = malloc(dstSize * sizeof(char)); - if (dst == NULL) { - PyErr_SetString(PyExc_RuntimeError, "Internal error on 'escapeString'"); - return NULL; - } - - wroteBytes = RabbitizerUtils_escapeString(dst, dstSize, src, srcSize); - if (wroteBytes > dstSize) { - PyErr_SetString(PyExc_RuntimeError, "Internal error on 'escapeString'"); - return NULL; - } - - ret = PyUnicode_FromStringAndSize(dst, wroteBytes); - free(dst); - return ret; -} - - -#define METHOD_NO_ARGS(name, docs) { #name, (PyCFunction) rabbitizer_submodule_Utils_##name, METH_NOARGS, PyDoc_STR(docs) } -#define METHOD_ARGS(name, docs) { #name, (PyCFunction) rabbitizer_submodule_Utils_##name, METH_VARARGS | METH_KEYWORDS, PyDoc_STR(docs) } - -static PyMethodDef rabbitizer_submodule_Utils_methods[] = { - METHOD_ARGS(from2Complement, ""), - METHOD_ARGS(escapeString, ""), - - { 0 }, -}; - - -static PyModuleDef rabbitizer_submodule_Utils_module = { - PyModuleDef_HEAD_INIT, - .m_name = "rabbitizer.Utils", - .m_doc = "", - .m_size = -1, - .m_methods = rabbitizer_submodule_Utils_methods, -}; - -PyObject *rabbitizer_submodule_Utils_Init(void) { - PyObject *submodule; - - submodule = PyModule_Create(&rabbitizer_submodule_Utils_module); - if (submodule == NULL) { - return NULL; - } - - return submodule; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_type_Instruction.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_type_Instruction.c deleted file mode 100644 index 5471408d..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_type_Instruction.c +++ /dev/null @@ -1,436 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "rabbitizer_module.h" - -#include "instructions/RabbitizerInstructionRsp.h" -#include "instructions/RabbitizerInstructionR5900.h" -#include "common/RabbitizerConfig.h" - - -static void rabbitizer_type_Instruction_dealloc(PyRabbitizerInstruction *self) { - RabbitizerInstruction_destroy(&self->instr); - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static int rabbitizer_type_Instruction_init(PyRabbitizerInstruction *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "word", "vram", "category", NULL }; - uint32_t word; - uint32_t vram; - PyObject *category = NULL; - int enumCheck; - RabbitizerInstrCategory instrCategory = RABBITIZER_INSTRCAT_CPU; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "I|IO!", kwlist, &word, &vram, &rabbitizer_type_Enum_TypeObject, &category)) { - return -1; - } - - if (category != NULL) { - enumCheck = rabbitizer_enum_InstrCategory_Check(category); - - if (enumCheck <= 0) { - if (enumCheck == 0) { - PyErr_SetString(PyExc_ValueError, "Invalid value for 'category' parameter"); - } - return -1; - } - - instrCategory = ((PyRabbitizerEnum*)category)->value; - } - - switch (instrCategory) { - case RABBITIZER_INSTRCAT_RSP: - RabbitizerInstructionRsp_init(&self->instr, word, vram); - RabbitizerInstructionRsp_processUniqueId(&self->instr); - break; - - case RABBITIZER_INSTRCAT_R5900: - RabbitizerInstructionR5900_init(&self->instr, word, vram); - RabbitizerInstructionR5900_processUniqueId(&self->instr); - break; - - case RABBITIZER_INSTRCAT_CPU: - case RABBITIZER_INSTRCAT_MAX: - RabbitizerInstruction_init(&self->instr, word, vram); - RabbitizerInstruction_processUniqueId(&self->instr); - break; - } - - return 0; -} - -static PyMemberDef rabbitizer_type_Instruction_members[] = { - { "vram", T_UINT, offsetof(PyRabbitizerInstruction, instr.vram), 0, "vram description" }, - { "inHandwrittenFunction", T_BOOL, offsetof(PyRabbitizerInstruction, instr.inHandwrittenFunction), 0, "inHandwrittenFunction description" }, - - { 0 } -}; - - -#define DEF_MEMBER_GET_UINT(name) \ - static PyObject *rabbitizer_type_Instruction_member_get_##name(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { \ - return PyLong_FromUnsignedLong(RAB_INSTR_GET_##name(&self->instr)); \ - } - -#define DEF_MEMBER_GET_REGGPR(name) \ - static PyObject *rabbitizer_type_Instruction_member_get_##name(PyRabbitizerInstruction *self, UNUSED PyObject *closure) { \ - uint32_t reg; \ - PyObject *enumInstance = NULL; \ - \ - if (!RabbitizerInstruction_hasOperandAlias(&self->instr, RAB_OPERAND_cpu_##name)) { \ - PyErr_Format(PyExc_RuntimeError, "'%s' instruction does not reference register '" #name "'", RabbitizerInstrId_getOpcodeName(self->instr.uniqueId)); \ - return NULL; \ - } \ - \ - reg = RAB_INSTR_GET_##name(&self->instr); \ - switch (RabbitizerConfig_Cfg.regNames.gprAbiNames) { \ - case RABBITIZER_ABI_N32: \ - case RABBITIZER_ABI_N64: \ - enumInstance = rabbitizer_enum_RegGprN32_enumvalues[reg].instance; \ - break; \ - \ - default: \ - enumInstance = rabbitizer_enum_RegGprO32_enumvalues[reg].instance; \ - break; \ - } \ - \ - if (enumInstance == NULL) { \ - PyErr_SetString(PyExc_RuntimeError, "Internal error: invalid RegGpr enum value"); \ - return NULL; \ - } \ - \ - Py_INCREF(enumInstance); \ - return enumInstance; \ - } - -DEF_MEMBER_GET_REGGPR(rs) -DEF_MEMBER_GET_REGGPR(rt) -DEF_MEMBER_GET_REGGPR(rd) - -DEF_MEMBER_GET_UINT(sa) - -static PyObject *rabbitizer_type_Instruction_member_get_uniqueId(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { - PyObject *enumInstance = rabbitizer_enum_InstrId_enumvalues[self->instr.uniqueId].instance; - - if (enumInstance == NULL) { - PyErr_SetString(PyExc_RuntimeError, "Internal error: invalid uniqueId enum value"); - return NULL; - } - - Py_INCREF(enumInstance); - return enumInstance; -} - -#define MEMBER_GET(name, docs, closure) { #name, (getter) rabbitizer_type_Instruction_member_get_##name, (setter) NULL, PyDoc_STR(docs), closure } -#define MEMBER_SET(name, docs, closure) { #name, (getter) NULL, (setter) rabbitizer_type_Instruction_member_set_##name, PyDoc_STR(docs), closure } -#define MEMBER_GET_SET(name, docs, closure) { #name, (getter) rabbitizer_type_Instruction_member_get_##name, (setter) rabbitizer_type_Instruction_member_set_##name, PyDoc_STR(docs), closure } - - -static PyGetSetDef rabbitizer_type_Instruction_getsetters[] = { - MEMBER_GET(rs, "", NULL), - MEMBER_GET(rt, "", NULL), - MEMBER_GET(rd, "", NULL), - MEMBER_GET(sa, "", NULL), - MEMBER_GET(uniqueId, "", NULL), - - { 0 } -}; - - -#define DEF_METHOD_GET_UINT(name) \ - static PyObject *rabbitizer_type_Instruction_##name(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { \ - return PyLong_FromUnsignedLong(RabbitizerInstruction_##name(&self->instr)); \ - } - -#define DEF_METHOD_GET_INT(name) \ - static PyObject *rabbitizer_type_Instruction_##name(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { \ - return PyLong_FromLong(RabbitizerInstruction_##name(&self->instr)); \ - } - -DEF_METHOD_GET_UINT(getRaw) -DEF_METHOD_GET_UINT(getImmediate) -DEF_METHOD_GET_INT(getProcessedImmediate) -DEF_METHOD_GET_UINT(getInstrIndexAsVram) -DEF_METHOD_GET_INT(getBranchOffset) - -static PyObject *rabbitizer_type_Instruction_getOpcodeName(PyRabbitizerInstruction *self, UNUSED PyObject *closure) { - return PyUnicode_FromString(RabbitizerInstrId_getOpcodeName(self->instr.uniqueId)); -} - -static PyObject *rabbitizer_type_Instruction_getGenericBranchOffset(PyRabbitizerInstruction *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "currentVram", NULL }; - uint32_t currentVram; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "I", kwlist, ¤tVram)) { - return NULL; - } - - return PyLong_FromLong(RabbitizerInstruction_getGenericBranchOffset(&self->instr, currentVram)); -} - -static PyObject *rabbitizer_type_Instruction_blankOut(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { - RabbitizerInstruction_blankOut(&self->instr); - Py_RETURN_NONE; -} - - -#define DEF_METHOD_BOOL(name) \ - static PyObject *rabbitizer_type_Instruction_##name(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { \ - if (RabbitizerInstruction_##name(&self->instr)) { \ - Py_RETURN_TRUE; \ - } \ - Py_RETURN_FALSE; \ - } - -DEF_METHOD_BOOL(isImplemented) -DEF_METHOD_BOOL(isLikelyHandwritten) -DEF_METHOD_BOOL(isNop) -DEF_METHOD_BOOL(isUnconditionalBranch) -DEF_METHOD_BOOL(isJrRa) -DEF_METHOD_BOOL(isJrNotRa) -DEF_METHOD_BOOL(hasDelaySlot) - -static PyObject *rabbitizer_type_Instruction_mapInstrToType(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { - const char *type = RabbitizerInstruction_mapInstrToType(&self->instr); - - if (type != NULL) { - return PyUnicode_FromString(type); - } - Py_RETURN_NONE; -} - -static PyObject *rabbitizer_type_Instruction_sameOpcode(PyRabbitizerInstruction *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "other", NULL }; - PyRabbitizerInstruction *other; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist, &rabbitizer_type_Instruction_TypeObject, &other)) { - return NULL; - } - - if (RabbitizerInstruction_sameOpcode(&self->instr, &other->instr)) { - Py_RETURN_TRUE; - } - Py_RETURN_FALSE; -} - -static PyObject *rabbitizer_type_Instruction_sameOpcodeButDifferentArguments(PyRabbitizerInstruction *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "other", NULL }; - PyRabbitizerInstruction *other; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist, &rabbitizer_type_Instruction_TypeObject, &other)) { - return NULL; - } - - if (RabbitizerInstruction_sameOpcodeButDifferentArguments(&self->instr, &other->instr)) { - Py_RETURN_TRUE; - } - Py_RETURN_FALSE; -} - -DEF_METHOD_BOOL(isValid) - -#define DEF_DESCRIPTOR_METHOD_BOOL(name) \ - static PyObject *rabbitizer_type_Instruction_##name(PyRabbitizerInstruction *self, PyObject *Py_UNUSED(ignored)) { \ - if (RabbitizerInstrDescriptor_##name(self->instr.descriptor)) { \ - Py_RETURN_TRUE; \ - } \ - Py_RETURN_FALSE; \ - } - -DEF_DESCRIPTOR_METHOD_BOOL(isUnknownType) -DEF_DESCRIPTOR_METHOD_BOOL(isJType) -DEF_DESCRIPTOR_METHOD_BOOL(isIType) -DEF_DESCRIPTOR_METHOD_BOOL(isRType) -DEF_DESCRIPTOR_METHOD_BOOL(isRegimmType) -DEF_DESCRIPTOR_METHOD_BOOL(isBranch) -DEF_DESCRIPTOR_METHOD_BOOL(isBranchLikely) -DEF_DESCRIPTOR_METHOD_BOOL(isJump) -DEF_DESCRIPTOR_METHOD_BOOL(isTrap) -DEF_DESCRIPTOR_METHOD_BOOL(isFloat) -DEF_DESCRIPTOR_METHOD_BOOL(isDouble) -DEF_DESCRIPTOR_METHOD_BOOL(isUnsigned) -DEF_DESCRIPTOR_METHOD_BOOL(modifiesRt) -DEF_DESCRIPTOR_METHOD_BOOL(modifiesRd) -DEF_DESCRIPTOR_METHOD_BOOL(notEmitedByCompilers) -DEF_DESCRIPTOR_METHOD_BOOL(canBeHi) -DEF_DESCRIPTOR_METHOD_BOOL(canBeLo) -DEF_DESCRIPTOR_METHOD_BOOL(doesLink) -DEF_DESCRIPTOR_METHOD_BOOL(doesDereference) -DEF_DESCRIPTOR_METHOD_BOOL(doesLoad) -DEF_DESCRIPTOR_METHOD_BOOL(doesStore) -DEF_DESCRIPTOR_METHOD_BOOL(maybeIsMove) -DEF_DESCRIPTOR_METHOD_BOOL(isPseudo) -// TODO: create an enum type for architectureVersion -// architectureVersion - - -static PyObject *rabbitizer_type_Instruction_disassemble(PyRabbitizerInstruction *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = {"immOverride", "extraLJust", NULL}; - const char *immOverride = NULL; - size_t immOverrideLength = 0; - int extraLJust = 0; - size_t bufferSize; - char *buffer; - PyObject *ret; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zi", kwlist, &immOverride, &extraLJust)) { - return NULL; - } - - if (immOverride != NULL) { - immOverrideLength = strlen(immOverride); - } - - bufferSize = RabbitizerInstruction_getSizeForBuffer(&self->instr, immOverrideLength, extraLJust); - - buffer = malloc(bufferSize+1); - if (buffer == NULL) { - // TODO: signal an exception? - return NULL; - } - - RabbitizerInstruction_disassemble(&self->instr, buffer, immOverride, immOverrideLength, extraLJust); - - ret = PyUnicode_FromString(buffer); - free(buffer); - return ret; -} - - -// To allow piclking the object -static PyObject *rabbitizer_type_Instruction___reduce__(PyRabbitizerInstruction *self, UNUSED PyObject *closure) { - PyObject *args; - PyObject *word; - PyObject *vram; - PyObject *category; - - word = PyLong_FromUnsignedLong(RabbitizerInstruction_getRaw(&self->instr)); - vram = PyLong_FromUnsignedLong(self->instr.vram); - category = rabbitizer_enum_InstrCategory_enumvalues[self->instr.category].instance; - - args = PyTuple_Pack(3, word, vram, category); - - return PyTuple_Pack(2, (PyObject*)&rabbitizer_type_Instruction_TypeObject, args); -} - - -#define METHOD_NO_ARGS(name, docs) { #name, (PyCFunction)rabbitizer_type_Instruction_##name, METH_NOARGS, PyDoc_STR(docs) } -#define METHOD_ARGS(name, docs) { #name, (PyCFunction)rabbitizer_type_Instruction_##name, METH_VARARGS | METH_KEYWORDS, PyDoc_STR(docs) } - - -static PyMethodDef rabbitizer_type_Instruction_methods[] = { - METHOD_NO_ARGS(getRaw, ""), - METHOD_NO_ARGS(getImmediate, ""), - METHOD_NO_ARGS(getProcessedImmediate, ""), - METHOD_NO_ARGS(getInstrIndexAsVram, ""), - METHOD_NO_ARGS(getBranchOffset, ""), - METHOD_ARGS(getGenericBranchOffset, ""), - METHOD_NO_ARGS(getOpcodeName, ""), - - METHOD_NO_ARGS(blankOut, ""), - - METHOD_NO_ARGS(isImplemented, ""), - METHOD_NO_ARGS(isLikelyHandwritten, ""), - METHOD_NO_ARGS(isNop, ""), - METHOD_NO_ARGS(isUnconditionalBranch, ""), - METHOD_NO_ARGS(isJrRa, ""), - METHOD_NO_ARGS(isJrNotRa, ""), - METHOD_NO_ARGS(hasDelaySlot, ""), - METHOD_NO_ARGS(mapInstrToType, ""), - - METHOD_ARGS(sameOpcode, "description"), - METHOD_ARGS(sameOpcodeButDifferentArguments, "description"), - - METHOD_NO_ARGS(isValid, ""), - - METHOD_NO_ARGS(isUnknownType, ""), - METHOD_NO_ARGS(isJType, ""), - METHOD_NO_ARGS(isIType, ""), - METHOD_NO_ARGS(isRType, ""), - METHOD_NO_ARGS(isRegimmType, ""), - METHOD_NO_ARGS(isBranch, ""), - METHOD_NO_ARGS(isBranchLikely, ""), - METHOD_NO_ARGS(isJump, ""), - METHOD_NO_ARGS(isTrap, ""), - METHOD_NO_ARGS(isFloat, ""), - METHOD_NO_ARGS(isDouble, ""), - METHOD_NO_ARGS(isUnsigned, ""), - METHOD_NO_ARGS(modifiesRt, ""), - METHOD_NO_ARGS(modifiesRd, ""), - METHOD_NO_ARGS(notEmitedByCompilers, ""), - METHOD_NO_ARGS(canBeHi, ""), - METHOD_NO_ARGS(canBeLo, ""), - METHOD_NO_ARGS(doesLink, ""), - METHOD_NO_ARGS(doesDereference, ""), - METHOD_NO_ARGS(doesLoad, ""), - METHOD_NO_ARGS(doesStore, ""), - METHOD_NO_ARGS(maybeIsMove, ""), - METHOD_NO_ARGS(isPseudo, ""), - // METHOD_NO_ARGS(getArchitectureVersion, ""), - - METHOD_ARGS(disassemble, "description"), - - METHOD_ARGS(__reduce__, ""), - - { 0 }, -}; - - -static PyObject *rabbitizer_type_Instruction_repr(PyRabbitizerInstruction *self) { - PyObject *ret; - size_t disasmBufferSize; - char *bufferStart; - char *buffer; - size_t typeNameLength; - size_t extraSize = 3 + 8 + 4; // "(0x" + 32bits hex + ") # " - int len; - - typeNameLength = strlen("rabbitizer.Instruction"); - - disasmBufferSize = RabbitizerInstruction_getSizeForBuffer(&self->instr, 0, 0); - - buffer = bufferStart = malloc(disasmBufferSize+1 + typeNameLength + extraSize); - if (buffer == NULL) { - // TODO: signal an exception? - return NULL; - } - - memcpy(buffer, "rabbitizer.Instruction", typeNameLength); - buffer += typeNameLength; - - len = sprintf(buffer, "(0x%08X) # ", RabbitizerInstruction_getRaw(&self->instr)); - if (len != 15) { - // bad stuff - // TODO: exception? - } - assert(len == 15); - buffer += len; - - RabbitizerInstruction_disassemble(&self->instr, buffer, NULL, 0, 0); - - ret = PyUnicode_FromString(bufferStart); - free(bufferStart); - return ret; -} - -static PyObject *rabbitizer_type_Instruction_str(PyRabbitizerInstruction *self) { - return rabbitizer_type_Instruction_disassemble(self, Py_BuildValue("()"), Py_BuildValue("{}")); -} - - -PyTypeObject rabbitizer_type_Instruction_TypeObject = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "rabbitizer.Instruction", - .tp_doc = PyDoc_STR("Instruction"), - .tp_basicsize = sizeof(PyRabbitizerInstruction), - .tp_itemsize = 0, - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .tp_new = PyType_GenericNew, - .tp_init = (initproc) rabbitizer_type_Instruction_init, - .tp_dealloc = (destructor) rabbitizer_type_Instruction_dealloc, - .tp_repr = (reprfunc) rabbitizer_type_Instruction_repr, - .tp_str = (reprfunc) rabbitizer_type_Instruction_str, - .tp_members = rabbitizer_type_Instruction_members, - .tp_methods = rabbitizer_type_Instruction_methods, - .tp_getset = rabbitizer_type_Instruction_getsetters, -}; diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_type_LoPairingInfo.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_type_LoPairingInfo.c deleted file mode 100644 index 5a9c62cf..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_type_LoPairingInfo.c +++ /dev/null @@ -1,50 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "rabbitizer_module.h" - - -static void rabbitizer_type_LoPairingInfo_dealloc(PyRabbitizerLoPairingInfo *self) { - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static int rabbitizer_type_LoPairingInfo_init(PyRabbitizerLoPairingInfo *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { NULL }; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "", kwlist)) { - return -1; - } - - RabbitizerLoPairingInfo_Init(&self->pairingInfo); - - return 0; -} - - -static PyMemberDef rabbitizer_type_LoPairingInfo_members[] = { - { "instrOffset", T_INT, offsetof(PyRabbitizerLoPairingInfo, pairingInfo.instrOffset), 0, "" }, - { "value", T_LONG, offsetof(PyRabbitizerLoPairingInfo, pairingInfo.value), 0, "" }, - { "shouldProcess", T_BOOL, offsetof(PyRabbitizerLoPairingInfo, pairingInfo.shouldProcess), 0, "" }, - { "isGpRel", T_BOOL, offsetof(PyRabbitizerLoPairingInfo, pairingInfo.isGpRel), 0, "" }, - { "isGpGot", T_BOOL, offsetof(PyRabbitizerLoPairingInfo, pairingInfo.isGpGot), 0, "" }, - - { 0 } -}; - - -PyTypeObject rabbitizer_type_LoPairingInfo_TypeObject = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "rabbitizer.LoPairingInfo", - .tp_doc = PyDoc_STR("LoPairingInfo"), - .tp_basicsize = sizeof(PyRabbitizerLoPairingInfo), - .tp_itemsize = 0, - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .tp_new = PyType_GenericNew, - .tp_init = (initproc) rabbitizer_type_LoPairingInfo_init, - .tp_dealloc = (destructor) rabbitizer_type_LoPairingInfo_dealloc, - // .tp_repr = (reprfunc) rabbitizer_type_LoPairingInfo_repr, - // .tp_str = (reprfunc) rabbitizer_type_LoPairingInfo_str, - .tp_members = rabbitizer_type_LoPairingInfo_members, - // .tp_methods = rabbitizer_type_Instr_methods, - // .tp_getset = Instr_getsetters, -}; diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_type_RegistersTracker.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_type_RegistersTracker.c deleted file mode 100644 index ec8f3642..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_type_RegistersTracker.c +++ /dev/null @@ -1,320 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "rabbitizer_module.h" - -#include "analysis/RabbitizerRegistersTracker.h" - - -typedef struct PyRabbitizerRegistersTracker { - PyObject_HEAD - RabbitizerRegistersTracker tracker; -} PyRabbitizerRegistersTracker; - - -static void rabbitizer_type_RegistersTracker_dealloc(PyRabbitizerRegistersTracker *self) { - RabbitizerRegistersTracker_destroy(&self->tracker); - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static int rabbitizer_type_RegistersTracker_init(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "other", NULL }; - PyRabbitizerRegistersTracker *pyOther = NULL; - RabbitizerRegistersTracker *other = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O!", kwlist, &rabbitizer_type_RegistersTracker_TypeObject, &pyOther)) { - return -1; - } - - if (pyOther != NULL) { - other = &pyOther->tracker; - } - - RabbitizerRegistersTracker_init(&self->tracker, other); - - return 0; -} - - -static PyObject *rabbitizer_type_RegistersTracker_moveRegisters(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", NULL }; - PyRabbitizerInstruction *instr; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr)) { - return NULL; - } - - if (RabbitizerRegistersTracker_moveRegisters(&self->tracker, &instr->instr)) { - Py_RETURN_TRUE; - } - Py_RETURN_FALSE; -} - -static PyObject *rabbitizer_type_RegistersTracker_overwriteRegisters(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", "instrOffset", NULL }; - PyRabbitizerInstruction *instr; - int instrOffset; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!i", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr, &instrOffset)) { - return NULL; - } - - RabbitizerRegistersTracker_overwriteRegisters(&self->tracker, &instr->instr, instrOffset); - - Py_RETURN_NONE; -} - -static PyObject *rabbitizer_type_RegistersTracker_unsetRegistersAfterFuncCall(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", "prevInstr", NULL }; - PyRabbitizerInstruction *instr; - PyRabbitizerInstruction *prevInstr; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr, &rabbitizer_type_Instruction_TypeObject, &prevInstr)) { - return NULL; - } - - RabbitizerRegistersTracker_unsetRegistersAfterFuncCall(&self->tracker, &instr->instr, &prevInstr->instr); - - Py_RETURN_NONE; -} - -static PyObject *rabbitizer_type_RegistersTracker_getAddressIfCanSetType(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", "instrOffset", NULL }; - PyRabbitizerInstruction *instr; - int instrOffset; - uint32_t dstAddress = 0; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!i", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr, &instrOffset)) { - return NULL; - } - - if (RabbitizerRegistersTracker_getAddressIfCanSetType(&self->tracker, &instr->instr, instrOffset, &dstAddress)) { - return PyLong_FromLong(dstAddress); - } - - Py_RETURN_NONE; -} - -static PyObject *rabbitizer_type_RegistersTracker_getJrInfo(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", NULL }; - PyRabbitizerInstruction *instr; - int dstOffset = 0; - uint32_t dstAddress = 0; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr)) { - return NULL; - } - - if (RabbitizerRegistersTracker_getJrInfo(&self->tracker, &instr->instr, &dstOffset, &dstAddress)) { - return PyTuple_Pack(2, PyLong_FromLong(dstOffset), PyLong_FromLong(dstAddress)); - } - - Py_RETURN_NONE; -} - -static PyObject *rabbitizer_type_RegistersTracker_processLui(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", "instrOffset", "prevInstr", NULL }; - PyRabbitizerInstruction *instr; - int instrOffset; - PyRabbitizerInstruction *pyPrevInstr = NULL; - RabbitizerInstruction *prevInstr = NULL; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!i|O!", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr, &instrOffset, &rabbitizer_type_Instruction_TypeObject, &pyPrevInstr)) { - return NULL; - } - - if (pyPrevInstr != NULL) { - prevInstr = &pyPrevInstr->instr; - } - - RabbitizerRegistersTracker_processLui(&self->tracker, &instr->instr, instrOffset, prevInstr); - - Py_RETURN_NONE; -} - -static PyObject *rabbitizer_type_RegistersTracker_processGpLoad(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", "instrOffset", NULL }; - PyRabbitizerInstruction *instr; - int instrOffset; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!i", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr, &instrOffset)) { - return NULL; - } - - RabbitizerRegistersTracker_processGpLoad(&self->tracker, &instr->instr, instrOffset); - - Py_RETURN_NONE; -} - -static PyObject *rabbitizer_type_RegistersTracker_getLuiOffsetForConstant(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", NULL }; - PyRabbitizerInstruction *instr; - int dstOffset = 0; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr)) { - return NULL; - } - - if (RabbitizerRegistersTracker_getLuiOffsetForConstant(&self->tracker, &instr->instr, &dstOffset)) { - return PyLong_FromLong(dstOffset); - } - - Py_RETURN_NONE; -} - -static PyObject *rabbitizer_type_RegistersTracker_processConstant(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", "value", "instrOffset", NULL }; - PyRabbitizerInstruction *instr; - uint32_t value; - int instrOffset; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!Ii", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr, &value, &instrOffset)) { - return NULL; - } - - RabbitizerRegistersTracker_processConstant(&self->tracker, &instr->instr, value, instrOffset); - - Py_RETURN_NONE; -} - -static PyObject *rabbitizer_type_RegistersTracker_getLuiOffsetForLo(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", "instrOffset", NULL }; - PyRabbitizerInstruction *instr; - int instrOffset; - int dstOffset = 0; - bool dstIsGp = false; - bool validResults = false; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!i", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr, &instrOffset)) { - return NULL; - } - - validResults = RabbitizerRegistersTracker_getLuiOffsetForLo(&self->tracker, &instr->instr, instrOffset, &dstOffset, &dstIsGp); - - return PyTuple_Pack(3, PyLong_FromLong(dstOffset), PyBool_FromLong(dstIsGp), PyBool_FromLong(validResults)); -} - -static PyObject *rabbitizer_type_RegistersTracker_preprocessLoAndGetInfo(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", "instrOffset", NULL }; - PyRabbitizerInstruction *instr; - int instrOffset; - PyRabbitizerLoPairingInfo *ret; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!i", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr, &instrOffset)) { - return NULL; - } - - ret = PyObject_CallObject((PyObject*)&rabbitizer_type_LoPairingInfo_TypeObject, NULL); - if (ret == NULL) { - PyErr_SetString(PyExc_RuntimeError, "Internal error: not able to instance LoPairingInfo object"); - return NULL; - } - - ret->pairingInfo = RabbitizerRegistersTracker_preprocessLoAndGetInfo(&self->tracker, &instr->instr, instrOffset); - - return ret; -} - -static PyObject *rabbitizer_type_RegistersTracker_processLo(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", "value", "instrOffset", NULL }; - PyRabbitizerInstruction *instr; - uint32_t value; - int instrOffset; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!Ii", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr, &value, &instrOffset)) { - return NULL; - } - - RabbitizerRegistersTracker_processLo(&self->tracker, &instr->instr, value, instrOffset); - - Py_RETURN_NONE; -} - -static PyObject *rabbitizer_type_RegistersTracker_hasLoButNoHi(PyRabbitizerRegistersTracker *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "instr", NULL }; - PyRabbitizerInstruction *instr; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!", kwlist, &rabbitizer_type_Instruction_TypeObject, &instr)) { - return NULL; - } - - if (RabbitizerRegistersTracker_hasLoButNoHi(&self->tracker, &instr->instr)) { - Py_RETURN_TRUE; - } - Py_RETURN_FALSE; -} - - -#define METHOD_NO_ARGS(name, docs) { #name, (PyCFunction)rabbitizer_type_RegistersTracker_##name, METH_NOARGS, PyDoc_STR(docs) } -#define METHOD_ARGS(name, docs) { #name, (PyCFunction)rabbitizer_type_RegistersTracker_##name, METH_VARARGS | METH_KEYWORDS, PyDoc_STR(docs) } - -static PyMethodDef rabbitizer_type_RegistersTracker_methods[] = { - METHOD_ARGS(moveRegisters, ""), - METHOD_ARGS(overwriteRegisters, ""), - METHOD_ARGS(unsetRegistersAfterFuncCall, ""), - METHOD_ARGS(getAddressIfCanSetType, ""), - METHOD_ARGS(getJrInfo, ""), - METHOD_ARGS(processLui, ""), - METHOD_ARGS(processGpLoad, ""), - METHOD_ARGS(getLuiOffsetForConstant, ""), - METHOD_ARGS(processConstant, ""), - METHOD_ARGS(getLuiOffsetForLo, ""), - METHOD_ARGS(preprocessLoAndGetInfo, ""), - METHOD_ARGS(processLo, ""), - METHOD_ARGS(hasLoButNoHi, ""), - - { 0 }, -}; - - -PyObject *rabbitizer_type_RegistersTracker___getitem__(PyRabbitizerRegistersTracker* self, Py_ssize_t index) { - RabbitizerTrackedRegisterState *state; - PyObject *args; - PyRabbitizerTrackedRegisterState *pyState; - - if (index < 0 || index >= ARRAY_COUNT(self->tracker.registers)) { - PyErr_SetString(PyExc_IndexError, "Index must be a value between 0 and 31"); - return NULL; - } - - state = &self->tracker.registers[index]; - - args = Py_BuildValue("(i)", state->registerNum); - if (args == NULL) { - PyErr_SetString(PyExc_RuntimeError, "Internal error: not able to instance TrackedRegisterState parameters"); - return NULL; - } - - pyState = PyObject_CallObject((PyObject*)&rabbitizer_type_TrackedRegisterState_TypeObject, args); - Py_DECREF(args); - if (pyState == NULL) { - PyErr_SetString(PyExc_RuntimeError, "Internal error: not able to instance TrackedRegisterState object"); - return NULL; - } - - RabbitizerTrackedRegisterState_copyState(&pyState->registerState, state); - return pyState; -} - - -static PySequenceMethods example_classSeqMethods = { - .sq_item = (ssizeargfunc)rabbitizer_type_RegistersTracker___getitem__, // sq_item -}; - - -PyTypeObject rabbitizer_type_RegistersTracker_TypeObject = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "rabbitizer.RegistersTracker", - .tp_doc = PyDoc_STR("RegistersTracker"), - .tp_basicsize = sizeof(PyRabbitizerRegistersTracker), - .tp_itemsize = 0, - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .tp_new = PyType_GenericNew, - .tp_init = (initproc) rabbitizer_type_RegistersTracker_init, - .tp_dealloc = (destructor) rabbitizer_type_RegistersTracker_dealloc, - // .tp_repr = (reprfunc) rabbitizer_type_RegistersTracker_repr, - .tp_as_sequence = &example_classSeqMethods, - // .tp_str = (reprfunc) rabbitizer_type_RegistersTracker_str, - .tp_methods = rabbitizer_type_RegistersTracker_methods, - // .tp_getset = rabbitizer_type_RegistersTracker_getsetters, -}; diff --git a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_type_TrackedRegisterState.c b/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_type_TrackedRegisterState.c deleted file mode 100644 index 1f52e4d0..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rabbitizer/rabbitizer_type_TrackedRegisterState.c +++ /dev/null @@ -1,102 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "rabbitizer_module.h" - - -static void rabbitizer_type_TrackedRegisterState_dealloc(PyRabbitizerTrackedRegisterState *self) { - RabbitizerTrackedRegisterState_destroy(&self->registerState); - Py_TYPE(self)->tp_free((PyObject *) self); -} - -static int rabbitizer_type_TrackedRegisterState_init(PyRabbitizerTrackedRegisterState *self, PyObject *args, PyObject *kwds) { - static char *kwlist[] = { "registerNum", NULL }; - int registerNum; - - if (!PyArg_ParseTupleAndKeywords(args, kwds, "i", kwlist, ®isterNum)) { - return -1; - } - - RabbitizerTrackedRegisterState_init(&self->registerState, registerNum); - - return 0; -} - - -#define DEF_MEMBER_GET_BOOL(name) \ - static PyObject *rabbitizer_type_TrackedRegisterState_member_get_##name(PyRabbitizerTrackedRegisterState *self, UNUSED PyObject *closure) { \ - if (self->registerState.name) { \ - Py_RETURN_TRUE; \ - } \ - Py_RETURN_FALSE; \ - } - -#define DEF_MEMBER_GET_INT(name) \ - static PyObject *rabbitizer_type_TrackedRegisterState_member_get_##name(PyRabbitizerTrackedRegisterState *self, UNUSED PyObject *closure) { \ - return PyLong_FromLong(self->registerState.name); \ - } - -#define DEF_MEMBER_GET_UINT(name) \ - static PyObject *rabbitizer_type_TrackedRegisterState_member_get_##name(PyRabbitizerTrackedRegisterState *self, UNUSED PyObject *closure) { \ - return PyLong_FromUnsignedLong(self->registerState.name); \ - } - - -DEF_MEMBER_GET_INT(registerNum) - -DEF_MEMBER_GET_BOOL(hasLuiValue) -DEF_MEMBER_GET_INT(luiOffset) -DEF_MEMBER_GET_BOOL(luiSetOnBranchLikely) - -DEF_MEMBER_GET_BOOL(hasGpGot) -DEF_MEMBER_GET_INT(gpGotOffset) - -DEF_MEMBER_GET_BOOL(hasLoValue) -DEF_MEMBER_GET_INT(loOffset) -DEF_MEMBER_GET_BOOL(dereferenced) -DEF_MEMBER_GET_INT(dereferenceOffset) - -DEF_MEMBER_GET_UINT(value) - - -#define MEMBER_GET(name, docs, closure) { #name, (getter) rabbitizer_type_TrackedRegisterState_member_get_##name, (setter) NULL, PyDoc_STR(docs), closure } -#define MEMBER_SET(name, docs, closure) { #name, (getter) NULL, (setter) rabbitizer_type_TrackedRegisterState_member_set_##name, PyDoc_STR(docs), closure } -#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 } - - -static PyGetSetDef rabbitizer_type_TrackedRegisterState_getsetters[] = { - MEMBER_GET(registerNum, "", NULL), - - MEMBER_GET(hasLuiValue, "", NULL), - MEMBER_GET(luiOffset, "", NULL), - MEMBER_GET(luiSetOnBranchLikely, "", NULL), - - MEMBER_GET(hasGpGot, "", NULL), - MEMBER_GET(gpGotOffset, "", NULL), - - MEMBER_GET(hasLoValue, "", NULL), - MEMBER_GET(loOffset, "", NULL), - MEMBER_GET(dereferenced, "", NULL), - MEMBER_GET(dereferenceOffset, "", NULL), - - MEMBER_GET(value, "", NULL), - - { 0 } -}; - - -PyTypeObject rabbitizer_type_TrackedRegisterState_TypeObject = { - PyVarObject_HEAD_INIT(NULL, 0) - .tp_name = "rabbitizer.TrackedRegisterState", - .tp_doc = PyDoc_STR("TrackedRegisterState"), - .tp_basicsize = sizeof(PyRabbitizerTrackedRegisterState), - .tp_itemsize = 0, - .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, - .tp_new = PyType_GenericNew, - .tp_init = (initproc) rabbitizer_type_TrackedRegisterState_init, - .tp_dealloc = (destructor) rabbitizer_type_TrackedRegisterState_dealloc, - // .tp_repr = (reprfunc) rabbitizer_type_TrackedRegisterState_repr, - // .tp_str = (reprfunc) rabbitizer_type_TrackedRegisterState_str, - // .tp_methods = rabbitizer_type_TrackedRegisterState_methods, - .tp_getset = rabbitizer_type_TrackedRegisterState_getsetters, -}; diff --git a/tools/ido-static-recomp/tools/rabbitizer/registersTrackerTest.c b/tools/ido-static-recomp/tools/rabbitizer/registersTrackerTest.c deleted file mode 100644 index 5aef0f83..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/registersTrackerTest.c +++ /dev/null @@ -1,41 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstruction.h" -#include "analysis/RabbitizerRegistersTracker.h" - - -int main() { - RabbitizerRegistersTracker regsTracker; - RabbitizerInstruction instr; - uint32_t word = 0x002D0821; // addu $at, $at, $t5 - uint32_t vram = 0x0042F170; - int instrOffset = 220; - - RabbitizerRegistersTracker_init(®sTracker, NULL); - - RabbitizerInstruction_init(&instr, word, vram); - RabbitizerInstruction_processUniqueId(&instr); - - regsTracker.registers[1] = (RabbitizerTrackedRegisterState){ - .dereferenceOffset = 212, - .dereferenced = true, - .gpGotOffset = 212, - .hasGpGot = true, - .hasLoValue = true, - .hasLuiValue = false, - .loOffset = 212, - .luiOffset = 0, - .luiSetOnBranchLikely = false, - .value = 0x10010000, - .registerNum = regsTracker.registers[1].registerNum, - }; - - RabbitizerRegistersTracker_overwriteRegisters(®sTracker, &instr, instrOffset); - - RabbitizerInstruction_destroy(&instr); - - RabbitizerRegistersTracker_destroy(®sTracker); - - return 0; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/rsptest.c b/tools/ido-static-recomp/tools/rabbitizer/rsptest.c deleted file mode 100644 index 7aa04eef..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/rsptest.c +++ /dev/null @@ -1,44 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstructionRsp.h" - -#include -#include -#include -#include - - -int main() { - uint32_t word; - RabbitizerInstruction instr; - char *buffer; - int extraLJust = 5; - uint32_t validbits; - - //word = 0x4B01C8E8; // vand $v3, $v25, $v1[0] - word = 0x48952000; // mtc2 $21, $v4[0] - - RabbitizerInstructionRsp_init(&instr, word, 0x80000000); - - RabbitizerInstructionRsp_processUniqueId(&instr); - - buffer = malloc(RabbitizerInstruction_getSizeForBuffer(&instr, 0, extraLJust) + 1); - assert(buffer != NULL); - - RabbitizerInstruction_disassemble(&instr, buffer, NULL, 0, extraLJust); - - printf("%08X: %s\n", word, buffer); - - validbits = RabbitizerInstruction_getValidBits(&instr); - - printf("word: %08X\n", instr.word); - printf("mandatory bits: %08X\n", instr._mandatorybits); - printf("valid bits: %08X\n", validbits); - printf("invalid bits: %08X\n", (~validbits) & instr.word); - - free(buffer); - RabbitizerInstructionRsp_destroy(&instr); - - return 0; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/setup.cfg b/tools/ido-static-recomp/tools/rabbitizer/setup.cfg deleted file mode 100644 index e2bd449e..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/setup.cfg +++ /dev/null @@ -1,24 +0,0 @@ -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -[metadata] -name = rabbitizer -# Version should be synced with include/common/RabbitizerVersion.h -version = 1.2.3 -author = Decompollaborate -license = MIT -description = MIPS instruction decoder -url = https://github.com/Decompollaborate/rabbitizer -project_urls = - Source = https://github.com/Decompollaborate/rabbitizer - Bug Tracker = https://github.com/Decompollaborate/rabbitizer/issues -long_description = file: README.md -long_description_content_type = text/markdown - -[options] -packages = rabbitizer - -[options.package_data] -rabbitizer = - **/*.pyi - **/py.typed diff --git a/tools/ido-static-recomp/tools/rabbitizer/setup.py b/tools/ido-static-recomp/tools/rabbitizer/setup.py deleted file mode 100644 index 2e048e69..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/setup.py +++ /dev/null @@ -1,28 +0,0 @@ -# SPDX-FileCopyrightText: © 2022 Decompollaborate -# SPDX-License-Identifier: MIT - -from setuptools import setup, Extension - - -setup( - ext_modules=[ - Extension( - name="rabbitizer", - sources=["rabbitizer/rabbitizer_module.c", "rabbitizer/rabbitizer_submodule_Utils.c", "rabbitizer/rabbitizer_type_Instruction.c", "rabbitizer/rabbitizer_global_config.c", "rabbitizer/rabbitizer_type_TrackedRegisterState.c", "rabbitizer/rabbitizer_type_RegistersTracker.c", "rabbitizer/rabbitizer_type_LoPairingInfo.c", - "rabbitizer/enums/rabbitizer_type_Enum.c", "rabbitizer/enums/enums_utils.c", "rabbitizer/enums/rabbitizer_enum_InstrCategory.c", "rabbitizer/enums/rabbitizer_enum_InstrId.c", "rabbitizer/enums/rabbitizer_enum_Abi.c", - "rabbitizer/enums/registers/rabbitizer_enum_GprO32.c", "rabbitizer/enums/registers/rabbitizer_enum_GprN32.c", - "src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction_ProcessUniqueId.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction.c", "src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c", - "src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c", "src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_ProcessUniqueId.c", - "src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c", "src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c", - "src/instructions/RabbitizerInstrDescriptor.c", "src/instructions/RabbitizerInstrId.c", "src/instructions/RabbitizerRegister.c", "src/instructions/RabbitizerInstrSuffix.c", - "src/analysis/RabbitizerTrackedRegisterState.c", "src/analysis/RabbitizerRegistersTracker.c", "src/analysis/RabbitizerLoPairingInfo.c", - "src/common/Utils.c", "src/common/RabbitizerVersion.c", "src/common/RabbitizerConfig.c"], - include_dirs=["include", "rabbitizer"], - extra_compile_args = [ - "-std=c11", - "-Wall", - "-g", - ], - ), - ], -) diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/analysis/RabbitizerLoPairingInfo.c b/tools/ido-static-recomp/tools/rabbitizer/src/analysis/RabbitizerLoPairingInfo.c deleted file mode 100644 index 0b4dc795..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/analysis/RabbitizerLoPairingInfo.c +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "analysis/RabbitizerLoPairingInfo.h" - -void RabbitizerLoPairingInfo_Init(RabbitizerLoPairingInfo *self) { - *self = (RabbitizerLoPairingInfo){ - .instrOffset = 0, - .value = 0, - .shouldProcess = false, - .isGpRel = false, - .isGpGot = false, - }; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/analysis/RabbitizerRegistersTracker.c b/tools/ido-static-recomp/tools/rabbitizer/src/analysis/RabbitizerRegistersTracker.c deleted file mode 100644 index 82913688..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/analysis/RabbitizerRegistersTracker.c +++ /dev/null @@ -1,425 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "analysis/RabbitizerRegistersTracker.h" - -#include - -#include "common/Utils.h" -#include "common/RabbitizerConfig.h" -#include "instructions/RabbitizerRegister.h" - -// TODO: abi checks - -void RabbitizerRegistersTracker_init(RabbitizerRegistersTracker *self, const RabbitizerRegistersTracker *other) { - size_t i; - - for (i = 0; i < ARRAY_COUNT(self->registers); i++) { - RabbitizerTrackedRegisterState_init(&self->registers[i], i); - if (other != NULL) { - RabbitizerTrackedRegisterState_copyState(&self->registers[i], &other->registers[i]); - } - } -} - -void RabbitizerRegistersTracker_destroy(RabbitizerRegistersTracker *self) { - for (size_t i = 0; i < ARRAY_COUNT(self->registers); i++) { - RabbitizerTrackedRegisterState_destroy(&self->registers[i]); - } -} - -// TODO: simplify logic -bool RabbitizerRegistersTracker_moveRegisters(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr) { - RabbitizerTrackedRegisterState *dstState; - RabbitizerTrackedRegisterState *srcState; - uint8_t reg; - uint8_t rd = RAB_INSTR_GET_rd(instr); - uint8_t rs = RAB_INSTR_GET_rs(instr); - uint8_t rt = RAB_INSTR_GET_rt(instr); - - if (!RabbitizerInstrDescriptor_maybeIsMove(instr->descriptor)) { - return false; - } - if (rt == 0 && rs == 0) { - // ? - // RabbitizerTrackedRegisterState_clear(dstState); - return false; - } - - if (rt == 0) { - reg = rs; - } else if (rs == 0) { - reg = rt; - } else { - if (RabbitizerTrackedRegisterState_hasAnyValue(&self->registers[rs]) && !RabbitizerTrackedRegisterState_hasAnyValue(&self->registers[rt])) { - reg = rs; - } else if (RabbitizerTrackedRegisterState_hasAnyValue(&self->registers[rt]) && !RabbitizerTrackedRegisterState_hasAnyValue(&self->registers[rs])) { - reg = rt; - } else if (rd == rs) { // Check stuff like `addu $3, $3, $2` - reg = rt; - if (self->registers[rs].hasLuiValue || self->registers[rs].hasGpGot) { - reg = rs; - } - } else if (rd == rt) { - reg = rs; - if (self->registers[rt].hasLuiValue || self->registers[rt].hasGpGot) { - reg = rt; - } - } else { - // ? - // RabbitizerTrackedRegisterState_clear(dstState); - return false; - } - - srcState = &self->registers[reg]; - RabbitizerTrackedRegisterState_copyState(&self->registers[rd], srcState); - return true; - } - - srcState = &self->registers[reg]; - dstState = &self->registers[rd]; - - if (RabbitizerTrackedRegisterState_hasAnyValue(srcState)) { - RabbitizerTrackedRegisterState_copyState(dstState, srcState); - return true; - } - - RabbitizerTrackedRegisterState_clear(dstState); - return false; -} - -void RabbitizerRegistersTracker_overwriteRegisters(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset) { - bool shouldRemove = false; - uint8_t reg = 0; - RabbitizerTrackedRegisterState *state = NULL; - - if (RabbitizerRegistersTracker_moveRegisters(self, instr)) { - return; - } - - if (RabbitizerInstrDescriptor_isFloat(instr->descriptor)) { - switch (instr->uniqueId) { - case RABBITIZER_INSTR_ID_cpu_mtc1: - case RABBITIZER_INSTR_ID_cpu_dmtc1: - case RABBITIZER_INSTR_ID_cpu_ctc1: - // IDO usually use a reg as a temp when loading a constant value - // into the float coprocessor, after that IDO never re-uses the value - // in that reg for anything else - shouldRemove = true; - reg = RAB_INSTR_GET_rt(instr); - break; - - default: - break; - } - } else if (RabbitizerInstrDescriptor_isRType(instr->descriptor) || - (RabbitizerInstrDescriptor_isBranch(instr->descriptor) && RabbitizerInstrDescriptor_isIType(instr->descriptor))) { - // $at usually is a one-use reg - uint8_t at = 0; - - if (RAB_INSTR_GET_rs(instr) == 1) { - at = RAB_INSTR_GET_rs(instr); - } else if (RAB_INSTR_GET_rt(instr) == 1) { - at = RAB_INSTR_GET_rt(instr); - } - - state = &self->registers[at]; - if (state->hasLoValue || state->hasLuiValue || state->hasGpGot) { - shouldRemove = true; - reg = at; - } - } - - if (RabbitizerInstrDescriptor_modifiesRt(instr->descriptor)) { - shouldRemove = true; - reg = RAB_INSTR_GET_rt(instr); - if (RabbitizerInstrDescriptor_canBeHi(instr->descriptor)) { - RabbitizerTrackedRegisterState_clearLo(&self->registers[RAB_INSTR_GET_rt(instr)]); - shouldRemove = false; - } - } - if (RabbitizerInstrDescriptor_modifiesRd(instr->descriptor)) { - shouldRemove = true; - reg = RAB_INSTR_GET_rd(instr); - } - - if (shouldRemove) { - state = &self->registers[reg]; -#if 0 - if (state->hasLuiValue) { - self->_printDebugInfo_clearRegister(instr, reg) - } -#endif - - RabbitizerTrackedRegisterState_clearHi(state); - if (!RabbitizerTrackedRegisterState_wasSetInCurrentOffset(state, instrOffset)) { - RabbitizerTrackedRegisterState_clearGp(state); - RabbitizerTrackedRegisterState_clearLo(state); - } - } -} - -void RabbitizerRegistersTracker_unsetRegistersAfterFuncCall(RabbitizerRegistersTracker *self, UNUSED const RabbitizerInstruction *instr, - const RabbitizerInstruction *prevInstr) { - RabbitizerTrackedRegisterState *state = NULL; - - if (!RabbitizerInstrDescriptor_doesLink(prevInstr->descriptor)) { - return; - } - - if (RabbitizerConfig_Cfg.regNames.gprAbiNames == RABBITIZER_ABI_O32 || RabbitizerConfig_Cfg.regNames.gprAbiNames == RABBITIZER_ABI_NUMERIC) { - for (size_t reg = 0; reg < ARRAY_COUNT(self->registers); reg++) { - switch (reg) { - case RABBITIZER_REG_GPR_O32_at: - case RABBITIZER_REG_GPR_O32_v0: - case RABBITIZER_REG_GPR_O32_v1: - case RABBITIZER_REG_GPR_O32_a0: - case RABBITIZER_REG_GPR_O32_a1: - case RABBITIZER_REG_GPR_O32_a2: - case RABBITIZER_REG_GPR_O32_a3: - case RABBITIZER_REG_GPR_O32_t0: - case RABBITIZER_REG_GPR_O32_t1: - case RABBITIZER_REG_GPR_O32_t2: - case RABBITIZER_REG_GPR_O32_t3: - case RABBITIZER_REG_GPR_O32_t4: - case RABBITIZER_REG_GPR_O32_t5: - case RABBITIZER_REG_GPR_O32_t6: - case RABBITIZER_REG_GPR_O32_t7: - case RABBITIZER_REG_GPR_O32_t8: - case RABBITIZER_REG_GPR_O32_t9: - case RABBITIZER_REG_GPR_O32_ra: - state = &self->registers[reg]; -#if 0 - if (state.hasLuiValue) { - self->_printDebugInfo_clearRegister(instr, reg) - } -#endif - RabbitizerTrackedRegisterState_clear(state); - break; - - default: - break; - } - } - } else if (RabbitizerConfig_Cfg.regNames.gprAbiNames == RABBITIZER_ABI_N32 || RabbitizerConfig_Cfg.regNames.gprAbiNames == RABBITIZER_ABI_N64) { - for (size_t reg = 0; reg < ARRAY_COUNT(self->registers); reg++) { - switch (reg) { - case RABBITIZER_REG_GPR_N32_at: - case RABBITIZER_REG_GPR_N32_v0: - case RABBITIZER_REG_GPR_N32_v1: - case RABBITIZER_REG_GPR_N32_a0: - case RABBITIZER_REG_GPR_N32_a1: - case RABBITIZER_REG_GPR_N32_a2: - case RABBITIZER_REG_GPR_N32_a3: - case RABBITIZER_REG_GPR_N32_a4: - case RABBITIZER_REG_GPR_N32_a5: - case RABBITIZER_REG_GPR_N32_a6: - case RABBITIZER_REG_GPR_N32_a7: - case RABBITIZER_REG_GPR_N32_t0: - case RABBITIZER_REG_GPR_N32_t1: - case RABBITIZER_REG_GPR_N32_t2: - case RABBITIZER_REG_GPR_N32_t3: - case RABBITIZER_REG_GPR_N32_t8: - case RABBITIZER_REG_GPR_N32_t9: - case RABBITIZER_REG_GPR_N32_ra: - state = &self->registers[reg]; -#if 0 - if (state.hasLuiValue) { - self->_printDebugInfo_clearRegister(instr, reg) - } -#endif - RabbitizerTrackedRegisterState_clear(state); - break; - - default: - break; - } - } - } -} - -bool RabbitizerRegistersTracker_getAddressIfCanSetType(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset, - uint32_t *dstAddress) { - const RabbitizerTrackedRegisterState *state = &self->registers[RAB_INSTR_GET_rs(instr)]; - - if (!state->hasLoValue) { - return false; - } - - if (!state->dereferenced || instrOffset == state->dereferenceOffset) { - *dstAddress = state->value; - return true; - } - - return false; -} - -bool RabbitizerRegistersTracker_getJrInfo(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int *dstOffset, uint32_t *dstAddress) { - const RabbitizerTrackedRegisterState *state = &self->registers[RAB_INSTR_GET_rs(instr)]; - - if (!state->hasLoValue || !state->dereferenced) { - return false; - } - - *dstOffset = state->loOffset; - *dstAddress = state->value; - return true; -} - -// prevInstr can be NULL -void RabbitizerRegistersTracker_processLui(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset, - const RabbitizerInstruction *prevInstr) { - RabbitizerTrackedRegisterState *state = NULL; - - assert(RabbitizerInstrDescriptor_canBeHi(instr->descriptor)); - - state = &self->registers[RAB_INSTR_GET_rt(instr)]; - RabbitizerTrackedRegisterState_clear(state); - RabbitizerTrackedRegisterState_setHi(state, RabbitizerInstruction_getImmediate(instr), instrOffset); - - if (prevInstr != NULL) { - // If the previous instructions is a branch likely, then nulify - // the effects of this instruction for future analysis - state->luiSetOnBranchLikely = RabbitizerInstrDescriptor_isBranchLikely(prevInstr->descriptor) || RabbitizerInstruction_isUnconditionalBranch(prevInstr); - } -} - -void RabbitizerRegistersTracker_processGpLoad(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset) { - RabbitizerTrackedRegisterState *state = NULL; - - assert(RabbitizerInstrDescriptor_canBeLo(instr->descriptor)); - - state = &self->registers[RAB_INSTR_GET_rt(instr)]; - - RabbitizerTrackedRegisterState_clear(state); - RabbitizerTrackedRegisterState_setGpLoad(state, RabbitizerInstruction_getImmediate(instr), instrOffset); -} - -bool RabbitizerRegistersTracker_getLuiOffsetForConstant(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int *dstOffset) { - const RabbitizerTrackedRegisterState *state = &self->registers[RAB_INSTR_GET_rs(instr)]; - - if (!state->hasLuiValue) { - return false; - } - - *dstOffset = state->luiOffset; - return true; -} - -void RabbitizerRegistersTracker_processConstant(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, uint32_t value, int offset) { - RabbitizerTrackedRegisterState *stateDst = &self->registers[RAB_INSTR_GET_rt(instr)]; - - RabbitizerTrackedRegisterState_setLo(stateDst, value, offset); -} - -// TODO: this function should not be changing the state of the tracker -bool RabbitizerRegistersTracker_getLuiOffsetForLo(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, int instrOffset, int *dstOffset, - bool *dstIsGp) { - const RabbitizerTrackedRegisterState *state = &self->registers[RAB_INSTR_GET_rs(instr)]; - - if (state->hasLuiValue && !state->luiSetOnBranchLikely) { - *dstOffset = state->luiOffset; - *dstIsGp = false; - return true; - } - - // TODO: abi - if (RAB_INSTR_GET_rs(instr) == 28) { // $gp - *dstOffset = 0; - *dstIsGp = true; - return true; - } - - if (RabbitizerInstrDescriptor_modifiesRt(instr->descriptor) && RabbitizerInstrDescriptor_doesDereference(instr->descriptor)) { - if (state->hasLoValue && !state->dereferenced) { - // Simulate a dereference - RabbitizerTrackedRegisterState_dereferenceState(&self->registers[RAB_INSTR_GET_rt(instr)], state, instrOffset); - } - } - - return false; -} - -RabbitizerLoPairingInfo RabbitizerRegistersTracker_preprocessLoAndGetInfo(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, - int instrOffset) { - const RabbitizerTrackedRegisterState *state = &self->registers[RAB_INSTR_GET_rs(instr)]; - RabbitizerLoPairingInfo pairingInfo; - - RabbitizerLoPairingInfo_Init(&pairingInfo); - - if (state->hasLuiValue && !state->luiSetOnBranchLikely) { - pairingInfo.instrOffset = state->luiOffset; - pairingInfo.value = state->value; - pairingInfo.shouldProcess = true; - return pairingInfo; - } - - if ((RAB_INSTR_GET_rs(instr) == RABBITIZER_REG_GPR_O32_gp) || (RAB_INSTR_GET_rs(instr) == RABBITIZER_REG_GPR_N32_gp)) { - pairingInfo.value = state->value; - pairingInfo.isGpRel = true; - pairingInfo.shouldProcess = true; - return pairingInfo; - } - - if (state->hasGpGot) { - pairingInfo.instrOffset = state->gpGotOffset; - pairingInfo.value = state->value; - pairingInfo.shouldProcess = true; - pairingInfo.isGpGot = true; - return pairingInfo; - } - - if (RabbitizerInstrDescriptor_modifiesRt(instr->descriptor) && RabbitizerInstrDescriptor_doesDereference(instr->descriptor)) { - if (state->hasLoValue && !state->dereferenced) { - // Simulate a dereference - RabbitizerTrackedRegisterState_dereferenceState(&self->registers[RAB_INSTR_GET_rt(instr)], state, instrOffset); - } - } - - return pairingInfo; -} - -void RabbitizerRegistersTracker_processLo(RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr, uint32_t value, int offset) { - RabbitizerTrackedRegisterState *stateDst; - - if (!RabbitizerInstrDescriptor_modifiesRt(instr->descriptor)) { - return; - } - - stateDst = &self->registers[RAB_INSTR_GET_rt(instr)]; - RabbitizerTrackedRegisterState_setLo(stateDst, value, offset); - if (RabbitizerInstrDescriptor_doesDereference(instr->descriptor)) { - RabbitizerTrackedRegisterState_deref(stateDst, offset); - } - if (RAB_INSTR_GET_rt(instr) == RAB_INSTR_GET_rs(instr)) { - RabbitizerTrackedRegisterState_clearHi(stateDst); - RabbitizerTrackedRegisterState_clearGp(stateDst); - } -} - -bool RabbitizerRegistersTracker_hasLoButNoHi(const RabbitizerRegistersTracker *self, const RabbitizerInstruction *instr) { - const RabbitizerTrackedRegisterState *state; - - assert(instr != NULL); - - state = &self->registers[RAB_INSTR_GET_rs(instr)]; - return state->hasLoValue && !state->hasLuiValue; -} - -#if 0 -def _printDebugInfo_clearRegister(self, instr: rabbitizer.Instruction, reg: int, currentVram: int|None=None) -> None: - if not common.GlobalConfig.PRINT_SYMBOL_FINDER_DEBUG_INFO: - return - - if currentVram is None: - return - - print("Clearing reg:") - // print() - print(f"vram: {currentVram:X}") - print(instr) - print(self->registers) - // TODO - // print(f"deleting {reg} / {instr->getRegisterName(reg)}") - print() -#endif diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/analysis/RabbitizerTrackedRegisterState.c b/tools/ido-static-recomp/tools/rabbitizer/src/analysis/RabbitizerTrackedRegisterState.c deleted file mode 100644 index 91298945..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/analysis/RabbitizerTrackedRegisterState.c +++ /dev/null @@ -1,142 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "analysis/RabbitizerTrackedRegisterState.h" - -#include - -#include "common/Utils.h" -#include "instructions/RabbitizerRegister.h" - -void RabbitizerTrackedRegisterState_init(RabbitizerTrackedRegisterState *self, int registerNum) { - self->registerNum = registerNum; - - self->hasLuiValue = false; - self->luiOffset = 0; - self->luiSetOnBranchLikely = false; - - self->hasGpGot = false; - self->gpGotOffset = 0; - - self->hasLoValue = false; - self->loOffset = 0; - self->dereferenced = false; - self->dereferenceOffset = 0; - - self->value = 0; -} - -void RabbitizerTrackedRegisterState_destroy(UNUSED RabbitizerTrackedRegisterState *self) { -} - -void RabbitizerTrackedRegisterState_clear(RabbitizerTrackedRegisterState *self) { - self->hasLuiValue = false; - self->luiOffset = 0; - self->luiSetOnBranchLikely = false; - - self->hasGpGot = false; - self->gpGotOffset = 0; - - self->hasLoValue = false; - self->loOffset = 0; - self->dereferenced = false; - self->dereferenceOffset = 0; - self->value = 0; -} - -void RabbitizerTrackedRegisterState_clearHi(RabbitizerTrackedRegisterState *self) { - self->hasLuiValue = false; - self->luiOffset = 0; - self->luiSetOnBranchLikely = false; -} - -void RabbitizerTrackedRegisterState_clearGp(RabbitizerTrackedRegisterState *self) { - self->hasGpGot = false; - self->gpGotOffset = 0; -} - -void RabbitizerTrackedRegisterState_clearLo(RabbitizerTrackedRegisterState *self) { - self->hasLoValue = false; - self->loOffset = 0; - self->dereferenced = false; - self->dereferenceOffset = 0; -} - -void RabbitizerTrackedRegisterState_copyState(RabbitizerTrackedRegisterState *self, const RabbitizerTrackedRegisterState *other) { - self->hasLuiValue = other->hasLuiValue; - self->luiOffset = other->luiOffset; - self->luiSetOnBranchLikely = other->luiSetOnBranchLikely; - - self->hasGpGot = other->hasGpGot; - self->gpGotOffset = other->gpGotOffset; - - self->hasLoValue = other->hasLoValue; - self->loOffset = other->loOffset; - self->dereferenced = other->dereferenced; - self->dereferenceOffset = other->dereferenceOffset; - - self->value = other->value; -} - -void RabbitizerTrackedRegisterState_setHi(RabbitizerTrackedRegisterState *self, uint32_t value, int offset) { - assert(!self->hasGpGot); - - self->hasLuiValue = true; - self->luiOffset = offset; - self->value = value << 16; -} - -void RabbitizerTrackedRegisterState_setGpLoad(RabbitizerTrackedRegisterState *self, uint32_t value, int offset) { - assert(!self->hasLuiValue); - - self->hasGpGot = true; - self->gpGotOffset = offset; - self->value = value; -} - -void RabbitizerTrackedRegisterState_setLo(RabbitizerTrackedRegisterState *self, uint32_t value, int offset) { - self->value = value; - self->loOffset = offset; - self->hasLoValue = true; - self->dereferenced = false; - self->dereferenceOffset = 0; -} - -void RabbitizerTrackedRegisterState_deref(RabbitizerTrackedRegisterState *self, int offset) { - self->dereferenced = true; - self->dereferenceOffset = offset; -} - -void RabbitizerTrackedRegisterState_dereferenceState(RabbitizerTrackedRegisterState *self, const RabbitizerTrackedRegisterState *other, int offset) { - assert(other->hasLoValue); - assert(!other->dereferenced); - - RabbitizerTrackedRegisterState_copyState(self, other); - RabbitizerTrackedRegisterState_deref(self, offset); -} - -bool RabbitizerTrackedRegisterState_hasAnyValue(const RabbitizerTrackedRegisterState *self) { - return self->hasLuiValue || self->hasLoValue || self->hasGpGot; -} - -bool RabbitizerTrackedRegisterState_wasSetInCurrentOffset(const RabbitizerTrackedRegisterState *self, int offset) { - return self->loOffset == offset || self->dereferenceOffset == offset; -} - -void RabbitizerTrackedRegisterState_fprint(const RabbitizerTrackedRegisterState *self, FILE *outFile) { - fprintf(outFile, "TrackedRegisterState(%i / %s)\n", self->registerNum, RabbitizerRegister_getNameGpr(self->registerNum)); - - fprintf(outFile, " hasLuiValue: %s\n", self->hasLuiValue ? "true" : "false"); - fprintf(outFile, " luiOffset: 0x%X\n", self->luiOffset); - fprintf(outFile, " luiSetOnBranchLikely: %s\n", self->luiSetOnBranchLikely ? "true" : "false"); - - fprintf(outFile, " hasGpGot: %s\n", self->hasGpGot ? "true" : "false"); - fprintf(outFile, " gpGotOffset: 0x%X\n", self->gpGotOffset); - - fprintf(outFile, " hasLoValue: %s\n", self->hasLoValue ? "true" : "false"); - fprintf(outFile, " loOffset: %X\n", self->loOffset); - fprintf(outFile, " dereferenced: %s\n", self->dereferenced ? "true" : "false"); - fprintf(outFile, " dereferenceOffset: %X\n", self->dereferenceOffset); - - fprintf(outFile, " value: %X\n", self->value); -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/common/RabbitizerConfig.c b/tools/ido-static-recomp/tools/rabbitizer/src/common/RabbitizerConfig.c deleted file mode 100644 index 88b554db..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/common/RabbitizerConfig.c +++ /dev/null @@ -1,50 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "common/RabbitizerConfig.h" - -#include - -RabbitizerAbi RabbitizerAbi_fromStr(const char *name) { - if (name == NULL || strcmp(name, "32") == 0 || strcmp(name, "o32") == 0 || strcmp(name, "O32") == 0) { - return RABBITIZER_ABI_O32; - } - if (strcmp(name, "n32") == 0 || strcmp(name, "N32") == 0) { - return RABBITIZER_ABI_N32; - } - if (strcmp(name, "64") == 0 || strcmp(name, "n64") == 0 || strcmp(name, "N64") == 0) { - return RABBITIZER_ABI_N64; - } - return RABBITIZER_ABI_NUMERIC; -} - -RabbitizerConfig RabbitizerConfig_Cfg = { - .regNames = { - .namedRegisters = true, - .gprAbiNames = RABBITIZER_ABI_O32, - .fprAbiNames = RABBITIZER_ABI_NUMERIC, - .userFpcCsr = true, - .vr4300Cop0NamedRegisters = true, - .vr4300RspCop0NamedRegisters = true, - }, - .pseudos = { - .enablePseudos = true, - .pseudoBeqz = true, - .pseudoBnez = true, - .pseudoB = true, - .pseudoMove = true, - .pseudoNot = true, - .pseudoNegu = true, - .pseudoBal = true, - }, - .toolchainTweaks = { - .treatJAsUnconditionalBranch = false, - .sn64DivFix = false, - }, - .misc = { - .opcodeLJust = 7+4, - .unknownInstrComment = true, - .omit0XOnSmallImm = false, - .upperCaseImm = true, - } -}; diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/common/RabbitizerVersion.c b/tools/ido-static-recomp/tools/rabbitizer/src/common/RabbitizerVersion.c deleted file mode 100644 index f700fbfe..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/common/RabbitizerVersion.c +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "common/RabbitizerVersion.h" - -const int RabVersion_Major = RAB_VERSION_MAJOR; -const int RabVersion_Minor = RAB_VERSION_MINOR; -const int RabVersion_Patch = RAB_VERSION_PATCH; - -const char RabVersion_Str[] = RAB_VERSION_STR; diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/common/Utils.c b/tools/ido-static-recomp/tools/rabbitizer/src/common/Utils.c deleted file mode 100644 index 7dd02622..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/common/Utils.c +++ /dev/null @@ -1,78 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "common/Utils.h" - -#include -#include - -int32_t RabbitizerUtils_From2Complement(uint32_t number, int bits) { - bool isNegative = number & (1ULL << (bits - 1)); - - if (isNegative) { - return -((~number + 1) & ((1ULL << bits) - 1)); - } - - return number; -} - -size_t RabbitizerUtils_CharFill(char *dst, int count, char fillchar) { - if (count <= 0) { - return 0; - } - - memset(dst, fillchar, count); - - return count; -} - -size_t RabbitizerUtils_escapeString(char *dst, size_t dstSize, const char *src, size_t srcSize) { - size_t srcPos = 0; - size_t dstpos = 0; - - for (; srcPos < srcSize && dstpos < dstSize; srcPos++, src++) { - // The cases of this switch are sorted by ASCII order - switch (*src) { - case '\a': - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, 'a'); - break; - - case '\t': - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, 't'); - break; - - case '\n': - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, 'n'); - break; - - case '\f': - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, 'f'); - break; - - case '\r': - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, 'r'); - break; - - case '"': - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '"'); - break; - - case '\\': - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, '\\'); - break; - - default: - RABUTILS_BUFFER_WRITE_CHAR(dst, dstpos, *src); - break; - } - } - - return dstpos; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstrDescriptor.c b/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstrDescriptor.c deleted file mode 100644 index a6e143f9..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstrDescriptor.c +++ /dev/null @@ -1,104 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstrDescriptor.h" - -#include "instructions/RabbitizerInstruction.h" - -#define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) [RABBITIZER_INSTR_ID_##prefix##_##name] = { __VA_ARGS__ }, - -#define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, __VA_ARGS__) - -const RabbitizerInstrDescriptor RabbitizerInstrDescriptor_Descriptors[] = { -#include "instructions/instr_id/RabbitizerInstrId_cpu.inc" -#include "instructions/instr_id/RabbitizerInstrId_rsp.inc" -#include "instructions/instr_id/RabbitizerInstrId_r5900.inc" -}; - -#undef RABBITIZER_DEF_INSTR_ID -#undef RABBITIZER_DEF_INSTR_ID_ALTNAME - -bool RabbitizerInstrDescriptor_isUnknownType(const RabbitizerInstrDescriptor *self) { - return self->instrType == RABBITIZER_INSTR_TYPE_UNKNOWN; -} -bool RabbitizerInstrDescriptor_isJType(const RabbitizerInstrDescriptor *self) { - return self->instrType == RABBITIZER_INSTR_TYPE_J; -} -bool RabbitizerInstrDescriptor_isIType(const RabbitizerInstrDescriptor *self) { - return self->instrType == RABBITIZER_INSTR_TYPE_I; -} -bool RabbitizerInstrDescriptor_isRType(const RabbitizerInstrDescriptor *self) { - return self->instrType == RABBITIZER_INSTR_TYPE_R; -} -bool RabbitizerInstrDescriptor_isRegimmType(const RabbitizerInstrDescriptor *self) { - return self->instrType == RABBITIZER_INSTR_TYPE_REGIMM; -} - -RabbitizerInstrSuffix RabbitizerInstrDescriptor_instrSuffix(const RabbitizerInstrDescriptor *self) { - return self->instrSuffix; -} - -bool RabbitizerInstrDescriptor_isBranch(const RabbitizerInstrDescriptor *self) { - return self->isBranch; -} -bool RabbitizerInstrDescriptor_isBranchLikely(const RabbitizerInstrDescriptor *self) { - return self->isBranchLikely; -} -bool RabbitizerInstrDescriptor_isJump(const RabbitizerInstrDescriptor *self) { - return self->isJump; -} -bool RabbitizerInstrDescriptor_isTrap(const RabbitizerInstrDescriptor *self) { - return self->isTrap; -} - -bool RabbitizerInstrDescriptor_isFloat(const RabbitizerInstrDescriptor *self) { - return self->isFloat; -} -bool RabbitizerInstrDescriptor_isDouble(const RabbitizerInstrDescriptor *self) { - return self->isDouble; -} - -bool RabbitizerInstrDescriptor_isUnsigned(const RabbitizerInstrDescriptor *self) { - return self->isUnsigned; -} - -bool RabbitizerInstrDescriptor_modifiesRt(const RabbitizerInstrDescriptor *self) { - return self->modifiesRt; -} -bool RabbitizerInstrDescriptor_modifiesRd(const RabbitizerInstrDescriptor *self) { - return self->modifiesRd; -} - -bool RabbitizerInstrDescriptor_notEmitedByCompilers(const RabbitizerInstrDescriptor *self) { - return self->notEmitedByCompilers; -} - -bool RabbitizerInstrDescriptor_canBeHi(const RabbitizerInstrDescriptor *self) { - return self->canBeHi; -} -bool RabbitizerInstrDescriptor_canBeLo(const RabbitizerInstrDescriptor *self) { - return self->canBeLo; -} -bool RabbitizerInstrDescriptor_doesLink(const RabbitizerInstrDescriptor *self) { - return self->doesLink; -} -bool RabbitizerInstrDescriptor_doesDereference(const RabbitizerInstrDescriptor *self) { - return self->doesDereference; -} -bool RabbitizerInstrDescriptor_doesLoad(const RabbitizerInstrDescriptor *self) { - return self->doesLoad; -} -bool RabbitizerInstrDescriptor_doesStore(const RabbitizerInstrDescriptor *self) { - return self->doesStore; -} -bool RabbitizerInstrDescriptor_maybeIsMove(const RabbitizerInstrDescriptor *self) { - return self->maybeIsMove; -} - -bool RabbitizerInstrDescriptor_isPseudo(const RabbitizerInstrDescriptor *self) { - return self->isPseudo; -} - -RabbitizerArchitectureVersion RabbitizerInstrDescriptor_getArchitectureVersion(const RabbitizerInstrDescriptor *self) { - return self->architectureVersion; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstrId.c b/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstrId.c deleted file mode 100644 index b8643314..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstrId.c +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstrId.h" - -#include - -#define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) [RABBITIZER_INSTR_ID_##prefix##_##name] = #name, - -#define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) [RABBITIZER_INSTR_ID_##prefix##_##name] = #altname, - -const char *RabbitizerInstrId_Names[] = { -#include "instructions/instr_id/RabbitizerInstrId_cpu.inc" -#include "instructions/instr_id/RabbitizerInstrId_rsp.inc" -#include "instructions/instr_id/RabbitizerInstrId_r5900.inc" -}; - -#undef RABBITIZER_DEF_INSTR_ID -#undef RABBITIZER_DEF_INSTR_ID_ALTNAME - -const char *RabbitizerInstrId_getOpcodeName(RabbitizerInstrId uniqueId) { - assert(uniqueId >= RABBITIZER_INSTR_ID_cpu_INVALID && uniqueId < RABBITIZER_INSTR_ID_ALL_MAX); - assert(uniqueId != RABBITIZER_INSTR_ID_cpu_MAX); - assert(uniqueId != RABBITIZER_INSTR_ID_rsp_MAX); - assert(uniqueId != RABBITIZER_INSTR_ID_r5900_MAX); - - return RabbitizerInstrId_Names[uniqueId]; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstrSuffix.c b/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstrSuffix.c deleted file mode 100644 index cef16b30..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstrSuffix.c +++ /dev/null @@ -1,62 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstrSuffix.h" - -#include - -#include "common/Utils.h" -#include "instructions/RabbitizerInstruction.h" -#include "instructions/RabbitizerInstructionRsp.h" -#include "instructions/RabbitizerInstructionR5900.h" - -typedef size_t (*InstrSuffixCallback)(const RabbitizerInstruction *self, char *dst); - -size_t RabbitizerInstrSuffix_None(UNUSED const RabbitizerInstruction *self, UNUSED char *dst) { - return 0; -} - -size_t RabbitizerInstrSuffixR5900_xyzw(const RabbitizerInstruction *self, char *dst) { - size_t totalSize = 0; - - 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)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '.'); - } - - if (RAB_INSTR_R5900_GET_xyzw_x(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x'); - } - if (RAB_INSTR_R5900_GET_xyzw_y(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y'); - } - if (RAB_INSTR_R5900_GET_xyzw_z(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z'); - } - if (RAB_INSTR_R5900_GET_xyzw_w(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w'); - } - - return totalSize; -} -const InstrSuffixCallback instrSuffixCallbacks[] = { - [RABINSTRSUFFIX_NONE] = RabbitizerInstrSuffix_None, - - [RABINSTRSUFFIX_R5900_xyzw] = RabbitizerInstrSuffixR5900_xyzw, -}; - -size_t RabbitizerInstrSuffix_getSizeForBuffer(UNUSED const RabbitizerInstruction *self, UNUSED RabbitizerInstrSuffix instrSuffix) { - // Just hardcode the size of the bigger possible suffix, faster than actually computing it. - return 5; -} - -size_t RabbitizerInstrSuffix_processSuffix(const RabbitizerInstruction *self, char *dst, RabbitizerInstrSuffix instrSuffix) { - InstrSuffixCallback callback; - - assert(instrSuffix >= RABINSTRSUFFIX_NONE); - assert(instrSuffix < RABINSTRSUFFIX_MAX); - - callback = instrSuffixCallbacks[instrSuffix]; - assert(callback != NULL); - - return callback(self, dst); -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c b/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c deleted file mode 100644 index 5e0bf056..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction.c +++ /dev/null @@ -1,368 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstruction.h" - -#include - -#include "common/RabbitizerConfig.h" -#include "instructions/RabbitizerRegister.h" -#include "instructions/RabbitizerInstructionRsp.h" -#include "instructions/RabbitizerInstructionR5900.h" - -void RabbitizerInstruction_init(RabbitizerInstruction *self, uint32_t word, uint32_t vram) { - self->word = word; - self->_mandatorybits = 0; - - self->uniqueId = RABBITIZER_INSTR_ID_cpu_INVALID; - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; - - self->vram = vram; - self->_handwrittenCategory = false; - self->inHandwrittenFunction = false; - self->category = RABBITIZER_INSTRCAT_CPU; -} - -void RabbitizerInstruction_destroy(UNUSED RabbitizerInstruction *self) { -} - -/* General getters */ - -uint32_t RabbitizerInstruction_getRaw(const RabbitizerInstruction *self) { - return self->word; -} - -uint32_t RabbitizerInstruction_getImmediate(const RabbitizerInstruction *self) { - return RAB_INSTR_GET_immediate(self); -} -int32_t RabbitizerInstruction_getProcessedImmediate(const RabbitizerInstruction *self) { - if (RabbitizerInstrDescriptor_isUnsigned(self->descriptor)) { - return RAB_INSTR_GET_immediate(self); - } - return RabbitizerUtils_From2Complement(RAB_INSTR_GET_immediate(self), 16); -} - -uint32_t RabbitizerInstruction_getInstrIndex(const RabbitizerInstruction *self) { - return RAB_INSTR_GET_instr_index(self); -} - -uint32_t RabbitizerInstruction_getInstrIndexAsVram(const RabbitizerInstruction *self) { - uint32_t vram = RabbitizerInstruction_getInstrIndex(self) << 2; - - if (self->vram == 0) { - vram |= 0x80000000; - } else { - // Jumps are PC-region branches. The upper bits are filled with the address in the delay slot - vram |= (self->vram + 4) & 0xFF000000; - } - return vram; -} - -int32_t RabbitizerInstruction_getBranchOffset(const RabbitizerInstruction *self) { - int32_t diff = RabbitizerUtils_From2Complement(RabbitizerInstruction_getImmediate(self), 16); - - return diff * 4 + 4; -} - -int32_t RabbitizerInstruction_getGenericBranchOffset(const RabbitizerInstruction *self, uint32_t currentVram) { - if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_j) { - return RabbitizerInstruction_getInstrIndexAsVram(self) - currentVram; - } - return RabbitizerInstruction_getBranchOffset(self); -} - -/* General getters */ - -void RabbitizerInstruction_blankOut(RabbitizerInstruction *self) { - size_t i; - - for (i = 0; i < ARRAY_COUNT(self->descriptor->operands) && self->descriptor->operands[i] != RAB_OPERAND_ALL_INVALID; i++) { - switch (self->descriptor->operands[i]) { - case RAB_OPERAND_cpu_rs: - self->word = RAB_INSTR_PACK_rs(self->word, 0); - break; - - case RAB_OPERAND_cpu_rt: - self->word = RAB_INSTR_PACK_rt(self->word, 0); - break; - - case RAB_OPERAND_cpu_rd: - self->word = RAB_INSTR_PACK_rd(self->word, 0); - break; - - case RAB_OPERAND_cpu_sa: - self->word = RAB_INSTR_PACK_sa(self->word, 0); - break; - - case RAB_OPERAND_cpu_zero: - break; - - case RAB_OPERAND_cpu_cop0d: - self->word = RAB_INSTR_PACK_cop0d(self->word, 0); - break; - - case RAB_OPERAND_cpu_fs: - self->word = RAB_INSTR_PACK_fs(self->word, 0); - break; - - case RAB_OPERAND_cpu_ft: - self->word = RAB_INSTR_PACK_ft(self->word, 0); - break; - - case RAB_OPERAND_cpu_fd: - self->word = RAB_INSTR_PACK_fd(self->word, 0); - break; - - case RAB_OPERAND_cpu_cop1cs: - self->word = RAB_INSTR_PACK_cop1cs(self->word, 0); - break; - - case RAB_OPERAND_cpu_cop2t: - self->word = RAB_INSTR_PACK_cop2t(self->word, 0); - break; - - case RAB_OPERAND_cpu_op: - self->word = RAB_INSTR_PACK_op(self->word, 0); - break; - - case RAB_OPERAND_cpu_code: - self->word = RAB_INSTR_PACK_code(self->word, 0); - break; - - case RAB_OPERAND_cpu_code_lower: - self->word = RAB_INSTR_PACK_code_lower(self->word, 0); - break; - - case RAB_OPERAND_cpu_copraw: - self->word = RAB_INSTR_PACK_copraw(self->word, 0); - break; - - case RAB_OPERAND_cpu_label: - self->word = RAB_INSTR_PACK_instr_index(self->word, 0); - break; - - case RAB_OPERAND_cpu_immediate: - self->word = RAB_INSTR_PACK_immediate(self->word, 0); - break; - - case RAB_OPERAND_cpu_branch_target_label: - self->word = RAB_INSTR_PACK_immediate(self->word, 0); - break; - - case RAB_OPERAND_cpu_immediate_base: - self->word = RAB_INSTR_PACK_rs(self->word, 0); - self->word = RAB_INSTR_PACK_immediate(self->word, 0); - break; - - /* rsp */ - case RAB_OPERAND_rsp_rs: - self->word = RAB_INSTR_PACK_rs(self->word, 0); - break; - - case RAB_OPERAND_rsp_rt: - self->word = RAB_INSTR_PACK_rt(self->word, 0); - break; - - case RAB_OPERAND_rsp_rd: - self->word = RAB_INSTR_PACK_rd(self->word, 0); - break; - - case RAB_OPERAND_rsp_cop0d: - self->word = RAB_INSTR_PACK_cop0d(self->word, 0); - break; - - case RAB_OPERAND_rsp_cop2t: - self->word = RAB_INSTR_RSP_PACK_cop2t(self->word, 0); - break; - - case RAB_OPERAND_rsp_cop2cd: - self->word = RAB_INSTR_RSP_PACK_cop2cd(self->word, 0); - break; - - case RAB_OPERAND_rsp_vs: - self->word = RAB_INSTR_RSP_PACK_vs(self->word, 0); - break; - - case RAB_OPERAND_rsp_vt: - self->word = RAB_INSTR_RSP_PACK_vt(self->word, 0); - break; - - case RAB_OPERAND_rsp_vd: - self->word = RAB_INSTR_RSP_PACK_vd(self->word, 0); - break; - - case RAB_OPERAND_rsp_vt_elementhigh: - self->word = RAB_INSTR_RSP_PACK_vt(self->word, 0); - self->word = RAB_INSTR_RSP_PACK_elementhigh(self->word, 0); - break; - - case RAB_OPERAND_rsp_vt_elementlow: - self->word = RAB_INSTR_RSP_PACK_vt(self->word, 0); - self->word = RAB_INSTR_RSP_PACK_elementlow(self->word, 0); - break; - - case RAB_OPERAND_rsp_vd_de: - self->word = RAB_INSTR_RSP_PACK_vd(self->word, 0); - self->word = RAB_INSTR_RSP_PACK_de(self->word, 0); - break; - - case RAB_OPERAND_rsp_vs_index: - self->word = RAB_INSTR_RSP_PACK_vs(self->word, 0); - self->word = RAB_INSTR_RSP_PACK_index(self->word, 0); - break; - - case RAB_OPERAND_rsp_offset_rs: - self->word = RAB_INSTR_RSP_PACK_offset(self->word, 0); - self->word = RAB_INSTR_PACK_rs(self->word, 0); - break; - - case RAB_OPERAND_rsp_immediate_base: - self->word = RAB_INSTR_PACK_rs(self->word, 0); - self->word = RAB_INSTR_PACK_immediate(self->word, 0); - break; - /* rsp */ - - /* r5900 */ - case RAB_OPERAND_r5900_I: - case RAB_OPERAND_r5900_Q: - case RAB_OPERAND_r5900_R: - case RAB_OPERAND_r5900_ACC: - // Not real registers encoded on the instruction itself - break; - - case RAB_OPERAND_r5900_ACCxyzw: - self->word = RAB_INSTR_R5900_PACK_xyzw_x(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_y(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_z(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_w(self->word, 0); - break; - - case RAB_OPERAND_r5900_vfs: - self->word = RAB_INSTR_R5900_PACK_vfs(self->word, 0); - break; - - case RAB_OPERAND_r5900_vft: - self->word = RAB_INSTR_R5900_PACK_vft(self->word, 0); - break; - - case RAB_OPERAND_r5900_vfd: - self->word = RAB_INSTR_R5900_PACK_vfd(self->word, 0); - break; - - case RAB_OPERAND_r5900_vfsxyzw: - self->word = RAB_INSTR_R5900_PACK_vfs(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_x(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_y(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_z(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_w(self->word, 0); - break; - - case RAB_OPERAND_r5900_vftxyzw: - self->word = RAB_INSTR_R5900_PACK_vft(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_x(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_y(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_z(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_w(self->word, 0); - break; - - case RAB_OPERAND_r5900_vfdxyzw: - self->word = RAB_INSTR_R5900_PACK_vfd(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_x(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_y(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_z(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_xyzw_w(self->word, 0); - break; - - case RAB_OPERAND_r5900_vfsn: - self->word = RAB_INSTR_R5900_PACK_vfs(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_n(self->word, 0); - break; - - case RAB_OPERAND_r5900_vftn: - self->word = RAB_INSTR_R5900_PACK_vft(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_n(self->word, 0); - break; - - case RAB_OPERAND_r5900_vfdn: - self->word = RAB_INSTR_R5900_PACK_vfd(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_n(self->word, 0); - break; - - case RAB_OPERAND_r5900_vfsl: - self->word = RAB_INSTR_R5900_PACK_vfs(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_l(self->word, 0); - break; - - case RAB_OPERAND_r5900_vftl: - self->word = RAB_INSTR_R5900_PACK_vft(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_l(self->word, 0); - break; - - case RAB_OPERAND_r5900_vfdl: - self->word = RAB_INSTR_R5900_PACK_vfd(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_l(self->word, 0); - break; - - case RAB_OPERAND_r5900_vfsm: - self->word = RAB_INSTR_R5900_PACK_vfs(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_m(self->word, 0); - break; - - case RAB_OPERAND_r5900_vftm: - self->word = RAB_INSTR_R5900_PACK_vft(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_m(self->word, 0); - break; - - case RAB_OPERAND_r5900_vfdm: - self->word = RAB_INSTR_R5900_PACK_vfd(self->word, 0); - self->word = RAB_INSTR_R5900_PACK_m(self->word, 0); - break; - - case RAB_OPERAND_r5900_vis: - self->word = RAB_INSTR_R5900_PACK_vis(self->word, 0); - break; - - case RAB_OPERAND_r5900_vit: - self->word = RAB_INSTR_R5900_PACK_vit(self->word, 0); - break; - - case RAB_OPERAND_r5900_vid: - self->word = RAB_INSTR_R5900_PACK_vid(self->word, 0); - break; - - case RAB_OPERAND_r5900_vis_predecr: - self->word = RAB_INSTR_R5900_PACK_vis(self->word, 0); - break; - - case RAB_OPERAND_r5900_vit_predecr: - self->word = RAB_INSTR_R5900_PACK_vit(self->word, 0); - break; - - case RAB_OPERAND_r5900_vid_predecr: - self->word = RAB_INSTR_R5900_PACK_vid(self->word, 0); - break; - - case RAB_OPERAND_r5900_vis_postincr: - self->word = RAB_INSTR_R5900_PACK_vis(self->word, 0); - break; - - case RAB_OPERAND_r5900_vit_postincr: - self->word = RAB_INSTR_R5900_PACK_vit(self->word, 0); - break; - - case RAB_OPERAND_r5900_vid_postincr: - self->word = RAB_INSTR_R5900_PACK_vid(self->word, 0); - break; - - case RAB_OPERAND_r5900_immediate5: - self->word = RAB_INSTR_R5900_PACK_imm5(self->word, 0); - break; - /* r5900 */ - - case RAB_OPERAND_ALL_INVALID: - case RAB_OPERAND_ALL_MAX: - assert(self->descriptor->operands[i] != RAB_OPERAND_ALL_INVALID && self->descriptor->operands[i] != RAB_OPERAND_ALL_MAX); - break; - } - } -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c b/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c deleted file mode 100644 index 3f94401c..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Disassemble.c +++ /dev/null @@ -1,986 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstruction.h" -#include "instructions/RabbitizerInstructionRsp.h" -#include "instructions/RabbitizerInstructionR5900.h" - -#include -#include -#include - -#include "common/Utils.h" -#include "common/RabbitizerConfig.h" -#include "instructions/RabbitizerRegister.h" -#include "instructions/RabbitizerInstrSuffix.h" - -typedef size_t (*OperandCallback)(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength); - -size_t RabbitizerOperandType_process_cpu_rs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameGpr(RAB_INSTR_GET_rs(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_rt(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameGpr(RAB_INSTR_GET_rt(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_rd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameGpr(RAB_INSTR_GET_rd(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_zero(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, - UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameGpr(0); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_cop0d(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameCop0(RAB_INSTR_GET_cop0d(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_fs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameCop1(RAB_INSTR_GET_fs(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_ft(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameCop1(RAB_INSTR_GET_ft(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_fd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameCop1(RAB_INSTR_GET_fd(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_cop1cs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameCop1Control(RAB_INSTR_GET_cop1cs(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_cop2t(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameCop2(RAB_INSTR_GET_cop2t(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_sa(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - -// TODO: consider making this a proper configuration -#if 0 - if (RAB_INSTR_GET_sa(self) < 10) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", RAB_INSTR_GET_sa(self)); - } else { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", RAB_INSTR_GET_sa(self)); - } -#endif - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", RAB_INSTR_GET_sa(self)); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_op(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - -// TODO: consider making this a proper configuration -#if 0 - if (RAB_INSTR_GET_op(self) < 10) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", RAB_INSTR_GET_op(self)); - } else { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", RAB_INSTR_GET_op(self)); - } -#endif - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%02X", RAB_INSTR_GET_op(self)); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_code(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - int code = RAB_INSTR_GET_code_upper(self); - int lower = RAB_INSTR_GET_code_lower(self); - - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", code); - if (lower) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, ", %i", lower); - } - - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_code_lower(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, - UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - int code_lower = RAB_INSTR_GET_code_lower(self); - - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", code_lower); - - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_copraw(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", RAB_INSTR_GET_copraw(self)); - - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_label(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - if ((immOverride != NULL) && (immOverrideLength > 0)) { - memcpy(dst, immOverride, immOverrideLength); - return immOverrideLength; - } - - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "func_%06X", RabbitizerInstruction_getInstrIndexAsVram(self)); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_immediate(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - int32_t number; - - if ((immOverride != NULL) && (immOverrideLength > 0)) { - memcpy(dst, immOverride, immOverrideLength); - return immOverrideLength; - } - - number = RabbitizerInstruction_getProcessedImmediate(self); - if (RabbitizerConfig_Cfg.misc.omit0XOnSmallImm) { - if (number > -10 && number < 10) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", number); - return totalSize; - } - } - if (number < 0) { - if (RabbitizerConfig_Cfg.misc.upperCaseImm) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%X", -number); - } else { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%x", -number); - } - } else { - if (RabbitizerConfig_Cfg.misc.upperCaseImm) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", number); - } else { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", number); - } - } - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_branch_target_label(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - if ((immOverride != NULL) && (immOverrideLength > 0)) { - memcpy(dst, immOverride, immOverrideLength); - return immOverrideLength; - } - - RABUTILS_BUFFER_CPY(dst, totalSize, ". + 4 + ("); - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, NULL, 0)); - RABUTILS_BUFFER_CPY(dst, totalSize, " << 2)"); - return totalSize; -} - -size_t RabbitizerOperandType_process_cpu_immediate_base(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - -// TODO: consider making this a proper configuration -#if 0 - if ((immOverride != NULL) && (immOverrideLength > 0) || RAB_INSTR_GET_immediate(self) != 0) { - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, immOverride, immOverrideLength)); - } -#endif - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, immOverride, immOverrideLength)); - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '('); - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_rs(self, dst, immOverride, immOverrideLength)); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')'); - - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_rs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameRspGpr(RAB_INSTR_GET_rs(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_rt(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameRspGpr(RAB_INSTR_GET_rt(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_rd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameRspGpr(RAB_INSTR_GET_rd(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_cop0d(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameRspCop0(RAB_INSTR_GET_cop0d(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_cop2t(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameRspCop2(RAB_INSTR_RSP_GET_cop2t(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_cop2cd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameRspCop2Control(RAB_INSTR_RSP_GET_cop2cd(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_vs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameRspVector(RAB_INSTR_RSP_GET_vs(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_vt(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameRspVector(RAB_INSTR_RSP_GET_vt(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_vd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameRspVector(RAB_INSTR_RSP_GET_vd(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_vt_elementhigh(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - uint8_t element; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_vt(self, dst, immOverride, immOverrideLength)); - - element = RAB_INSTR_RSP_GET_elementhigh(self); - if (element != 0) { - if ((element & 0x8) == 0x8) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", element & 7); - } else if ((element & 0xC) == 0x4) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%ih]", element & (~0xC)); - } else if ((element & 0xE) == 0x2) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%iq]", element & (~0xE)); - } else { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", element); - } - } - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_vt_elementlow(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_vt(self, dst, immOverride, immOverrideLength)); - - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", RAB_INSTR_RSP_GET_elementlow(self)); - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_vd_de(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - uint8_t de; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_vd(self, dst, immOverride, immOverrideLength)); - - de = RAB_INSTR_RSP_GET_de(self); - if ((de & 0x8) == 0x8) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", de & (~0x8)); - } else if ((de & 0xC) == 0x4) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%ih]", de & (~0xC)); - } else if ((de & 0xE) == 0x2) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%iq]", de & (~0xE)); - } else { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", de); - } - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_vs_index(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_vs(self, dst, immOverride, immOverrideLength)); - - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "[%i]", RAB_INSTR_RSP_GET_index(self)); - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_offset_rs(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", RabbitizerInstructionRsp_GetOffsetVector(self)); - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '('); - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_rs(self, dst, immOverride, immOverrideLength)); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')'); - return totalSize; -} - -size_t RabbitizerOperandType_process_rsp_immediate_base(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - -// TODO: consider making this a proper configuration -#if 0 - if ((immOverride != NULL) && (immOverrideLength > 0) || RAB_INSTR_GET_immediate(self) != 0) { - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, immOverride, immOverrideLength)); - } -#endif - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_cpu_immediate(self, dst, immOverride, immOverrideLength)); - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '('); - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_rsp_rs(self, dst, immOverride, immOverrideLength)); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')'); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_I(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, - UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_CPY(dst, totalSize, "$I"); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_Q(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, - UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_CPY(dst, totalSize, "$Q"); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_R(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, - UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_CPY(dst, totalSize, "$R"); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_ACC(UNUSED const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, - UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_CPY(dst, totalSize, "$ACC"); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_ACCxyzw(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_ACC(self, dst, immOverride, immOverrideLength)); - -#if 0 - if (RAB_INSTR_R5900_GET_xyzw_x(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x'); - } - if (RAB_INSTR_R5900_GET_xyzw_y(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y'); - } - if (RAB_INSTR_R5900_GET_xyzw_z(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z'); - } - if (RAB_INSTR_R5900_GET_xyzw_w(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w'); - } -#endif - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vfs(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameR5900VF(RAB_INSTR_R5900_GET_vfs(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vft(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameR5900VF(RAB_INSTR_R5900_GET_vft(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vfd(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameR5900VF(RAB_INSTR_R5900_GET_vfd(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vfsxyzw(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfs(self, dst, immOverride, immOverrideLength)); - -#if 0 - if (RAB_INSTR_R5900_GET_xyzw_x(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x'); - } - if (RAB_INSTR_R5900_GET_xyzw_y(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y'); - } - if (RAB_INSTR_R5900_GET_xyzw_z(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z'); - } - if (RAB_INSTR_R5900_GET_xyzw_w(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w'); - } -#endif - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vftxyzw(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vft(self, dst, immOverride, immOverrideLength)); - -#if 0 - if (RAB_INSTR_R5900_GET_xyzw_x(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x'); - } - if (RAB_INSTR_R5900_GET_xyzw_y(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y'); - } - if (RAB_INSTR_R5900_GET_xyzw_z(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z'); - } - if (RAB_INSTR_R5900_GET_xyzw_w(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w'); - } -#endif - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vfdxyzw(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfd(self, dst, immOverride, immOverrideLength)); - -#if 0 - if (RAB_INSTR_R5900_GET_xyzw_x(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'x'); - } - if (RAB_INSTR_R5900_GET_xyzw_y(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'y'); - } - if (RAB_INSTR_R5900_GET_xyzw_z(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'z'); - } - if (RAB_INSTR_R5900_GET_xyzw_w(self)) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, 'w'); - } -#endif - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vfsn(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - uint8_t n; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfs(self, dst, immOverride, immOverrideLength)); - - n = RAB_INSTR_R5900_GET_n(self); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vftn(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - uint8_t n; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vft(self, dst, immOverride, immOverrideLength)); - - n = RAB_INSTR_R5900_GET_n(self); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vfdn(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - uint8_t n; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfd(self, dst, immOverride, immOverrideLength)); - - n = RAB_INSTR_R5900_GET_n(self); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vfsl(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - uint8_t n; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfs(self, dst, immOverride, immOverrideLength)); - - n = RAB_INSTR_R5900_GET_l(self); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vftl(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - uint8_t n; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vft(self, dst, immOverride, immOverrideLength)); - - n = RAB_INSTR_R5900_GET_l(self); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vfdl(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - uint8_t n; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfd(self, dst, immOverride, immOverrideLength)); - - n = RAB_INSTR_R5900_GET_l(self); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vfsm(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - uint8_t n; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfs(self, dst, immOverride, immOverrideLength)); - - n = RAB_INSTR_R5900_GET_m(self); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vftm(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - uint8_t n; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vft(self, dst, immOverride, immOverrideLength)); - - n = RAB_INSTR_R5900_GET_m(self); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vfdm(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - uint8_t n; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vfd(self, dst, immOverride, immOverrideLength)); - - n = RAB_INSTR_R5900_GET_m(self); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, "xyzw"[n]); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vis(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameR5900VI(RAB_INSTR_R5900_GET_vis(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vit(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameR5900VI(RAB_INSTR_R5900_GET_vit(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vid(const RabbitizerInstruction *self, char *dst, UNUSED const char *immOverride, UNUSED size_t immOverrideLength) { - size_t totalSize = 0; - const char *reg = RabbitizerRegister_getNameR5900VI(RAB_INSTR_R5900_GET_vid(self)); - - RABUTILS_BUFFER_CPY(dst, totalSize, reg); - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vis_predecr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '('); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-'); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-'); - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vis(self, dst, immOverride, immOverrideLength)); - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')'); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vit_predecr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '('); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-'); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-'); - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vit(self, dst, immOverride, immOverrideLength)); - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')'); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vid_predecr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '('); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-'); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '-'); - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vid(self, dst, immOverride, immOverrideLength)); - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')'); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vis_postincr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '('); - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vis(self, dst, immOverride, immOverrideLength)); - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+'); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+'); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')'); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vit_postincr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '('); - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vit(self, dst, immOverride, immOverrideLength)); - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+'); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+'); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')'); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_vid_postincr(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '('); - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerOperandType_process_r5900_vid(self, dst, immOverride, immOverrideLength)); - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+'); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '+'); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ')'); - - return totalSize; -} - -size_t RabbitizerOperandType_process_r5900_immediate5(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - int32_t number; - - if ((immOverride != NULL) && (immOverrideLength > 0)) { - memcpy(dst, immOverride, immOverrideLength); - return immOverrideLength; - } - - number = RAB_INSTR_R5900_GET_imm5(self); - if (RabbitizerConfig_Cfg.misc.omit0XOnSmallImm) { - if (number > -10 && number < 10) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "%i", number); - return totalSize; - } - } - if (number < 0) { - if (RabbitizerConfig_Cfg.misc.upperCaseImm) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%X", -number); - } else { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "-0x%x", -number); - } - } else { - if (RabbitizerConfig_Cfg.misc.upperCaseImm) { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%X", number); - } else { - RABUTILS_BUFFER_SPRINTF(dst, totalSize, "0x%x", number); - } - } - return totalSize; -} - -#define RAB_DEF_OPERAND(prefix, operand) [RAB_OPERAND_##prefix##_##operand] = RabbitizerOperandType_process_##prefix##_##operand, - -const OperandCallback instrOpercandCallbacks[] = { -#include "instructions/operands/RabbitizerOperandType_cpu.inc" -#include "instructions/operands/RabbitizerOperandType_rsp.inc" -#include "instructions/operands/RabbitizerOperandType_r5900.inc" -}; - -#undef RAB_DEF_OPERAND - -size_t RabbitizerInstruction_getSizeForBufferOperandsDisasm(const RabbitizerInstruction *self, size_t immOverrideLength) { - size_t totalSize = 0; - char auxBuffer[0x100] = { 0 }; - char immOverride[0x100] = { 0 }; - - for (size_t i = 0; i < ARRAY_COUNT(self->descriptor->operands) && self->descriptor->operands[i] != RAB_OPERAND_ALL_INVALID; i++) { - RabbitizerOperandType operand; - OperandCallback callback; - - if (i != 0) { - totalSize += 2; - } - - operand = self->descriptor->operands[i]; - assert(operand > RAB_OPERAND_ALL_INVALID); - assert(operand < RAB_OPERAND_ALL_MAX); - - callback = instrOpercandCallbacks[operand]; - assert(callback != NULL); - totalSize += callback(self, auxBuffer, immOverride, immOverrideLength); - } - - return totalSize; -} - -size_t RabbitizerInstruction_disassembleOperands(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength) { - size_t totalSize = 0; - - for (size_t i = 0; i < ARRAY_COUNT(self->descriptor->operands) && self->descriptor->operands[i] != RAB_OPERAND_ALL_INVALID; i++) { - RabbitizerOperandType operand; - OperandCallback callback; - - if (i != 0) { - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ','); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ' '); - } - - operand = self->descriptor->operands[i]; - assert(operand > RAB_OPERAND_ALL_INVALID); - assert(operand < RAB_OPERAND_ALL_MAX); - - callback = instrOpercandCallbacks[operand]; - assert(callback != NULL); - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, callback(self, dst, immOverride, immOverrideLength)); - } - - *dst = '\0'; - return totalSize; -} - -size_t RabbitizerInstruction_getSizeForBufferInstrDisasm(const RabbitizerInstruction *self, size_t immOverrideLength, int extraLJust) { - size_t totalSize = 0; - size_t opcodeNameLength; - - opcodeNameLength = strlen(RabbitizerInstrId_getOpcodeName(self->uniqueId)); - - totalSize += opcodeNameLength; - - totalSize += RabbitizerInstrSuffix_getSizeForBuffer(self, self->descriptor->instrSuffix); - - if (self->descriptor->operands[0] == RAB_OPERAND_ALL_INVALID) { - // There are no operands - return totalSize; - } - - if (RabbitizerConfig_Cfg.misc.opcodeLJust > 0) { - totalSize += RabbitizerConfig_Cfg.misc.opcodeLJust; - } - if (extraLJust > 0) { - totalSize += extraLJust; - } - totalSize++; - - totalSize += RabbitizerInstruction_getSizeForBufferOperandsDisasm(self, immOverrideLength); - - return totalSize; -} - -size_t RabbitizerInstruction_disassembleInstruction(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength, - int extraLJust) { - size_t totalSize = 0; - const char *opcodeName = RabbitizerInstrId_getOpcodeName(self->uniqueId); - - RABUTILS_BUFFER_CPY(dst, totalSize, opcodeName); - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerInstrSuffix_processSuffix(self, dst, self->descriptor->instrSuffix)); - - if (self->descriptor->operands[0] == RAB_OPERAND_ALL_INVALID) { - // There are no operands - *dst = '\0'; - return totalSize; - } - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerUtils_CharFill(dst, RabbitizerConfig_Cfg.misc.opcodeLJust + extraLJust - totalSize, ' ')); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ' '); - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerInstruction_disassembleOperands(self, dst, immOverride, immOverrideLength)); - - *dst = '\0'; - return totalSize; -} - -size_t RabbitizerInstruction_getSizeForBufferDataDisasm(UNUSED const RabbitizerInstruction *self, int extraLJust) { - size_t totalSize = 0; - - totalSize += strlen(".word"); - totalSize += RabbitizerConfig_Cfg.misc.opcodeLJust + extraLJust; - totalSize += 11; - return totalSize; -} - -size_t RabbitizerInstruction_disassembleAsData(const RabbitizerInstruction *self, char *dst, int extraLJust) { - size_t totalSize = 0; - - RABUTILS_BUFFER_CPY(dst, totalSize, ".word"); - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerUtils_CharFill(dst, RabbitizerConfig_Cfg.misc.opcodeLJust + extraLJust - totalSize, ' ')); - - RABUTILS_BUFFER_SPRINTF(dst, totalSize, " 0x%08X", RabbitizerInstruction_getRaw(self)); - return totalSize; -} - -bool RabbitizerInstruction_mustDisasmAsData(const RabbitizerInstruction *self) { - if (RabbitizerConfig_Cfg.toolchainTweaks.sn64DivFix) { - if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_break) { - return true; - } - } - - if (!RabbitizerInstruction_isValid(self)) { - return true; - } - return false; -} - -size_t RabbitizerInstruction_getSizeForBuffer(const RabbitizerInstruction *self, size_t immOverrideLength, int extraLJust) { - if (!RabbitizerInstruction_isImplemented(self) || RabbitizerInstruction_mustDisasmAsData(self)) { - size_t totalSize = RabbitizerInstruction_getSizeForBufferDataDisasm(self, extraLJust); - - if (RabbitizerConfig_Cfg.misc.unknownInstrComment) { - totalSize += 40; - totalSize += 3; - totalSize += RabbitizerInstruction_getSizeForBufferInstrDisasm(self, immOverrideLength, extraLJust); - totalSize += 11; - } - return totalSize; - } - - return RabbitizerInstruction_getSizeForBufferInstrDisasm(self, immOverrideLength, extraLJust); -} - -size_t RabbitizerInstruction_disassemble(const RabbitizerInstruction *self, char *dst, const char *immOverride, size_t immOverrideLength, int extraLJust) { - assert(dst != NULL); - - if (!RabbitizerInstruction_isImplemented(self) || RabbitizerInstruction_mustDisasmAsData(self)) { - size_t totalSize = 0; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerInstruction_disassembleAsData(self, dst, extraLJust)); - - if (RabbitizerConfig_Cfg.misc.unknownInstrComment) { - uint32_t validBits; - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerUtils_CharFill(dst, 40 - totalSize, ' ')); - - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ' '); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, '#'); - RABUTILS_BUFFER_WRITE_CHAR(dst, totalSize, ' '); - - RABUTILS_BUFFER_ADVANCE(dst, totalSize, RabbitizerInstruction_disassembleInstruction(self, dst, immOverride, immOverrideLength, extraLJust)); - - validBits = RabbitizerInstruction_getValidBits(self); - - RABUTILS_BUFFER_SPRINTF(dst, totalSize, " # %08X", ((~validBits) & self->word)); - } - - return totalSize; - } - - return RabbitizerInstruction_disassembleInstruction(self, dst, immOverride, immOverrideLength, extraLJust); -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c b/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c deleted file mode 100644 index 136e4aa6..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_Examination.c +++ /dev/null @@ -1,840 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstruction.h" - -#include - -#include "common/RabbitizerConfig.h" -#include "instructions/RabbitizerInstructionRsp.h" -#include "instructions/RabbitizerInstructionR5900.h" -#include "instructions/RabbitizerRegister.h" - -bool RabbitizerInstruction_isImplemented(const RabbitizerInstruction *self) { - switch (self->uniqueId) { - case RABBITIZER_INSTR_ID_cpu_INVALID: - case RABBITIZER_INSTR_ID_rsp_INVALID: - case RABBITIZER_INSTR_ID_r5900_INVALID: - return false; - - default: - return true; - } -} - -bool RabbitizerInstruction_isLikelyHandwritten(const RabbitizerInstruction *self) { - if (self->_handwrittenCategory) { - return true; - } - - if (RabbitizerInstrDescriptor_isIType(self->descriptor) && !RabbitizerInstrDescriptor_isFloat(self->descriptor)) { - if (RAB_INSTR_GET_rs(self) == RABBITIZER_REG_GPR_O32_k0 || RAB_INSTR_GET_rs(self) == RABBITIZER_REG_GPR_O32_k1) { - return true; - } - if (RAB_INSTR_GET_rt(self) == RABBITIZER_REG_GPR_O32_k0 || RAB_INSTR_GET_rt(self) == RABBITIZER_REG_GPR_O32_k1) { - return true; - } - } - - if (RabbitizerInstrDescriptor_notEmitedByCompilers(self->descriptor)) { - return true; - } - - return false; -} - -bool RabbitizerInstruction_isNop(const RabbitizerInstruction *self) { - return self->word == 0; -} - -bool RabbitizerInstruction_isUnconditionalBranch(const RabbitizerInstruction *self) { - if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_b) { - return true; - } - if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_beq && RAB_INSTR_GET_rt(self) == 0 && RAB_INSTR_GET_rs(self) == 0) { - return true; - } - if (RabbitizerConfig_Cfg.toolchainTweaks.treatJAsUnconditionalBranch && self->uniqueId == RABBITIZER_INSTR_ID_cpu_j) { - return true; - } - return false; -} - -bool RabbitizerInstruction_isJrRa(const RabbitizerInstruction *self) { - if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_jr) { - // TODO: abi stuffs - return RAB_INSTR_GET_rs(self) == RABBITIZER_REG_GPR_O32_ra; - } - return false; -} - -bool RabbitizerInstruction_isJrNotRa(const RabbitizerInstruction *self) { - if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_jr) { - // TODO: abi stuffs - return RAB_INSTR_GET_rs(self) != RABBITIZER_REG_GPR_O32_ra; - } - return false; -} - -bool RabbitizerInstruction_hasDelaySlot(const RabbitizerInstruction *self) { - return RabbitizerInstrDescriptor_isBranch(self->descriptor) || RabbitizerInstrDescriptor_isJump(self->descriptor); -} - -const char *RabbitizerInstruction_mapInstrToType(const RabbitizerInstruction *self) { - if (RabbitizerInstrDescriptor_isDouble(self->descriptor)) { - return "f64"; - } - if (RabbitizerInstrDescriptor_isFloat(self->descriptor)) { - return "f32"; - } - if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_lwu) { - return "u32"; - } - if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_lh || self->uniqueId == RABBITIZER_INSTR_ID_cpu_sh) { - return "s16"; - } - if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_lhu) { - return "u16"; - } - if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_lb || self->uniqueId == RABBITIZER_INSTR_ID_cpu_sb) { - return "s8"; - } - if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_lbu) { - return "u8"; - } - if (self->uniqueId == RABBITIZER_INSTR_ID_cpu_ld || self->uniqueId == RABBITIZER_INSTR_ID_cpu_sd) { - return "s64"; - } - return NULL; -} - -bool RabbitizerInstruction_sameOpcode(const RabbitizerInstruction *self, const RabbitizerInstruction *other) { - if (!RabbitizerInstruction_isImplemented(self) || !RabbitizerInstruction_isImplemented(other)) { - return false; - } - return self->uniqueId == other->uniqueId; -} - -bool RabbitizerInstruction_sameOpcodeButDifferentArguments(const RabbitizerInstruction *self, const RabbitizerInstruction *other) { - if (!RabbitizerInstruction_sameOpcode(self, other)) { - return false; - } - return RabbitizerInstruction_getRaw(self) != RabbitizerInstruction_getRaw(other); -} - -bool RabbitizerInstruction_hasOperand(const RabbitizerInstruction *self, RabbitizerOperandType operand) { - size_t i; - - for (i = 0; i < ARRAY_COUNT(self->descriptor->operands) && self->descriptor->operands[i] != RAB_OPERAND_ALL_INVALID; i++) { - if (self->descriptor->operands[i] == operand) { - return true; - } - } - - return false; -} - -bool RabbitizerInstruction_hasOperandAlias(const RabbitizerInstruction *self, RabbitizerOperandType operand) { - switch (operand) { - case RAB_OPERAND_cpu_rs: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_cpu_immediate_base)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_rsp_rs)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_rsp_offset_rs)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_rsp_immediate_base)) { - return true; - } - break; - - case RAB_OPERAND_cpu_immediate: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_cpu_immediate_base)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_cpu_branch_target_label)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_rsp_immediate_base)) { - return true; - } - break; - - case RAB_OPERAND_cpu_rt: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_rsp_rt)) { - return true; - } - break; - - case RAB_OPERAND_cpu_rd: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_rsp_rd)) { - return true; - } - break; - - case RAB_OPERAND_cpu_sa: - case RAB_OPERAND_cpu_zero: - // case RAB_OPERAND_cpu_function: - case RAB_OPERAND_cpu_cop0d: - case RAB_OPERAND_cpu_fs: - case RAB_OPERAND_cpu_ft: - case RAB_OPERAND_cpu_fd: - case RAB_OPERAND_cpu_cop1cs: - case RAB_OPERAND_cpu_cop2t: - case RAB_OPERAND_cpu_op: - case RAB_OPERAND_cpu_code: - case RAB_OPERAND_cpu_code_lower: - case RAB_OPERAND_cpu_copraw: - case RAB_OPERAND_cpu_label: - break; - - case RAB_OPERAND_cpu_branch_target_label: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_cpu_immediate)) { - return true; - } - break; - - case RAB_OPERAND_cpu_immediate_base: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_cpu_rs)) { - return true; - } - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_cpu_immediate)) { - return true; - } - break; - - /* rsp */ - case RAB_OPERAND_rsp_rs: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_cpu_rs)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_rsp_offset_rs)) { - return true; - } - break; - - case RAB_OPERAND_rsp_rt: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_cpu_rt)) { - return true; - } - break; - - case RAB_OPERAND_rsp_rd: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_cpu_rd)) { - return true; - } - break; - - case RAB_OPERAND_rsp_cop0d: - case RAB_OPERAND_rsp_cop2t: - case RAB_OPERAND_rsp_cop2cd: - break; - - // case RAB_OPERAND_rsp_elementhigh: - // case RAB_OPERAND_rsp_elementlow: - // case RAB_OPERAND_rsp_index: - // case RAB_OPERAND_rsp_offset: - - case RAB_OPERAND_rsp_vs: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_rsp_vs_index)) { - return true; - } - break; - - case RAB_OPERAND_rsp_vt: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_rsp_vt_elementhigh)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_rsp_vt_elementlow)) { - return true; - } - break; - - case RAB_OPERAND_rsp_vd: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_rsp_vd_de)) { - return true; - } - break; - - case RAB_OPERAND_rsp_vt_elementhigh: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_rsp_vt)) { - return true; - } - break; - - case RAB_OPERAND_rsp_vt_elementlow: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_rsp_vt)) { - return true; - } - break; - - case RAB_OPERAND_rsp_vd_de: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_rsp_vd)) { - return true; - } - break; - - case RAB_OPERAND_rsp_vs_index: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_rsp_vs)) { - return true; - } - break; - - case RAB_OPERAND_rsp_offset_rs: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_rsp_rs)) { - return true; - } - break; - - case RAB_OPERAND_rsp_immediate_base: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_rsp_rs)) { - return true; - } - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_cpu_rs)) { - return true; - } - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_cpu_immediate)) { - return true; - } - break; - /* rsp */ - - /* r5900 */ - case RAB_OPERAND_r5900_I: - case RAB_OPERAND_r5900_Q: - case RAB_OPERAND_r5900_R: - break; - - case RAB_OPERAND_r5900_ACC: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_ACCxyzw)) { - return true; - } - break; - - case RAB_OPERAND_r5900_ACCxyzw: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_ACC)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vfs: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfsxyzw)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfsn)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfsl)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfsm)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vft: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vftxyzw)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vftn)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vftl)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vftm)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vfd: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfdxyzw)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfdn)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfdl)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfdm)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vfsxyzw: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfs)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfsn)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vftxyzw: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vft)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vftn)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vfdxyzw: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfd)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfdn)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vfsn: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfs)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfsxyzw)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vftn: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vft)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vftxyzw)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vfdn: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfd)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vfdxyzw)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vfsl: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_r5900_vfs)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vftl: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_r5900_vft)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vfdl: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_r5900_vfd)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vfsm: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_r5900_vfs)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vftm: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_r5900_vft)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vfdm: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_r5900_vfd)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vis: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vis_predecr)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vis_postincr)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vit: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vit_predecr)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vit_postincr)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vid: - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vid_predecr)) { - return true; - } - if (RabbitizerInstruction_hasOperand(self, RAB_OPERAND_r5900_vid_postincr)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vis_predecr: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_r5900_vis)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vit_predecr: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_r5900_vit)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vid_predecr: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_r5900_vid)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vis_postincr: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_r5900_vis)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vit_postincr: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_r5900_vit)) { - return true; - } - break; - - case RAB_OPERAND_r5900_vid_postincr: - if (RabbitizerInstruction_hasOperandAlias(self, RAB_OPERAND_r5900_vid)) { - return true; - } - break; - - case RAB_OPERAND_r5900_immediate5: - break; - /* r5900 */ - - case RAB_OPERAND_ALL_INVALID: - case RAB_OPERAND_ALL_MAX: - assert(operand != RAB_OPERAND_ALL_INVALID && operand != RAB_OPERAND_ALL_MAX); - break; - } - - return RabbitizerInstruction_hasOperand(self, operand); -} - -uint32_t RabbitizerInstruction_getValidBits(const RabbitizerInstruction *self) { - size_t i; - uint32_t validbits; - - validbits = self->_mandatorybits; - - for (i = 0; i < ARRAY_COUNT(self->descriptor->operands) && self->descriptor->operands[i] != RAB_OPERAND_ALL_INVALID; i++) { - - switch (self->descriptor->operands[i]) { - case RAB_OPERAND_cpu_rs: - validbits = RAB_INSTR_PACK_rs(validbits, ~0); - break; - - case RAB_OPERAND_cpu_rt: - validbits = RAB_INSTR_PACK_rt(validbits, ~0); - break; - - case RAB_OPERAND_cpu_rd: - validbits = RAB_INSTR_PACK_rd(validbits, ~0); - break; - - case RAB_OPERAND_cpu_sa: - validbits = RAB_INSTR_PACK_sa(validbits, ~0); - break; - - case RAB_OPERAND_cpu_zero: - break; - - case RAB_OPERAND_cpu_cop0d: - validbits = RAB_INSTR_PACK_cop0d(validbits, ~0); - break; - - case RAB_OPERAND_cpu_fs: - validbits = RAB_INSTR_PACK_fs(validbits, ~0); - break; - - case RAB_OPERAND_cpu_ft: - validbits = RAB_INSTR_PACK_ft(validbits, ~0); - break; - - case RAB_OPERAND_cpu_fd: - validbits = RAB_INSTR_PACK_fd(validbits, ~0); - break; - - case RAB_OPERAND_cpu_cop1cs: - validbits = RAB_INSTR_PACK_cop1cs(validbits, ~0); - break; - - case RAB_OPERAND_cpu_cop2t: - validbits = RAB_INSTR_PACK_cop2t(validbits, ~0); - break; - - case RAB_OPERAND_cpu_op: - validbits = RAB_INSTR_PACK_op(validbits, ~0); - break; - - case RAB_OPERAND_cpu_code: - validbits = RAB_INSTR_PACK_code(validbits, ~0); - break; - - case RAB_OPERAND_cpu_code_lower: - validbits = RAB_INSTR_PACK_code_lower(validbits, ~0); - break; - - case RAB_OPERAND_cpu_copraw: - validbits = RAB_INSTR_PACK_copraw(validbits, ~0); - break; - - case RAB_OPERAND_cpu_label: - validbits = RAB_INSTR_PACK_instr_index(validbits, ~0); - break; - - case RAB_OPERAND_cpu_immediate: - validbits = RAB_INSTR_PACK_immediate(validbits, ~0); - break; - - case RAB_OPERAND_cpu_branch_target_label: - validbits = RAB_INSTR_PACK_immediate(validbits, ~0); - break; - - case RAB_OPERAND_cpu_immediate_base: - validbits = RAB_INSTR_PACK_immediate(validbits, ~0); - validbits = RAB_INSTR_PACK_rs(validbits, ~0); - break; - - /* rsp */ - case RAB_OPERAND_rsp_rs: - validbits = RAB_INSTR_PACK_rs(validbits, ~0); - break; - - case RAB_OPERAND_rsp_rt: - validbits = RAB_INSTR_PACK_rt(validbits, ~0); - break; - - case RAB_OPERAND_rsp_rd: - validbits = RAB_INSTR_PACK_rd(validbits, ~0); - break; - - case RAB_OPERAND_rsp_cop0d: - validbits = RAB_INSTR_PACK_cop0d(validbits, ~0); - break; - - case RAB_OPERAND_rsp_cop2t: - validbits = RAB_INSTR_RSP_PACK_cop2t(validbits, ~0); - break; - - case RAB_OPERAND_rsp_cop2cd: - validbits = RAB_INSTR_RSP_PACK_cop2cd(validbits, ~0); - break; - - case RAB_OPERAND_rsp_vs: - validbits = RAB_INSTR_RSP_PACK_vs(validbits, ~0); - break; - - case RAB_OPERAND_rsp_vt: - validbits = RAB_INSTR_RSP_PACK_vt(validbits, ~0); - break; - - case RAB_OPERAND_rsp_vd: - validbits = RAB_INSTR_RSP_PACK_vd(validbits, ~0); - break; - - case RAB_OPERAND_rsp_vt_elementhigh: - validbits = RAB_INSTR_RSP_PACK_vt(validbits, ~0); - validbits = RAB_INSTR_RSP_PACK_elementhigh(validbits, ~0); - break; - - case RAB_OPERAND_rsp_vt_elementlow: - validbits = RAB_INSTR_RSP_PACK_vt(validbits, ~0); - validbits = RAB_INSTR_RSP_PACK_elementlow(validbits, ~0); - break; - - case RAB_OPERAND_rsp_vd_de: - validbits = RAB_INSTR_RSP_PACK_vd(validbits, ~0); - validbits = RAB_INSTR_RSP_PACK_de(validbits, ~0); - break; - - case RAB_OPERAND_rsp_vs_index: - validbits = RAB_INSTR_RSP_PACK_vs(validbits, ~0); - validbits = RAB_INSTR_RSP_PACK_index(validbits, ~0); - break; - - case RAB_OPERAND_rsp_offset_rs: - validbits = RAB_INSTR_RSP_PACK_offset(validbits, ~0); - validbits = RAB_INSTR_PACK_rs(validbits, ~0); - break; - - case RAB_OPERAND_rsp_immediate_base: - validbits = RAB_INSTR_PACK_immediate(validbits, ~0); - validbits = RAB_INSTR_PACK_rs(validbits, ~0); - break; - /* rsp */ - - /* r5900 */ - case RAB_OPERAND_r5900_I: - case RAB_OPERAND_r5900_Q: - case RAB_OPERAND_r5900_R: - case RAB_OPERAND_r5900_ACC: - // Not real registers encoded on the instruction itself - break; - - case RAB_OPERAND_r5900_ACCxyzw: - validbits = RAB_INSTR_R5900_PACK_xyzw_x(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_y(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_z(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_w(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vfs: - validbits = RAB_INSTR_R5900_PACK_vfs(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vft: - validbits = RAB_INSTR_R5900_PACK_vft(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vfd: - validbits = RAB_INSTR_R5900_PACK_vfd(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vfsxyzw: - validbits = RAB_INSTR_R5900_PACK_vfs(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_x(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_y(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_z(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_w(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vftxyzw: - validbits = RAB_INSTR_R5900_PACK_vft(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_x(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_y(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_z(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_w(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vfdxyzw: - validbits = RAB_INSTR_R5900_PACK_vfd(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_x(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_y(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_z(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_xyzw_w(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vfsn: - validbits = RAB_INSTR_R5900_PACK_vfs(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_n(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vftn: - validbits = RAB_INSTR_R5900_PACK_vft(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_n(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vfdn: - validbits = RAB_INSTR_R5900_PACK_vfd(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_n(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vfsl: - validbits = RAB_INSTR_R5900_PACK_vfs(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_l(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vftl: - validbits = RAB_INSTR_R5900_PACK_vft(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_l(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vfdl: - validbits = RAB_INSTR_R5900_PACK_vfd(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_l(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vfsm: - validbits = RAB_INSTR_R5900_PACK_vfs(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_m(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vftm: - validbits = RAB_INSTR_R5900_PACK_vft(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_m(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vfdm: - validbits = RAB_INSTR_R5900_PACK_vfd(validbits, ~0); - validbits = RAB_INSTR_R5900_PACK_m(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vis: - validbits = RAB_INSTR_R5900_PACK_vis(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vit: - validbits = RAB_INSTR_R5900_PACK_vit(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vid: - validbits = RAB_INSTR_R5900_PACK_vid(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vis_predecr: - validbits = RAB_INSTR_R5900_PACK_vis(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vit_predecr: - validbits = RAB_INSTR_R5900_PACK_vit(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vid_predecr: - validbits = RAB_INSTR_R5900_PACK_vid(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vis_postincr: - validbits = RAB_INSTR_R5900_PACK_vis(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vit_postincr: - validbits = RAB_INSTR_R5900_PACK_vit(validbits, ~0); - break; - - case RAB_OPERAND_r5900_vid_postincr: - validbits = RAB_INSTR_R5900_PACK_vid(validbits, ~0); - break; - - case RAB_OPERAND_r5900_immediate5: - validbits = RAB_INSTR_R5900_PACK_imm5(validbits, ~0); - break; - /* r5900 */ - - case RAB_OPERAND_ALL_INVALID: - case RAB_OPERAND_ALL_MAX: - assert(self->descriptor->operands[i] != RAB_OPERAND_ALL_INVALID && self->descriptor->operands[i] != RAB_OPERAND_ALL_MAX); - break; - } - } - - return validbits; -} - -bool RabbitizerInstruction_isValid(const RabbitizerInstruction *self) { - uint32_t validbits; - - validbits = RabbitizerInstruction_getValidBits(self); - - return ((~validbits) & self->word) == 0; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_ProcessUniqueId.c b/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_ProcessUniqueId.c deleted file mode 100644 index 0d71c6dd..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstruction/RabbitizerInstruction_ProcessUniqueId.c +++ /dev/null @@ -1,319 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstruction.h" - -#include "common/RabbitizerConfig.h" -#include "instructions/RabbitizerRegister.h" - -#define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) \ - case (caseBits): \ - self->uniqueId = RABBITIZER_INSTR_ID_##prefix##_##name; \ - break; -#define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, __VA_ARGS__) - -void RabbitizerInstruction_processUniqueId_Normal(RabbitizerInstruction *self) { - uint32_t opcode = RAB_INSTR_GET_opcode(self); - - self->_mandatorybits = RAB_INSTR_PACK_opcode(self->_mandatorybits, opcode); - - switch (opcode) { -#include "instructions/instr_id/cpu/cpu_normal.inc" - } - - if (RabbitizerConfig_Cfg.pseudos.enablePseudos) { - switch (self->uniqueId) { - case RABBITIZER_INSTR_ID_cpu_beq: - if (RAB_INSTR_GET_rt(self) == 0) { - if (RAB_INSTR_GET_rs(self) == 0) { - if (RabbitizerConfig_Cfg.pseudos.pseudoB) { - self->uniqueId = RABBITIZER_INSTR_ID_cpu_b; - } - } else { - if (RabbitizerConfig_Cfg.pseudos.pseudoBeqz) { - self->uniqueId = RABBITIZER_INSTR_ID_cpu_beqz; - } - } - } - break; - - case RABBITIZER_INSTR_ID_cpu_bne: - if (RAB_INSTR_GET_rt(self) == 0) { - if (RabbitizerConfig_Cfg.pseudos.pseudoBnez) { - self->uniqueId = RABBITIZER_INSTR_ID_cpu_bnez; - } - } - break; - - default: - break; - } - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -void RabbitizerInstruction_processUniqueId_Special(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_GET_function(self); - - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/cpu/cpu_special.inc" - } - - if (RabbitizerInstruction_isNop(self)) { - // NOP is special enough - self->uniqueId = RABBITIZER_INSTR_ID_cpu_nop; - } else if (RabbitizerConfig_Cfg.pseudos.enablePseudos) { - switch (self->uniqueId) { - case RABBITIZER_INSTR_ID_cpu_or: - if (RAB_INSTR_GET_rt(self) == 0) { - if (RabbitizerConfig_Cfg.pseudos.pseudoMove) { - self->uniqueId = RABBITIZER_INSTR_ID_cpu_move; - } - } - break; - - case RABBITIZER_INSTR_ID_cpu_nor: - if (RAB_INSTR_GET_rt(self) == 0) { - if (RabbitizerConfig_Cfg.pseudos.pseudoNot) { - self->uniqueId = RABBITIZER_INSTR_ID_cpu_not; - } - } - break; - - case RABBITIZER_INSTR_ID_cpu_subu: - if (RAB_INSTR_GET_rs(self) == 0) { - if (RabbitizerConfig_Cfg.pseudos.pseudoNegu) { - self->uniqueId = RABBITIZER_INSTR_ID_cpu_negu; - } - } - break; - - default: - break; - } - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; - - switch (self->uniqueId) { - case RABBITIZER_INSTR_ID_cpu_jalr: - self->_mandatorybits = RAB_INSTR_PACK_rd(self->_mandatorybits, RAB_INSTR_GET_rd(self)); - - if (RabbitizerConfig_Cfg.regNames.gprAbiNames == RABBITIZER_ABI_NUMERIC || RabbitizerConfig_Cfg.regNames.gprAbiNames == RABBITIZER_ABI_O32) { - if (RAB_INSTR_GET_rd(self) != RABBITIZER_REG_GPR_O32_ra) { - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[RABBITIZER_INSTR_ID_cpu_jalr_rd]; - } - } else { - if (RAB_INSTR_GET_rd(self) != RABBITIZER_REG_GPR_N32_ra) { - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[RABBITIZER_INSTR_ID_cpu_jalr_rd]; - } - } - break; - - case RABBITIZER_INSTR_ID_cpu_div: - if (RabbitizerConfig_Cfg.toolchainTweaks.sn64DivFix && !self->inHandwrittenFunction) { - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[RABBITIZER_INSTR_ID_cpu_sn64_div]; - } - break; - - case RABBITIZER_INSTR_ID_cpu_divu: - if (RabbitizerConfig_Cfg.toolchainTweaks.sn64DivFix && !self->inHandwrittenFunction) { - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[RABBITIZER_INSTR_ID_cpu_sn64_divu]; - } - break; - - default: - break; - } -} - -void RabbitizerInstruction_processUniqueId_Regimm(RabbitizerInstruction *self) { - uint32_t rt = RAB_INSTR_GET_rt(self); - - self->_mandatorybits = RAB_INSTR_PACK_rt(self->_mandatorybits, rt); - - switch (rt) { -#include "instructions/instr_id/cpu/cpu_regimm.inc" - } - - if (RabbitizerConfig_Cfg.pseudos.enablePseudos) { - switch (self->uniqueId) { - case RABBITIZER_INSTR_ID_cpu_bgezal: - if (RAB_INSTR_GET_rs(self) == 0) { - if (RabbitizerConfig_Cfg.pseudos.pseudoBal) { - self->uniqueId = RABBITIZER_INSTR_ID_cpu_bal; - } - } - break; - - default: - break; - } - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -void RabbitizerInstruction_processUniqueId_Coprocessor0_BC0(RabbitizerInstruction *self) { - uint32_t fmt = RAB_INSTR_GET_bc_fmt(self); - - self->_mandatorybits = RAB_INSTR_PACK_bc_fmt(self->_mandatorybits, fmt); - - switch (fmt) { -#include "instructions/instr_id/cpu/cpu_cop0_bc0.inc" - } -} - -void RabbitizerInstruction_processUniqueId_Coprocessor0_Tlb(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_GET_function(self); - - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/cpu/cpu_cop0_tlb.inc" - } -} - -void RabbitizerInstruction_processUniqueId_Coprocessor0(RabbitizerInstruction *self) { - uint32_t fmt = RAB_INSTR_GET_fmt(self); - - self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt); - self->_handwrittenCategory = true; - - switch (fmt) { -#include "instructions/instr_id/cpu/cpu_cop0.inc" - - case 0x08: - RabbitizerInstruction_processUniqueId_Coprocessor0_BC0(self); - break; - - case 0x10: - RabbitizerInstruction_processUniqueId_Coprocessor0_Tlb(self); - break; - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -void RabbitizerInstruction_processUniqueId_Coprocessor1_BC1(RabbitizerInstruction *self) { - uint32_t fmt = RAB_INSTR_GET_bc_fmt(self); - - self->_mandatorybits = RAB_INSTR_PACK_bc_fmt(self->_mandatorybits, fmt); - - switch (fmt) { -#include "instructions/instr_id/cpu/cpu_cop1_bc1.inc" - } -} - -void RabbitizerInstruction_processUniqueId_Coprocessor1_FpuS(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_GET_function(self); - - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/cpu/cpu_cop1_fpu_s.inc" - } -} - -void RabbitizerInstruction_processUniqueId_Coprocessor1_FpuD(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_GET_function(self); - - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/cpu/cpu_cop1_fpu_d.inc" - } -} - -void RabbitizerInstruction_processUniqueId_Coprocessor1_FpuW(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_GET_function(self); - - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/cpu/cpu_cop1_fpu_w.inc" - } -} - -void RabbitizerInstruction_processUniqueId_Coprocessor1_FpuL(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_GET_function(self); - - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/cpu/cpu_cop1_fpu_l.inc" - } -} - -void RabbitizerInstruction_processUniqueId_Coprocessor1(RabbitizerInstruction *self) { - uint8_t fmt = RAB_INSTR_GET_fmt(self); - - self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt); - - switch (fmt) { -#include "instructions/instr_id/cpu/cpu_cop1.inc" - - case 0x08: // fmt = BC - RabbitizerInstruction_processUniqueId_Coprocessor1_BC1(self); - break; - - case 0x10: - RabbitizerInstruction_processUniqueId_Coprocessor1_FpuS(self); - break; - - case 0x11: - RabbitizerInstruction_processUniqueId_Coprocessor1_FpuD(self); - break; - - case 0x14: - RabbitizerInstruction_processUniqueId_Coprocessor1_FpuW(self); - break; - - case 0x15: - RabbitizerInstruction_processUniqueId_Coprocessor1_FpuL(self); - break; - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -void RabbitizerInstruction_processUniqueId_Coprocessor2(RabbitizerInstruction *self) { - self->_handwrittenCategory = true; - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -#undef RABBITIZER_DEF_INSTR_ID -#undef RABBITIZER_DEF_INSTR_ID_ALTNAME - -void RabbitizerInstruction_processUniqueId(RabbitizerInstruction *self) { - uint32_t opcode = RAB_INSTR_GET_opcode(self); - - self->_mandatorybits = RAB_INSTR_PACK_opcode(self->_mandatorybits, opcode); - - self->uniqueId = RABBITIZER_INSTR_ID_cpu_INVALID; - - switch (opcode) { - default: - RabbitizerInstruction_processUniqueId_Normal(self); - break; - case 0x00: - RabbitizerInstruction_processUniqueId_Special(self); - break; - case 0x01: - RabbitizerInstruction_processUniqueId_Regimm(self); - break; - case 0x10: - RabbitizerInstruction_processUniqueId_Coprocessor0(self); - break; - case 0x11: - RabbitizerInstruction_processUniqueId_Coprocessor1(self); - break; - case 0x12: - RabbitizerInstruction_processUniqueId_Coprocessor2(self); - break; - } -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c b/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c deleted file mode 100644 index 3b9bd2ce..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900.c +++ /dev/null @@ -1,17 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstructionR5900.h" - -void RabbitizerInstructionR5900_init(RabbitizerInstruction *self, uint32_t word, uint32_t vram) { - RabbitizerInstruction_init(self, word, vram); - - self->uniqueId = RABBITIZER_INSTR_ID_r5900_INVALID; - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; - - self->category = RABBITIZER_INSTRCAT_R5900; -} - -void RabbitizerInstructionR5900_destroy(RabbitizerInstruction *self) { - RabbitizerInstruction_destroy(self); -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c b/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c deleted file mode 100644 index 1972f3fa..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstructionR5900/RabbitizerInstructionR5900_ProcessUniqueId.c +++ /dev/null @@ -1,328 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstructionR5900.h" - -#define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) \ - case (caseBits): \ - self->uniqueId = RABBITIZER_INSTR_ID_##prefix##_##name; \ - break; -#define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, __VA_ARGS__) - -void RabbitizerInstructionR5900_processUniqueId_Normal(RabbitizerInstruction *self) { - uint32_t opcode = RAB_INSTR_GET_opcode(self); - bool fetchDescriptor = true; - - self->_mandatorybits = RAB_INSTR_PACK_opcode(self->_mandatorybits, opcode); - - switch (opcode) { -#include "instructions/instr_id/r5900/r5900_normal.inc" - - default: - RabbitizerInstruction_processUniqueId_Normal(self); - fetchDescriptor = false; - break; - } - - if (fetchDescriptor) { - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; - } -} - -void RabbitizerInstructionR5900_processUniqueId_Special(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_GET_function(self); - bool fetchDescriptor = true; - uint32_t stype; - - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/r5900/r5900_special.inc" - - default: - RabbitizerInstruction_processUniqueId_Special(self); - fetchDescriptor = false; - break; - } - - switch (self->uniqueId) { - case RABBITIZER_INSTR_ID_cpu_sync: - stype = RAB_INSTR_GET_stype(self); - self->_mandatorybits = RAB_INSTR_PACK_stype(self->_mandatorybits, stype); - if ((stype & 0x10) == 0x10) { - self->uniqueId = RABBITIZER_INSTR_ID_r5900_sync_p; - fetchDescriptor = true; - } - break; - - default: - break; - } - - if (fetchDescriptor) { - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; - } -} - -void RabbitizerInstructionR5900_processUniqueId_Regimm(RabbitizerInstruction *self) { - uint32_t rt = RAB_INSTR_GET_rt(self); - bool fetchDescriptor = true; - - self->_mandatorybits = RAB_INSTR_PACK_rt(self->_mandatorybits, rt); - - switch (rt) { -#include "instructions/instr_id/r5900/r5900_regimm.inc" - - default: - RabbitizerInstruction_processUniqueId_Regimm(self); - fetchDescriptor = false; - break; - } - - if (fetchDescriptor) { - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; - } -} - -void RabbitizerInstructionR5900_processUniqueId_Coprocessor0_Tlb(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_GET_function(self); - - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/r5900/r5900_cop0_tlb.inc" - - default: - RabbitizerInstruction_processUniqueId_Coprocessor0_Tlb(self); - break; - } -} - -void RabbitizerInstructionR5900_processUniqueId_Coprocessor0(RabbitizerInstruction *self) { - uint32_t fmt = RAB_INSTR_GET_fmt(self); - - self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt); - self->_handwrittenCategory = true; - - switch (fmt) { -#include "instructions/instr_id/cpu/cpu_cop0.inc" - - case 0x08: - RabbitizerInstruction_processUniqueId_Coprocessor0_BC0(self); - break; - - case 0x10: - RabbitizerInstructionR5900_processUniqueId_Coprocessor0_Tlb(self); - break; - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -void RabbitizerInstructionR5900_processUniqueId_Coprocessor1_FpuS(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_GET_function(self); - - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/r5900/r5900_cop1_fpu_s.inc" - - default: - RabbitizerInstruction_processUniqueId_Coprocessor1_FpuS(self); - break; - } -} - -void RabbitizerInstructionR5900_processUniqueId_Coprocessor1(RabbitizerInstruction *self) { - uint8_t fmt = RAB_INSTR_GET_fmt(self); - - self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt); - - switch (fmt) { -#include "instructions/instr_id/cpu/cpu_cop1.inc" - - case 0x08: // fmt = BC - RabbitizerInstruction_processUniqueId_Coprocessor1_BC1(self); - break; - - case 0x10: - RabbitizerInstructionR5900_processUniqueId_Coprocessor1_FpuS(self); - break; - - case 0x14: - RabbitizerInstruction_processUniqueId_Coprocessor1_FpuW(self); - break; - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -void RabbitizerInstruction_processUniqueId_Coprocessor2_BC2(RabbitizerInstruction *self) { - uint32_t fmt = RAB_INSTR_GET_bc_fmt(self); - - self->_mandatorybits = RAB_INSTR_PACK_bc_fmt(self->_mandatorybits, fmt); - - switch (fmt) { -#include "instructions/instr_id/r5900/r5900_cop2_bc2.inc" - } -} - -void RabbitizerInstructionR5900_processUniqueId_Coprocessor2_Special2(UNUSED RabbitizerInstruction *self) { - uint32_t fhiflo = RAB_INSTR_R5900_GET_fhi_flo(self); - - self->_mandatorybits = RAB_INSTR_R5900_PACK_fhi_flo(self->_mandatorybits, fhiflo); - - switch (fhiflo) { -#include "instructions/instr_id/r5900/r5900_cop2_special2.inc" - } -} - -void RabbitizerInstructionR5900_processUniqueId_Coprocessor2_Special1(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_GET_function(self); - - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/r5900/r5900_cop2_special1.inc" - - case 0x3C: - case 0x3D: - case 0x3E: - case 0x3F: - RabbitizerInstructionR5900_processUniqueId_Coprocessor2_Special2(self); - break; - } -} - -void RabbitizerInstructionR5900_processUniqueId_Coprocessor2(RabbitizerInstruction *self) { - uint8_t fmt = RAB_INSTR_GET_fmt(self); - - self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt); - - switch (fmt) { -#include "instructions/instr_id/r5900/r5900_cop2.inc" - - case 0x08: - RabbitizerInstruction_processUniqueId_Coprocessor2_BC2(self); - break; - - case 0x10: - case 0x11: - case 0x12: - case 0x13: - case 0x14: - case 0x15: - case 0x16: - case 0x17: - case 0x18: - case 0x19: - case 0x1A: - case 0x1B: - case 0x1C: - case 0x1D: - case 0x1E: - case 0x1F: - RabbitizerInstructionR5900_processUniqueId_Coprocessor2_Special1(self); - break; - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -void RabbitizerInstructionR5900_processUniqueId_MMI_0(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_R5900_GET_mmi_function(self); - - self->_mandatorybits = RAB_INSTR_R5900_PACK_mmi_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/r5900/r5900_mmi_0.inc" - } -} - -void RabbitizerInstructionR5900_processUniqueId_MMI_1(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_R5900_GET_mmi_function(self); - - self->_mandatorybits = RAB_INSTR_R5900_PACK_mmi_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/r5900/r5900_mmi_1.inc" - } -} - -void RabbitizerInstructionR5900_processUniqueId_MMI_2(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_R5900_GET_mmi_function(self); - - self->_mandatorybits = RAB_INSTR_R5900_PACK_mmi_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/r5900/r5900_mmi_2.inc" - } -} - -void RabbitizerInstructionR5900_processUniqueId_MMI_3(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_R5900_GET_mmi_function(self); - - self->_mandatorybits = RAB_INSTR_R5900_PACK_mmi_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/r5900/r5900_mmi_3.inc" - } -} - -void RabbitizerInstructionR5900_processUniqueId_MMI(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_GET_function(self); - - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/r5900/r5900_mmi.inc" - - case 0x08: - RabbitizerInstructionR5900_processUniqueId_MMI_0(self); - break; - case 0x09: - RabbitizerInstructionR5900_processUniqueId_MMI_2(self); - break; - case 0x28: - RabbitizerInstructionR5900_processUniqueId_MMI_1(self); - break; - case 0x29: - RabbitizerInstructionR5900_processUniqueId_MMI_3(self); - break; - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -#undef RABBITIZER_DEF_INSTR_ID -#undef RABBITIZER_DEF_INSTR_ID_ALTNAME - -void RabbitizerInstructionR5900_processUniqueId(RabbitizerInstruction *self) { - uint32_t opcode = RAB_INSTR_GET_opcode(self); - - self->_mandatorybits = RAB_INSTR_PACK_opcode(self->_mandatorybits, opcode); - - switch (opcode) { - default: - RabbitizerInstructionR5900_processUniqueId_Normal(self); - break; - case 0x00: - RabbitizerInstructionR5900_processUniqueId_Special(self); - break; - case 0x01: - RabbitizerInstructionR5900_processUniqueId_Regimm(self); - break; - case 0x10: - RabbitizerInstructionR5900_processUniqueId_Coprocessor0(self); - break; - case 0x11: - RabbitizerInstructionR5900_processUniqueId_Coprocessor1(self); - break; - case 0x12: - RabbitizerInstructionR5900_processUniqueId_Coprocessor2(self); - break; - case 0x1C: - RabbitizerInstructionR5900_processUniqueId_MMI(self); - break; - } -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c b/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c deleted file mode 100644 index 1e63453c..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp.c +++ /dev/null @@ -1,56 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstructionRsp.h" - -void RabbitizerInstructionRsp_init(RabbitizerInstruction *self, uint32_t word, uint32_t vram) { - RabbitizerInstruction_init(self, word, vram); - - self->uniqueId = RABBITIZER_INSTR_ID_rsp_INVALID; - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; - - self->_handwrittenCategory = true; - self->category = RABBITIZER_INSTRCAT_RSP; -} - -void RabbitizerInstructionRsp_destroy(RabbitizerInstruction *self) { - RabbitizerInstruction_destroy(self); -} - -uint16_t RabbitizerInstructionRsp_GetOffsetVector(const RabbitizerInstruction *self) { - uint16_t offset = RAB_INSTR_RSP_GET_OFFSET_VECTOR_RAW(self); - - switch (self->uniqueId) { - case RABBITIZER_INSTR_ID_rsp_lsv: - case RABBITIZER_INSTR_ID_rsp_ssv: - return offset << 1; - - case RABBITIZER_INSTR_ID_rsp_llv: - case RABBITIZER_INSTR_ID_rsp_slv: - return offset << 2; - - case RABBITIZER_INSTR_ID_rsp_ldv: - case RABBITIZER_INSTR_ID_rsp_sdv: - case RABBITIZER_INSTR_ID_rsp_lpv: - case RABBITIZER_INSTR_ID_rsp_spv: - case RABBITIZER_INSTR_ID_rsp_luv: - case RABBITIZER_INSTR_ID_rsp_suv: - return offset << 3; - - case RABBITIZER_INSTR_ID_rsp_lqv: - case RABBITIZER_INSTR_ID_rsp_sqv: - case RABBITIZER_INSTR_ID_rsp_lrv: - case RABBITIZER_INSTR_ID_rsp_srv: - case RABBITIZER_INSTR_ID_rsp_lhv: - case RABBITIZER_INSTR_ID_rsp_shv: - case RABBITIZER_INSTR_ID_rsp_lfv: - case RABBITIZER_INSTR_ID_rsp_sfv: - case RABBITIZER_INSTR_ID_rsp_ltv: - case RABBITIZER_INSTR_ID_rsp_stv: - case RABBITIZER_INSTR_ID_rsp_swv: - return offset << 4; - - default: - return offset; - } -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_ProcessUniqueId.c b/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_ProcessUniqueId.c deleted file mode 100644 index e491f1be..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerInstructionRsp/RabbitizerInstructionRsp_ProcessUniqueId.c +++ /dev/null @@ -1,233 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstructionRsp.h" - -#include "common/RabbitizerConfig.h" - -#define RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, ...) \ - case (caseBits): \ - self->uniqueId = RABBITIZER_INSTR_ID_##prefix##_##name; \ - break; -#define RABBITIZER_DEF_INSTR_ID_ALTNAME(prefix, caseBits, name, altname, ...) RABBITIZER_DEF_INSTR_ID(prefix, caseBits, name, __VA_ARGS__) - -void RabbitizerInstructionRsp_processUniqueId_Normal_Lwc2(RabbitizerInstruction *self) { - uint32_t rd = RAB_INSTR_GET_rd(self); - - self->_mandatorybits = RAB_INSTR_PACK_rd(self->_mandatorybits, rd); - - switch (rd) { -#include "instructions/instr_id/rsp/rsp_normal_lwc2.inc" - } -} - -void RabbitizerInstructionRsp_processUniqueId_Normal_Swc2(RabbitizerInstruction *self) { - uint32_t rd = RAB_INSTR_GET_rd(self); - uint32_t elementlow; - - self->_mandatorybits = RAB_INSTR_PACK_rd(self->_mandatorybits, rd); - - switch (rd) { -#include "instructions/instr_id/rsp/rsp_normal_swc2.inc" - } - - switch (self->uniqueId) { - case RABBITIZER_INSTR_ID_rsp_suv: - elementlow = RAB_INSTR_RSP_GET_elementlow(self); - self->_mandatorybits = RAB_INSTR_RSP_PACK_elementlow(self->_mandatorybits, elementlow); - if (elementlow != 0) { - self->uniqueId = RABBITIZER_INSTR_ID_rsp_swv; - } - break; - - default: - break; - } -} - -void RabbitizerInstructionRsp_processUniqueId_Normal(RabbitizerInstruction *self) { - uint32_t opcode = RAB_INSTR_GET_opcode(self); - - self->_mandatorybits = RAB_INSTR_PACK_opcode(self->_mandatorybits, opcode); - - switch (opcode) { -#include "instructions/instr_id/rsp/rsp_normal.inc" - - // new rsp stuff - case 0x32: - RabbitizerInstructionRsp_processUniqueId_Normal_Lwc2(self); - break; - - case 0x3A: - RabbitizerInstructionRsp_processUniqueId_Normal_Swc2(self); - break; - } - - if (RabbitizerConfig_Cfg.pseudos.enablePseudos) { - if (RAB_INSTR_GET_rt(self) == 0) { - if (self->uniqueId == RABBITIZER_INSTR_ID_rsp_beq) { - if (RAB_INSTR_GET_rs(self) == 0) { - if (RabbitizerConfig_Cfg.pseudos.pseudoB) { - self->uniqueId = RABBITIZER_INSTR_ID_rsp_b; - } - } else { - if (RabbitizerConfig_Cfg.pseudos.pseudoBeqz) { - self->uniqueId = RABBITIZER_INSTR_ID_rsp_beqz; - } - } - } else if (self->uniqueId == RABBITIZER_INSTR_ID_rsp_bne) { - if (RabbitizerConfig_Cfg.pseudos.pseudoBnez) { - self->uniqueId = RABBITIZER_INSTR_ID_rsp_bnez; - } - } - } - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -void RabbitizerInstructionRsp_processUniqueId_Special(RabbitizerInstruction *self) { - uint32_t function = RAB_INSTR_GET_function(self); - - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/rsp/rsp_special.inc" - } - - if (RabbitizerInstruction_isNop(self)) { - // NOP is special enough - self->uniqueId = RABBITIZER_INSTR_ID_rsp_nop; - } else if (RabbitizerConfig_Cfg.pseudos.enablePseudos) { - if (RAB_INSTR_GET_rt(self) == 0) { - if (self->uniqueId == RABBITIZER_INSTR_ID_rsp_or) { - if (RabbitizerConfig_Cfg.pseudos.pseudoMove) { - self->uniqueId = RABBITIZER_INSTR_ID_rsp_move; - } - } else if (self->uniqueId == RABBITIZER_INSTR_ID_rsp_nor) { - if (RabbitizerConfig_Cfg.pseudos.pseudoNot) { - self->uniqueId = RABBITIZER_INSTR_ID_rsp_not; - } - } - } else if (self->uniqueId == RABBITIZER_INSTR_ID_rsp_subu) { - if (RAB_INSTR_GET_rs(self) == 0) { - if (RabbitizerConfig_Cfg.pseudos.pseudoNegu) { - self->uniqueId = RABBITIZER_INSTR_ID_rsp_negu; - } - } - } - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; - - if (self->uniqueId == RABBITIZER_INSTR_ID_rsp_jalr) { - // $ra - if (RAB_INSTR_GET_rd(self) != 31) { - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[RABBITIZER_INSTR_ID_rsp_jalr_rd]; - } - } -} - -void RabbitizerInstructionRsp_processUniqueId_Regimm(RabbitizerInstruction *self) { - uint32_t rt = RAB_INSTR_GET_rt(self); - - self->_mandatorybits = RAB_INSTR_PACK_rt(self->_mandatorybits, rt); - - switch (rt) { -#include "instructions/instr_id/rsp/rsp_regimm.inc" - } - - if (RabbitizerConfig_Cfg.pseudos.enablePseudos) { - switch (self->uniqueId) { - case RABBITIZER_INSTR_ID_rsp_bgezal: - if (RAB_INSTR_GET_rs(self) == 0) { - if (RabbitizerConfig_Cfg.pseudos.pseudoBal) { - self->uniqueId = RABBITIZER_INSTR_ID_rsp_bal; - } - } - break; - - default: - break; - } - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -void RabbitizerInstructionRsp_processUniqueId_Coprocessor0(RabbitizerInstruction *self) { - uint32_t fmt = RAB_INSTR_GET_fmt(self); - - self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt); - - switch (fmt) { -#include "instructions/instr_id/cpu/cpu_cop0.inc" - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -void RabbitizerInstructionRsp_processUniqueId_Coprocessor2_Vu(RabbitizerInstruction *self) { - uint32_t aux = SHIFTR(self->word, 25, 1); - uint32_t function = RAB_INSTR_GET_function(self); - - if (aux != 1) { - return; - } - - // TODO: name this bit range - self->_mandatorybits = BITREPACK(self->_mandatorybits, aux, 25, 1); - self->_mandatorybits = RAB_INSTR_PACK_function(self->_mandatorybits, function); - - switch (function) { -#include "instructions/instr_id/rsp/rsp_cop2_vu.inc" - } -} - -void RabbitizerInstructionRsp_processUniqueId_Coprocessor2(RabbitizerInstruction *self) { - uint32_t fmt = RAB_INSTR_GET_fmt(self); - - self->_mandatorybits = RAB_INSTR_PACK_fmt(self->_mandatorybits, fmt); - - switch (fmt) { -#include "instructions/instr_id/cpu/cpu_cop0.inc" - - default: - RabbitizerInstructionRsp_processUniqueId_Coprocessor2_Vu(self); - break; - } - - self->descriptor = &RabbitizerInstrDescriptor_Descriptors[self->uniqueId]; -} - -#undef RABBITIZER_DEF_INSTR_ID -#undef RABBITIZER_DEF_INSTR_ID_ALTNAME - -void RabbitizerInstructionRsp_processUniqueId(RabbitizerInstruction *self) { - uint32_t opcode = RAB_INSTR_GET_opcode(self); - - self->_mandatorybits = RAB_INSTR_PACK_opcode(self->_mandatorybits, opcode); - - self->uniqueId = RABBITIZER_INSTR_ID_rsp_INVALID; - - switch (opcode) { - default: - RabbitizerInstructionRsp_processUniqueId_Normal(self); - break; - case 0x00: - RabbitizerInstructionRsp_processUniqueId_Special(self); - break; - case 0x01: - RabbitizerInstructionRsp_processUniqueId_Regimm(self); - break; - case 0x10: - RabbitizerInstructionRsp_processUniqueId_Coprocessor0(self); - break; - // case 0x11: - // RabbitizerInstructionRsp_processUniqueId_Coprocessor1(self); - // break; - case 0x12: - RabbitizerInstructionRsp_processUniqueId_Coprocessor2(self); - break; - } -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerRegister.c b/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerRegister.c deleted file mode 100644 index 4d16024f..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/src/instructions/RabbitizerRegister.c +++ /dev/null @@ -1,181 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerRegister.h" - -#include - -#include "common/Utils.h" -#include "common/RabbitizerConfig.h" - -#define RABBITIZER_DEF_REG(prefix, name, numeric) [RABBITIZER_REG_##prefix##_##name] = { "$" #numeric, "$" #name } - -#define RABBITIZER_DEF_REG_NODOLLAR(prefix, name, numeric) [RABBITIZER_REG_##prefix##_##name] = { "$" #numeric, #name } - -// numeric, named - -const char *RabbitizerRegister_GprO32_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_GprO32.inc" -}; - -const char *RabbitizerRegister_GprN32_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_GprN32.inc" -}; - -const char *RabbitizerRegister_Cop0_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_Cop0.inc" -}; - -const char *RabbitizerRegister_Cop1O32_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_Cop1O32.inc" -}; - -const char *RabbitizerRegister_Cop1N32_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_Cop1N32.inc" -}; - -const char *RabbitizerRegister_Cop1N64_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_Cop1N64.inc" -}; - -const char *RabbitizerRegister_Cop1Control_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_Cop1Control.inc" -}; - -const char *RabbitizerRegister_Cop2_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_Cop2.inc" -}; - -/* RSP */ - -const char *RabbitizerRegister_RspGpr_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_RspGpr.inc" -}; - -const char *RabbitizerRegister_RspCop0_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_RspCop0.inc" -}; - -const char *RabbitizerRegister_RspCop2_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_RspCop2.inc" -}; - -const char *RabbitizerRegister_RspCop2Control_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_RspCop2Control.inc" -}; - -const char *RabbitizerRegister_RspVector_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_RspVector.inc" -}; - -/* RSP */ - -/* R5900 */ - -const char *RabbitizerRegister_R5900VF_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_R5900VF.inc" -}; - -const char *RabbitizerRegister_R5900VI_Names[][2] = { -#include "instructions/registers/RabbitizerRegister_R5900VI.inc" -}; - -/* R5900 */ - -const char *RabbitizerRegister_getNameGpr(uint8_t regValue) { - assert(regValue < ARRAY_COUNT(RabbitizerRegister_GprO32_Names)); - - switch (RabbitizerConfig_Cfg.regNames.gprAbiNames) { - case RABBITIZER_ABI_NUMERIC: - return RabbitizerRegister_GprO32_Names[regValue][0]; - - default: - case RABBITIZER_ABI_O32: - return RabbitizerRegister_GprO32_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters ? 1 : 0]; - - case RABBITIZER_ABI_N32: - case RABBITIZER_ABI_N64: - return RabbitizerRegister_GprN32_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters ? 1 : 0]; - } -} - -const char *RabbitizerRegister_getNameCop0(uint8_t regValue) { - assert(regValue < ARRAY_COUNT(RabbitizerRegister_Cop0_Names)); - - return RabbitizerRegister_Cop0_Names[regValue] - [RabbitizerConfig_Cfg.regNames.namedRegisters && RabbitizerConfig_Cfg.regNames.vr4300Cop0NamedRegisters ? 1 : 0]; -} - -const char *RabbitizerRegister_getNameCop1(uint8_t regValue) { - assert(regValue < ARRAY_COUNT(RabbitizerRegister_Cop1O32_Names)); - - switch (RabbitizerConfig_Cfg.regNames.fprAbiNames) { - default: - case RABBITIZER_ABI_NUMERIC: - return RabbitizerRegister_Cop1O32_Names[regValue][0]; - - case RABBITIZER_ABI_O32: - return RabbitizerRegister_Cop1O32_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters ? 1 : 0]; - - case RABBITIZER_ABI_N32: - return RabbitizerRegister_Cop1N32_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters ? 1 : 0]; - - case RABBITIZER_ABI_N64: - return RabbitizerRegister_Cop1N64_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters ? 1 : 0]; - } -} - -const char *RabbitizerRegister_getNameCop1Control(uint8_t regValue) { - assert(regValue < ARRAY_COUNT(RabbitizerRegister_Cop1Control_Names)); - - return RabbitizerRegister_Cop1Control_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters && RabbitizerConfig_Cfg.regNames.userFpcCsr ? 1 : 0]; -} - -const char *RabbitizerRegister_getNameCop2(uint8_t regValue) { - assert(regValue < ARRAY_COUNT(RabbitizerRegister_Cop2_Names)); - - return RabbitizerRegister_Cop2_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters ? 1 : 0]; -} - -const char *RabbitizerRegister_getNameRspGpr(uint8_t regValue) { - assert(regValue < ARRAY_COUNT(RabbitizerRegister_RspGpr_Names)); - - return RabbitizerRegister_RspGpr_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters ? 1 : 0]; -} - -const char *RabbitizerRegister_getNameRspCop0(uint8_t regValue) { - assert(regValue < ARRAY_COUNT(RabbitizerRegister_RspCop0_Names)); - - return RabbitizerRegister_RspCop0_Names[regValue] - [RabbitizerConfig_Cfg.regNames.namedRegisters && RabbitizerConfig_Cfg.regNames.vr4300RspCop0NamedRegisters ? 1 : 0]; -} - -const char *RabbitizerRegister_getNameRspCop2(uint8_t regValue) { - assert(regValue < ARRAY_COUNT(RabbitizerRegister_RspCop2_Names)); - - return RabbitizerRegister_RspCop2_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters ? 1 : 0]; -} - -const char *RabbitizerRegister_getNameRspCop2Control(uint8_t regValue) { - assert(regValue < ARRAY_COUNT(RabbitizerRegister_RspCop2Control_Names)); - - return RabbitizerRegister_RspCop2Control_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters ? 1 : 0]; -} - -const char *RabbitizerRegister_getNameRspVector(uint8_t regValue) { - assert(regValue < ARRAY_COUNT(RabbitizerRegister_RspVector_Names)); - - return RabbitizerRegister_RspVector_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters ? 1 : 0]; -} - -const char *RabbitizerRegister_getNameR5900VF(uint8_t regValue) { - assert(regValue < ARRAY_COUNT(RabbitizerRegister_R5900VF_Names)); - - return RabbitizerRegister_R5900VF_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters ? 1 : 0]; -} - -const char *RabbitizerRegister_getNameR5900VI(uint8_t regValue) { - assert(regValue < ARRAY_COUNT(RabbitizerRegister_R5900VI_Names)); - - return RabbitizerRegister_R5900VI_Names[regValue][RabbitizerConfig_Cfg.regNames.namedRegisters ? 1 : 0]; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/test.c b/tools/ido-static-recomp/tools/rabbitizer/test.c deleted file mode 100644 index e968dfaf..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/test.c +++ /dev/null @@ -1,40 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/RabbitizerInstruction.h" - -#include -#include -#include -#include - - -int main() { - uint32_t word; - RabbitizerInstruction instr; - char *buffer; - int extraLJust = 5; - size_t bufferSize; - size_t disassembledSize; - - word = 0x8D4A7E18; // lw - //word = 0x00004010; // mfhi - - RabbitizerInstruction_init(&instr, word, 0x80000000); - - RabbitizerInstruction_processUniqueId(&instr); - - bufferSize = RabbitizerInstruction_getSizeForBuffer(&instr, 0, extraLJust); - buffer = malloc(bufferSize + 1); - assert(buffer != NULL); - - disassembledSize = RabbitizerInstruction_disassemble(&instr, buffer, NULL, 0, extraLJust); - assert(disassembledSize <= bufferSize); - - printf("%08X: %s\n", word, buffer); - - free(buffer); - RabbitizerInstruction_destroy(&instr); - - return 0; -} diff --git a/tools/ido-static-recomp/tools/rabbitizer/tests/cplusplus/test.cpp b/tools/ido-static-recomp/tools/rabbitizer/tests/cplusplus/test.cpp deleted file mode 100644 index 689e12b3..00000000 --- a/tools/ido-static-recomp/tools/rabbitizer/tests/cplusplus/test.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-FileCopyrightText: © 2022 Decompollaborate */ -/* SPDX-License-Identifier: MIT */ - -#include "instructions/InstructionCpu.hpp" - - -int main() { - uint32_t word = 0x8D4A7E18; // lw - uint32_t vram = 0x80000000; - int extraLJust = 5; - rabbitizer::InstructionCpu instr(word, vram); - - printf("%08X: %s\n", word, instr.disassemble(extraLJust).c_str()); - - return 0; -} diff --git a/tools/ido5.3_compiler/LICENSE.md b/tools/ido5.3_compiler/LICENSE.md deleted file mode 100644 index 015107d4..00000000 --- a/tools/ido5.3_compiler/LICENSE.md +++ /dev/null @@ -1,18 +0,0 @@ -# Silicon Graphics Freeware Legal Notice -## Copyright 1995, Silicon Graphics, Inc. -- ALL RIGHTS RESERVED - -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. - -**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.** - -**U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND:** - -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. - -## Product Support - -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. - ----- - -**NOTE:** This license was copied verbatim from https://web.archive.org/web/19991008090202/http://toolbox.sgi.com/TasteOfDT/public/freeware1.0/legal_notice.html . diff --git a/tools/ido5.3_compiler/lib/libmalloc.so b/tools/ido5.3_compiler/lib/libmalloc.so deleted file mode 100644 index a58e1034..00000000 Binary files a/tools/ido5.3_compiler/lib/libmalloc.so and /dev/null differ diff --git a/tools/ido5.3_compiler/lib/libmalloc_old.so b/tools/ido5.3_compiler/lib/libmalloc_old.so deleted file mode 100644 index 2a14987d..00000000 Binary files a/tools/ido5.3_compiler/lib/libmalloc_old.so and /dev/null differ diff --git a/tools/ido5.3_compiler/lib/rld b/tools/ido5.3_compiler/lib/rld deleted file mode 100755 index 727b4269..00000000 Binary files a/tools/ido5.3_compiler/lib/rld and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/bin/cc b/tools/ido5.3_compiler/usr/bin/cc deleted file mode 100755 index 2936fc3f..00000000 Binary files a/tools/ido5.3_compiler/usr/bin/cc and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/acpp b/tools/ido5.3_compiler/usr/lib/acpp deleted file mode 100755 index d5392cf6..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/acpp and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/as0 b/tools/ido5.3_compiler/usr/lib/as0 deleted file mode 100755 index badf8c83..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/as0 and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/as1 b/tools/ido5.3_compiler/usr/lib/as1 deleted file mode 100755 index c246db53..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/as1 and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/cfe b/tools/ido5.3_compiler/usr/lib/cfe deleted file mode 100755 index 305a50be..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/cfe and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/copt b/tools/ido5.3_compiler/usr/lib/copt deleted file mode 100755 index 2e689fdc..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/copt and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/crt1.o b/tools/ido5.3_compiler/usr/lib/crt1.o deleted file mode 100644 index 3052ae27..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/crt1.o and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/err.english.cc b/tools/ido5.3_compiler/usr/lib/err.english.cc deleted file mode 100644 index 6976e38a..00000000 --- a/tools/ido5.3_compiler/usr/lib/err.english.cc +++ /dev/null @@ -1,1260 +0,0 @@ -@ - 358 358 358 - 6464 6482 6553 - 6553 6593 6728 - 6728 6746 6803 - 6803 6808 6808 - 6808 6818 6818 - 6818 6826 6826 - 6826 6847 6847 - 6847 6875 6922 - 6922 6930 6930 - 6930 6939 6939 - 6939 6948 6948 - 6948 6974 7120 - 7120 7149 7204 - 7210 7248 7311 - 7317 7350 7442 - 7450 7497 7627 - 7635 7709 7930 - 7938 7975 8063 - 8071 8113 8253 - 8261 8289 8289 - 8298 8338 8445 - 8460 8502 8635 - 8650 8690 8819 - 8834 8857 8965 - 8965 9008 9113 - 9119 9142 9227 - 9235 9282 9451 - 9451 9462 9462 - 9462 9477 9477 - 9477 9497 9497 - 9497 9545 9545 - 9545 9584 9584 - 9584 9604 9662 - 9662 9682 9720 - 9720 9749 9749 - 9749 9788 9788 - 9788 9802 9802 - 9802 9829 9829 - 9829 9861 9861 - 9861 9904 9904 - 9904 9920 9920 - 9920 9962 9962 - 9962 9988 9988 - 9988 10014 10014 -10014 10035 10035 -10035 10054 10097 -10097 10115 10115 -10115 10147 10147 -10147 10183 10183 -10183 10208 10208 -10208 10236 10236 -10236 10269 10269 -10269 10304 10304 -10304 10328 10328 -10328 10351 10351 -10351 10371 10371 -10371 10402 10402 -10402 10447 10447 -10447 10497 10497 -10497 10533 10533 -10533 10598 10598 -10606 10630 10630 -10640 10671 10671 -10690 10719 10719 -10728 10752 10795 -10795 10837 10837 -10837 10876 10876 -10876 10900 10900 -10900 10948 10948 -10960 11021 11103 -11103 11128 11128 -11128 11153 11153 -11153 11216 11216 -11216 11239 11239 -11239 11303 11303 -11303 11347 11347 -11357 11393 11393 -11393 11432 11432 -11442 11494 11494 -11494 11536 11536 -11536 11595 11595 -11595 11622 11622 -11622 11684 11684 -11684 11726 11726 -11738 11778 11778 -11782 11813 11813 -11813 11850 11850 -11850 11900 12087 -12111 12120 12120 -12120 12129 12129 -12129 12158 12158 -12158 12192 12192 -12192 12237 12237 -12237 12273 12273 -12273 12326 12326 -12330 12366 12366 -12366 12423 12423 -12427 12482 12482 -12486 12560 12560 -12568 12631 12631 -12637 12691 12691 -12691 12743 12743 -12743 12785 12785 -12785 12826 12826 -12826 12865 12865 -12865 12883 12883 -12883 12946 12946 -12956 12995 12995 -13005 13066 13066 -13077 13163 13163 -13163 13211 13211 -13211 13270 13270 -13270 13318 13318 -13318 13350 13350 -13350 13387 13387 -13387 13428 13428 -13428 13464 13533 -13533 13580 13737 -13737 13776 13854 -13854 13913 13913 -13913 13950 13950 -13950 14118 14118 -14118 14150 14150 -14150 14163 14194 -14194 14224 14255 -14255 14275 14319 -14319 14353 14458 -14466 14484 14530 -14534 14567 14567 -14567 14635 14682 -14690 14742 14742 -14742 14789 14789 -14801 14875 14875 -14886 14947 14947 -14947 14992 14992 -14992 15035 15085 -15085 15134 15205 -15214 15267 15448 -15454 15496 16810 -16822 16875 16960 -16972 17053 17179 -17191 17236 17332 -17344 17491 17841 -17853 17939 18304 -18316 18471 18774 -18786 18952 19323 -19335 19364 19496 -19500 19527 19598 -19598 19613 19776 -19797 19808 19837 -19837 19862 19862 -19868 19927 20026 -20034 20075 20179 -20187 20223 20223 -20223 20290 20382 -20392 20441 20589 -20601 20656 20656 -20656 20699 20818 -20826 20860 21038 -21046 21094 21191 -21203 21236 21314 -21326 21395 21457 -21469 21502 21502 -21502 21587 21731 -21756 21789 21864 -21875 21901 21976 -22013 22059 22220 -22257 22397 22561 -22561 22595 22595 -22603 22623 22623 -22631 22667 22828 -22865 22919 22994 -23031 23059 23120 -23132 23201 23201 -23212 23274 23274 -23285 23345 23345 -23356 23393 23393 -23399 23431 23532 -23542 23587 23646 -23656 23697 23745 -23755 23796 23844 -23854 23876 23928 -23942 23971 24153 -24160 24243 24243 -24247 24273 24743 -24755 24784 24984 -24996 25034 25034 -25034 25075 25273 -25281 25332 25410 -25420 25467 25544 -25554 25583 25744 -25754 25783 26061 -26071 26111 26185 -26194 26239 26525 -26535 26568 26914 -26924 26951 26998 -27008 27035 27082 -27093 27120 27167 -27178 27206 27251 -27261 27289 27334 -27345 27391 27931 -27938 27959 28007 -28019 28037 28037 -28043 28069 28069 -28077 28147 28199 -28207 28266 28266 -28274 28306 28306 -28314 28339 28339 -28347 28404 28510 -28518 28567 28682 -28690 28728 28728 -28736 28782 29023 -29033 29085 29234 -29246 29303 29383 -29395 29432 29570 -29592 29631 29644 -29644 29693 29758 -29767 29810 29875 -29875 29911 29976 -29984 30014 30014 -30027 30086 30151 -30157 30223 30293 -30301 30369 30445 -30457 30511 30568 -30580 30630 30743 -30755 30812 30874 -30886 30959 31035 -31043 31076 31175 -31183 31243 31243 -31251 31323 31323 -31331 31433 31433 -31445 31544 31686 -31698 31740 31740 -31740 31783 31783 -31783 31824 31824 -31824 31873 31996 -32008 32056 32164 -32176 32210 32210 -32229 32271 32271 -32279 32323 32569 -32581 32642 32718 -32739 32779 32916 -32926 32953 33047 -33057 33116 33315 -33325 33373 33373 -33373 33407 33469 -33494 33527 33527 -33536 33573 33573 -33584 33650 33697 -33705 33763 33763 -33763 33797 33797 -33797 33829 33906 -33915 33976 33976 -33985 34016 34098 -34098 34133 34198 -34198 34261 34261 -34269 34312 34312 -34324 34363 34438 -34444 34530 34530 -34538 34596 34626 -34636 34675 34754 -34764 34821 34821 -34821 34867 34950 -34959 35016 35135 -35145 35198 35198 -35208 35266 35344 -35355 35382 35537 -35547 35576 35629 -35637 35705 35705 -35713 35764 35764 -35764 35784 35876 -35888 35932 35950 -35950 36013 36138 -36150 36191 36280 -36286 36314 36419 -36431 36516 36516 -36516 36554 36642 -36642 36689 36808 -36818 36881 37105 -37113 37183 37204 -37204 37225 37225 -37225 37255 37348 -37348 37388 37388 -37388 37454 37454 -37454 37518 37518 -37518 37584 37584 -37584 37717 37717 -37717 37752 37752 -37752 37783 37889 -37901 37928 38034 -38046 38115 38115 -38115 38140 38187 -38195 38219 38339 -38351 38422 38422 -38422 38486 38486 -38486 38555 38555 -38555 38619 38619 -38619 38641 38641 -38641 38758 38758 -38758 38929 38929 -38929 38975 39043 -39055 39084 39133 -39133 39175 39265 -39275 39310 39494 -39504 39547 39576 -39587 39614 39668 -39674 39697 39797 -39797 39845 40094 -40094 40158 40264 -40264 40369 40523 -40523 40593 40593 -40593 40629 40876 -40876 40911 40971 -40977 41026 41026 -41038 41077 41077 -41077 41116 41116 -41116 41156 41156 -41156 41195 41195 -41195 41237 41237 -41237 41285 41285 -41285 41304 41304 -41304 41371 41371 -41371 41429 41429 -41429 41491 41491 -41491 41519 41519 -41519 41572 41572 -41572 41642 41642 -41642 41676 41676 -41676 41713 41713 -41713 41751 41751 -41751 41792 41792 -41792 41856 41856 -41856 41881 41881 -41881 41936 41936 -41936 41977 41977 -41977 42018 42018 -42018 42090 42090 -42090 42162 42162 -42162 42205 42205 -42205 42267 42267 -42267 42294 42294 -42294 42309 42309 -42309 42338 42386 -42393 42425 42522 -42530 42577 42577 -42577 42623 42623 -42623 42643 42725 -42725 42748 42748 -42748 42829 42897 -42901 42952 42952 -42952 42978 43025 -43025 43116 43116 -43116 43171 43171 -43171 43204 43376 -43386 43453 43471 -43471 43547 43780 -43798 43921 44116 -44120 44120 44120 -Out of memory: %s -There is no more memory left in the system for compiling this program. -Internal Error Unknown Error Message %s -1) An internal error, while attempting to print an unavailable message -2) The error message file is inaccessible or has other problems -Unknown Signal %s -1) An unknown signal has been caught -2) 2 Nested signals -line -Warning: -Fatal: -Source not available -Too many errors... goodbye. -There is a limit of 30 errors before aborting. -Error: -reserved -reserved -Unknown Control Statement -1) The line begins with a '#' and is not of the form: - # "" -2) Please compile this program with the preprocessor enabled. -Unknown character %s ignored -The character is not part of the source character set. -2.2.1 -Unknown control character \%s ignored -The control character is not part of the source character set. -2.2.1 -Illegal character %s in exponent -1) Digits or sign expected after 'e' or 'E'. -2) Digits are expected after sign in exponent. -3.1.3.1 -Constant is out of range and may be truncated. -The constant is too large to be accurately represented and may be -truncated. The limits are in the system include file limits.h. -2.2.4.2 -Constant is out of range for a 32-bit data type, but accepted as written. -The constant is too large to fit in a 32-bit data type, but will be -accurately represented in a wider data type. The value may be truncated, -depending on its context. The limits are in the system include file -limits.h. -2.2.4.2 -Character constant size out of range -1) No characters in a character constant. -2) More than 4 bytes in a character constant. -3.1.3.4 -Wide character constant size out of range -1) No characters in the multibyte sequence (0 assumed). -2) More than 1 byte in the multi-byte sequence (only the first byte was converted). -3.1.3.4 -Invalid multibyte character -4.10.7.2 -Newline in string or character constant -1) Terminate your string or character constant with closing quotes. -2) Put a backslash before the newline. -3.1.3.4, 3.1.4 -Octal character escape too large: %s > %s -1) Terminate end of octal sequence with a non-octal character. -2) Select a character value within the limits. -Value may be truncated -3.1.3.4, 3.1.4 -Hex character escape too large: %s > %s -1) Terminate end of hex sequence with a non-hex character. -2) Select a character value within the limits. -Value may be truncated -3.1.3.4, 3.1.4 -Unexpected End-of-file -1) Unterminated string or character constant -2) Missing closing comment marker (*/) -3) File system problems -Unrecognized escape sequence in string \%s -Recognized escape sequences are \a, \b, \f, \n, \r, \t, and \v. -Character will be treated as un-escaped. -3.9.2 -Illegal octal digit %s -Octal constants, beginning with 0, must only have digits between 0 and 7, -inclusive. -3.1.3.2 -Unable to open temporary file for compiling %s -1) TMPDIR environment variable is set to a directory that you have no - permissions for. -2) The file system is full. -3) System errors beyond the scope of the compiler. -%s: Hangup -%s: Interrupt -%s: Quit (ASCII FS) -%s: Illegal instruction (not reset when caught) -%s: Trace trap (not reset when caught) -%s: IOT instruction -Also SIGABRT, used by abort, replace SIGIOT in the future -%s: EMT instruction -Also SIGXCPU, Exceeded CPU time limit -%s: Floating point exception -%s: Kill (cannot be caught or ignored) -%s: Bus error -%s: Segmentation violation -%s: Bad argument to system call -%s: Write on a pipe with no one to read it -%s: Alarm clock -%s: Software termination signal from kill -%s: User defined signal 1 -%s: User defined signal 2 -%s: Death of a child -Power-fail restart -%s: Also SIGXFSZ, exceeded file size limit -%s: Window change -%s: Handset, line status change -%s: Sendablestop signalnot from tty -%s: Stop signal from tty -%s: Pollable event occurred -%s: Input/Output possible signal -%s: Urgent condition on IO channel -%s: Window size changes -%s: Virtual time alarm -%s: Profiling alarm -%s: Continue a stopped process -%s: To readers pgrp upon background tty read -%s: Like TTIN for output if (tp->t_local<OSTOP) -%s: Resource lost (eg, record-lock) -'auto' and 'register' are not allowed in an external declaration -3.7(10) -must have function type -3.7.1(30) -Functions cannot return arrays -3.7.1(33), 3.3.2.2 -Declaration list not allowed -3.7.1(5) -Too many input files %s -The command line may contain only one file -cpp internal error: input stack underflow -cpp internal error: if stack underflow -Cannot open the file %s -No new-line character at the end of the file %s -2.1.1.2(30) -Fatal: Exceeded the limit of nesting level for #include file -Fatal: Exceeded the limit of nesting level for #include file. This limit -is 200. -Fail to read the file %s -Cannot write the file %s -%s: %s: An if directive is not terminated properly in the file -%s: %s: nested comment -%s:%s: Illegal macro name %s; macro name shall be an identifier -%s:%s: Illegal preprocessing token sequence -3.8.3(35) -%s:%s: Illegal macro parameter name -%s:%s: Non-unique macro parameter name -3.8.3(18) -%s:%s: Missing ')' in parameter list for #define %s -%s:%s: Missing ')' in macro instantiation -%s:%s: Bad punctuator in the parameter list for #define %s -%s:%s: Macro %s redefined. -%s:%s: # operator should be followed by a macro argument name -%s:%s: Badly formed constant expression%s -3.4(9), 3.8 -%s:%s: Division by zero in #if or #elif -3.8 -unknown command line option %s -extraneous input/output file name %s -%s: %s: Unterminated string or character constant -A preprocessing string or character constant token was not -terminated. Note that preprocessing directives are processed -after the source file has been divided into preprocessing tokens. -2.1.1.2(30) 3.1(18) 3.8 -%s: %s: -%s: %s: -%s: %s: Unterminated comment -%s: %s: Unknown directive type %s -%s: %s: #elif or #else after #else directive -%s: %s: Bad identifier after the %s -%s: %s: #%s accepts only one identifier as parameter -3.8 -%s: %s: Bad identifier after the %s -%s: %s: text following #%s violates the ANSI C standard. -3.8 -%s: %s: Bad character %s occurs after the # directive. -3.8 -%s: %s: the ## operator shall not be the %s token in the replacement list -3.8.3.3 -%s: %s: the defined operator takes identifier as operand only. -3.8.1 -%s: %s: Not in a conditional directive while using %s -%s: %s: Illegal filename specification for #include -%s: %s: Invalid file name %s for #include -%s: %s: Cannot open file %s for #include -%s: %s: Bad argument for #line command -%s: %s: #error %s -%s: %s: Tried to redefine predefined macro %s, attempt ignored -3.8.7(22) -%s: %s: Undefining predefined macro %s -3.8.7(22) -%s: %s: Undefined the ANSI standard library defined macro %s -4.1.2.1(9) -%s: %s: The number of arguments in the macro invocation does not match the definition -%s: %s: Illegal character %s in preprocessor if -%s: %s: Illegal character %s for number in preprocessor if -%s: %s: No string is allowed in preprocessor if -%s: %s: Not supported pragma %s -%s: %s: Not supported #pragma format -%s: %s: ANSI C does not allow #ident; %s -%s: %s: Not supported #ident format -This cpp extension accepts the following format: -#ident "any string" -%s: %s: Not supported #assert/#unassert format -This cpp extension accepts the following format: -#assert identifier -#assert identifier ( pp-tokens ) -#unassert identifier -#unassert identifier ( pp-tokens ) -%s: %s: Bad assertion predicate format -The correct syntax for this cpp extension is: -#assert identifier ( pp-token ) -%s: %s: directive is an upward-compatible ANSI C extension -%s: This option requires an argument -%s: %s: A macro has expanded recursively more than %s times. Further expansion will be disabled! Use command-line option: -Wp,-max_rec_depth=depth to recurse deeper. -A status return from cpp to cfe -Syntax Error -The token read was unexpected. -Syntax Error -- cannot backup -The token read was unexpected. -Yacc stack overflow -The expression is too complicated to parse. -Trailing comma in enumerator list -The use of a trailing comma in an enumerator list is not standard C. There -may be portability problems. -3.5.2.2 -Empty declaration -Empty declarations are invalid in standard C. -3.5 -%s declared, but not referenced. -redeclaration of '%s'; previous declaration at line %s in file '%s' -Identifier redeclared in the same scope/block. -3.1.2.3 -'%s' undefined; reoccurrences will not be reported. -Non-function name referenced in function call. -3.3.2.2(18) -The number of arguments doesn't agree with the number in the declaration. -3.3.2.2(5) -'%s' section name longer than 8 characters. Name truncated. -'%s' is already placed by pragma alloc_text. -Cannot write ucode file while compiling %s -1) The file system is full -2) Permissions problem -Must have corresponding formal argument for '%s' -Parameter found in the declaration part, but not in the argument list. -3.7.1(7) -Non-prototype declaration is an obsolescent feature. -The use of function definitions with separate parameter identifier -and declaration lists (not prototype-format parameter type and -identifier declarators) is an obsolescent feature. -3.9.5 -Incompatible function declarations for %s -For two function types to be compatible, both shall specify compatible -return types. Moreover, the parameter type lists, if both are present, -shall agree in the number of parameters and in use of the ellipsis -terminator; corresponding parameters shall have compatible types. If -one type has a parameter type list and the other type is specified by -a function declarator that is not part of a function definition and -contains an empty identifier list, the parameter list shall not have -an ellipsis terminator and the type of each parameter shall be -compatible with they type that results from application of the default -argument promotions. If one type has a parameter type list and the -other is specified by a function definition that contains a (possibly -empty) identifier list, both shall agree in the number of parameters, -and the type of each prototype parameter shall be compatible with the -type that results from application of the default argument promotions -to the type of the corresponding identifier. (For each parameter -declared with function or array type, its type for these comparisons -is the one that results from conversion to a pointer type. For each -parameter declared with qualified type, its type for these comparisons -is the unqualified version of its declared type.) There you have it! -3.5.4.3(15) -Incompatible function return type for this function. -For two function types to be compatible, both shall specify compatible -return types. -3.5.4.3(15) -The number of parameters for function is different from the previous declaration -The parameter type lists, if both are present, shall agree in the -number of parameters and in use of the ellipsis terminator. -3.5.4.3(15) -Incompatible type for the function parameter -If both parameter type lists are present, corresponding -parameters shall have compatible types. -3.5.4.3(15) -Function %s is redeclared with an incompatible argument type (after default argument promotion), which could lead to undefined run-time behaviour. -The redeclaration could cause arguments at a call site to be passed -inconsistently with what the function implementation expects, and -parameters would therefore be accessed erroneously when executing the -function body. Note that a float argument is promoted to a double -when passed (potentially through fp registers) to an unprototyped -function. -3.5.4.3(15) -prototype and non-prototype declaration found for %s, ellipsis terminator not allowed -If one type has a parameter type list and the other type is specified -by a function declarator that is not part of a function definition and -contains an empty identifier list, the parameter list shall not have -an ellipsis terminator and the type of each parameter shall be -compatible with they type that results from application of the default -argument promotions. -3.5.4.3(15) -prototype and non-prototype declaration found for %s, the type of this parameter is not compatible with the type after applying default argument promotion -If one type has a parameter type list and the other type is specified -by a function declarator that is not part of a function definition and -contains an empty identifier list, the type of each parameter shall be -compatible with the type that results from application of the default -argument promotions. -3.5.4.3(15) -prototype declaration and non-prototype definition found for %s, the type of this parameter is not compatible with the type after applying default argument promotion -If one type has a parameter type list and the other is specified by a -function definition that contains a (possibly empty) identifier list, -both shall agree in the number of parameters, and the type of each -prototype parameter shall be compatible with the type that results -from application of the default argument promotions to the type of the -corresponding identifier. -3.5.4.3(15) -Empty declaration specifiers -Standard C requires at least a storage class specifier, type specifier, -or a type qualifier in declarations. 'extern int' assumed. -3.5 -Can't write to the file %s -1) The output file cannot be opened for writing. -2) Out of file space. -Duplicate '%s' -typedef, extern, static, auto, register, const, volatile may not -appear more than once in the same specifier list or qualifier list. -Duplicate occurrence ignored. -3.5.1(10) , 3.5.3(5) -Null input -There is nothing to compile. -Illegal type combination -3.5.2 -Missing ';' at end of structure / union member declaration -In standard C, each member declaration must be terminated by a ';'. A -terminating ';' is assumed. -3.5.2.1 -Missing member name in structure / union -In standard C, each member declaration have a member name. The missing -member is assumed to not exist. -3.5.2.1 -This variable is initialized twice. -Neither 'const' or 'volatile' have any effect on function results. -Qualifiers only apply to expressions designating an object that -can be altered or examined. -3.5.3(10) -An integer constant expression is required here. -The expression that defines the value of an enumeration constant -shall be an integral constant expression that has a value -representable as an int. -3.5.2.2(28) -(previous declaration of '%s' at line %s in file '%s') -Must be an integer type greater than zero. -The array size must be either a char, signed or unsigned integer or -an enumerated type with a value greater than zero. -3.5.4.2 -Array size cannot be a long long. -Arrays with more than 2^32 elements are not yet supported. -The array size must be either a char, signed or unsigned integer or -an enumerated type with a value greater than zero. -3.5.4.2 -bit-field '%s' width is not an integer constant -The expression that specifies the width of a bit-field shall be an -integral constant expression. -3.5.2.1(15) -bit-field '%s' width is negative -The expression that specifies the width of a bit-field shall be -non-negative. -3.5.2.1(15) -bit-field '%s' type required to be int, unsigned int, or signed int. -A bit-field shall have type int, unsigned int, or signed int. -3.5.2.1(30) -bit-field %s's type not integer. -Non-scalar type or pointer type to a non-object for increment or decrement operator. -The operand of the prefix/postfix increment or decrement operator shall have scalar type; if it is of pointer type, it must point to an object. -3.3.2.4(37), 3.3.3.1(25) -Assign value to a function type. -An assignment operator shall have a modifiable lvalue as its left operand. -3.2.2.1(5) -Assign value to an array. -An assignment operator shall have a modifiable lvalue as its left operand. -3.3.2.4(36), 3.3.3.1(24), 3.2.2.1(5) -Change value for variable of incomplete type. -The operand of increment and decrement operator shall be a modifiable -scalar lvalue. An assignment operator shall have a modifiable lvalue -as its left operand. -3.3.2.4(36), 3.3.3.1(24), 3.2.2.1(5) -The left-hand side of the '.' operator must be an addressable lvalue, when a bit-field is not contained within a unit of 32 bits alignment. -This is a restriction in our implementation, which can be worked -around by always accessing long long bit-fields indirectly (i.e. -by means of the '->' operator). -This expression is not an lvalue. -3.2.2.1 -Modified an rvalue. -3.2.2.1 -Change value for constant variable. -The operand of increment and decrement operators shall be modifiable -scalar lvalues. An assignment operator shall have a modifiable lvalue -as its left operand. -3.3.2.4(36), 3.3.3.1(24), 3.2.2.1(5) -Change value for constant field of a struct or union. -An assignment operator shall have a modifiable lvalue as its left operand. -3.3.2.4(36), 3.3.3.1(24), 3.2.2.1(5) -Dereferenced a non-pointer. -The operand of the unary * operator shall have pointer type. -3.3.3.2(39) -The operand of the unary + or - operator shall have arithmetic type. -3.3.3.3(6) -The operand of the unary ~ operator shall have integral type. -3.3.3.3(6) -The operand of the unary ! operator shall have scalar type. -3.3.3.3(6) -Constants must have arithmetic type. -3.1.3 -Bad type name for cast operator -The type name for the cast operator should either be void or a -qualified or unqualified scalar type. -3.3.4(22) -Improper cast of non-scalar type expression. -The operand for the cast operator shall be of scalar type. -3.3.4(23) -Cast a pointer into a non-integral type. -A pointer may be converted to an integral type. -3.3.4(31) -Cast a non-integral type into a pointer. -An integral type may be converted to a pointer. -3.3.4(31) -Duplicate member '%s' -Two members of a struct may not have the same name. -3.1.2.2(7,25) -Invalid constant expression. -Constant expressions shall not contain assignment, increment, decrement, -function-call, or comma operators, except when they are contained within -the operand of the sizeof operator. -3.4(9) -Constant expressions must be derived from a constant value or a constant -variable. -3.4 -Dangerous operand of '&'. -The operand of the unary & operator shall be either a function -designator or an lvalue that designates an object that is not a -bit-field and is not declared with the register storage-class -specifier. This operand is NOT an lvalue, but we let it pass. -Note that a segmentation error with possible core dump will result -when the resulting address does not denote a valid (declared) -storage location. This feature will be discontinued in future -releases of the compiler! -3.3.3.2(36) -Unacceptable operand of '&'. -The operand of the unary & operator shall be either a function -designator or an lvalue that designates an object that is not a -bit-field and is not declared with the register storage-class -specifier. -3.3.3.2(36) -'&' before array or function; ignored -Unacceptable operand of sizeof operator. -The sizeof operator shall not be applied to an expression that has -function type or an incomplete type, to the parenthesized name of such -a type, or to an lvalue that designates a bit-field object. -3.3.3.4 -Unacceptable operand of a multiplicative operator. -Each of the operands of a multiplicative operator shall have arithmetic type. -3.3.5(18) -Unacceptable operand of the remainder operator -Each of the operands of the remainder (%) operator shall have integral type. -3.3.5(18) -Unacceptable operand of '+'. -For the + operator, either both operands shall have arithmetic type, or -one operand shall be a pointer to an object type and the other shall -have integral type. -3.3.6(39) -Unacceptable operand of '-'. -For the subtraction operator, one of the following shall hold: both operands -have arithmetic type; operands are pointers to qualified or unqualified -versions of compatible object types; or the left operand is a pointer -to an object type and the right operand has integral type. -3.3.6(39) -Unacceptable operand of shift operator. -Each of the operands of bitwise shift operators shall have integral type. -3.3.7(9) -Unacceptable operand of relational operator. -For relational operators, one of the following shall hold: both -operands have arithmetic type; both operands are pointers to qualified -or unqualified versions of compatible object types; or both operands -are pointers to qualified or unqualified versions of compatible -incomplete types. -3.3.8(32) -Unacceptable operand of == or != -For the == or != operator, one of the following shall hold: both operands -are pointers to qualified or unqualified versions of compatible types; one -operand is a pointer to an object or incomplete type and the other is a -pointer to a qualified or unqualified version of void; or one operand is -a pointer and the other is a null pointer constant. -3.3.9(21) -Unacceptable operand of &. -Each of the operands shall have integral type. -3.3.10(7) -Unacceptable operand of ^. -Each of the operands shall have integral type. -3.3.11(18) -Unacceptable operand of |. -Each of the operands shall have integral type. -3.3.12(30) -Unacceptable operand of &&. -Each of the operands shall have scalar type. -3.3.13(7) -Unacceptable operand of ||. -Each of the operands shall have scalar type. -3.3.14(20) -Unacceptable operand of conditional operator. -The first operand of conditional operator shall have scalar type. One -of the following shall hold for the second and third operands: -both operands have arithmetic type; both operands have compatible -structure or union types; both operands have void type; both operands -are pointers to qualified or unqualified versions of compatible types; -one operand is a pointer and the other is a null pointer constant; or -one operand is pointer to an object or incomplete type and the other -is a pointer to a qualified or unqualified version of void. -3.3.15 -Duplicate label '%s' -A label name can only occur once in a function. -3.1.2.1(25) -Division by zero. -3.3.5 -Subscripting a non-array. -3.3.2.1 -Subscripting an array of incomplete type which is not an object type. -The element of the array shall have an object type. -3.3.2.1 -Should only subscript an array with an integral expression -3.3.2.1 -Subscripting an unbounded array -3.3.2.1 -Array index out of range -3.3.2.1 -Selector requires struct/union pointer as left hand side -In K&R mode the expression is implicitly converted to the '.' selector -for a struct/union left-hand side. -3.3.2.3 -Selector requires struct/union as left hand side -In K&R mode the expression is implicitly converted to the '->' selector -for a struct/union pointer left-hand side. -3.3.2.3 -member of structure or union required -3.3.2.3 -types have different qualifier specifications -For two qualified types to be compatible, both shall have the -identically qualified version of a compatible type; qualified -and unqualified versions of a type are distinct types. For two -types to be compatible their types must be the same. -3.5.3(26) -Incompatible array type due to different array size -For two array types to be compatible, both shall have compatible element -types; if both size specifiers are present, they shall have the -same value. -3.5.4.2(11) -Incompatible array type due to incompatible element type -For two array types to be compatible, both shall have compatible element -types. -3.5.4.2(11) -Incompatible pointer type assignment -The type pointed to by the left-hand side of simple assignment -statement is incompatible with the type pointed to by the right-hand side. -3.3.16.1, 3.5.4.1(21) -Incompatible base type of pointer type -K&R feature. -Type %s of %s is incompatible with type %s of %s -Incompatible types can be resolved by casting or by other means. -3.3.16.1 -illegal combination of pointer and integer -Assigning an integral expression to a pointer is a bad practice. -Type for %s is incompatible with %s -Incompatible types can be resolved by casting or by other means. -3.1.2.6 -Bad operand type for += or -= -3.3.16.2(26) -A case or default label appears outside a switch statement -A case or default label shall appear only in a switch statement. -3.6.1 -The controlling expression of the if statement is not scalar type -The controlling expression of an if statement shall have scalar type. -3.6.4.1 -The controlling expression of switch statement is not integral type -The controlling expression of an switch statement shall have integral type. -3.6.4.2(20) -The case label is not an integral constant expression -The case label shall be an integral constant expression. -3.6.4.2(22) -Duplicate case label in the same switch statement -No two of the case constant expressions in the same switch statement -shall have the same value after conversion. -3.6.4.2(22) -More than one default label in the same switch statement -There may be at most one default label in a switch statement. -3.6.4.2(23) -The controlling expression of the iteration statement is not scalar -type -The controlling expression of a iteration statement shall have scalar -type. -3.6.5.1 -label '%s' used, but not defined -The identifier in a goto statement shall name a label located -somewhere in the enclosing function. -3.6.6.1 -A continue statement shall appear only in or as a loop body -3.6.6.2 -A break statement shall appear only in or as a switch body or loop body -3.6.6.3 -A return statement with an expression should not appear -in a function '%s', whose return type is void -3.6.6.4(24) -A return statement without an expression appears in a -function '%s', whose return type is not void -If a return statement without an expression is executed, and the value -of the function call is used by the caller, the behavior is undefined. -3.6.6.4(33) -Internal Error: statement stack underflow -Long double not supported; double assumed. -Long float not standard; double assumed. -Only 'register' allowed in parameter declaration -The only storage-class specifier that shall occur in a parameter -declaration is 'register'; illegal storage class ignored. -3.5.4.3(25) -Name(s) without types in a function declaration -An old-style function declaration is not allowed to have names -in the parameter list; useless names ignored -3.5.4.3(26) -Functions cannot return functions -3.7.1(33), 3.3.2.2 -Functions cannot return a non-object type -3.3.2.2 -enum declaration must contain enum literals -Although structs or unions may delay the declaration of their members, -a similar construction with enum does not exist and is not necessary, -as there can be no mutual dependencies between the declaration of an -enumerated type and any other type. -3.5.2.3(27) -Register qualification has no effect for this type of object -Register declarations for array, struct, and function types have -no effect. -3.5.1(16), 3.5.1(19) -Functions cannot be declared 'register' -The declaration of an identifier for a function that has block -scope shall have no explicit storage-class specifier other than -'extern'. -3.5.1(19) -'%s' cannot be initialized -The type of the entity to be initialized shall be an object type -or an array of unknown size. -3.5.7(32) -Cannot initialize 'extern' variable '%s' within a function -If the declaration of an identifier has block scope, and the -identifier has 'extern' or 'static' linkage, the declaration -shall have no initializer for the identifier; initialization -allowed anyway. -3.5.7(35) -initializing an 'extern' is an ANSI C extension -conflicting declarations for '%s' -'static' and 'extern' declarations conflict. Which is meant? -3.1.2.2(15), 3.1.2.2(27) -Too many initial values for '%s' -3.5.7(1) -incompatible types in initialization -3.3.16(35) -redefinition of '%s'; previous definition at line %s in file '%s' -Identifier redeclared in the same scope/block. -3.1.2.3 -bit-fields as members of a union are an ANSI C invention. -storage size for '%s' isn't known -type mismatch in initialization -Missing braces in a union initialization or illegally formed -initialization. -3.5.7(5) -union '%s' only allowed one initializer for the first member -3.5.7(5) -width of '%s' exceeds its type -the specified bitfield width is too large to be contained within a -bitfield type. -structure has no member named '%s' -This is allowed for compatibility with AT&T pcc-based compilers. -Reference of an expression of void type or an incomplete type. -3.2.2.1 -element size of an array shall not be zero -3.2.2.5(25) -invalid combination of type specifiers -Although order is unimportant, not all type specifiers can occur together. -3.5.2 -declaration must at least declare an identifier, tag, or the member of an enumeration -3.5(16) -at most one storage class may be given in the declaration -Duplicate occurrence ignored. -3.5.1(10) -size of function's return type is zero -The return type of a function must be void or an object type other than array. -3.7.1(33) -Expecting an integral return type from the main function -identifier missing from parameter declaration -Prototypes for function definitions require identifiers in parameter -declarations. -3.7.1(4) -only 'register' allowed for storage class for parameters -The declarations in the declaration list shall contain no storage class -other than 'register', and no initializations. -3.7.1(10) -parameters declarations can not have initializations -3.7.1(10) -only one instance of 'void' allowed in the parameter list -'void' must occur by itself (specifying that the function has no parameters). -3.5.4.3(1) -%s must have function type -1) An argument list must be explicitly present in the declarator; it cannot - be inherited from a typedef (3.5.4.3). -2) The declarator is not a function. -3.7.1(30) -Illegal hexadecimal constant -You have no digits after the 0x or 0X. 0x0 assumed. -3.1.3.2 -value overflows its type in this context. Value is set to be '%s'! -3.2.1.4 -value is outside range representable for type '%s' -missing member name -K&R mode permits a missing member name; otherwise, only bitfields can omit -the member name. -3.5.2.1(10) -useless keyword or type name in declaration -Type was ignored. -'%s' declared within and is limited to this function prototype -Possible program error, since parameter type checking will always fail -unless the type declaration is visible to the caller. -3.1.2.1(35) -Extra spaces within operator, %s assumed -In ANSI C, the compound assignment operator cannot have embedded -white space characters. -3.1.5 -missing size for array '%s' -Incomplete types permitted for identifiers with internal or -external linkage, but not automatic linkage. -3.1.2.5(10) -can't jump into (from outside of) the body of a 'try' or into either type of handler -'%s' missing, please #include excpt.h -excpt.h required to declare exception statements, intrinsics or compiler -runtime names. -local function declarations cannot be 'static' -A function declaration can only contain the storage-class 'static' -if it is at file scope. Declaration made 'extern'. -3.5.1(19) -static function '%s' declared and referenced, but not defined. -If an identifier declared with internal linkage is used in an -expression (other than as a part of the operand of a sizeof -operator), there shall be exactly one external definition for -the identifier in the translation unit. -3.7(12) -pragma argument '%s' must be declared prior to being used in a pragma -Pragma name ignored. -Pragma not supported -'%s' not enabled as intrinsic -It may have already appeared in a function pragma, or never occurred in -an intrinsic pragma. -'%s' is already enabled as an intrinsic -weak definition for '%s' is later redefined; pragma weak ignored. -definition of primary name '%s' not found; pragma weak ignored. -definition of secondary name '%s' not found; pragma weak ignored. -primary name '%s' is declared as a common or external, and is not defined -with initial value within this file; pragma weak ignored. -useless '%s' storage class ignored -array of functions not allowed -The element type must be an object type representing a region -of data storage which can represent values. -3.1.2.5(23) -array of voids not allowed -The element type must be an object type representing a region -of data storage which can represent values. -3.1.2.5(23) -argument for pragma pack must be an integer constant; pragma ignored -'%s' has wrong tag type. -Identifier redeclared in the same scope/block. -3.1.2.3 -missing dimension bound -For multidimensional arrays, the constant bounds of the array may be -omitted only for the first member of the sequence. -3.1.2.5(23) -Internal error in parameters to function substr; loc: '%s'; len: '%s'. -Internal error in parameters to function insertstr; indx: '%s'. -Internal error in function get_tag_name; input is a non-tagged type. -Internal error in function gen_type_str -- not a type tree '%s' -Cannot open file '%s' -Prototype should be moved after tag or a typedef declaration. -Please look for comments in the extracted header file. -The extracted header file includes prototypes for static functions, -which should be removed, if you wish to include the header in a source file -other than the originator. -ANSI C requires formal parameter before "..." -This extension is meant to be used for compatibility with varargs.h -3.5.4.3(35) -syntax error: "&..." invalid -extension used to access "..." formal arguments. -function '%s' initialized like a variable -The type of entity to be initialized shall be an object type or an -array of unknown size. -3.5.7(31) -initializer not an array aggregate -The initializer for an object that has aggregate type shall be a -brace-enclosed list of initializers for the members of the aggregate, -written in increasing subscript or member order. -3.5.7(20) -'%s' type is incomplete; cannot initialize -Was the struct ever defined? -3.5.7.(31) -'%s' is not standard ANSI. -This keyword/type is not defined in strict ANSI mode. -3.1.1 -not a legal asm string -The first operand of an asm string should be, after argument substitution, -a legal assembly string. -The -float option will be ignored in ANSI mode. -The -float option is ignored, since otherwise program semantics would -violate the ANSI standard. In particular, fp constants are always -'double' with ANSI-C, while with -float the type of fp constants will -depend on the context and may be 'float'. -ANSI C support unavailable with C compiler bundled with RISC/os -The C compiler bundled with RISC/os does not support ANSI C. ANSI -C support requires a separate license. -Ignored invalid warning number(s) in -woff option, %s%s ! -Warning numbers must be in the range %s to %s. -The set of warning numbers in cfe is disjoint from the set of warning numbers -in accom, since accom warnings cannot be mapped one-to-one to cfe warnings. -'%s' not handled as an intrinsic due to incompatible argument types . -'__unalign' only qualifies pointers -'__unalign' indicates the object pointed at by pointer is unaligned (e.g., -int * __unalign p). This is an extension to ANSI C and like 'volatile' -and 'const' can follow the '*' in pointer declarations, but unlike both -cannot qualify a base type. -index expression is an anachronism -ANSI C++ doesn't support array index expressions in delete. -5.3.4 -member cannot be of function or incomplete type. -3.5.2.1(12) -Illegal lint option, '%s', is ignored. -cannot open header message buffer file -cannot write header message buffer file -cannot read header message buffer file -cannot seek in header message buffer file -struct/union/enum '%s' is used, but not defined -static '%s' unused -nonportable character comparison (chars may be signed or unsigned) -redundant comparison of unsigned with constant expression -redundant statement, control flow cannot reach this statement -'%s' may be used before set -function parameter '%s' is not used in function '%s' -'%s' can be const qualified, since it is not set within its lifetime. -'%s' is not used in function '%s' -'%s' set but unused in function '%s' -control may fall through %s statement -function '%s' has return(e); and return; -function '%s' may return random value to place of invocation %s -label without goto: '%s' -width of %s constant is smaller than size of type (%s) -explicit conversion from '%s' to '%s' %s -implicit conversion from '%s' to '%s' %s -'%s' may be indistinguishable from '%s' due to internal name truncation -Promoted formal parameter and promoted argument have incompatible types -No prototype for the definition of '%s' %s -References to '%s' are substituted by its literal initializer - (as included in %s) -============== -unsupported language linkage -string-literal specifies an unsupported linkage -7.4(1) -No prototype for the call to %s -To achieve better type-checking, there should be a full prototype for -the function being called. -3.5.4.3 -'inline' only applies to function declarations -leave statment can occur only within try body -Microsoft extension -Use of a Microsoft extension detected without usage of the -compiler option -msft. -No parameter mentioned -A file with no declarations or definitions is accepted as an extension to ANSI C -The translation unit must contain at least one external definition. -3.7 -Incompatible signed and unsigned version of a type -Yacc initialization error -Internal error: yacc cannot initialize itself. -The cfe option %s may not be in future releases. We suggest that you not use this option! -Incompatible char and unsigned char versions of a type -Lshift with undefined behaviour. -Lshift with a negative right operand, or a right operand that is greater -than or equal to the width in bits of the promoted left operand, results -in undefined behaviour. -3.3.7(11) -useless type name in declaration, possibly a semicolon is missing. -Type was ignored. -constant initializer expression is invalid (refers to automatic variables). -All the expressions in an initializer for an object that has static storage -duration or in the initializer list for an object that has aggregate or -union type shall be constant expressions. Otherwise, unexpected results -may occur. -3.5.7(32) and 3.4 -invalid explicit or implicit conversion of an address constant to an integral value in a constant initializing expression. -An address constant in a constant initializing expression can neither -initialize a bit-field nor be directly or indirectly converted to an -integral type of size different from an address type. -6.4 diff --git a/tools/ido5.3_compiler/usr/lib/libc.so.1 b/tools/ido5.3_compiler/usr/lib/libc.so.1 deleted file mode 100755 index 17495ef6..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/libc.so.1 and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/libexc.so b/tools/ido5.3_compiler/usr/lib/libexc.so deleted file mode 100644 index 209c5366..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/libexc.so and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/libgen.so b/tools/ido5.3_compiler/usr/lib/libgen.so deleted file mode 100644 index 7b8ec7fd..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/libgen.so and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/libm.so b/tools/ido5.3_compiler/usr/lib/libm.so deleted file mode 100644 index 05bf4781..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/libm.so and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/ugen b/tools/ido5.3_compiler/usr/lib/ugen deleted file mode 100755 index beb81f4b..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/ugen and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/ujoin b/tools/ido5.3_compiler/usr/lib/ujoin deleted file mode 100755 index 23a4cbbd..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/ujoin and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/uld b/tools/ido5.3_compiler/usr/lib/uld deleted file mode 100755 index bd182fdc..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/uld and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/umerge b/tools/ido5.3_compiler/usr/lib/umerge deleted file mode 100755 index e8e09e66..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/umerge and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/uopt b/tools/ido5.3_compiler/usr/lib/uopt deleted file mode 100755 index 5451428b..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/uopt and /dev/null differ diff --git a/tools/ido5.3_compiler/usr/lib/usplit b/tools/ido5.3_compiler/usr/lib/usplit deleted file mode 100755 index 112abfcd..00000000 Binary files a/tools/ido5.3_compiler/usr/lib/usplit and /dev/null differ