Skip to content

Commit a95b06f

Browse files
committed
Minor code clean-up
1 parent 226c097 commit a95b06f

6 files changed

Lines changed: 37 additions & 24 deletions

File tree

cpu/ppc/poweropcodes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ template void dppc_interpreter::power_abs<RC1, OV1>();
6161

6262
void dppc_interpreter::power_clcs() {
6363
uint32_t ppc_result_d;
64-
ppc_grab_regsda(ppc_cur_instruction);
64+
ppc_grab_da(ppc_cur_instruction);
6565
switch (reg_a) {
6666
case 12: //instruction cache line size
6767
case 13: //data cache line size

cpu/ppc/ppcmacros.h

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,54 +36,68 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
3636
uint32_t uimm = uint16_t(opcode); \
3737
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
3838

39-
# define ppc_grab_regsasimm(opcode) \
39+
#define ppc_grab_regsasimm(opcode) \
4040
int reg_a = (opcode >> 16) & 31; \
4141
int32_t simm = int32_t(int16_t(opcode)); \
4242
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
4343

44-
# define ppc_grab_regssauimm(opcode) \
44+
#define ppc_grab_regssauimm(opcode) \
4545
int reg_s = (opcode >> 21) & 31; \
4646
int reg_a = (opcode >> 16) & 31; \
4747
uint32_t uimm = uint16_t(opcode); \
4848
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
4949
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
5050

51+
#define ppc_grab_da(opcode)\
52+
int reg_d = (opcode >> 21) & 31;\
53+
int reg_a = (opcode >> 16) & 31;\
54+
5155
#define ppc_grab_dab(opcode) \
5256
int reg_d = (opcode >> 21) & 31; \
5357
int reg_a = (opcode >> 16) & 31; \
5458
int reg_b = (opcode >> 11) & 31;
5559

60+
#define ppc_grab_s(opcode) \
61+
int reg_s = (opcode >> 21) & 31; \
62+
uint32_t ppc_result_d = ppc_state.gpr[reg_s];
63+
5664
#define ppc_grab_regsdab(opcode) \
5765
int reg_d = (opcode >> 21) & 31; \
58-
uint32_t reg_a = (opcode >> 16) & 31; \
59-
uint32_t reg_b = (opcode >> 11) & 31; \
66+
int reg_a = (opcode >> 16) & 31; \
67+
int reg_b = (opcode >> 11) & 31; \
6068
uint32_t ppc_result_a = ppc_state.gpr[reg_a]; \
6169
uint32_t ppc_result_b = ppc_state.gpr[reg_b];
6270

6371
#define ppc_grab_regssab(opcode) \
64-
uint32_t reg_s = (opcode >> 21) & 31; \
65-
uint32_t reg_a = (opcode >> 16) & 31; \
66-
uint32_t reg_b = (opcode >> 11) & 31; \
72+
int reg_s = (opcode >> 21) & 31; \
73+
int reg_a = (opcode >> 16) & 31; \
74+
int reg_b = (opcode >> 11) & 31; \
6775
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
6876
uint32_t ppc_result_a = ppc_state.gpr[reg_a]; \
6977
uint32_t ppc_result_b = ppc_state.gpr[reg_b]; \
7078

71-
#define ppc_grab_regssa(opcode) \
72-
uint32_t reg_s = (opcode >> 21) & 31; \
73-
uint32_t reg_a = (opcode >> 16) & 31; \
79+
#define ppc_grab_regsab(opcode) \
80+
int reg_a = (opcode >> 16) & 31;\
81+
int reg_b = (opcode >> 11) & 31;\
82+
uint32_t ppc_result_a = ppc_state.gpr[reg_a];\
83+
uint32_t ppc_result_b = ppc_state.gpr[reg_b];
84+
85+
#define ppc_grab_regssa(opcode) \
86+
int reg_s = (opcode >> 21) & 31; \
87+
int reg_a = (opcode >> 16) & 31; \
7488
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
7589
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
7690

7791
#define ppc_grab_regssash(opcode) \
78-
uint32_t reg_s = (opcode >> 21) & 31; \
79-
uint32_t reg_a = (opcode >> 16) & 31; \
80-
uint32_t rot_sh = (opcode >> 11) & 31; \
92+
int reg_s = (opcode >> 21) & 31; \
93+
int reg_a = (opcode >> 16) & 31; \
94+
int rot_sh = (opcode >> 11) & 31; \
8195
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
8296
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
8397

8498
#define ppc_grab_regssb(opcode) \
85-
uint32_t reg_s = (opcode >> 21) & 31; \
86-
uint32_t reg_b = (opcode >> 11) & 31; \
99+
int reg_s = (opcode >> 21) & 31; \
100+
int reg_b = (opcode >> 11) & 31; \
87101
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
88102
uint32_t ppc_result_b = ppc_state.gpr[reg_b]; \
89103

cpu/ppc/ppcopcodes.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ void dppc_interpreter::ppc_mftb() {
10481048
}
10491049

10501050
void dppc_interpreter::ppc_mtcrf() {
1051-
ppc_grab_regssa(ppc_cur_instruction);
1051+
ppc_grab_s(ppc_cur_instruction);
10521052
uint8_t crm = (ppc_cur_instruction >> 12) & 0xFFU;
10531053

10541054
uint32_t cr_mask = 0;
@@ -1215,7 +1215,7 @@ void dppc_interpreter::ppc_cmp() {
12151215
#endif
12161216

12171217
int crf_d = (ppc_cur_instruction >> 21) & 0x1C;
1218-
ppc_grab_regssab(ppc_cur_instruction);
1218+
ppc_grab_regsab(ppc_cur_instruction);
12191219
uint32_t xercon = (ppc_state.spr[SPR::XER] & XER::SO) >> 3;
12201220
uint32_t cmp_c = (int32_t(ppc_result_a) == int32_t(ppc_result_b)) ? 0x20000000UL : \
12211221
(int32_t(ppc_result_a) > int32_t(ppc_result_b)) ? 0x40000000UL : 0x80000000UL;
@@ -1247,7 +1247,7 @@ void dppc_interpreter::ppc_cmpl() {
12471247
#endif
12481248

12491249
int crf_d = (ppc_cur_instruction >> 21) & 0x1C;
1250-
ppc_grab_regssab(ppc_cur_instruction);
1250+
ppc_grab_regsab(ppc_cur_instruction);
12511251
uint32_t xercon = (ppc_state.spr[SPR::XER] & XER::SO) >> 3;
12521252
uint32_t cmp_c = (ppc_result_a == ppc_result_b) ? 0x20000000UL : \
12531253
(ppc_result_a > ppc_result_b) ? 0x40000000UL : 0x80000000UL;
@@ -1261,7 +1261,6 @@ void dppc_interpreter::ppc_cmpli() {
12611261
return;
12621262
}
12631263
#endif
1264-
12651264
int crf_d = (ppc_cur_instruction >> 21) & 0x1C;
12661265
ppc_grab_regssauimm(ppc_cur_instruction);
12671266
uint32_t xercon = (ppc_state.spr[SPR::XER] & XER::SO) >> 3;

devices/common/ata/atapicdrom.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
2929

3030
#include <string>
3131

32-
class AtapiCdrom : public AtapiBaseDevice, public CdromDrive {
32+
class AtapiCdrom : public CdromDrive, public AtapiBaseDevice {
3333
public:
3434
AtapiCdrom(std::string name);
3535
~AtapiCdrom() = default;

devices/common/scsi/scsicdrom.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
3232
#include <memory>
3333
#include <string>
3434

35-
class ScsiCdrom : public ScsiDevice, public CdromDrive {
35+
class ScsiCdrom : public CdromDrive, public ScsiDevice {
3636
public:
3737
ScsiCdrom(std::string name, int my_id);
3838
~ScsiCdrom() = default;

main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
4040

4141
using namespace std;
4242

43-
void sigint_handler(int signum) {
43+
static void sigint_handler(int signum) {
4444
power_on = false;
4545
power_off_reason = po_signal_interrupt;
4646
}
4747

48-
void sigabrt_handler(int signum) {
48+
static void sigabrt_handler(int signum) {
4949
LOG_F(INFO, "Shutting down...");
5050

5151
delete gMachineObj.release();

0 commit comments

Comments
 (0)