2016-07-01 15:01:06 +02:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
2016-07-07 11:53:09 +02:00
|
|
|
#include "common/assert.h"
|
2016-09-03 22:48:03 +02:00
|
|
|
#include "frontend/ir/ir_emitter.h"
|
|
|
|
#include "frontend/ir/opcodes.h"
|
2016-07-01 15:01:06 +02:00
|
|
|
|
|
|
|
namespace Dynarmic {
|
2016-08-25 18:36:42 +02:00
|
|
|
namespace IR {
|
2016-07-01 15:01:06 +02:00
|
|
|
|
|
|
|
void IREmitter::Unimplemented() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-07-11 23:43:53 +02:00
|
|
|
u32 IREmitter::PC() {
|
2016-08-01 21:03:13 +02:00
|
|
|
u32 offset = current_location.TFlag() ? 4 : 8;
|
|
|
|
return current_location.PC() + offset;
|
2016-07-11 23:43:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 IREmitter::AlignPC(size_t alignment) {
|
|
|
|
u32 pc = PC();
|
|
|
|
return static_cast<u32>(pc - pc % alignment);
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Imm1(bool imm1) {
|
|
|
|
return Value(imm1);
|
2016-07-08 11:09:18 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Imm8(u8 imm8) {
|
|
|
|
return Value(imm8);
|
2016-07-01 15:01:06 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Imm32(u32 imm32) {
|
|
|
|
return Value(imm32);
|
2016-07-08 11:09:18 +02:00
|
|
|
}
|
|
|
|
|
2016-12-03 12:29:50 +01:00
|
|
|
Value IREmitter::Imm64(u64 imm64) {
|
|
|
|
return Value(imm64);
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::GetRegister(Arm::Reg reg) {
|
|
|
|
if (reg == Arm::Reg::PC) {
|
2016-07-11 23:43:53 +02:00
|
|
|
return Imm32(PC());
|
2016-07-08 11:09:18 +02:00
|
|
|
}
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::GetRegister, { Value(reg) });
|
2016-07-01 15:01:06 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::GetExtendedRegister(Arm::ExtReg reg) {
|
2016-09-07 13:08:35 +02:00
|
|
|
if (Arm::IsSingleExtReg(reg)) {
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::GetExtendedRegister32, {Value(reg)});
|
2016-09-07 13:08:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Arm::IsDoubleExtReg(reg)) {
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::GetExtendedRegister64, {Value(reg)});
|
2016-08-05 19:54:19 +02:00
|
|
|
}
|
2016-09-07 13:08:35 +02:00
|
|
|
|
|
|
|
ASSERT_MSG(false, "Invalid reg.");
|
2016-08-05 19:54:19 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::SetRegister(const Arm::Reg reg, const Value& value) {
|
|
|
|
ASSERT(reg != Arm::Reg::PC);
|
|
|
|
Inst(Opcode::SetRegister, { Value(reg), value });
|
2016-07-01 15:01:06 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::SetExtendedRegister(const Arm::ExtReg reg, const Value& value) {
|
2016-09-07 13:08:35 +02:00
|
|
|
if (Arm::IsSingleExtReg(reg)) {
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::SetExtendedRegister32, {Value(reg), value});
|
2016-09-07 13:08:35 +02:00
|
|
|
} else if (Arm::IsDoubleExtReg(reg)) {
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::SetExtendedRegister64, {Value(reg), value});
|
2016-08-05 19:54:19 +02:00
|
|
|
} else {
|
|
|
|
ASSERT_MSG(false, "Invalid reg.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::ALUWritePC(const Value& value) {
|
2016-07-08 11:09:18 +02:00
|
|
|
// This behaviour is ARM version-dependent.
|
2016-07-12 11:58:14 +02:00
|
|
|
// The below implementation is for ARMv6k
|
2016-07-18 22:04:39 +02:00
|
|
|
BranchWritePC(value);
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::BranchWritePC(const Value& value) {
|
2016-08-01 21:03:13 +02:00
|
|
|
if (!current_location.TFlag()) {
|
2016-07-12 11:58:14 +02:00
|
|
|
auto new_pc = And(value, Imm32(0xFFFFFFFC));
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::SetRegister, { Value(Arm::Reg::PC), new_pc });
|
2016-07-12 11:58:14 +02:00
|
|
|
} else {
|
|
|
|
auto new_pc = And(value, Imm32(0xFFFFFFFE));
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::SetRegister, { Value(Arm::Reg::PC), new_pc });
|
2016-07-12 11:58:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::BXWritePC(const Value& value) {
|
|
|
|
Inst(Opcode::BXWritePC, {value});
|
2016-07-18 22:04:39 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::LoadWritePC(const Value& value) {
|
2016-07-12 11:58:14 +02:00
|
|
|
// This behaviour is ARM version-dependent.
|
|
|
|
// The below implementation is for ARMv6k
|
2016-07-18 22:04:39 +02:00
|
|
|
BXWritePC(value);
|
2016-07-08 11:09:18 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::CallSupervisor(const Value& value) {
|
|
|
|
Inst(Opcode::CallSupervisor, {value});
|
2016-07-14 15:04:43 +02:00
|
|
|
}
|
|
|
|
|
2016-09-05 12:54:09 +02:00
|
|
|
void IREmitter::PushRSB(const LocationDescriptor& return_location) {
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::PushRSB, {Value(return_location.UniqueHash())});
|
2016-08-13 01:10:23 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::GetCpsr() {
|
|
|
|
return Inst(Opcode::GetCpsr, {});
|
2016-08-14 20:39:16 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::SetCpsr(const Value& value) {
|
|
|
|
Inst(Opcode::SetCpsr, {value});
|
2016-08-14 20:39:16 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::GetCFlag() {
|
|
|
|
return Inst(Opcode::GetCFlag, {});
|
2016-07-01 15:01:06 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::SetNFlag(const Value& value) {
|
|
|
|
Inst(Opcode::SetNFlag, {value});
|
2016-07-01 15:01:06 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::SetZFlag(const Value& value) {
|
|
|
|
Inst(Opcode::SetZFlag, {value});
|
2016-07-01 15:01:06 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::SetCFlag(const Value& value) {
|
|
|
|
Inst(Opcode::SetCFlag, {value});
|
2016-07-01 15:01:06 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::SetVFlag(const Value& value) {
|
|
|
|
Inst(Opcode::SetVFlag, {value});
|
2016-07-08 11:09:18 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::OrQFlag(const Value& value) {
|
|
|
|
Inst(Opcode::OrQFlag, {value});
|
2016-11-23 20:44:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Value IREmitter::GetGEFlags() {
|
|
|
|
return Inst(Opcode::GetGEFlags, {});
|
|
|
|
}
|
|
|
|
|
|
|
|
void IREmitter::SetGEFlags(const Value& value) {
|
|
|
|
Inst(Opcode::SetGEFlags, {value});
|
2016-08-06 23:04:52 +02:00
|
|
|
}
|
|
|
|
|
2016-08-26 23:47:54 +02:00
|
|
|
Value IREmitter::GetFpscr() {
|
|
|
|
return Inst(Opcode::GetFpscr, {});
|
|
|
|
}
|
|
|
|
|
|
|
|
void IREmitter::SetFpscr(const Value& new_fpscr) {
|
|
|
|
Inst(Opcode::SetFpscr, {new_fpscr});
|
|
|
|
}
|
|
|
|
|
|
|
|
Value IREmitter::GetFpscrNZCV() {
|
|
|
|
return Inst(Opcode::GetFpscrNZCV, {});
|
|
|
|
}
|
|
|
|
|
|
|
|
void IREmitter::SetFpscrNZCV(const Value& new_fpscr_nzcv) {
|
|
|
|
Inst(Opcode::SetFpscrNZCV, {new_fpscr_nzcv});
|
|
|
|
}
|
|
|
|
|
|
|
|
Value IREmitter::Pack2x32To1x64(const Value& lo, const Value& hi) {
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::Pack2x32To1x64, {lo, hi});
|
2016-08-04 23:04:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::LeastSignificantWord(const Value& value) {
|
|
|
|
return Inst(Opcode::LeastSignificantWord, {value});
|
2016-08-04 23:04:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
IREmitter::ResultAndCarry IREmitter::MostSignificantWord(const Value& value) {
|
|
|
|
auto result = Inst(Opcode::MostSignificantWord, {value});
|
|
|
|
auto carry_out = Inst(Opcode::GetCarryFromOp, {result});
|
2016-08-06 22:03:57 +02:00
|
|
|
return {result, carry_out};
|
2016-08-04 23:04:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::LeastSignificantHalf(const Value& value) {
|
|
|
|
return Inst(Opcode::LeastSignificantHalf, {value});
|
2016-07-12 00:06:35 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::LeastSignificantByte(const Value& value) {
|
|
|
|
return Inst(Opcode::LeastSignificantByte, {value});
|
2016-07-01 15:01:06 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::MostSignificantBit(const Value& value) {
|
|
|
|
return Inst(Opcode::MostSignificantBit, {value});
|
2016-07-01 15:01:06 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::IsZero(const Value& value) {
|
|
|
|
return Inst(Opcode::IsZero, {value});
|
2016-07-01 15:01:06 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::IsZero64(const Value& value) {
|
|
|
|
return Inst(Opcode::IsZero64, {value});
|
2016-08-04 23:04:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
IREmitter::ResultAndCarry IREmitter::LogicalShiftLeft(const Value& value_in, const Value& shift_amount, const Value& carry_in) {
|
|
|
|
auto result = Inst(Opcode::LogicalShiftLeft, {value_in, shift_amount, carry_in});
|
|
|
|
auto carry_out = Inst(Opcode::GetCarryFromOp, {result});
|
2016-07-01 15:01:06 +02:00
|
|
|
return {result, carry_out};
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
IREmitter::ResultAndCarry IREmitter::LogicalShiftRight(const Value& value_in, const Value& shift_amount, const Value& carry_in) {
|
|
|
|
auto result = Inst(Opcode::LogicalShiftRight, {value_in, shift_amount, carry_in});
|
|
|
|
auto carry_out = Inst(Opcode::GetCarryFromOp, {result});
|
2016-07-01 15:01:06 +02:00
|
|
|
return {result, carry_out};
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::LogicalShiftRight64(const Value& value_in, const Value& shift_amount) {
|
|
|
|
return Inst(Opcode::LogicalShiftRight64, {value_in, shift_amount});
|
2016-08-07 15:23:33 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
IREmitter::ResultAndCarry IREmitter::ArithmeticShiftRight(const Value& value_in, const Value& shift_amount, const Value& carry_in) {
|
|
|
|
auto result = Inst(Opcode::ArithmeticShiftRight, {value_in, shift_amount, carry_in});
|
|
|
|
auto carry_out = Inst(Opcode::GetCarryFromOp, {result});
|
2016-07-04 11:22:11 +02:00
|
|
|
return {result, carry_out};
|
|
|
|
}
|
2016-07-01 15:01:06 +02:00
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
IREmitter::ResultAndCarry IREmitter::RotateRight(const Value& value_in, const Value& shift_amount, const Value& carry_in) {
|
|
|
|
auto result = Inst(Opcode::RotateRight, {value_in, shift_amount, carry_in});
|
|
|
|
auto carry_out = Inst(Opcode::GetCarryFromOp, {result});
|
2016-07-10 02:18:17 +02:00
|
|
|
return {result, carry_out};
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
IREmitter::ResultAndCarry IREmitter::RotateRightExtended(const Value& value_in, const Value& carry_in) {
|
|
|
|
auto result = Inst(Opcode::RotateRightExtended, {value_in, carry_in});
|
|
|
|
auto carry_out = Inst(Opcode::GetCarryFromOp, {result});
|
2016-07-31 20:07:35 +02:00
|
|
|
return {result, carry_out};
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
IREmitter::ResultAndCarryAndOverflow IREmitter::AddWithCarry(const Value& a, const Value& b, const Value& carry_in) {
|
|
|
|
auto result = Inst(Opcode::AddWithCarry, {a, b, carry_in});
|
|
|
|
auto carry_out = Inst(Opcode::GetCarryFromOp, {result});
|
|
|
|
auto overflow = Inst(Opcode::GetOverflowFromOp, {result});
|
2016-07-08 11:09:18 +02:00
|
|
|
return {result, carry_out, overflow};
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Add(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::AddWithCarry, {a, b, Imm1(0)});
|
2016-07-11 23:43:53 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Add64(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::Add64, {a, b});
|
2016-08-04 23:04:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
IREmitter::ResultAndCarryAndOverflow IREmitter::SubWithCarry(const Value& a, const Value& b, const Value& carry_in) {
|
2016-07-08 12:49:30 +02:00
|
|
|
// This is equivalent to AddWithCarry(a, Not(b), carry_in).
|
2016-08-25 18:36:42 +02:00
|
|
|
auto result = Inst(Opcode::SubWithCarry, {a, b, carry_in});
|
|
|
|
auto carry_out = Inst(Opcode::GetCarryFromOp, {result});
|
|
|
|
auto overflow = Inst(Opcode::GetOverflowFromOp, {result});
|
2016-07-08 12:49:30 +02:00
|
|
|
return {result, carry_out, overflow};
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Sub(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::SubWithCarry, {a, b, Imm1(1)});
|
2016-07-18 16:11:16 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Sub64(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::Sub64, {a, b});
|
2016-08-06 07:09:47 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Mul(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::Mul, {a, b});
|
2016-08-04 23:04:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Mul64(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::Mul64, {a, b});
|
2016-08-04 23:04:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::And(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::And, {a, b});
|
2016-07-08 11:43:28 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Eor(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::Eor, {a, b});
|
2016-07-08 12:14:50 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Or(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::Or, {a, b});
|
2016-07-10 03:06:38 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Not(const Value& a) {
|
|
|
|
return Inst(Opcode::Not, {a});
|
2016-07-10 04:44:45 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::SignExtendWordToLong(const Value& a) {
|
|
|
|
return Inst(Opcode::SignExtendWordToLong, {a});
|
2016-08-04 23:04:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::SignExtendHalfToWord(const Value& a) {
|
|
|
|
return Inst(Opcode::SignExtendHalfToWord, {a});
|
2016-07-16 20:23:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::SignExtendByteToWord(const Value& a) {
|
|
|
|
return Inst(Opcode::SignExtendByteToWord, {a});
|
2016-07-16 20:23:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ZeroExtendWordToLong(const Value& a) {
|
|
|
|
return Inst(Opcode::ZeroExtendWordToLong, {a});
|
2016-07-16 20:23:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ZeroExtendHalfToWord(const Value& a) {
|
|
|
|
return Inst(Opcode::ZeroExtendHalfToWord, {a});
|
2016-07-16 20:23:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ZeroExtendByteToWord(const Value& a) {
|
|
|
|
return Inst(Opcode::ZeroExtendByteToWord, {a});
|
2016-07-16 20:23:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ByteReverseWord(const Value& a) {
|
|
|
|
return Inst(Opcode::ByteReverseWord, {a});
|
2016-07-16 20:23:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ByteReverseHalf(const Value& a) {
|
|
|
|
return Inst(Opcode::ByteReverseHalf, {a});
|
2016-07-16 20:23:42 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ByteReverseDual(const Value& a) {
|
|
|
|
return Inst(Opcode::ByteReverseDual, {a});
|
2016-07-20 16:34:17 +02:00
|
|
|
}
|
2016-07-16 20:23:42 +02:00
|
|
|
|
2016-12-04 21:52:33 +01:00
|
|
|
IREmitter::ResultAndGE IREmitter::PackedAddU8(const Value& a, const Value& b) {
|
|
|
|
auto result = Inst(Opcode::PackedAddU8, {a, b});
|
|
|
|
auto ge = Inst(Opcode::GetGEFromOp, {result});
|
|
|
|
return {result, ge};
|
|
|
|
}
|
|
|
|
|
2016-11-25 21:32:22 +01:00
|
|
|
Value IREmitter::PackedHalvingAddU8(const Value& a, const Value& b) {
|
2016-11-26 19:12:29 +01:00
|
|
|
return Inst(Opcode::PackedHalvingAddU8, {a, b});
|
|
|
|
}
|
|
|
|
|
|
|
|
Value IREmitter::PackedHalvingAddS8(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedHalvingAddS8, {a, b});
|
2016-11-25 21:32:22 +01:00
|
|
|
}
|
|
|
|
|
2016-11-26 19:27:21 +01:00
|
|
|
Value IREmitter::PackedHalvingSubU8(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedHalvingSubU8, {a, b});
|
|
|
|
}
|
|
|
|
|
2016-11-26 12:28:20 +01:00
|
|
|
Value IREmitter::PackedHalvingAddU16(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedHalvingAddU16, {a, b});
|
|
|
|
}
|
|
|
|
|
2016-11-26 19:12:29 +01:00
|
|
|
Value IREmitter::PackedHalvingAddS16(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedHalvingAddS16, {a, b});
|
|
|
|
}
|
|
|
|
|
2016-11-26 19:27:21 +01:00
|
|
|
Value IREmitter::PackedHalvingSubU16(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedHalvingSubU16, {a, b});
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::PackedSaturatedAddU8(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedSaturatedAddU8, {a, b});
|
2016-08-12 19:26:14 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::PackedSaturatedAddS8(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedSaturatedAddS8, {a, b});
|
2016-08-12 19:26:14 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::PackedSaturatedSubU8(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedSaturatedSubU8, {a, b});
|
2016-08-12 17:53:16 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::PackedSaturatedSubS8(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedSaturatedSubS8, {a, b});
|
2016-08-12 19:18:38 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::PackedSaturatedAddU16(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedSaturatedAddU16, {a, b});
|
2016-08-12 19:42:16 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::PackedSaturatedAddS16(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedSaturatedAddS16, {a, b});
|
2016-08-12 19:42:16 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::PackedSaturatedSubU16(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedSaturatedSubU16, {a, b});
|
2016-08-12 19:42:16 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::PackedSaturatedSubS16(const Value& a, const Value& b) {
|
|
|
|
return Inst(Opcode::PackedSaturatedSubS16, {a, b});
|
2016-08-12 19:42:16 +02:00
|
|
|
}
|
|
|
|
|
2016-12-04 23:56:33 +01:00
|
|
|
Value IREmitter::CountLeadingZeros(const Value& a) {
|
|
|
|
return Inst(Opcode::CountLeadingZeros, {a});
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::TransferToFP32(const Value& a) {
|
|
|
|
return Inst(Opcode::TransferToFP32, {a});
|
2016-08-07 20:25:12 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::TransferToFP64(const Value& a) {
|
|
|
|
return Inst(Opcode::TransferToFP64, {a});
|
2016-08-07 20:25:12 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::TransferFromFP32(const Value& a) {
|
|
|
|
return Inst(Opcode::TransferFromFP32, {a});
|
2016-08-07 20:25:12 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::TransferFromFP64(const Value& a) {
|
|
|
|
return Inst(Opcode::TransferFromFP64, {a});
|
2016-08-07 20:25:12 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPAbs32(const Value& a) {
|
|
|
|
return Inst(Opcode::FPAbs32, {a});
|
2016-08-07 02:27:18 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPAbs64(const Value& a) {
|
|
|
|
return Inst(Opcode::FPAbs64, {a});
|
2016-08-07 02:27:18 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPAdd32(const Value& a, const Value& b, bool fpscr_controlled) {
|
2016-08-06 18:21:29 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPAdd32, {a, b});
|
2016-08-06 18:21:29 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPAdd64(const Value& a, const Value& b, bool fpscr_controlled) {
|
2016-08-06 18:21:29 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPAdd64, {a, b});
|
2016-08-06 18:21:29 +02:00
|
|
|
}
|
|
|
|
|
2016-11-26 12:17:16 +01:00
|
|
|
void IREmitter::FPCompare32(const Value& a, const Value& b, bool quiet, bool fpscr_controlled) {
|
|
|
|
ASSERT(fpscr_controlled);
|
|
|
|
Inst(Opcode::FPCompare32, {a, b, Imm1(quiet)});
|
|
|
|
}
|
|
|
|
|
|
|
|
void IREmitter::FPCompare64(const Value& a, const Value& b, bool quiet, bool fpscr_controlled) {
|
|
|
|
ASSERT(fpscr_controlled);
|
|
|
|
Inst(Opcode::FPCompare64, {a, b, Imm1(quiet)});
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPDiv32(const Value& a, const Value& b, bool fpscr_controlled) {
|
2016-08-07 11:56:12 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPDiv32, {a, b});
|
2016-08-07 11:56:12 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPDiv64(const Value& a, const Value& b, bool fpscr_controlled) {
|
2016-08-07 11:56:12 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPDiv64, {a, b});
|
2016-08-07 11:56:12 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPMul32(const Value& a, const Value& b, bool fpscr_controlled) {
|
2016-08-07 11:21:14 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPMul32, {a, b});
|
2016-08-07 11:21:14 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPMul64(const Value& a, const Value& b, bool fpscr_controlled) {
|
2016-08-07 11:21:14 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPMul64, {a, b});
|
2016-08-07 11:21:14 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPNeg32(const Value& a) {
|
|
|
|
return Inst(Opcode::FPNeg32, {a});
|
2016-08-07 11:56:12 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPNeg64(const Value& a) {
|
|
|
|
return Inst(Opcode::FPNeg64, {a});
|
2016-08-07 11:56:12 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPSqrt32(const Value& a) {
|
|
|
|
return Inst(Opcode::FPSqrt32, {a});
|
2016-08-07 13:19:07 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPSqrt64(const Value& a) {
|
|
|
|
return Inst(Opcode::FPSqrt64, {a});
|
2016-08-07 13:19:07 +02:00
|
|
|
}
|
2016-08-07 11:56:12 +02:00
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPSub32(const Value& a, const Value& b, bool fpscr_controlled) {
|
2016-08-07 02:41:25 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPSub32, {a, b});
|
2016-08-07 02:41:25 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPSub64(const Value& a, const Value& b, bool fpscr_controlled) {
|
2016-08-07 02:41:25 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPSub64, {a, b});
|
2016-08-07 02:41:25 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPDoubleToSingle(const Value& a, bool fpscr_controlled) {
|
2016-08-23 23:04:46 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPDoubleToSingle, {a});
|
2016-08-23 23:04:46 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPSingleToDouble(const Value& a, bool fpscr_controlled) {
|
2016-08-23 23:04:46 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPSingleToDouble, {a});
|
2016-08-23 23:04:46 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPSingleToS32(const Value& a, bool round_towards_zero, bool fpscr_controlled) {
|
2016-08-23 23:04:46 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPSingleToS32, {a, Imm1(round_towards_zero)});
|
2016-08-23 23:04:46 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPSingleToU32(const Value& a, bool round_towards_zero, bool fpscr_controlled) {
|
2016-08-23 23:04:46 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPSingleToU32, {a, Imm1(round_towards_zero)});
|
2016-08-23 23:04:46 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPDoubleToS32(const Value& a, bool round_towards_zero, bool fpscr_controlled) {
|
2016-08-23 23:04:46 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPDoubleToS32, {a, Imm1(round_towards_zero)});
|
2016-08-23 23:04:46 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPDoubleToU32(const Value& a, bool round_towards_zero, bool fpscr_controlled) {
|
2016-08-23 23:04:46 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPDoubleToU32, {a, Imm1(round_towards_zero)});
|
2016-08-23 23:04:46 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPS32ToSingle(const Value& a, bool round_to_nearest, bool fpscr_controlled) {
|
2016-08-23 23:04:46 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPS32ToSingle, {a, Imm1(round_to_nearest)});
|
2016-08-23 23:04:46 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPU32ToSingle(const Value& a, bool round_to_nearest, bool fpscr_controlled) {
|
2016-08-23 23:04:46 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPU32ToSingle, {a, Imm1(round_to_nearest)});
|
2016-08-23 23:04:46 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPS32ToDouble(const Value& a, bool round_to_nearest, bool fpscr_controlled) {
|
2016-08-23 23:04:46 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPS32ToDouble, {a, Imm1(round_to_nearest)});
|
2016-08-23 23:04:46 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::FPU32ToDouble(const Value& a, bool round_to_nearest, bool fpscr_controlled) {
|
2016-08-23 23:04:46 +02:00
|
|
|
ASSERT(fpscr_controlled);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::FPU32ToDouble, {a, Imm1(round_to_nearest)});
|
2016-08-23 23:04:46 +02:00
|
|
|
}
|
|
|
|
|
2016-09-02 13:17:22 +02:00
|
|
|
void IREmitter::ClearExclusive() {
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::ClearExclusive, {});
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::SetExclusive(const Value& vaddr, size_t byte_size) {
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
ASSERT(byte_size == 1 || byte_size == 2 || byte_size == 4 || byte_size == 8 || byte_size == 16);
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::SetExclusive, {vaddr, Imm8(u8(byte_size))});
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ReadMemory8(const Value& vaddr) {
|
|
|
|
return Inst(Opcode::ReadMemory8, {vaddr});
|
2016-07-11 23:43:53 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ReadMemory16(const Value& vaddr) {
|
|
|
|
auto value = Inst(Opcode::ReadMemory16, {vaddr});
|
2016-08-01 21:03:13 +02:00
|
|
|
return current_location.EFlag() ? ByteReverseHalf(value) : value;
|
2016-07-11 23:43:53 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ReadMemory32(const Value& vaddr) {
|
|
|
|
auto value = Inst(Opcode::ReadMemory32, {vaddr});
|
2016-08-01 21:03:13 +02:00
|
|
|
return current_location.EFlag() ? ByteReverseWord(value) : value;
|
2016-07-11 23:43:53 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ReadMemory64(const Value& vaddr) {
|
|
|
|
auto value = Inst(Opcode::ReadMemory64, {vaddr});
|
2016-08-01 21:03:13 +02:00
|
|
|
return current_location.EFlag() ? ByteReverseDual(value) : value;
|
2016-07-11 23:43:53 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::WriteMemory8(const Value& vaddr, const Value& value) {
|
|
|
|
Inst(Opcode::WriteMemory8, {vaddr, value});
|
2016-07-11 23:43:53 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::WriteMemory16(const Value& vaddr, const Value& value) {
|
2016-08-01 21:03:13 +02:00
|
|
|
if (current_location.EFlag()) {
|
2016-07-23 00:55:00 +02:00
|
|
|
auto v = ByteReverseHalf(value);
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::WriteMemory16, {vaddr, v});
|
2016-07-23 00:55:00 +02:00
|
|
|
} else {
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::WriteMemory16, {vaddr, value});
|
2016-07-20 16:34:17 +02:00
|
|
|
}
|
2016-07-11 23:43:53 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::WriteMemory32(const Value& vaddr, const Value& value) {
|
2016-08-01 21:03:13 +02:00
|
|
|
if (current_location.EFlag()) {
|
2016-07-23 00:55:00 +02:00
|
|
|
auto v = ByteReverseWord(value);
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::WriteMemory32, {vaddr, v});
|
2016-07-23 00:55:00 +02:00
|
|
|
} else {
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::WriteMemory32, {vaddr, value});
|
2016-07-20 16:34:17 +02:00
|
|
|
}
|
2016-07-11 23:43:53 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::WriteMemory64(const Value& vaddr, const Value& value) {
|
2016-08-01 21:03:13 +02:00
|
|
|
if (current_location.EFlag()) {
|
2016-07-23 00:55:00 +02:00
|
|
|
auto v = ByteReverseDual(value);
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::WriteMemory64, {vaddr, v});
|
2016-07-23 00:55:00 +02:00
|
|
|
} else {
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::WriteMemory64, {vaddr, value});
|
2016-07-20 16:34:17 +02:00
|
|
|
}
|
2016-07-11 23:43:53 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ExclusiveWriteMemory8(const Value& vaddr, const Value& value) {
|
|
|
|
return Inst(Opcode::ExclusiveWriteMemory8, {vaddr, value});
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ExclusiveWriteMemory16(const Value& vaddr, const Value& value) {
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
if (current_location.EFlag()) {
|
|
|
|
auto v = ByteReverseHalf(value);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::ExclusiveWriteMemory16, {vaddr, v});
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
} else {
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::ExclusiveWriteMemory16, {vaddr, value});
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ExclusiveWriteMemory32(const Value& vaddr, const Value& value) {
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
if (current_location.EFlag()) {
|
|
|
|
auto v = ByteReverseWord(value);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::ExclusiveWriteMemory32, {vaddr, v});
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
} else {
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::ExclusiveWriteMemory32, {vaddr, value});
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::ExclusiveWriteMemory64(const Value& vaddr, const Value& value_lo, const Value& value_hi) {
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
if (current_location.EFlag()) {
|
|
|
|
auto vlo = ByteReverseWord(value_lo);
|
|
|
|
auto vhi = ByteReverseWord(value_hi);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::ExclusiveWriteMemory64, {vaddr, vlo, vhi});
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
} else {
|
2016-08-25 18:36:42 +02:00
|
|
|
return Inst(Opcode::ExclusiveWriteMemory64, {vaddr, value_lo, value_hi});
|
TranslateArm: Implement CLREX, LDREX, LDREXB, LDREXD, LDREXH, STREX, STREXB, STREXD, STREXH, SWP, SWPB
2016-08-09 23:48:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-05 15:07:27 +02:00
|
|
|
void IREmitter::Breakpoint() {
|
2016-08-25 18:36:42 +02:00
|
|
|
Inst(Opcode::Breakpoint, {});
|
2016-08-05 15:07:27 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
void IREmitter::SetTerm(const Terminal& terminal) {
|
2016-08-25 16:35:50 +02:00
|
|
|
block.SetTerminal(terminal);
|
2016-07-07 11:53:09 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
Value IREmitter::Inst(Opcode op, std::initializer_list<Value> args) {
|
2016-08-25 16:35:50 +02:00
|
|
|
block.AppendNewInst(op, args);
|
2016-08-25 18:36:42 +02:00
|
|
|
return Value(&block.back());
|
2016-07-01 15:01:06 +02:00
|
|
|
}
|
|
|
|
|
2016-08-25 18:36:42 +02:00
|
|
|
} // namespace IR
|
2016-07-01 15:01:06 +02:00
|
|
|
} // namespace Dynarmic
|
|
|
|
|