thumb32_data_processing_plain_binary_immediate: Make invalid {S,U}SSAT16 decode undefined

This commit is contained in:
MerryMage 2021-03-02 20:51:40 +00:00
parent 2ac615b882
commit 67e954a4cf
2 changed files with 3 additions and 4 deletions

View file

@ -77,6 +77,7 @@ INST(thumb32_MOVW_imm, "MOVW (imm)", "11110i100100iiii0iiidd
//INST(thumb32_ADR, "ADR", "11110-10101011110---------------") //INST(thumb32_ADR, "ADR", "11110-10101011110---------------")
INST(thumb32_SUB_imm_2, "SUB (imm)", "11110i10101011010iiiddddiiiiiiii") INST(thumb32_SUB_imm_2, "SUB (imm)", "11110i10101011010iiiddddiiiiiiii")
INST(thumb32_MOVT, "MOVT", "11110i101100iiii0iiiddddiiiiiiii") INST(thumb32_MOVT, "MOVT", "11110i101100iiii0iiiddddiiiiiiii")
INST(thumb32_UDF, "Invalid decoding", "11110011-010----0000----0001----")
INST(thumb32_SSAT16, "SSAT16", "111100110010nnnn0000dddd0000iiii") INST(thumb32_SSAT16, "SSAT16", "111100110010nnnn0000dddd0000iiii")
INST(thumb32_USAT16, "USAT16", "111100111010nnnn0000dddd0000iiii") INST(thumb32_USAT16, "USAT16", "111100111010nnnn0000dddd0000iiii")
INST(thumb32_SSAT, "SSAT", "1111001100s0nnnn0iiiddddii0bbbbb") INST(thumb32_SSAT, "SSAT", "1111001100s0nnnn0iiiddddii0bbbbb")

View file

@ -19,14 +19,12 @@ static IR::U16 MostSignificantHalf(A32::IREmitter& ir, IR::U32 value) {
using SaturationFunction = IR::ResultAndOverflow<IR::U32> (IREmitter::*)(const IR::U32&, size_t); using SaturationFunction = IR::ResultAndOverflow<IR::U32> (IREmitter::*)(const IR::U32&, size_t);
static bool Saturation(ThumbTranslatorVisitor& v, bool sh, Reg n, Reg d, Imm<5> shift_amount, size_t saturate_to, SaturationFunction sat_fn) { static bool Saturation(ThumbTranslatorVisitor& v, bool sh, Reg n, Reg d, Imm<5> shift_amount, size_t saturate_to, SaturationFunction sat_fn) {
ASSERT_MSG(!(sh && shift_amount == 0), "Invalid decode");
if (d == Reg::PC || n == Reg::PC) { if (d == Reg::PC || n == Reg::PC) {
return v.UnpredictableInstruction(); return v.UnpredictableInstruction();
} }
if (sh && shift_amount == 0) {
ASSERT_FALSE("Invalid decode");
}
const auto shift = sh ? ShiftType::ASR : ShiftType::LSL; const auto shift = sh ? ShiftType::ASR : ShiftType::LSL;
const auto operand = v.EmitImmShift(v.ir.GetRegister(n), shift, shift_amount, v.ir.GetCFlag()); const auto operand = v.EmitImmShift(v.ir.GetRegister(n), shift, shift_amount, v.ir.GetCFlag());
const auto result = (v.ir.*sat_fn)(operand.result, saturate_to); const auto result = (v.ir.*sat_fn)(operand.result, saturate_to);