Skip to content

armgit / gecko

Public Imported from GitHub
0

A GameCube/Wii emulator and debugger written in Rust.

upgraded for chipi 0.7

Layle94d491b0e93e
diff --git a/Cargo.lock b/Cargo.lock
index c35fc10..3dca15c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -400,10 +400,23 @@ dependencies = [
]
[[package]]
-name = "chipi"
-version = "0.5.3"
+name = "chipi-build"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f6adea386dd961a22b3d1243545077aa700c407d522be3c68b3edb4e7ae36cd4"
+dependencies = [
+ "chipi-core",
+]
+
+[[package]]
+name = "chipi-core"
+version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a7d2ab3ac8eccf8652db81b52914ee4822e03efb764d16e72791a46366071032"
+checksum = "c45f19321253fca12a2d8c0a89b09a3b7f0d06e6d7f44e4848444867ec9c1dca"
+dependencies = [
+ "serde",
+ "toml",
+]
[[package]]
name = "clap"
@@ -653,7 +666,7 @@ dependencies = [
name = "disasm"
version = "0.1.0"
dependencies = [
- "chipi",
+ "chipi-build",
]
[[package]]
@@ -1019,7 +1032,7 @@ name = "gecko"
version = "0.1.0"
dependencies = [
"chapa",
- "chipi",
+ "chipi-build",
"image 0.1.0",
"tracing",
]
@@ -2179,7 +2192,7 @@ version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f"
dependencies = [
- "toml_edit",
+ "toml_edit 0.25.8+spec-1.1.0",
]
[[package]]
@@ -2443,6 +2456,15 @@ dependencies = [
"syn",
]
+[[package]]
+name = "serde_spanned"
+version = "0.6.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3"
+dependencies = [
+ "serde",
+]
+
[[package]]
name = "sharded-slab"
version = "0.1.7"
@@ -2783,6 +2805,27 @@ dependencies = [
"zerovec",
]
+[[package]]
+name = "toml"
+version = "0.8.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362"
+dependencies = [
+ "serde",
+ "serde_spanned",
+ "toml_datetime 0.6.11",
+ "toml_edit 0.22.27",
+]
+
+[[package]]
+name = "toml_datetime"
+version = "0.6.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c"
+dependencies = [
+ "serde",
+]
+
[[package]]
name = "toml_datetime"
version = "1.1.0+spec-1.1.0"
@@ -2792,6 +2835,20 @@ dependencies = [
"serde_core",
]
+[[package]]
+name = "toml_edit"
+version = "0.22.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a"
+dependencies = [
+ "indexmap",
+ "serde",
+ "serde_spanned",
+ "toml_datetime 0.6.11",
+ "toml_write",
+ "winnow 0.7.15",
+]
+
[[package]]
name = "toml_edit"
version = "0.25.8+spec-1.1.0"
@@ -2799,9 +2856,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16bff38f1d86c47f9ff0647e6838d7bb362522bdf44006c7068c2b1e606f1f3c"
dependencies = [
"indexmap",
- "toml_datetime",
+ "toml_datetime 1.1.0+spec-1.1.0",
"toml_parser",
- "winnow",
+ "winnow 1.0.0",
]
[[package]]
@@ -2810,9 +2867,15 @@ version = "1.1.0+spec-1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2334f11ee363607eb04df9b8fc8a13ca1715a72ba8662a26ac285c98aabb4011"
dependencies = [
- "winnow",
+ "winnow 1.0.0",
]
+[[package]]
+name = "toml_write"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801"
+
[[package]]
name = "tracing"
version = "0.1.44"
@@ -3733,6 +3796,15 @@ dependencies = [
"xkbcommon-dl",
]
+[[package]]
+name = "winnow"
+version = "0.7.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945"
+dependencies = [
+ "memchr",
+]
+
[[package]]
name = "winnow"
version = "1.0.0"
diff --git a/crates/disasm/Cargo.toml b/crates/disasm/Cargo.toml
index 095f718..1da0a49 100644
--- a/crates/disasm/Cargo.toml
+++ b/crates/disasm/Cargo.toml
@@ -4,4 +4,4 @@ version = "0.1.0"
edition = "2024"
[build-dependencies]
-chipi = "0.5.3"
\ No newline at end of file
+chipi-build = "0.7.0"
\ No newline at end of file
diff --git a/crates/disasm/build.rs b/crates/disasm/build.rs
index daae735..bce541b 100644
--- a/crates/disasm/build.rs
+++ b/crates/disasm/build.rs
@@ -1,22 +1,3 @@
-use std::env;
-use std::path::PathBuf;
-
fn main() {
- let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
-
- // Generate Gekko (PowerPC) decoder
- chipi::generate(
- "../../submodules/chipi-spec/gamecube/gekko.chipi",
- out_dir.join("gekko.rs").to_str().unwrap(),
- )
- .expect("failed to generate gekko decoder");
- println!("cargo:rerun-if-changed=../../submodules/chipi-spec/gamecube/gekko.chipi");
-
- // Generate DSP decoder
- chipi::generate(
- "../../submodules/chipi-spec/gamecube/dsp.chipi",
- out_dir.join("dsp.rs").to_str().unwrap(),
- )
- .expect("failed to generate dsp decoder");
- println!("cargo:rerun-if-changed=../../submodules/chipi-spec/gamecube/dsp.chipi");
+ chipi_build::run_config("chipi.toml").expect("chipi codegen failed");
}
diff --git a/crates/disasm/chipi.toml b/crates/disasm/chipi.toml
new file mode 100644
index 0000000..6e592f1
--- /dev/null
+++ b/crates/disasm/chipi.toml
@@ -0,0 +1,13 @@
+[[gen]]
+input = "../../submodules/chipi-spec/gamecube/gekko.chipi"
+lang = "rust"
+output = "$OUT_DIR/gekko.rs"
+
+[gen.type_map]
+gpr = "crate::cpu::Gpr"
+fpr = "crate::cpu::Fpr"
+
+[[gen]]
+input = "../../submodules/chipi-spec/gamecube/dsp.chipi"
+lang = "rust"
+output = "$OUT_DIR/dsp.rs"
diff --git a/crates/gctool/src/disassembly.rs b/crates/gctool/src/disassembly.rs
index f96d594..1b95640 100644
--- a/crates/gctool/src/disassembly.rs
+++ b/crates/gctool/src/disassembly.rs
@@ -1,4 +1,4 @@
-use disasm::dsp::DspInstruction;
+use disasm::dsp::GcDspInstruction;
use disasm::gekko::GekkoInstruction;
pub fn disassemble_ppc(data: &[u8], start: usize) {
@@ -22,7 +22,7 @@ pub fn disassemble_dsp(data: &[u8], start: usize) {
let word = u16::from_be_bytes(data[offset..offset + 2].try_into().unwrap());
let addr = (offset / 2) as u32;
- match DspInstruction::decode(&data[offset..]) {
+ match GcDspInstruction::decode(&data[offset..]) {
Some((instr, bytes_consumed)) => {
let hex_parts: Vec<_> = data[offset..offset + bytes_consumed]
.chunks_exact(2)
diff --git a/crates/gecko/Cargo.toml b/crates/gecko/Cargo.toml
index ad09e48..be58fac 100644
--- a/crates/gecko/Cargo.toml
+++ b/crates/gecko/Cargo.toml
@@ -8,7 +8,7 @@ scripting = []
scripting-mut-traps = ["scripting"]
[build-dependencies]
-chipi = "0.5.3"
+chipi-build = "0.7.0"
[dependencies]
chapa = { git = "https://github.com/ioncodes/chapa.git" }
diff --git a/crates/gecko/build.rs b/crates/gecko/build.rs
index 6c3f370..bce541b 100644
--- a/crates/gecko/build.rs
+++ b/crates/gecko/build.rs
@@ -1,156 +1,3 @@
-use std::env;
-use std::path::PathBuf;
-
fn main() {
- let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
- let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
- let spec = "../../submodules/chipi-spec/gamecube/gekko.chipi";
-
- let builder = chipi::LutBuilder::new(spec)
- .handler_mod("crate::cpu::interpreter")
- .ctx_type("crate::gamecube::GameCube")
- .instr_type("crate::cpu::semantics::Instruction")
- .group("branch", ["bx", "bcx", "bclrx", "bcctrx"])
- .group(
- "alu",
- [
- "ori",
- "oris",
- "addx",
- "addi",
- "addis",
- "xori",
- "xoris",
- "andi_dot",
- "andis_dot",
- "subfx",
- "negx",
- "addcx",
- "subfcx",
- "addex",
- "subfex",
- "addzex",
- "subfzex",
- "addmex",
- "subfmex",
- "mullwx",
- "divwux",
- "divwx",
- "mulhwux",
- "mulhwx",
- "subfic",
- "addic",
- "addic_dot",
- "mulli",
- ],
- )
- .group("rotate", ["rlwinmx", "rlwimix", "rlwnmx"])
- .group("msr", ["mtmsr", "mfmsr", "rfi"])
- .group("spr", ["mtspr", "mfspr"])
- .group("segment", ["mtsr", "mfsr"])
- .group(
- "store_load",
- [
- "stw", "stwu", "sth", "sthu", "lwz", "lwzu", "lbz", "lbzu", "stb", "stbu", "lhz", "lhzu", "lha",
- "lhau", "lmw", "stmw", "lwzx", "lbzx", "lhzx", "lhax", "stwx", "stbx", "sthx", "lwzux", "lbzux",
- "lhzux", "lhaux", "stwux", "stbux", "sthux",
- ],
- )
- .group(
- "store_load_fp",
- [
- "lfd", "lfdu", "stfd", "stfdu", "lfs", "lfsu", "stfs", "stfsu", "lfsx", "lfsux", "lfdx", "lfdux",
- "stfsx", "stfsux", "stfdx", "stfdux", "stfiwx",
- ],
- )
- .group(
- "store_load_psq",
- [
- "psq_l", "psq_lu", "psq_st", "psq_stu", "psq_lx", "psq_lux", "psq_stx", "psq_stux",
- ],
- )
- .group("compare", ["cmp", "cmpi", "cmpli", "cmpl"])
- .group(
- "nop",
- [
- "isync", "sync", "eieio", "dcbf", "dcbi", "dcbst", "dcbt", "dcbtst", "dcba", "dcbz", "dcbz_l", "icbi",
- "tlbie", "tlbia", "tlbsync", "tlbld", "tlbli",
- ],
- )
- .group(
- "logical",
- [
- "andx", "orx", "xorx", "nandx", "norx", "andcx", "orcx", "eqvx", "slwx", "srwx", "srawx", "srawix",
- "cntlzwx", "extshx", "extsbx",
- ],
- )
- .group(
- "cr_ops",
- [
- "mtcrf", "mfcr", "crxor", "cror", "crand", "creqv", "crnor", "crnand", "crandc", "crorc", "mcrf",
- ],
- )
- .group(
- "fp_ops",
- [
- "mtfsfx", "mffsx", "mtfsb0x", "mtfsb1x", "mtfsfix", "mcrfs", "fmrx", "fnegx", "fabsx", "fnabsx",
- "frspx", "fctiwx", "fctiwzx", "fcmpu", "fcmpo", "faddx", "fsubx", "fmulx", "fdivx", "fmaddx", "fmsubx",
- "fnmaddx", "fnmsubx", "faddsx", "fsubsx", "fmulsx", "fdivsx", "fmaddsx", "fmsubsx", "fnmaddsx",
- "fnmsubsx", "fsqrtsx", "fresx", "fsqrtx", "fselx", "frsqrtex",
- ],
- )
- .group(
- "ps_ops",
- [
- "ps_cmpu0",
- "ps_cmpo0",
- "ps_cmpu1",
- "ps_cmpo1",
- "ps_res",
- "ps_rsqrte",
- "ps_neg",
- "ps_mr",
- "ps_nabs",
- "ps_abs",
- "ps_merge00",
- "ps_merge01",
- "ps_merge10",
- "ps_merge11",
- "ps_sum0",
- "ps_sum1",
- "ps_muls0",
- "ps_muls1",
- "ps_madds0",
- "ps_madds1",
- "ps_div",
- "ps_sub",
- "ps_add",
- "ps_sel",
- "ps_mul",
- "ps_msub",
- "ps_madd",
- "ps_nmsub",
- "ps_nmadd",
- ],
- );
-
- // Generate the instruction type with accessor methods
- builder
- .build_instr_type(out_dir.join("gekko_instr.rs").to_str().unwrap())
- .expect("failed to generate instruction type");
-
- // Always regenerate the LUT dispatch tables
- builder
- .build_lut(out_dir.join("gekko_lut.rs").to_str().unwrap())
- .expect("failed to generate Gecko LUT");
-
- // Generate interpreter stubs once
- let stubs = manifest_dir.join("src/cpu/interpreter.rs");
- if !stubs.exists() {
- builder
- .build_stubs(stubs.to_str().unwrap())
- .expect("failed to generate interpreter stubs");
- }
-
- println!("cargo:rerun-if-changed={spec}");
+ chipi_build::run_config("chipi.toml").expect("chipi codegen failed");
}
diff --git a/crates/gecko/chipi.toml b/crates/gecko/chipi.toml
new file mode 100644
index 0000000..09154ab
--- /dev/null
+++ b/crates/gecko/chipi.toml
@@ -0,0 +1,226 @@
+[[lut]]
+input = "../../submodules/chipi-spec/gamecube/gekko.chipi"
+output = "$OUT_DIR/gekko_lut.rs"
+handler_mod = "crate::cpu::interpreter"
+ctx_type = "crate::gamecube::GameCube"
+instr_type = "crate::cpu::semantics::Instruction"
+lut_mod = "crate::cpu::lut"
+dispatch = "jump_table"
+instr_type_output = "$OUT_DIR/gekko_instr.rs"
+
+[lut.groups]
+branch = ["bx", "bcx", "bclrx", "bcctrx"]
+alu = [
+ "ori",
+ "oris",
+ "addx",
+ "addi",
+ "addis",
+ "xori",
+ "xoris",
+ "andi_dot",
+ "andis_dot",
+ "subfx",
+ "negx",
+ "addcx",
+ "subfcx",
+ "addex",
+ "subfex",
+ "addzex",
+ "subfzex",
+ "addmex",
+ "subfmex",
+ "mullwx",
+ "divwux",
+ "divwx",
+ "mulhwux",
+ "mulhwx",
+ "subfic",
+ "addic",
+ "addic_dot",
+ "mulli",
+]
+rotate = ["rlwinmx", "rlwimix", "rlwnmx"]
+msr = ["mtmsr", "mfmsr", "rfi"]
+spr = ["mtspr", "mfspr"]
+segment = ["mtsr", "mfsr"]
+store_load = [
+ "stw",
+ "stwu",
+ "sth",
+ "sthu",
+ "lwz",
+ "lwzu",
+ "lbz",
+ "lbzu",
+ "stb",
+ "stbu",
+ "lhz",
+ "lhzu",
+ "lha",
+ "lhau",
+ "lmw",
+ "stmw",
+ "lwzx",
+ "lbzx",
+ "lhzx",
+ "lhax",
+ "stwx",
+ "stbx",
+ "sthx",
+ "lwzux",
+ "lbzux",
+ "lhzux",
+ "lhaux",
+ "stwux",
+ "stbux",
+ "sthux",
+]
+store_load_fp = [
+ "lfd",
+ "lfdu",
+ "stfd",
+ "stfdu",
+ "lfs",
+ "lfsu",
+ "stfs",
+ "stfsu",
+ "lfsx",
+ "lfsux",
+ "lfdx",
+ "lfdux",
+ "stfsx",
+ "stfsux",
+ "stfdx",
+ "stfdux",
+ "stfiwx",
+]
+store_load_psq = [
+ "psq_l",
+ "psq_lu",
+ "psq_st",
+ "psq_stu",
+ "psq_lx",
+ "psq_lux",
+ "psq_stx",
+ "psq_stux",
+]
+compare = ["cmp", "cmpi", "cmpli", "cmpl"]
+nop = [
+ "isync",
+ "sync",
+ "eieio",
+ "dcbf",
+ "dcbi",
+ "dcbst",
+ "dcbt",
+ "dcbtst",
+ "dcba",
+ "dcbz",
+ "dcbz_l",
+ "icbi",
+ "tlbie",
+ "tlbia",
+ "tlbsync",
+ "tlbld",
+ "tlbli",
+]
+logical = [
+ "andx",
+ "orx",
+ "xorx",
+ "nandx",
+ "norx",
+ "andcx",
+ "orcx",
+ "eqvx",
+ "slwx",
+ "srwx",
+ "srawx",
+ "srawix",
+ "cntlzwx",
+ "extshx",
+ "extsbx",
+]
+cr_ops = [
+ "mtcrf",
+ "mfcr",
+ "crxor",
+ "cror",
+ "crand",
+ "creqv",
+ "crnor",
+ "crnand",
+ "crandc",
+ "crorc",
+ "mcrf",
+]
+fp_ops = [
+ "mtfsfx",
+ "mffsx",
+ "mtfsb0x",
+ "mtfsb1x",
+ "mtfsfix",
+ "mcrfs",
+ "fmrx",
+ "fnegx",
+ "fabsx",
+ "fnabsx",
+ "frspx",
+ "fctiwx",
+ "fctiwzx",
+ "fcmpu",
+ "fcmpo",
+ "faddx",
+ "fsubx",
+ "fmulx",
+ "fdivx",
+ "fmaddx",
+ "fmsubx",
+ "fnmaddx",
+ "fnmsubx",
+ "faddsx",
+ "fsubsx",
+ "fmulsx",
+ "fdivsx",
+ "fmaddsx",
+ "fmsubsx",
+ "fnmaddsx",
+ "fnmsubsx",
+ "fsqrtsx",
+ "fresx",
+ "fsqrtx",
+ "fselx",
+ "frsqrtex",
+]
+ps_ops = [
+ "ps_cmpu0",
+ "ps_cmpo0",
+ "ps_cmpu1",
+ "ps_cmpo1",
+ "ps_res",
+ "ps_rsqrte",
+ "ps_neg",
+ "ps_mr",
+ "ps_nabs",
+ "ps_abs",
+ "ps_merge00",
+ "ps_merge01",
+ "ps_merge10",
+ "ps_merge11",
+ "ps_sum0",
+ "ps_sum1",
+ "ps_muls0",
+ "ps_muls1",
+ "ps_madds0",
+ "ps_madds1",
+ "ps_div",
+ "ps_sub",
+ "ps_add",
+ "ps_sel",
+ "ps_mul",
+ "ps_msub",
+ "ps_madd",
+ "ps_nmsub",
+ "ps_nmadd",
+]
diff --git a/crates/gecko/src/cpu/interpreter/alu.rs b/crates/gecko/src/cpu/interpreter/alu.rs
index b03547b..ff22045 100644
--- a/crates/gecko/src/cpu/interpreter/alu.rs
+++ b/crates/gecko/src/cpu/interpreter/alu.rs
@@ -1,3 +1,4 @@
+#[inline(always)]
pub fn alu<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
match OP {
crate::cpu::lut::OP_ADDX => {
@@ -210,6 +211,7 @@ pub fn alu<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu
}
}
+#[inline(always)]
pub fn logical<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
let rs = ctx.cpu.read_gpr(instr.rs());
let rb = ctx.cpu.read_gpr(instr.rb());
diff --git a/crates/gecko/src/cpu/interpreter/branch.rs b/crates/gecko/src/cpu/interpreter/branch.rs
index 7b0ef76..d149a62 100644
--- a/crates/gecko/src/cpu/interpreter/branch.rs
+++ b/crates/gecko/src/cpu/interpreter/branch.rs
@@ -1,5 +1,6 @@
use crate::cpu::condition::BranchControl;
+#[inline(always)]
pub fn branch<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
// Read LR before potentially overwriting LR with CIA+4 (matters for blrl/bctrl)
let old_lr = ctx.cpu.spr.lr;
diff --git a/crates/gecko/src/cpu/interpreter/compare.rs b/crates/gecko/src/cpu/interpreter/compare.rs
index 2d3e46e..080ec07 100644
--- a/crates/gecko/src/cpu/interpreter/compare.rs
+++ b/crates/gecko/src/cpu/interpreter/compare.rs
@@ -1,5 +1,6 @@
use crate::cpu::condition::ConditionRegister;
+#[inline(always)]
pub fn compare<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
let field = match OP {
crate::cpu::lut::OP_CMP => ConditionRegister::field_from_ord(
diff --git a/crates/gecko/src/cpu/interpreter/cr_ops.rs b/crates/gecko/src/cpu/interpreter/cr_ops.rs
index b8e5138..9e207f0 100644
--- a/crates/gecko/src/cpu/interpreter/cr_ops.rs
+++ b/crates/gecko/src/cpu/interpreter/cr_ops.rs
@@ -1,3 +1,4 @@
+#[inline(always)]
pub fn cr_ops<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
match OP {
crate::cpu::lut::OP_MTCRF => {
diff --git a/crates/gecko/src/cpu/interpreter/fp_ops.rs b/crates/gecko/src/cpu/interpreter/fp_ops.rs
index 3b76a06..35f4d91 100644
--- a/crates/gecko/src/cpu/interpreter/fp_ops.rs
+++ b/crates/gecko/src/cpu/interpreter/fp_ops.rs
@@ -1,5 +1,6 @@
use crate::cpu::condition::ConditionField;
+#[inline(always)]
pub fn fp_ops<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
match OP {
crate::cpu::lut::OP_MTFSFX => {
diff --git a/crates/gecko/src/cpu/interpreter/ps_ops.rs b/crates/gecko/src/cpu/interpreter/ps_ops.rs
index cab0194..4e083f9 100644
--- a/crates/gecko/src/cpu/interpreter/ps_ops.rs
+++ b/crates/gecko/src/cpu/interpreter/ps_ops.rs
@@ -1,5 +1,6 @@
use crate::cpu::condition::ConditionField;
+#[inline(always)]
pub fn ps_ops<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
match OP {
crate::cpu::lut::OP_PS_ADD => {
diff --git a/crates/gecko/src/cpu/interpreter/psq.rs b/crates/gecko/src/cpu/interpreter/psq.rs
index 78be071..ab6982d 100644
--- a/crates/gecko/src/cpu/interpreter/psq.rs
+++ b/crates/gecko/src/cpu/interpreter/psq.rs
@@ -114,6 +114,7 @@ fn psq_store(ctx: &mut crate::gamecube::GameCube, fs: u8, addr: u32, w: bool, gq
}
}
+#[inline(always)]
pub fn store_load_psq<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
use crate::cpu::lut::*;
diff --git a/crates/gecko/src/cpu/interpreter/rotate.rs b/crates/gecko/src/cpu/interpreter/rotate.rs
index 590e039..531fb73 100644
--- a/crates/gecko/src/cpu/interpreter/rotate.rs
+++ b/crates/gecko/src/cpu/interpreter/rotate.rs
@@ -5,6 +5,7 @@ fn mask(mb: u32, me: u32) -> u32 {
if mb <= me { begin & !end } else { begin | !end }
}
+#[inline(always)]
pub fn rotate<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
let rs = ctx.cpu.read_gpr(instr.rs());
let mb = instr.mb() as u32;
diff --git a/crates/gecko/src/cpu/interpreter/store_load.rs b/crates/gecko/src/cpu/interpreter/store_load.rs
index 0d890a4..1af0889 100644
--- a/crates/gecko/src/cpu/interpreter/store_load.rs
+++ b/crates/gecko/src/cpu/interpreter/store_load.rs
@@ -1,5 +1,6 @@
use crate::cpu::condition::ConditionField;
+#[inline(always)]
pub fn store_load<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
match OP {
crate::cpu::lut::OP_STW | crate::cpu::lut::OP_STWU => {
@@ -149,6 +150,7 @@ pub fn store_load<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: cra
}
}
+#[inline(always)]
pub fn lwarx(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
let addr = ctx
.cpu
@@ -159,6 +161,7 @@ pub fn lwarx(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::
ctx.cpu.reserve_addr = Some(addr);
}
+#[inline(always)]
pub fn stwcx_dot(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
let addr = ctx
.cpu
@@ -175,6 +178,7 @@ pub fn stwcx_dot(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semanti
}
}
+#[inline(always)]
pub fn store_load_fp<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
match OP {
crate::cpu::lut::OP_LFD | crate::cpu::lut::OP_LFDU => {
diff --git a/crates/gecko/src/cpu/interpreter/stubs.rs b/crates/gecko/src/cpu/interpreter/stubs.rs
index fd2134a..b0f6821 100644
--- a/crates/gecko/src/cpu/interpreter/stubs.rs
+++ b/crates/gecko/src/cpu/interpreter/stubs.rs
@@ -2,6 +2,7 @@ macro_rules! stub {
($($name:ident),* $(,)?) => {
$(
#[rustfmt::skip]
+ #[inline(always)]
pub fn $name(
_ctx: &mut crate::gamecube::GameCube,
_instr: crate::cpu::semantics::Instruction,
diff --git a/crates/gecko/src/cpu/interpreter/system.rs b/crates/gecko/src/cpu/interpreter/system.rs
index 1fbab48..1ddec66 100644
--- a/crates/gecko/src/cpu/interpreter/system.rs
+++ b/crates/gecko/src/cpu/interpreter/system.rs
@@ -1,5 +1,6 @@
use crate::cpu::sr::Sr;
+#[inline(always)]
pub fn msr<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
match OP {
crate::cpu::lut::OP_MTMSR => {
@@ -18,6 +19,7 @@ pub fn msr<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu
}
}
+#[inline(always)]
pub fn spr<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
match OP {
crate::cpu::lut::OP_MTSPR => {
@@ -42,6 +44,7 @@ pub fn spr<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu
}
}
+#[inline(always)]
pub fn segment<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
match OP {
crate::cpu::lut::OP_MTSR => {
@@ -54,6 +57,7 @@ pub fn segment<const OP: u32>(ctx: &mut crate::gamecube::GameCube, instr: crate:
}
}
+#[inline(always)]
pub fn mftb(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::Instruction) {
let tbr = instr.spr_swapped();
let val = match tbr {
@@ -64,8 +68,10 @@ pub fn mftb(ctx: &mut crate::gamecube::GameCube, instr: crate::cpu::semantics::I
ctx.cpu.write_gpr(instr.rd(), val);
}
+#[inline(always)]
pub fn nop<const OP: u32>(_ctx: &mut crate::gamecube::GameCube, _instr: crate::cpu::semantics::Instruction) {}
+#[inline(always)]
pub fn sc(ctx: &mut crate::gamecube::GameCube, _instr: crate::cpu::semantics::Instruction) {
ctx.cause_syscall_interrupt();
}
diff --git a/crates/gecko/src/mmio.rs b/crates/gecko/src/mmio.rs
index 7c5e441..71077bc 100644
--- a/crates/gecko/src/mmio.rs
+++ b/crates/gecko/src/mmio.rs
@@ -1,6 +1,3 @@
-#[cfg(test)]
-mod tests;
-
pub mod bus;
pub mod constants;
pub mod fp;
diff --git a/crates/gecko/src/mmio/tests.rs b/crates/gecko/src/mmio/tests.rs
deleted file mode 100644
index fd3c161..0000000
--- a/crates/gecko/src/mmio/tests.rs
+++ /dev/null
@@ -1,67 +0,0 @@
-#[cfg(test)]
-mod tests {
- use crate::mmio::Mmio;
-
- #[test]
- fn ram_phys_read_write_roundtrip() {
- let mut mmio = Mmio::new();
- mmio.phys_write_u32(0x100, 0xDEAD_BEEF);
- assert_eq!(mmio.phys_read_u32(0x100), 0xDEAD_BEEF);
- assert_eq!(mmio.phys_read_u16(0x100), 0xDEAD);
- assert_eq!(mmio.phys_read_u8(0x100), 0xDE);
- }
-
- #[test]
- fn cached_virtual_maps_to_physical() {
- let mut mmio = Mmio::new();
- mmio.virt_write_u32(0x8000_0100, 0x1234_5678);
- assert_eq!(mmio.phys_read_u32(0x100), 0x1234_5678);
- }
-
- #[test]
- fn uncached_virtual_maps_to_physical() {
- let mut mmio = Mmio::new();
- mmio.virt_write_u32(0xC000_0100, 0xAAAA_BBBB);
- assert_eq!(mmio.phys_read_u32(0x100), 0xAAAA_BBBB);
- }
-
- #[test]
- fn efb_virtual_maps_to_efb_storage() {
- let mut mmio = Mmio::new();
- // 0xC8000000 virtual -> phys 0x08000000 (EFB)
- mmio.virt_write_u32(0xC800_0000, 0xFB_FB_FB_FB);
- assert_eq!(mmio.phys_read_u32(0x0800_0000), 0xFB_FB_FB_FB);
- // Confirm it did NOT touch RAM
- assert_eq!(mmio.phys_read_u32(0x0), 0);
- }
-
- #[test]
- fn efb_address_does_not_alias_ram() {
- let mut mmio = Mmio::new();
- mmio.phys_write_u32(0x0, 0x1111_1111);
- mmio.phys_write_u32(0x0800_0000, 0x2222_2222);
- assert_eq!(mmio.phys_read_u32(0x0), 0x1111_1111);
- assert_eq!(mmio.phys_read_u32(0x0800_0000), 0x2222_2222);
- }
-
- #[test]
- fn unmapped_address_returns_fallback() {
- let mmio = Mmio::new();
- let _ = mmio.phys_read_u8(0x1000_0000);
- }
-
- #[test]
- fn hw_register_range_reads_from_hwr_fallback() {
- // HW reg reads go to the hwr fallback Vec; default value is 0
- let mmio = Mmio::new();
- assert_eq!(mmio.phys_read_u8(0x0C00_0000), 0);
- }
-
- #[test]
- fn phys_slice_returns_correct_data() {
- let mut mmio = Mmio::new();
- mmio.phys_write_u32(0x200, 0xCAFE_BABE);
- let slice = mmio.phys_slice(0x200, 4);
- assert_eq!(slice, &[0xCA, 0xFE, 0xBA, 0xBE]);
- }
-}