Browse Source

fix RortateRight for windows

lizzie/unity-build
lizzie 1 week ago
parent
commit
ff8dda2441
  1. 6
      src/dynarmic/src/dynarmic/backend/arm64/emit_arm64_data_processing.cpp
  2. 7
      src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_data_processing.cpp
  3. 4
      src/dynarmic/src/dynarmic/backend/x64/emit_x64_data_processing.cpp
  4. 6
      src/dynarmic/src/dynarmic/ir/ir_emitter.h
  5. 6
      src/dynarmic/src/dynarmic/ir/opcodes.h
  6. 5
      src/dynarmic/src/dynarmic/ir/opcodes.inc
  7. 4
      src/dynarmic/src/dynarmic/ir/opt_passes.cpp

6
src/dynarmic/src/dynarmic/backend/arm64/emit_arm64_data_processing.cpp

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
/* This file is part of the dynarmic project.
@ -642,7 +642,7 @@ void EmitIR<IR::Opcode::ArithmeticShiftRight64>(oaknut::CodeGenerator& code, Emi
}
template<>
void EmitIR<IR::Opcode::RotateRight32>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
void EmitIR<IR::Opcode::BitRotateRight32>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
const auto carry_inst = inst->GetAssociatedPseudoOperation(IR::Opcode::GetCarryFromOp);
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
@ -708,7 +708,7 @@ void EmitIR<IR::Opcode::RotateRight32>(oaknut::CodeGenerator& code, EmitContext&
}
template<>
void EmitIR<IR::Opcode::RotateRight64>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
void EmitIR<IR::Opcode::BitRotateRight64>(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst* inst) {
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
auto& operand_arg = args[0];
auto& shift_arg = args[1];

7
src/dynarmic/src/dynarmic/backend/riscv64/emit_riscv64_data_processing.cpp

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
/* This file is part of the dynarmic project.
* Copyright (c) 2024 MerryMage
* SPDX-License-Identifier: 0BSD
@ -164,12 +167,12 @@ void EmitIR<IR::Opcode::ArithmeticShiftRight64>(biscuit::Assembler&, EmitContext
}
template<>
void EmitIR<IR::Opcode::RotateRight32>(biscuit::Assembler&, EmitContext&, IR::Inst*) {
void EmitIR<IR::Opcode::BitRotateRight32>(biscuit::Assembler&, EmitContext&, IR::Inst*) {
UNIMPLEMENTED();
}
template<>
void EmitIR<IR::Opcode::RotateRight64>(biscuit::Assembler&, EmitContext&, IR::Inst*) {
void EmitIR<IR::Opcode::BitRotateRight64>(biscuit::Assembler&, EmitContext&, IR::Inst*) {
UNIMPLEMENTED();
}

4
src/dynarmic/src/dynarmic/backend/x64/emit_x64_data_processing.cpp

@ -663,7 +663,7 @@ void EmitX64::EmitArithmeticShiftRight64(EmitContext& ctx, IR::Inst* inst) {
}
}
void EmitX64::EmitRotateRight32(EmitContext& ctx, IR::Inst* inst) {
void EmitX64::EmitBitRotateRight32(EmitContext& ctx, IR::Inst* inst) {
const auto carry_inst = inst->GetAssociatedPseudoOperation(IR::Opcode::GetCarryFromOp);
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
@ -736,7 +736,7 @@ void EmitX64::EmitRotateRight32(EmitContext& ctx, IR::Inst* inst) {
}
}
void EmitX64::EmitRotateRight64(EmitContext& ctx, IR::Inst* inst) {
void EmitX64::EmitBitRotateRight64(EmitContext& ctx, IR::Inst* inst) {
auto args = ctx.reg_alloc.GetArgumentInfo(inst);
auto& operand_arg = args[0];
auto& shift_arg = args[1];

6
src/dynarmic/src/dynarmic/ir/ir_emitter.h

@ -228,7 +228,7 @@ public:
}
ResultAndCarry<U32> RotateRight(const U32& value_in, const U8& shift_amount, const U1& carry_in) {
const auto result = Inst<U32>(Opcode::RotateRight32, value_in, shift_amount, carry_in);
const auto result = Inst<U32>(Opcode::BitRotateRight32, value_in, shift_amount, carry_in);
const auto carry_out = Inst<U1>(Opcode::GetCarryFromOp, result);
return {result, carry_out};
}
@ -265,9 +265,9 @@ public:
U32U64 RotateRight(const U32U64& value_in, const U8& shift_amount) {
if (value_in.GetType() == Type::U32) {
return Inst<U32>(Opcode::RotateRight32, value_in, shift_amount, Imm1(0));
return Inst<U32>(Opcode::BitRotateRight32, value_in, shift_amount, Imm1(0));
} else {
return Inst<U64>(Opcode::RotateRight64, value_in, shift_amount);
return Inst<U64>(Opcode::BitRotateRight64, value_in, shift_amount);
}
}

6
src/dynarmic/src/dynarmic/ir/opcodes.h

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
/* This file is part of the dynarmic project.
@ -45,8 +45,8 @@ constexpr bool IsArithmeticShift(const Opcode op) noexcept {
/// @brief Determines whether or not this instruction performs a logical shift.
constexpr bool IsCircularShift(const Opcode op) noexcept {
return op == Opcode::RotateRight32
|| op == Opcode::RotateRight64
return op == Opcode::BitRotateRight32
|| op == Opcode::BitRotateRight64
|| op == Opcode::RotateRightExtended;
}

5
src/dynarmic/src/dynarmic/ir/opcodes.inc

@ -46,8 +46,9 @@ OPCODE(LogicalShiftRight32, U32, U32,
OPCODE(LogicalShiftRight64, U64, U64, U8 )
OPCODE(ArithmeticShiftRight32, U32, U32, U8, U1 )
OPCODE(ArithmeticShiftRight64, U64, U64, U8 )
OPCODE(RotateRight32, U32, U32, U8, U1 )
OPCODE(RotateRight64, U64, U64, U8 )
// windows.h defines RotateRight64 and RotateRight32
OPCODE(BitRotateRight32, U32, U32, U8, U1 )
OPCODE(BitRotateRight64, U64, U64, U8 )
OPCODE(RotateRightExtended, U32, U32, U1 )
OPCODE(LogicalShiftLeftMasked32, U32, U32, U32 )
OPCODE(LogicalShiftLeftMasked64, U64, U64, U64 )

4
src/dynarmic/src/dynarmic/ir/opt_passes.cpp

@ -1072,12 +1072,12 @@ static void ConstantPropagation(IR::Block& block) {
ReplaceUsesWith(inst, false, Safe::ArithmeticShiftRight<u64>(inst.GetArg(0).GetU64(), inst.GetArg(1).GetU8()));
}
break;
case Op::RotateRight32:
case Op::BitRotateRight32:
if (FoldShifts(inst)) {
ReplaceUsesWith(inst, true, mcl::bit::rotate_right<u32>(inst.GetArg(0).GetU32(), inst.GetArg(1).GetU8()));
}
break;
case Op::RotateRight64:
case Op::BitRotateRight64:
if (FoldShifts(inst)) {
ReplaceUsesWith(inst, false, mcl::bit::rotate_right<u64>(inst.GetArg(0).GetU64(), inst.GetArg(1).GetU8()));
}

Loading…
Cancel
Save