mirror of
https://git.suyu.dev/suyu/dynarmic.git
synced 2026-02-07 03:53:35 +00:00
40 lines
1.2 KiB
C++
40 lines
1.2 KiB
C++
/* This file is part of the dynarmic project.
|
|
* Copyright (c) 2021 MerryMage
|
|
* SPDX-License-Identifier: 0BSD
|
|
*/
|
|
|
|
#include "frontend/A32/translate/impl/translate_thumb.h"
|
|
|
|
namespace Dynarmic::A32 {
|
|
static IR::U32 Rotate(A32::IREmitter& ir, Reg m, SignExtendRotation rotate) {
|
|
const u8 rotate_by = static_cast<u8>(static_cast<size_t>(rotate) * 8);
|
|
return ir.RotateRight(ir.GetRegister(m), ir.Imm8(rotate_by), ir.Imm1(0)).result;
|
|
}
|
|
|
|
bool ThumbTranslatorVisitor::thumb32_SXTH(Reg d, SignExtendRotation rotate, Reg m) {
|
|
if (d == Reg::PC || m == Reg::PC) {
|
|
return UnpredictableInstruction();
|
|
}
|
|
|
|
const auto rotated = Rotate(ir, m, rotate);
|
|
const auto result = ir.SignExtendHalfToWord(ir.LeastSignificantHalf(rotated));
|
|
|
|
ir.SetRegister(d, result);
|
|
return true;
|
|
}
|
|
|
|
bool ThumbTranslatorVisitor::thumb32_SXTAH(Reg n, Reg d, SignExtendRotation rotate, Reg m) {
|
|
if (d == Reg::PC || m == Reg::PC) {
|
|
return UnpredictableInstruction();
|
|
}
|
|
|
|
const auto rotated = Rotate(ir, m, rotate);
|
|
const auto reg_n = ir.GetRegister(n);
|
|
const auto result = ir.Add(reg_n, ir.SignExtendHalfToWord(ir.LeastSignificantHalf(rotated)));
|
|
|
|
ir.SetRegister(d, result);
|
|
return true;
|
|
}
|
|
|
|
} // namespace Dynarmic::A32
|