Implement Thumb instructions: BX, BLX (reg), B (T1), B (T2)

This commit is contained in:
MerryMage
2016-07-18 21:04:39 +01:00
parent 2363759c62
commit e0d6e28b67
6 changed files with 217 additions and 142 deletions

View File

@@ -57,6 +57,10 @@ void IREmitter::SetRegister(const Reg reg, IR::ValuePtr value) {
void IREmitter::ALUWritePC(IR::ValuePtr value) {
// This behaviour is ARM version-dependent.
// The below implementation is for ARMv6k
BranchWritePC(value);
}
void IREmitter::BranchWritePC(IR::ValuePtr value) {
if (!current_location.TFlag) {
auto new_pc = And(value, Imm32(0xFFFFFFFC));
Inst(IR::Opcode::SetRegister, { RegRef(Reg::PC), new_pc });
@@ -66,10 +70,14 @@ void IREmitter::ALUWritePC(IR::ValuePtr value) {
}
}
void IREmitter::BXWritePC(IR::ValuePtr value) {
Inst(IR::Opcode::BXWritePC, {value});
}
void IREmitter::LoadWritePC(IR::ValuePtr value) {
// This behaviour is ARM version-dependent.
// The below implementation is for ARMv6k
Inst(IR::Opcode::BXWritePC, {value});
BXWritePC(value);
}
void IREmitter::CallSupervisor(IR::ValuePtr value) {