diff --git a/src/xenia/cpu/ppc/ppc_emit_alu.cc b/src/xenia/cpu/ppc/ppc_emit_alu.cc index 1b0ed6327..78f51b106 100644 --- a/src/xenia/cpu/ppc/ppc_emit_alu.cc +++ b/src/xenia/cpu/ppc/ppc_emit_alu.cc @@ -858,13 +858,53 @@ int InstrEmit_xoris(PPCHIRBuilder& f, const InstrData& i) { // Integer rotate (A-6) int InstrEmit_rldclx(PPCHIRBuilder& f, const InstrData& i) { - XEINSTRNOTIMPLEMENTED(); - return 1; + // n <- rB[58:63] + // r <- ROTL[64](rS, n) + // b <- mb[5] || mb[0:4] + // m <- MASK(b, 63) + // rA <- r & m + Value* n = f.And(f.Truncate(f.LoadGPR(i.MDS.RB), INT8_TYPE), + f.LoadConstantInt8(0x3F)); + + uint32_t mb = (i.MDS.MB5 << 5) | i.MDS.MB; + uint64_t m = XEMASK(mb, 63); + Value* v = f.LoadGPR(i.MDS.RT); + + v = f.RotateLeft(v, n); + if (m != 0xFFFFFFFFFFFFFFFF) { + v = f.And(v, f.LoadConstantUint64(m)); + } + + f.StoreGPR(i.MDS.RA, v); + if (i.MDS.Rc) { + f.UpdateCR(0, v); + } + return 0; } int InstrEmit_rldcrx(PPCHIRBuilder& f, const InstrData& i) { - XEINSTRNOTIMPLEMENTED(); - return 1; + // n <- rB[58:63] + // r <- ROTL[64](rS, n) + // b <- mb[5] || mb[0:4] + // m <- MASK(0, b) + // rA <- r & m + Value* n = f.And(f.Truncate(f.LoadGPR(i.MDS.RB), INT8_TYPE), + f.LoadConstantInt8(0x3F)); + + uint32_t mb = (i.MDS.MB5 << 5) | i.MDS.MB; + uint64_t m = XEMASK(0, mb); + Value* v = f.LoadGPR(i.MDS.RT); + + v = f.RotateLeft(v, n); + if (m != 0xFFFFFFFFFFFFFFFF) { + v = f.And(v, f.LoadConstantUint64(m)); + } + + f.StoreGPR(i.MDS.RA, v); + if (i.MDS.Rc) { + f.UpdateCR(0, v); + } + return 0; } int InstrEmit_rldicx(PPCHIRBuilder& f, const InstrData& i) {