Skip to content

Commit c3b2996

Browse files
committed
Move floating point instructions to unified opcode table
To make them throw NO_FPU exceptions when the MSR FP bit is not set, we switch between two different opcode tables (using the same approach as dingusdev/dingusppc#135 and dingusdev/dingusppc#136) Should be a no-op to a slight regression in the benchmark (since it has no FPU instructions and there's the slight overhead of checking for MSR changes), but instead it goes from ~442.5 to 460 MiB/s. ¯\_(ツ)_/¯
1 parent 14d0501 commit c3b2996

File tree

4 files changed

+133
-204
lines changed

4 files changed

+133
-204
lines changed

src/cpu/cpu_generic/ppc_cpu.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ void ppc_cpu_run()
112112
PPC_CPU_TRACE("execution started at %08x\n", gCPU.pc);
113113
uint ops=0;
114114
uint32 opc;
115+
ppc_opc_function *opc_table = ppc_current_opc_table();
116+
uint32 opc_table_msr = gCPU.msr;
115117
gCPU.effective_code_page = 0xffffffff;
116118
// ppc_fpu_test();
117119
// return;
@@ -133,7 +135,7 @@ void ppc_cpu_run()
133135
gCPU.effective_code_page = gCPU.pc & ~0xfff;
134136
continue;
135137
}
136-
ppc_exec_opc(opc);
138+
ppc_exec_opc(opc_table, opc);
137139
ops++;
138140
gCPU.ptb++;
139141
if (gCPU.pdec == 0) [[unlikely]] {
@@ -190,6 +192,11 @@ void ppc_cpu_run()
190192
}
191193

192194
gCPU.pc = gCPU.npc;
195+
196+
if ((opc_table_msr ^ gCPU.msr) & PPC_OPC_TABLE_MSR_BITS) [[unlikely]] {
197+
opc_table = ppc_current_opc_table();
198+
opc_table_msr = gCPU.msr;
199+
}
193200

194201
if (gCPU.exception_pending) [[unlikely]] {
195202
if (gCPU.stop_exception) {

0 commit comments

Comments
 (0)