diff --git a/include/dynarmic/A32/config.h b/include/dynarmic/A32/config.h index bb38be4a..da17ce82 100644 --- a/include/dynarmic/A32/config.h +++ b/include/dynarmic/A32/config.h @@ -48,6 +48,8 @@ enum class Exception { PreloadData, /// A PLDW instruction was executed. (Hint instruction.) PreloadDataWithIntentToWrite, + /// A PLI instruction was executed. (Hint instruction.) + PreloadInstruction, }; /// These function pointers may be inserted into compiled code. diff --git a/src/frontend/A32/decoder/thumb32.inc b/src/frontend/A32/decoder/thumb32.inc index a5660a52..4a1c4600 100644 --- a/src/frontend/A32/decoder/thumb32.inc +++ b/src/frontend/A32/decoder/thumb32.inc @@ -149,10 +149,10 @@ INST(thumb32_PLD_lit, "PLD (lit)", "11111000U00111111111ii INST(thumb32_PLD_reg, "PLD (reg)", "1111100000W1nnnn1111000000iimmmm") INST(thumb32_PLD_imm8, "PLD (imm8)", "1111100000W1nnnn11111100iiiiiiii") INST(thumb32_PLD_imm12, "PLD (imm12)", "1111100010W1nnnn1111iiiiiiiiiiii") -//INST(thumb32_PLI_lit, "PLI (lit)", "11111001-00111111111------------") -//INST(thumb32_PLI_reg, "PLI (reg)", "111110010001----1111000000------") -//INST(thumb32_PLI_imm8, "PLI (imm8)", "111110010001----11111100--------") -//INST(thumb32_PLI_imm12, "PLI (imm12)", "111110011001----1111------------") +INST(thumb32_PLI_lit, "PLI (lit)", "11111001U00111111111iiiiiiiiiiii") +INST(thumb32_PLI_reg, "PLI (reg)", "111110010001nnnn1111000000iimmmm") +INST(thumb32_PLI_imm8, "PLI (imm8)", "111110010001nnnn11111100iiiiiiii") +INST(thumb32_PLI_imm12, "PLI (imm12)", "111110011001nnnn1111iiiiiiiiiiii") //INST(thumb32_LDRB_lit, "LDRB (lit)", "11111000-0011111----------------") //INST(thumb32_LDRB_reg, "LDRB (reg)", "111110000001--------000000------") //INST(thumb32_LDRBT, "LDRBT", "111110000001--------1110--------") diff --git a/src/frontend/A32/translate/impl/thumb32_load_byte.cpp b/src/frontend/A32/translate/impl/thumb32_load_byte.cpp index 40f6a07d..eb5474ce 100644 --- a/src/frontend/A32/translate/impl/thumb32_load_byte.cpp +++ b/src/frontend/A32/translate/impl/thumb32_load_byte.cpp @@ -17,6 +17,14 @@ static bool PLDHandler(ThumbTranslatorVisitor& v, bool W) { return v.RaiseException(exception); } +static bool PLIHandler(ThumbTranslatorVisitor& v) { + if (!v.options.hook_hint_instructions) { + return true; + } + + return v.RaiseException(Exception::PreloadInstruction); +} + bool ThumbTranslatorVisitor::thumb32_PLD_lit([[maybe_unused]] bool U, [[maybe_unused]] Imm<12> imm12) { return PLDHandler(*this, false); @@ -45,4 +53,29 @@ bool ThumbTranslatorVisitor::thumb32_PLD_reg(bool W, return PLDHandler(*this, W); } +bool ThumbTranslatorVisitor::thumb32_PLI_lit([[maybe_unused]] bool U, + [[maybe_unused]] Imm<12> imm12) { + return PLIHandler(*this); +} + +bool ThumbTranslatorVisitor::thumb32_PLI_imm8([[maybe_unused]] Reg n, + [[maybe_unused]] Imm<8> imm8) { + return PLIHandler(*this); +} + +bool ThumbTranslatorVisitor::thumb32_PLI_imm12([[maybe_unused]] Reg n, + [[maybe_unused]] Imm<12> imm12) { + return PLIHandler(*this); +} + +bool ThumbTranslatorVisitor::thumb32_PLI_reg([[maybe_unused]] Reg n, + [[maybe_unused]] Imm<2> imm2, + Reg m) { + if (m == Reg::PC) { + return UnpredictableInstruction(); + } + + return PLIHandler(*this); +} + } // namespace Dynarmic::A32 diff --git a/src/frontend/A32/translate/impl/translate_thumb.h b/src/frontend/A32/translate/impl/translate_thumb.h index 846c7d35..cda76ce6 100644 --- a/src/frontend/A32/translate/impl/translate_thumb.h +++ b/src/frontend/A32/translate/impl/translate_thumb.h @@ -210,6 +210,10 @@ struct ThumbTranslatorVisitor final { bool thumb32_PLD_imm8(bool W, Reg n, Imm<8> imm8); bool thumb32_PLD_imm12(bool W, Reg n, Imm<12> imm12); bool thumb32_PLD_reg(bool W, Reg n, Imm<2> imm2, Reg m); + bool thumb32_PLI_lit(bool U, Imm<12> imm12); + bool thumb32_PLI_imm8(Reg n, Imm<8> imm8); + bool thumb32_PLI_imm12(Reg n, Imm<12> imm12); + bool thumb32_PLI_reg(Reg n, Imm<2> imm2, Reg m); // thumb32 data processing (register) instructions bool thumb32_ASR_reg(Reg m, Reg d, Reg s);