Skip to content

Commit 75dbcfb

Browse files
committed
Use an explicit function parameter for the current opcode
Similar to dingusdev/dingusppc@564c43c, allows more efficient execution, since it's always in a register (instead of being loaded from the gCPU.current_opc global). Saves about 15% from the initial time spent during Mac OS X 10.2 boot when run under JS/Emscripten.
1 parent b211824 commit 75dbcfb

14 files changed

Lines changed: 1283 additions & 1281 deletions

File tree

src/cpu/cpu_generic/ppc_alu.cc

Lines changed: 190 additions & 190 deletions
Large diffs are not rendered by default.

src/cpu/cpu_generic/ppc_alu.h

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -21,79 +21,79 @@
2121
#ifndef __PPC_ALU_H__
2222
#define __PPC_ALU_H__
2323

24-
void ppc_opc_addx();
25-
void ppc_opc_addcx();
26-
void ppc_opc_addex();
27-
void ppc_opc_addi();
28-
void ppc_opc_addic();
29-
void ppc_opc_addic_();
30-
void ppc_opc_addis();
31-
void ppc_opc_addmex();
32-
void ppc_opc_addzex();
33-
34-
void ppc_opc_andx();
35-
void ppc_opc_andcx();
36-
void ppc_opc_andi_();
37-
void ppc_opc_andis_();
38-
39-
void ppc_opc_cmp();
40-
void ppc_opc_cmpi();
41-
void ppc_opc_cmpl();
42-
void ppc_opc_cmpli();
43-
44-
void ppc_opc_cntlzwx();
45-
46-
void ppc_opc_crand();
47-
void ppc_opc_crandc();
48-
void ppc_opc_creqv();
49-
void ppc_opc_crnand();
50-
void ppc_opc_crnor();
51-
void ppc_opc_cror();
52-
void ppc_opc_crorc();
53-
void ppc_opc_crxor();
54-
55-
void ppc_opc_divwx();
56-
void ppc_opc_divwux();
57-
58-
void ppc_opc_eqvx();
59-
60-
void ppc_opc_extsbx();
61-
void ppc_opc_extshx();
62-
63-
void ppc_opc_mulhwx();
64-
void ppc_opc_mulhwux();
65-
void ppc_opc_mulli();
66-
void ppc_opc_mullwx();
67-
68-
void ppc_opc_nandx();
69-
70-
void ppc_opc_negx();
71-
void ppc_opc_norx();
72-
73-
void ppc_opc_orx();
74-
void ppc_opc_orcx();
75-
void ppc_opc_ori();
76-
void ppc_opc_oris();
77-
78-
void ppc_opc_rlwimix();
79-
void ppc_opc_rlwinmx();
80-
void ppc_opc_rlwnmx();
81-
82-
void ppc_opc_slwx();
83-
void ppc_opc_srawx();
84-
void ppc_opc_srawix();
85-
void ppc_opc_srwx();
86-
87-
void ppc_opc_subfx();
88-
void ppc_opc_subfcx();
89-
void ppc_opc_subfex();
90-
void ppc_opc_subfic();
91-
void ppc_opc_subfmex();
92-
void ppc_opc_subfzex();
93-
94-
void ppc_opc_xorx();
95-
void ppc_opc_xori();
96-
void ppc_opc_xoris();
24+
void ppc_opc_addx(uint32 opc);
25+
void ppc_opc_addcx(uint32 opc);
26+
void ppc_opc_addex(uint32 opc);
27+
void ppc_opc_addi(uint32 opc);
28+
void ppc_opc_addic(uint32 opc);
29+
void ppc_opc_addic_(uint32 opc);
30+
void ppc_opc_addis(uint32 opc);
31+
void ppc_opc_addmex(uint32 opc);
32+
void ppc_opc_addzex(uint32 opc);
33+
34+
void ppc_opc_andx(uint32 opc);
35+
void ppc_opc_andcx(uint32 opc);
36+
void ppc_opc_andi_(uint32 opc);
37+
void ppc_opc_andis_(uint32 opc);
38+
39+
void ppc_opc_cmp(uint32 opc);
40+
void ppc_opc_cmpi(uint32 opc);
41+
void ppc_opc_cmpl(uint32 opc);
42+
void ppc_opc_cmpli(uint32 opc);
43+
44+
void ppc_opc_cntlzwx(uint32 opc);
45+
46+
void ppc_opc_crand(uint32 opc);
47+
void ppc_opc_crandc(uint32 opc);
48+
void ppc_opc_creqv(uint32 opc);
49+
void ppc_opc_crnand(uint32 opc);
50+
void ppc_opc_crnor(uint32 opc);
51+
void ppc_opc_cror(uint32 opc);
52+
void ppc_opc_crorc(uint32 opc);
53+
void ppc_opc_crxor(uint32 opc);
54+
55+
void ppc_opc_divwx(uint32 opc);
56+
void ppc_opc_divwux(uint32 opc);
57+
58+
void ppc_opc_eqvx(uint32 opc);
59+
60+
void ppc_opc_extsbx(uint32 opc);
61+
void ppc_opc_extshx(uint32 opc);
62+
63+
void ppc_opc_mulhwx(uint32 opc);
64+
void ppc_opc_mulhwux(uint32 opc);
65+
void ppc_opc_mulli(uint32 opc);
66+
void ppc_opc_mullwx(uint32 opc);
67+
68+
void ppc_opc_nandx(uint32 opc);
69+
70+
void ppc_opc_negx(uint32 opc);
71+
void ppc_opc_norx(uint32 opc);
72+
73+
void ppc_opc_orx(uint32 opc);
74+
void ppc_opc_orcx(uint32 opc);
75+
void ppc_opc_ori(uint32 opc);
76+
void ppc_opc_oris(uint32 opc);
77+
78+
void ppc_opc_rlwimix(uint32 opc);
79+
void ppc_opc_rlwinmx(uint32 opc);
80+
void ppc_opc_rlwnmx(uint32 opc);
81+
82+
void ppc_opc_slwx(uint32 opc);
83+
void ppc_opc_srawx(uint32 opc);
84+
void ppc_opc_srawix(uint32 opc);
85+
void ppc_opc_srwx(uint32 opc);
86+
87+
void ppc_opc_subfx(uint32 opc);
88+
void ppc_opc_subfcx(uint32 opc);
89+
void ppc_opc_subfex(uint32 opc);
90+
void ppc_opc_subfic(uint32 opc);
91+
void ppc_opc_subfmex(uint32 opc);
92+
void ppc_opc_subfzex(uint32 opc);
93+
94+
void ppc_opc_xorx(uint32 opc);
95+
void ppc_opc_xori(uint32 opc);
96+
void ppc_opc_xoris(uint32 opc);
9797

9898
#endif
99-
99+

src/cpu/cpu_generic/ppc_cpu.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,13 +108,14 @@ void ppc_cpu_run()
108108
// gDebugger->mAlwaysShowRegs = true;
109109
PPC_CPU_TRACE("execution started at %08x\n", gCPU.pc);
110110
uint ops=0;
111+
uint32 opc;
111112
gCPU.effective_code_page = 0xffffffff;
112113
// ppc_fpu_test();
113114
// return;
114115
while (true) {
115116
gCPU.npc = gCPU.pc+4;
116117
if ((gCPU.pc & ~0xfff) == gCPU.effective_code_page) {
117-
gCPU.current_opc = ppc_word_from_BE(*((uint32*)(&gCPU.physical_code_page[gCPU.pc & 0xfff])));
118+
opc = ppc_word_from_BE(*((uint32*)(&gCPU.physical_code_page[gCPU.pc & 0xfff])));
118119
//ppc_debug_hook();
119120
} else {
120121
int ret;
@@ -129,7 +130,7 @@ void ppc_cpu_run()
129130
gCPU.effective_code_page = gCPU.pc & ~0xfff;
130131
continue;
131132
}
132-
ppc_exec_opc();
133+
ppc_exec_opc(opc);
133134
ops++;
134135
gCPU.ptb++;
135136
if (gCPU.pdec == 0) {

src/cpu/cpu_generic/ppc_cpu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ struct PPC_CPU_State {
7979

8080
uint32 pc;
8181
uint32 npc;
82-
uint32 current_opc;
8382
bool exception_pending;
8483
bool dec_exception;
8584
bool ext_exception;

0 commit comments

Comments
 (0)