MCPcopy Create free account
hub / github.com/N64Recomp/N64Recomp / emit_function_start

Method emit_function_start

LiveRecomp/live_generator.cpp:1306–1323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1304}
1305
1306void N64Recomp::LiveGenerator::emit_function_start(const std::string& function_name, size_t func_index) const {
1307 context->function_name = function_name;
1308 context->func_labels[func_index] = sljit_emit_label(compiler);
1309 // sljit_emit_op0(compiler, SLJIT_BREAKPOINT);
1310 sljit_emit_enter(compiler, 0, SLJIT_ARGS2V(P, P), 4 | SLJIT_ENTER_FLOAT(1), 5 | SLJIT_ENTER_FLOAT(0), 0);
1311 sljit_emit_op2(compiler, SLJIT_SUB, Registers::rdram, 0, Registers::rdram, 0, SLJIT_IMM, rdram_offset);
1312
1313 // Check if this function's entry is hooked and emit the hook call if so.
1314 auto find_hook_it = inputs.entry_func_hooks.find(func_index);
1315 if (find_hook_it != inputs.entry_func_hooks.end()) {
1316 // Load rdram and ctx into R0 and R1.
1317 sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R0, 0, Registers::rdram, 0, SLJIT_IMM, rdram_offset);
1318 sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R1, 0, Registers::ctx, 0);
1319 // Load the hook's index into R2.
1320 sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R2, 0, SLJIT_IMM, find_hook_it->second);
1321 sljit_emit_icall(compiler, SLJIT_CALL, SLJIT_ARGS3V(P, P, W), SLJIT_IMM, sljit_sw(inputs.run_hook));
1322 }
1323}
1324
1325void N64Recomp::LiveGenerator::emit_function_end() const {
1326 // Check that all jumps have been paired to a label.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected