Fixed divu sign extension in live recompiler and fixed warnings

This commit is contained in:
Mr-Wiseguy 2024-10-12 13:30:07 -04:00
parent dc2a5b6a46
commit 4a44e2b4c0
4 changed files with 11 additions and 13 deletions

10
.gitignore vendored
View file

@ -6,8 +6,8 @@
*.elf
*.z64
# Output C files
test/funcs
# Local working data
tests
# Linux build output
build/
@ -42,12 +42,6 @@ bld/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Libraries (binaries that aren't in the repo)
test/Lib
# RT64 (since it's not public yet)
test/RT64
# Runtime files
imgui.ini
rt64.log

View file

@ -48,8 +48,8 @@ struct N64Recomp::LiveGeneratorContext {
sljit_jump* cur_branch_jump;
};
N64Recomp::LiveGenerator::LiveGenerator(size_t num_funcs, const LiveGeneratorInputs& inputs) : compiler(compiler), inputs(inputs) {
compiler = sljit_create_compiler(NULL);
N64Recomp::LiveGenerator::LiveGenerator(size_t num_funcs, const LiveGeneratorInputs& inputs) : inputs(inputs) {
compiler = sljit_create_compiler(nullptr);
context = std::make_unique<LiveGeneratorContext>();
context->func_labels.resize(num_funcs);
}
@ -1026,7 +1026,7 @@ void N64Recomp::LiveGenerator::emit_muldiv(InstrId instr_id, int reg1, int reg2)
sljit_set_label(jump_skip_division, after_division);
// Move the numerator into hi.
sljit_emit_op1(compiler, SLJIT_MOV, Registers::hi, 0, SLJIT_R0, 0);
sljit_emit_op1(compiler, save_opcode, Registers::hi, 0, SLJIT_R0, 0);
if (is_signed) {
// Calculate the negative signum of the numerator and place it in lo.
@ -1037,7 +1037,7 @@ void N64Recomp::LiveGenerator::emit_muldiv(InstrId instr_id, int reg1, int reg2)
}
else {
// Move -1 into lo.
sljit_emit_op1(compiler, SLJIT_MOV, Registers::lo, 0, SLJIT_IMM, -1);
sljit_emit_op1(compiler, SLJIT_MOV, Registers::lo, 0, SLJIT_IMM, sljit_sw(-1));
}
// Emit a label and set it as the target of the jump after the divison.

View file

@ -1,6 +1,7 @@
#include <fstream>
#include <chrono>
#include <filesystem>
#include <cinttypes>
#include "sljitLir.h"
#include "recompiler/live_recompiler.h"
@ -274,7 +275,7 @@ int main(int argc, const char** argv) {
switch (stats.error) {
case TestError::Success:
printf(" Success\n");
printf(" Generated %llu bytes in %llu microseconds and ran in %llu microseconds\n",
printf(" Generated %" PRIu64 " bytes in %" PRIu64 " microseconds and ran in %" PRIu64 " microseconds\n",
stats.code_size, stats.codegen_microseconds, stats.execution_microseconds);
passed_count++;
break;

View file

@ -490,6 +490,9 @@ void N64Recomp::CGenerator::emit_muldiv(InstrId instr_id, int reg1, int reg2) co
case InstrId::cpu_ddivu:
fmt::print(output_file, "DDIVU(U64({}), U64({}), &lo, &hi);\n", gpr_to_string(reg1), gpr_to_string(reg2));
break;
default:
assert(false);
break;
}
}