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

Method emit_function_call_reference_symbol

LiveRecomp/live_generator.cpp:1404–1428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1402}
1403
1404void N64Recomp::LiveGenerator::emit_function_call_reference_symbol(const Context&, uint16_t section_index, size_t symbol_index, uint32_t target_section_offset) const {
1405 (void)symbol_index;
1406
1407 // Load rdram and ctx into R0 and R1.
1408 sljit_emit_op2(compiler, SLJIT_ADD, SLJIT_R0, 0, Registers::rdram, 0, SLJIT_IMM, rdram_offset);
1409 sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R1, 0, Registers::ctx, 0);
1410 // sljit_emit_op0(compiler, SLJIT_BREAKPOINT);
1411 // Call the function and save the jump to set its label later on.
1412 sljit_jump* call_jump = sljit_emit_call(compiler, SLJIT_CALL | SLJIT_REWRITABLE_JUMP, SLJIT_ARGS2V(P, P));
1413 // Set a dummy jump value, this will get replaced during reference/import symbol jump population.
1414 if (section_index == N64Recomp::SectionImport) {
1415 sljit_set_target(call_jump, sljit_uw(-1));
1416 context->import_jumps_by_index.emplace(symbol_index, call_jump);
1417 }
1418 else {
1419 sljit_set_target(call_jump, sljit_uw(-2));
1420 context->reference_symbol_jumps.emplace_back(std::make_pair(
1421 ReferenceJumpDetails{
1422 .section = section_index,
1423 .section_offset = target_section_offset
1424 },
1425 call_jump
1426 ));
1427 }
1428}
1429
1430void N64Recomp::LiveGenerator::emit_function_call(const Context&, size_t function_index) const {
1431 // Load rdram and ctx into R0 and R1.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected