Skip to content

armgit / gecko

Public Imported from GitHub
0

A GameCube/Wii emulator and debugger written in Rust.

this isnt it either but worth anyways

Laylee42f8817b980
diff --git a/crates/gecko/src/gekko/jit.rs b/crates/gecko/src/gekko/jit.rs
index 62a0754..72e148d 100644
--- a/crates/gecko/src/gekko/jit.rs
+++ b/crates/gecko/src/gekko/jit.rs
@@ -913,7 +913,7 @@ impl<const SYSTEM: SystemId> JitEngine<SYSTEM> {
if let Some(spec) = self.block_specs.get(pc) {
for (i, &raw) in spec.instrs.iter().enumerate() {
- let ipc = spec.start_pc.wrapping_add((i as u32) * 4);
+ let ipc = spec.pc_of(i);
let text = decode_gekko_instr(raw);
writeln!(dfile, " {:08X} {:08X} {}", ipc, raw, text)?;
}
@@ -1290,7 +1290,7 @@ fn looks_like_polling_shape(spec: &block::BlockSpec, body_cap: usize) -> bool {
let aa = (raw >> 1) & 1 != 0;
let bd = (((raw >> 2) & 0x3FFF) as i32) << 18 >> 18;
let bd_bytes = bd << 2;
- let term_pc = spec.start_pc.wrapping_add((last_idx as u32) * 4);
+ let term_pc = spec.pc_of(last_idx);
let target = if aa {
bd_bytes as u32
} else {
diff --git a/crates/gecko/src/gekko/jit/idle.rs b/crates/gecko/src/gekko/jit/idle.rs
index e85ef20..d264bb6 100644
--- a/crates/gecko/src/gekko/jit/idle.rs
+++ b/crates/gecko/src/gekko/jit/idle.rs
@@ -65,7 +65,7 @@ fn classify_pointer_iter_loop(spec: &BlockSpec) -> Option<IdleClass> {
if bo & 0b00010 != 0 {
return None;
}
- let branch_pc = spec.start_pc.wrapping_add(8);
+ let branch_pc = spec.pc_of(2);
let target = if i2.aa() {
i2.bd() as u32
} else {
@@ -103,7 +103,7 @@ fn classify_branch_to_self(spec: &BlockSpec) -> Option<IdleClass> {
let target = if instr.aa() {
li as u32
} else {
- spec.start_pc.wrapping_add_signed(li)
+ spec.pc_of(0).wrapping_add_signed(li)
};
if target == spec.start_pc {
@@ -130,7 +130,8 @@ fn classify_polling_loop(spec: &BlockSpec) -> bool {
}
let term = crate::gekko::instruction::Instruction(spec.instrs[last_idx]);
- let term_pc = spec.start_pc.wrapping_add((last_idx as u32) * 4);
+ // Forward branches can be folded out, so instruction PCs need not be contiguous.
+ let term_pc = spec.pc_of(last_idx);
if !is_idle_loop_terminator(term, term_pc, spec.start_pc) {
return false;
}
diff --git a/crates/gecko/src/gekko/jit/translator.rs b/crates/gecko/src/gekko/jit/translator.rs
index 976301e..84d0c8d 100644
--- a/crates/gecko/src/gekko/jit/translator.rs
+++ b/crates/gecko/src/gekko/jit/translator.rs
@@ -292,7 +292,7 @@ pub(crate) fn translate<const SYSTEM: SystemId>(
let new_cyc = builder.ins().iadd(cyc_val, cyc_delta);
builder.ins().store(vmctx_flags(), new_cyc, ctx_ptr, cyc_off);
- let final_nia = builder.ins().iconst(types::I32, spec.start_pc.wrapping_add(12) as i64);
+ let final_nia = builder.ins().iconst(types::I32, spec.end_pc() as i64);
if let Some(slot_addr) = chain_fall_addr {
emit_chain_or_exit::<SYSTEM>(