thumb32: Implement PLI variants

This commit is contained in:
Lioncash 2021-03-06 09:55:29 -05:00
parent b2802aaf17
commit c66afadbc1
4 changed files with 43 additions and 4 deletions

View file

@ -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.

View file

@ -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--------")

View file

@ -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

View file

@ -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);