Skip to content

Commit 6c430b7

Browse files
joevtdingusdev
authored andcommitted
poweropcodes: Use ROTR_32 where possible.
1 parent 2ce4e13 commit 6c430b7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

cpu/ppc/poweropcodes.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ void dppc_interpreter::power_sraiq(uint32_t opcode) {
492492
ppc_grab_regssash(opcode);
493493
uint32_t mask = (1U << rot_sh) - 1;
494494
ppc_result_a = (int32_t)ppc_result_d >> rot_sh;
495-
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
495+
ppc_state.spr[SPR::MQ] = ROTR_32(ppc_result_d, rot_sh);
496496

497497
if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & mask)) {
498498
ppc_state.spr[SPR::XER] |= XER::CA;
@@ -523,7 +523,7 @@ void dppc_interpreter::power_sraq(uint32_t opcode) {
523523
ppc_state.spr[SPR::XER] &= ~XER::CA;
524524
}
525525

526-
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
526+
ppc_state.spr[SPR::MQ] = ROTR_32(ppc_result_d, rot_sh);
527527

528528
if (rec)
529529
ppc_changecrf0(ppc_result_a);
@@ -541,7 +541,7 @@ void dppc_interpreter::power_sre(uint32_t opcode) {
541541
unsigned rot_sh = ppc_result_b & 0x1F;
542542
ppc_result_a = ppc_result_d >> rot_sh;
543543

544-
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
544+
ppc_state.spr[SPR::MQ] = ROTR_32(ppc_result_d, rot_sh);
545545

546546
if (rec)
547547
ppc_changecrf0(ppc_result_a);
@@ -557,7 +557,7 @@ void dppc_interpreter::power_srea(uint32_t opcode) {
557557
ppc_grab_regssab(opcode);
558558
unsigned rot_sh = ppc_result_b & 0x1F;
559559
ppc_result_a = (int32_t)ppc_result_d >> rot_sh;
560-
uint32_t r = (rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d);
560+
uint32_t r = ROTR_32(ppc_result_d, rot_sh);
561561
uint32_t mask = -1U >> rot_sh;
562562

563563
if ((int32_t(ppc_result_d) < 0) && (r & ~mask)) {
@@ -583,7 +583,7 @@ void dppc_interpreter::power_sreq(uint32_t opcode) {
583583
uint32_t mask = -1U >> rot_sh;
584584

585585
ppc_result_a = (ppc_result_d >> rot_sh) | (ppc_state.spr[SPR::MQ] & ~mask);
586-
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
586+
ppc_state.spr[SPR::MQ] = ROTR_32(ppc_result_d, rot_sh);
587587

588588
if (rec)
589589
ppc_changecrf0(ppc_result_a);
@@ -598,7 +598,7 @@ template <field_rc rec>
598598
void dppc_interpreter::power_sriq(uint32_t opcode) {
599599
ppc_grab_regssash(opcode);
600600
ppc_result_a = ppc_result_d >> rot_sh;
601-
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
601+
ppc_state.spr[SPR::MQ] = ROTR_32(ppc_result_d, rot_sh);
602602

603603
if (rec)
604604
ppc_changecrf0(ppc_result_a);
@@ -612,7 +612,7 @@ template void dppc_interpreter::power_sriq<RC1>(uint32_t opcode);
612612
template <field_rc rec>
613613
void dppc_interpreter::power_srliq(uint32_t opcode) {
614614
ppc_grab_regssash(opcode);
615-
uint32_t r = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
615+
uint32_t r = ROTR_32(ppc_result_d, rot_sh);
616616
unsigned mask = power_rot_mask(rot_sh, 31);
617617

618618
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
@@ -631,7 +631,7 @@ template <field_rc rec>
631631
void dppc_interpreter::power_srlq(uint32_t opcode) {
632632
ppc_grab_regssab(opcode);
633633
unsigned rot_sh = ppc_result_b & 0x1F;
634-
uint32_t r = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
634+
uint32_t r = ROTR_32(ppc_result_d, rot_sh);
635635
unsigned mask = power_rot_mask(rot_sh, 31);
636636

637637
if (ppc_result_b & 0x20) {
@@ -660,7 +660,7 @@ void dppc_interpreter::power_srq(uint32_t opcode) {
660660
ppc_result_a = ppc_result_d >> rot_sh;
661661
}
662662

663-
ppc_state.spr[SPR::MQ] = rot_sh ? ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh))) : ppc_result_d;
663+
ppc_state.spr[SPR::MQ] = ROTR_32(ppc_result_d, rot_sh);
664664

665665
if (rec)
666666
ppc_changecrf0(ppc_result_a);

0 commit comments

Comments
 (0)