dynarmic/src/frontend/ir/ir_emitter.cpp

538 lines
17 KiB
C++
Raw Normal View History

2016-07-01 14:01:06 +01: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 10:53:09 +01:00
#include "common/assert.h"
#include "frontend/ir/ir_emitter.h"
#include "frontend/ir/opcodes.h"
2016-07-01 14:01:06 +01:00
namespace Dynarmic {
namespace IR {
2016-07-01 14:01:06 +01:00
2018-01-01 15:47:56 +00:00
void IREmitter::Unimplemented() {
2016-07-01 14:01:06 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Imm1(bool imm1) {
return Value(imm1);
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Imm8(u8 imm8) {
return Value(imm8);
2016-07-01 14:01:06 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Imm32(u32 imm32) {
return Value(imm32);
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Imm64(u64 imm64) {
2016-12-03 11:29:50 +00:00
return Value(imm64);
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Pack2x32To1x64(const Value& lo, const Value& hi) {
return Inst(Opcode::Pack2x32To1x64, {lo, hi});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::LeastSignificantWord(const Value& value) {
return Inst(Opcode::LeastSignificantWord, {value});
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndCarry IREmitter::MostSignificantWord(const Value& value) {
auto result = Inst(Opcode::MostSignificantWord, {value});
auto carry_out = Inst(Opcode::GetCarryFromOp, {result});
return {result, carry_out};
}
2018-01-01 15:47:56 +00:00
Value IREmitter::LeastSignificantHalf(const Value& value) {
return Inst(Opcode::LeastSignificantHalf, {value});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::LeastSignificantByte(const Value& value) {
return Inst(Opcode::LeastSignificantByte, {value});
2016-07-01 14:01:06 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::MostSignificantBit(const Value& value) {
return Inst(Opcode::MostSignificantBit, {value});
2016-07-01 14:01:06 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::IsZero(const Value& value) {
return Inst(Opcode::IsZero, {value});
2016-07-01 14:01:06 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::IsZero64(const Value& value) {
return Inst(Opcode::IsZero64, {value});
}
2018-01-01 15:47:56 +00: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 14:01:06 +01:00
return {result, carry_out};
}
2018-01-01 15:47:56 +00: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 14:01:06 +01:00
return {result, carry_out};
}
2018-01-01 15:47:56 +00:00
Value IREmitter::LogicalShiftRight64(const Value& value_in, const Value& shift_amount) {
return Inst(Opcode::LogicalShiftRight64, {value_in, shift_amount});
}
2018-01-01 15:47:56 +00: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});
return {result, carry_out};
}
2016-07-01 14:01:06 +01:00
2018-01-01 15:47:56 +00: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 01:18:17 +01:00
return {result, carry_out};
}
2018-01-01 15:47:56 +00: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});
return {result, carry_out};
}
2018-01-01 15:47:56 +00: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});
return {result, carry_out, overflow};
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Add(const Value& a, const Value& b) {
return Inst(Opcode::AddWithCarry, {a, b, Imm1(0)});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Add64(const Value& a, const Value& b) {
return Inst(Opcode::Add64, {a, b});
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndCarryAndOverflow IREmitter::SubWithCarry(const Value& a, const Value& b, const Value& carry_in) {
2016-07-08 11:49:30 +01:00
// This is equivalent to AddWithCarry(a, Not(b), carry_in).
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 11:49:30 +01:00
return {result, carry_out, overflow};
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Sub(const Value& a, const Value& b) {
return Inst(Opcode::SubWithCarry, {a, b, Imm1(1)});
2016-07-18 15:11:16 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Sub64(const Value& a, const Value& b) {
return Inst(Opcode::Sub64, {a, b});
2016-08-06 06:09:47 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Mul(const Value& a, const Value& b) {
return Inst(Opcode::Mul, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Mul64(const Value& a, const Value& b) {
return Inst(Opcode::Mul64, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::And(const Value& a, const Value& b) {
return Inst(Opcode::And, {a, b});
2016-07-08 10:43:28 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Eor(const Value& a, const Value& b) {
return Inst(Opcode::Eor, {a, b});
2016-07-08 11:14:50 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Or(const Value& a, const Value& b) {
return Inst(Opcode::Or, {a, b});
2016-07-10 02:06:38 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Not(const Value& a) {
return Inst(Opcode::Not, {a});
2016-07-10 03:44:45 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::SignExtendWordToLong(const Value& a) {
return Inst(Opcode::SignExtendWordToLong, {a});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::SignExtendHalfToWord(const Value& a) {
return Inst(Opcode::SignExtendHalfToWord, {a});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::SignExtendByteToWord(const Value& a) {
return Inst(Opcode::SignExtendByteToWord, {a});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::ZeroExtendWordToLong(const Value& a) {
return Inst(Opcode::ZeroExtendWordToLong, {a});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::ZeroExtendHalfToWord(const Value& a) {
return Inst(Opcode::ZeroExtendHalfToWord, {a});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::ZeroExtendByteToWord(const Value& a) {
return Inst(Opcode::ZeroExtendByteToWord, {a});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::ByteReverseWord(const Value& a) {
return Inst(Opcode::ByteReverseWord, {a});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::ByteReverseHalf(const Value& a) {
return Inst(Opcode::ByteReverseHalf, {a});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::ByteReverseDual(const Value& a) {
return Inst(Opcode::ByteReverseDual, {a});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::CountLeadingZeros(const Value& a) {
2016-12-15 22:33:20 +00:00
return Inst(Opcode::CountLeadingZeros, {a});
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndOverflow IREmitter::SignedSaturatedAdd(const Value& a, const Value& b) {
2016-12-15 22:33:20 +00:00
auto result = Inst(Opcode::SignedSaturatedAdd, {a, b});
auto overflow = Inst(Opcode::GetOverflowFromOp, {result});
return {result, overflow};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndOverflow IREmitter::SignedSaturatedSub(const Value& a, const Value& b) {
2016-12-15 22:33:20 +00:00
auto result = Inst(Opcode::SignedSaturatedSub, {a, b});
auto overflow = Inst(Opcode::GetOverflowFromOp, {result});
return {result, overflow};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndOverflow IREmitter::UnsignedSaturation(const Value& a, size_t bit_size_to_saturate_to) {
ASSERT(bit_size_to_saturate_to <= 31);
auto result = Inst(Opcode::UnsignedSaturation, {a, Imm8(static_cast<u8>(bit_size_to_saturate_to))});
auto overflow = Inst(Opcode::GetOverflowFromOp, {result});
return {result, overflow};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndOverflow IREmitter::SignedSaturation(const Value& a, size_t bit_size_to_saturate_to) {
ASSERT(bit_size_to_saturate_to >= 1 && bit_size_to_saturate_to <= 32);
auto result = Inst(Opcode::SignedSaturation, {a, Imm8(static_cast<u8>(bit_size_to_saturate_to))});
auto overflow = Inst(Opcode::GetOverflowFromOp, {result});
return {result, overflow};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndGE IREmitter::PackedAddU8(const Value& a, const Value& b) {
2016-12-04 20:52:33 +00:00
auto result = Inst(Opcode::PackedAddU8, {a, b});
auto ge = Inst(Opcode::GetGEFromOp, {result});
return {result, ge};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndGE IREmitter::PackedAddS8(const Value& a, const Value& b) {
auto result = Inst(Opcode::PackedAddS8, {a, b});
auto ge = Inst(Opcode::GetGEFromOp, {result});
return {result, ge};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndGE IREmitter::PackedAddU16(const Value& a, const Value& b) {
auto result = Inst(Opcode::PackedAddU16, {a, b});
auto ge = Inst(Opcode::GetGEFromOp, {result});
return {result, ge};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndGE IREmitter::PackedAddS16(const Value& a, const Value& b) {
auto result = Inst(Opcode::PackedAddS16, {a, b});
auto ge = Inst(Opcode::GetGEFromOp, {result});
return {result, ge};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndGE IREmitter::PackedSubU8(const Value& a, const Value& b) {
2016-12-05 00:27:59 +00:00
auto result = Inst(Opcode::PackedSubU8, {a, b});
auto ge = Inst(Opcode::GetGEFromOp, {result});
return {result, ge};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndGE IREmitter::PackedSubS8(const Value& a, const Value& b) {
auto result = Inst(Opcode::PackedSubS8, {a, b});
auto ge = Inst(Opcode::GetGEFromOp, {result});
return {result, ge};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndGE IREmitter::PackedSubU16(const Value& a, const Value& b) {
auto result = Inst(Opcode::PackedSubU16, {a, b});
auto ge = Inst(Opcode::GetGEFromOp, {result});
return {result, ge};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndGE IREmitter::PackedSubS16(const Value& a, const Value& b) {
auto result = Inst(Opcode::PackedSubS16, {a, b});
auto ge = Inst(Opcode::GetGEFromOp, {result});
return {result, ge};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndGE IREmitter::PackedAddSubU16(const Value& a, const Value& b) {
auto result = Inst(Opcode::PackedAddSubU16, {a, b});
auto ge = Inst(Opcode::GetGEFromOp, {result});
return {result, ge};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndGE IREmitter::PackedAddSubS16(const Value& a, const Value& b) {
auto result = Inst(Opcode::PackedAddSubS16, {a, b});
auto ge = Inst(Opcode::GetGEFromOp, {result});
return {result, ge};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndGE IREmitter::PackedSubAddU16(const Value& a, const Value& b) {
auto result = Inst(Opcode::PackedSubAddU16, {a, b});
auto ge = Inst(Opcode::GetGEFromOp, {result});
return {result, ge};
}
2018-01-01 15:47:56 +00:00
IREmitter::ResultAndGE IREmitter::PackedSubAddS16(const Value& a, const Value& b) {
auto result = Inst(Opcode::PackedSubAddS16, {a, b});
auto ge = Inst(Opcode::GetGEFromOp, {result});
return {result, ge};
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedHalvingAddU8(const Value& a, const Value& b) {
2016-11-26 18:12:29 +00:00
return Inst(Opcode::PackedHalvingAddU8, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedHalvingAddS8(const Value& a, const Value& b) {
2016-11-26 18:12:29 +00:00
return Inst(Opcode::PackedHalvingAddS8, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedHalvingSubU8(const Value& a, const Value& b) {
2016-11-26 18:27:21 +00:00
return Inst(Opcode::PackedHalvingSubU8, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedHalvingSubS8(const Value& a, const Value& b) {
return Inst(Opcode::PackedHalvingSubS8, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedHalvingAddU16(const Value& a, const Value& b) {
2016-11-26 11:28:20 +00:00
return Inst(Opcode::PackedHalvingAddU16, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedHalvingAddS16(const Value& a, const Value& b) {
2016-11-26 18:12:29 +00:00
return Inst(Opcode::PackedHalvingAddS16, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedHalvingSubU16(const Value& a, const Value& b) {
2016-11-26 18:27:21 +00:00
return Inst(Opcode::PackedHalvingSubU16, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedHalvingSubS16(const Value& a, const Value& b) {
return Inst(Opcode::PackedHalvingSubS16, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedHalvingAddSubU16(const Value& a, const Value& b) {
return Inst(Opcode::PackedHalvingAddSubU16, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedHalvingAddSubS16(const Value& a, const Value& b) {
return Inst(Opcode::PackedHalvingAddSubS16, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedHalvingSubAddU16(const Value& a, const Value& b) {
return Inst(Opcode::PackedHalvingSubAddU16, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedHalvingSubAddS16(const Value& a, const Value& b) {
return Inst(Opcode::PackedHalvingSubAddS16, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedSaturatedAddU8(const Value& a, const Value& b) {
return Inst(Opcode::PackedSaturatedAddU8, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedSaturatedAddS8(const Value& a, const Value& b) {
return Inst(Opcode::PackedSaturatedAddS8, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedSaturatedSubU8(const Value& a, const Value& b) {
return Inst(Opcode::PackedSaturatedSubU8, {a, b});
2016-08-12 16:53:16 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedSaturatedSubS8(const Value& a, const Value& b) {
return Inst(Opcode::PackedSaturatedSubS8, {a, b});
2016-08-12 18:18:38 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedSaturatedAddU16(const Value& a, const Value& b) {
return Inst(Opcode::PackedSaturatedAddU16, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedSaturatedAddS16(const Value& a, const Value& b) {
return Inst(Opcode::PackedSaturatedAddS16, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedSaturatedSubU16(const Value& a, const Value& b) {
return Inst(Opcode::PackedSaturatedSubU16, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedSaturatedSubS16(const Value& a, const Value& b) {
return Inst(Opcode::PackedSaturatedSubS16, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedAbsDiffSumS8(const Value& a, const Value& b) {
2016-12-17 19:52:22 +00:00
return Inst(Opcode::PackedAbsDiffSumS8, {a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::PackedSelect(const Value& ge, const Value& a, const Value& b) {
return Inst(Opcode::PackedSelect, {ge, a, b});
}
2018-01-01 15:47:56 +00:00
Value IREmitter::TransferToFP32(const Value& a) {
return Inst(Opcode::TransferToFP32, {a});
2016-08-07 19:25:12 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::TransferToFP64(const Value& a) {
return Inst(Opcode::TransferToFP64, {a});
2016-08-07 19:25:12 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::TransferFromFP32(const Value& a) {
return Inst(Opcode::TransferFromFP32, {a});
2016-08-07 19:25:12 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::TransferFromFP64(const Value& a) {
return Inst(Opcode::TransferFromFP64, {a});
2016-08-07 19:25:12 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPAbs32(const Value& a) {
return Inst(Opcode::FPAbs32, {a});
2016-08-07 01:27:18 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPAbs64(const Value& a) {
return Inst(Opcode::FPAbs64, {a});
2016-08-07 01:27:18 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPAdd32(const Value& a, const Value& b, bool fpscr_controlled) {
2016-08-06 17:21:29 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPAdd32, {a, b});
2016-08-06 17:21:29 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPAdd64(const Value& a, const Value& b, bool fpscr_controlled) {
2016-08-06 17:21:29 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPAdd64, {a, b});
2016-08-06 17:21:29 +01:00
}
2018-01-01 15:47:56 +00:00
void IREmitter::FPCompare32(const Value& a, const Value& b, bool exc_on_qnan, bool fpscr_controlled) {
2016-11-26 11:17:16 +00:00
ASSERT(fpscr_controlled);
Inst(Opcode::FPCompare32, {a, b, Imm1(exc_on_qnan)});
2016-11-26 11:17:16 +00:00
}
2018-01-01 15:47:56 +00:00
void IREmitter::FPCompare64(const Value& a, const Value& b, bool exc_on_qnan, bool fpscr_controlled) {
2016-11-26 11:17:16 +00:00
ASSERT(fpscr_controlled);
Inst(Opcode::FPCompare64, {a, b, Imm1(exc_on_qnan)});
2016-11-26 11:17:16 +00:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPDiv32(const Value& a, const Value& b, bool fpscr_controlled) {
2016-08-07 10:56:12 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPDiv32, {a, b});
2016-08-07 10:56:12 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPDiv64(const Value& a, const Value& b, bool fpscr_controlled) {
2016-08-07 10:56:12 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPDiv64, {a, b});
2016-08-07 10:56:12 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPMul32(const Value& a, const Value& b, bool fpscr_controlled) {
2016-08-07 10:21:14 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPMul32, {a, b});
2016-08-07 10:21:14 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPMul64(const Value& a, const Value& b, bool fpscr_controlled) {
2016-08-07 10:21:14 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPMul64, {a, b});
2016-08-07 10:21:14 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPNeg32(const Value& a) {
return Inst(Opcode::FPNeg32, {a});
2016-08-07 10:56:12 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPNeg64(const Value& a) {
return Inst(Opcode::FPNeg64, {a});
2016-08-07 10:56:12 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPSqrt32(const Value& a) {
return Inst(Opcode::FPSqrt32, {a});
2016-08-07 12:19:07 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPSqrt64(const Value& a) {
return Inst(Opcode::FPSqrt64, {a});
2016-08-07 12:19:07 +01:00
}
2016-08-07 10:56:12 +01:00
2018-01-01 15:47:56 +00:00
Value IREmitter::FPSub32(const Value& a, const Value& b, bool fpscr_controlled) {
2016-08-07 01:41:25 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPSub32, {a, b});
2016-08-07 01:41:25 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPSub64(const Value& a, const Value& b, bool fpscr_controlled) {
2016-08-07 01:41:25 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPSub64, {a, b});
2016-08-07 01:41:25 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPDoubleToSingle(const Value& a, bool fpscr_controlled) {
2016-08-23 22:04:46 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPDoubleToSingle, {a});
2016-08-23 22:04:46 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPSingleToDouble(const Value& a, bool fpscr_controlled) {
2016-08-23 22:04:46 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPSingleToDouble, {a});
2016-08-23 22:04:46 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPSingleToS32(const Value& a, bool round_towards_zero, bool fpscr_controlled) {
2016-08-23 22:04:46 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPSingleToS32, {a, Imm1(round_towards_zero)});
2016-08-23 22:04:46 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPSingleToU32(const Value& a, bool round_towards_zero, bool fpscr_controlled) {
2016-08-23 22:04:46 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPSingleToU32, {a, Imm1(round_towards_zero)});
2016-08-23 22:04:46 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPDoubleToS32(const Value& a, bool round_towards_zero, bool fpscr_controlled) {
2016-08-23 22:04:46 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPDoubleToS32, {a, Imm1(round_towards_zero)});
2016-08-23 22:04:46 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPDoubleToU32(const Value& a, bool round_towards_zero, bool fpscr_controlled) {
2016-08-23 22:04:46 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPDoubleToU32, {a, Imm1(round_towards_zero)});
2016-08-23 22:04:46 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPS32ToSingle(const Value& a, bool round_to_nearest, bool fpscr_controlled) {
2016-08-23 22:04:46 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPS32ToSingle, {a, Imm1(round_to_nearest)});
2016-08-23 22:04:46 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPU32ToSingle(const Value& a, bool round_to_nearest, bool fpscr_controlled) {
2016-08-23 22:04:46 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPU32ToSingle, {a, Imm1(round_to_nearest)});
2016-08-23 22:04:46 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPS32ToDouble(const Value& a, bool round_to_nearest, bool fpscr_controlled) {
2016-08-23 22:04:46 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPS32ToDouble, {a, Imm1(round_to_nearest)});
2016-08-23 22:04:46 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::FPU32ToDouble(const Value& a, bool round_to_nearest, bool fpscr_controlled) {
2016-08-23 22:04:46 +01:00
ASSERT(fpscr_controlled);
return Inst(Opcode::FPU32ToDouble, {a, Imm1(round_to_nearest)});
2016-08-23 22:04:46 +01:00
}
2018-01-01 15:47:56 +00:00
void IREmitter::Breakpoint() {
Inst(Opcode::Breakpoint, {});
}
2018-01-01 15:47:56 +00:00
void IREmitter::SetTerm(const Terminal& terminal) {
block.SetTerminal(terminal);
2016-07-07 10:53:09 +01:00
}
2018-01-01 15:47:56 +00:00
Value IREmitter::Inst(Opcode op, std::initializer_list<Value> args) {
block.AppendNewInst(op, args);
return Value(&block.back());
2016-07-01 14:01:06 +01:00
}
} // namespace IR
2016-07-01 14:01:06 +01:00
} // namespace Dynarmic