mirror of
https://github.com/azahar-emu/dynarmic
synced 2025-11-07 07:29:59 +01:00
66 lines
1.6 KiB
C++
66 lines
1.6 KiB
C++
/* This file is part of the dynarmic project.
|
|
* Copyright (c) 2016 MerryMage
|
|
* This software may be used and distributed according to the terms of the GNU
|
|
* General Public License version 2 or any later version.
|
|
*/
|
|
|
|
#include "common/bit_util.h"
|
|
#include "translate_arm.h"
|
|
|
|
namespace Dynarmic::A32 {
|
|
|
|
// BFC<c> <Rd>, #<lsb>, #<width>
|
|
bool ArmTranslatorVisitor::arm_BFC(Cond cond, Imm5 msb, Reg d, Imm5 lsb) {
|
|
if (d == Reg::PC) {
|
|
return UnpredictableInstruction();
|
|
}
|
|
if (msb < lsb) {
|
|
return UnpredictableInstruction();
|
|
}
|
|
|
|
if (!ConditionPassed(cond)) {
|
|
return true;
|
|
}
|
|
|
|
const u32 mask = ~(Common::Ones<u32>(msb - lsb + 1) << lsb);
|
|
const IR::U32 operand = ir.GetRegister(d);
|
|
const IR::U32 result = ir.And(operand, ir.Imm32(mask));
|
|
|
|
ir.SetRegister(d, result);
|
|
return true;
|
|
}
|
|
|
|
// CLZ<c> <Rd>, <Rm>
|
|
bool ArmTranslatorVisitor::arm_CLZ(Cond cond, Reg d, Reg m) {
|
|
if (d == Reg::PC || m == Reg::PC) {
|
|
return UnpredictableInstruction();
|
|
}
|
|
|
|
if (!ConditionPassed(cond)) {
|
|
return true;
|
|
}
|
|
|
|
ir.SetRegister(d, ir.CountLeadingZeros(ir.GetRegister(m)));
|
|
return true;
|
|
}
|
|
|
|
// SEL<c> <Rd>, <Rn>, <Rm>
|
|
bool ArmTranslatorVisitor::arm_SEL(Cond cond, Reg n, Reg d, Reg m) {
|
|
if (n == Reg::PC || d == Reg::PC || m == Reg::PC) {
|
|
return UnpredictableInstruction();
|
|
}
|
|
|
|
if (!ConditionPassed(cond)) {
|
|
return true;
|
|
}
|
|
|
|
const auto to = ir.GetRegister(m);
|
|
const auto from = ir.GetRegister(n);
|
|
const auto result = ir.PackedSelect(ir.GetGEFlags(), to, from);
|
|
|
|
ir.SetRegister(d, result);
|
|
return true;
|
|
}
|
|
|
|
} // namespace Dynarmic::A32
|