Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/core/ee/ee_jit64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,6 @@ uint64_t EE_JIT64::get_vf_addr(const EmotionEngine&ee, int index) const
default:
Errors::die("[EE_JIT64] get_vf_addr error: Unrecognized reg %d", index);
}
return 0;
}

uint64_t EE_JIT64::get_fpu_addr(const EmotionEngine &ee, int index) const
Expand All @@ -1475,7 +1474,6 @@ uint64_t EE_JIT64::get_fpu_addr(const EmotionEngine &ee, int index) const
default:
Errors::die("[EE_JIT64] get_fpu_addr error: Unrecognized reg %d", index);
}
return 0;
}

uint64_t EE_JIT64::get_gpr_addr(const EmotionEngine &ee, int index) const
Expand All @@ -1498,7 +1496,6 @@ uint64_t EE_JIT64::get_gpr_addr(const EmotionEngine &ee, int index) const
default:
Errors::die("[EE_JIT64] get_gpr_addr error: Unrecognized reg %d", index);
}
return 0;
}

uint64_t EE_JIT64::get_gpr_offset(int index) const
Expand Down
33 changes: 19 additions & 14 deletions src/core/ee/ee_jit64_gpr.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cmath>
#include <algorithm>
#include <climits>
#include "ee_jit64.hpp"
#include "vu.hpp"

Expand Down Expand Up @@ -431,7 +432,7 @@ void EE_JIT64::divide_unsigned_word(EmotionEngine& ee, IR::Instruction& instr, b

emitter.set_jump_dest(label1);
emitter.MOVSX32_TO_64(dividend, HI);
emitter.MOV64_OI(-1, LO);
emitter.MOV64_OI(ULLONG_MAX, LO);

emitter.set_jump_dest(end);
}
Expand Down Expand Up @@ -492,7 +493,7 @@ void EE_JIT64::divide_word(EmotionEngine& ee, IR::Instruction &instr, bool hi)
uint8_t *label1_1 = emitter.JCC_NEAR_DEFERRED(ConditionCode::NE);
emitter.CMP32_IMM(0xFFFFFFFF, divisor);
uint8_t *label1_2 = emitter.JCC_NEAR_DEFERRED(ConditionCode::NE);
emitter.MOV64_OI((int64_t)(int32_t)0x80000000, LO);
emitter.MOV64_OI(0xFFFFFFFF'80000000, LO);
emitter.MOV64_OI(0, HI);
uint8_t *end_1 = emitter.JMP_NEAR_DEFERRED();

Expand Down Expand Up @@ -627,6 +628,9 @@ void EE_JIT64::exception_return(EmotionEngine& ee, IR::Instruction& instr)
free_int_reg(ee, R15);
}

// EmotionEngine argument is unneeded in this method,
// included for consistency in emit_instruction
#pragma warning(disable:4100)
void EE_JIT64::jump(EmotionEngine& ee, IR::Instruction& instr)
{
// Simply set the PC
Expand All @@ -638,6 +642,7 @@ void EE_JIT64::jump(EmotionEngine& ee, IR::Instruction& instr)
emitter.MOV32_IMM_MEM(instr.get_return_addr(), REG_64::R15, offsetof(EmotionEngine, gpr) + get_gpr_offset(EE_NormalReg::ra));
}
}
#pragma warning(default:4100)

void EE_JIT64::jump_indirect(EmotionEngine& ee, IR::Instruction& instr)
{
Expand Down Expand Up @@ -727,7 +732,7 @@ void EE_JIT64::load_doubleword_left(EmotionEngine& ee, IR::Instruction& instr)
else
emitter.MOV32_REG(source, addr);
emitter.MOV32_REG(addr, RCX);
emitter.AND32_REG_IMM(~0x7, RCX);
emitter.AND32_REG_IMM(~0x7u, RCX);
prepare_abi((uint64_t)&ee);
prepare_abi_reg(RCX);
call_abi_func((uint64_t)ee_read64);
Expand Down Expand Up @@ -764,7 +769,7 @@ void EE_JIT64::load_doubleword_right(EmotionEngine& ee, IR::Instruction& instr)
else
emitter.MOV32_REG(source, addr);
emitter.MOV32_REG(addr, RCX);
emitter.AND32_REG_IMM(~0x7, RCX);
emitter.AND32_REG_IMM(~0x7u, RCX);
prepare_abi((uint64_t)&ee);
prepare_abi_reg(RCX);
call_abi_func((uint64_t)ee_read64);
Expand Down Expand Up @@ -869,7 +874,7 @@ void EE_JIT64::load_word_left(EmotionEngine& ee, IR::Instruction& instr)
else
emitter.MOV32_REG(source, addr);
emitter.MOV32_REG(addr, RCX);
emitter.AND32_REG_IMM(~0x3, RCX);
emitter.AND32_REG_IMM(~0x3u, RCX);
prepare_abi((uint64_t)&ee);
prepare_abi_reg(RCX);
call_abi_func((uint64_t)ee_read32);
Expand Down Expand Up @@ -907,7 +912,7 @@ void EE_JIT64::load_word_right(EmotionEngine& ee, IR::Instruction& instr)
else
emitter.MOV32_REG(source, addr);
emitter.MOV32_REG(addr, RCX);
emitter.AND32_REG_IMM(~0x3, RCX);
emitter.AND32_REG_IMM(~0x3u, RCX);
prepare_abi((uint64_t)&ee);
prepare_abi_reg(RCX);
call_abi_func((uint64_t)ee_read32);
Expand Down Expand Up @@ -1388,7 +1393,7 @@ void EE_JIT64::store_doubleword_left(EmotionEngine& ee, IR::Instruction& instr)
else
emitter.MOV32_REG(dest, addr);
emitter.MOV32_REG(addr, addr_backup);
emitter.AND32_REG_IMM(~0x7, addr);
emitter.AND32_REG_IMM(~0x7u, addr);
prepare_abi((uint64_t)&ee);
prepare_abi_reg(addr);
call_abi_func((uint64_t)ee_read64);
Expand All @@ -1410,7 +1415,7 @@ void EE_JIT64::store_doubleword_left(EmotionEngine& ee, IR::Instruction& instr)
emitter.LEA32_M(dest, addr_backup, offset);
else
emitter.MOV32_REG(dest, addr_backup);
emitter.AND32_REG_IMM(~0x7, addr_backup);
emitter.AND32_REG_IMM(~0x7u, addr_backup);
prepare_abi((uint64_t)&ee);
prepare_abi_reg(addr_backup);
prepare_abi_reg(addr);
Expand All @@ -1434,7 +1439,7 @@ void EE_JIT64::store_doubleword_right(EmotionEngine& ee, IR::Instruction& instr)
else
emitter.MOV32_REG(dest, addr);
emitter.MOV32_REG(addr, addr_backup);
emitter.AND32_REG_IMM(~0x7, addr);
emitter.AND32_REG_IMM(~0x7u, addr);
prepare_abi((uint64_t)&ee);
prepare_abi_reg(addr);
call_abi_func((uint64_t)ee_read64);
Expand All @@ -1455,7 +1460,7 @@ void EE_JIT64::store_doubleword_right(EmotionEngine& ee, IR::Instruction& instr)
emitter.LEA32_M(dest, addr_backup, offset);
else
emitter.MOV32_REG(dest, addr_backup);
emitter.AND32_REG_IMM(~0x7, addr_backup);
emitter.AND32_REG_IMM(~0x7u, addr_backup);
prepare_abi((uint64_t)&ee);
prepare_abi_reg(addr_backup);
prepare_abi_reg(addr);
Expand Down Expand Up @@ -1515,7 +1520,7 @@ void EE_JIT64::store_word_left(EmotionEngine& ee, IR::Instruction& instr)
else
emitter.MOV32_REG(dest, addr);
emitter.MOV32_REG(addr, addr_backup);
emitter.AND32_REG_IMM(~0x3, addr);
emitter.AND32_REG_IMM(~0x3u, addr);
prepare_abi((uint64_t)&ee);
prepare_abi_reg(addr);
call_abi_func((uint64_t)ee_read32);
Expand All @@ -1537,7 +1542,7 @@ void EE_JIT64::store_word_left(EmotionEngine& ee, IR::Instruction& instr)
emitter.LEA32_M(dest, addr_backup, offset);
else
emitter.MOV32_REG(dest, addr_backup);
emitter.AND32_REG_IMM(~0x3, addr_backup);
emitter.AND32_REG_IMM(~0x3u, addr_backup);
prepare_abi((uint64_t)&ee);
prepare_abi_reg(addr_backup);
prepare_abi_reg(addr);
Expand All @@ -1561,7 +1566,7 @@ void EE_JIT64::store_word_right(EmotionEngine& ee, IR::Instruction& instr)
else
emitter.MOV32_REG(dest, addr);
emitter.MOV32_REG(addr, addr_backup);
emitter.AND32_REG_IMM(~0x3, addr);
emitter.AND32_REG_IMM(~0x3u, addr);
prepare_abi((uint64_t)&ee);
prepare_abi_reg(addr);
call_abi_func((uint64_t)ee_read32);
Expand All @@ -1582,7 +1587,7 @@ void EE_JIT64::store_word_right(EmotionEngine& ee, IR::Instruction& instr)
emitter.LEA32_M(dest, addr_backup, offset);
else
emitter.MOV32_REG(dest, addr_backup);
emitter.AND32_REG_IMM(~0x3, addr_backup);
emitter.AND32_REG_IMM(~0x3u, addr_backup);
prepare_abi((uint64_t)&ee);
prepare_abi_reg(addr_backup);
prepare_abi_reg(addr);
Expand Down
4 changes: 2 additions & 2 deletions src/core/ee/ee_jit64_mmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ void EE_JIT64::parallel_divide_word(EmotionEngine& ee, IR::Instruction& instr)
uint8_t *label1_1 = emitter.JCC_NEAR_DEFERRED(ConditionCode::NE);
emitter.CMP32_IMM(0xFFFFFFFF, divisor64);
uint8_t *label1_2 = emitter.JCC_NEAR_DEFERRED(ConditionCode::NE);
emitter.MOV64_OI((int64_t)(int32_t)0x80000000, REG_64::RAX);
emitter.MOV64_OI(0xFFFFFFFF'80000000, REG_64::RAX);
emitter.MOVQ_TO_XMM(REG_64::RAX, LO);
emitter.MOV64_OI(0, REG_64::RAX);
emitter.MOVQ_TO_XMM(REG_64::RAX, HI);
Expand Down Expand Up @@ -448,7 +448,7 @@ void EE_JIT64::parallel_divide_word(EmotionEngine& ee, IR::Instruction& instr)
uint8_t *label3_1 = emitter.JCC_NEAR_DEFERRED(ConditionCode::NE);
emitter.CMP32_IMM(0xFFFFFFFF, divisor64);
uint8_t *label3_2 = emitter.JCC_NEAR_DEFERRED(ConditionCode::NE);
emitter.MOV64_OI((int64_t)(int32_t)0x80000000, REG_64::RAX);
emitter.MOV64_OI(0xFFFFFFFF'80000000, REG_64::RAX);
emitter.PINSRQ_XMM(1, REG_64::RAX, LO);
emitter.MOV64_OI(0, REG_64::RAX);
emitter.PINSRQ_XMM(1, REG_64::RAX, HI);
Expand Down
5 changes: 5 additions & 0 deletions src/core/ee/emotion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,14 @@ class EmotionEngine

EE_OsdConfigParam osd_config_param;

// Suppress any warnings caused by the padding due to the use of alignas
#pragma warning(disable:4324)

//Each register is 128-bit
alignas(16) uint8_t gpr[32 * sizeof(uint64_t) * 2];
alignas(16) uint128_t LO, HI;
#pragma warning(default:4324)

uint32_t PC, new_PC;
uint64_t SA;

Expand Down
20 changes: 5 additions & 15 deletions src/core/ee/emotion_mmi.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include "emotioninterpreter.hpp"

void EmotionInterpreter::mmi(EE_InstrInfo &info, uint32_t instruction)
Expand Down Expand Up @@ -443,20 +444,9 @@ int64_t EmotionInterpreter::clamp_doubleword(int64_t word)
}
}

int16_t EmotionInterpreter::clamp_halfword(int32_t word)
inline int16_t EmotionInterpreter::clamp_halfword(int32_t word)
{
if (word > (int32_t)0x00007FFF)
{
return 0x7FFF;
}
else if (word < (int32_t)0xFFFF80000)
{
return 0x8000;
}
else
{
return (int16_t)word;
}
return std::max((int32_t)0xFFFF8000, std::min(0x00007FFF, word));
}

/*
Expand Down Expand Up @@ -2642,7 +2632,7 @@ void EmotionInterpreter::div1(EmotionEngine &cpu, uint32_t instruction)
op2 = cpu.get_gpr<int32_t>(op2);
if (op1 == 0x80000000 && op2 == 0xFFFFFFFF)
{
cpu.set_LO_HI((int64_t)(int32_t)0x80000000, 0, true);
cpu.set_LO_HI(0xFFFFFFFF'80000000, 0, true);
}
else if (op2)
{
Expand Down Expand Up @@ -2671,7 +2661,7 @@ void EmotionInterpreter::divu1(EmotionEngine &cpu, uint32_t instruction)
}
else
{
cpu.set_LO_HI((int64_t)-1, (int64_t)(int32_t)op1, true);
cpu.set_LO_HI(UINT64_MAX, (int64_t)(int32_t)op1, true);
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/core/ee/emotion_special.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cstdio>
#include <cstdlib>
#include <climits>
#include "emotioninterpreter.hpp"

void EmotionInterpreter::special(EE_InstrInfo &info, uint32_t instruction)
Expand Down Expand Up @@ -527,7 +528,7 @@ void EmotionInterpreter::div(EmotionEngine &cpu, uint32_t instruction)
op2 = cpu.get_gpr<int32_t>(op2);
if (op1 == 0x80000000 && op2 == 0xFFFFFFFF)
{
cpu.set_LO_HI((int64_t)(int32_t)0x80000000, 0);
cpu.set_LO_HI(0xFFFFFFFF'80000000, 0);
}
else if (op2)
{
Expand Down Expand Up @@ -556,7 +557,7 @@ void EmotionInterpreter::divu(EmotionEngine &cpu, uint32_t instruction)
}
else
{
cpu.set_LO_HI((int64_t)-1, (int64_t)(int32_t)op1);
cpu.set_LO_HI(UINT64_MAX, (int64_t)(int32_t)op1);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/core/ee/ipu/dct_coeff_table1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,5 +370,4 @@ bool DCT_Coeff_Table1::get_runlevel_pair_dc(IPU_FIFO &FIFO, RunLevelPair &pair,
{
//DCT_Coeff_Table1 only gets called by intra macroblocks, so this should never happen
Errors::die("get_runlevel_pair_dc should never happen");
return false;
}
1 change: 0 additions & 1 deletion src/core/ee/ipu/vlc_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ bool VLC_Table::peek_symbol(IPU_FIFO &FIFO, VLC_Entry &entry)
}
}
throw VLC_Error("VLC symbol not found");
return false;
}

bool VLC_Table::get_symbol(IPU_FIFO& FIFO, uint32_t &result)
Expand Down
12 changes: 12 additions & 0 deletions src/core/ee/vu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include "emotion.hpp"
#include "../int128.hpp"

// Prevent warnings due to padding inserted due to use of alignas
#pragma warning(disable:4324)
union alignas(16) VU_R
{
float f;
Expand All @@ -32,6 +34,7 @@ struct alignas(16) VU_Mem
{
uint8_t m[1024 * 16];
};
#pragma warning(default:4324)

struct VPU_STAT
{
Expand All @@ -53,6 +56,8 @@ struct DecodedRegs
void reset();
};

// Prevent warnings due to padding inserted due to use of alignas
#pragma warning(disable:4324)
struct VuIntBranchPipelineEntry
{
uint8_t write_reg; // reg that was overwritten
Expand All @@ -61,6 +66,7 @@ struct VuIntBranchPipelineEntry

void clear();
};
#pragma warning(default:4324)

struct VuIntBranchPipeline
{
Expand All @@ -87,6 +93,10 @@ extern "C" uint8_t* exec_block_ee(EE_JIT64& jit, EmotionEngine& ee);

class VectorUnit
{
// Suppress any warnings caused by the padding due to the use of alignas
// VU_R requires 16-bit alignment
#pragma warning(disable:4324)

private:
GraphicsInterface* gif;
int id;
Expand Down Expand Up @@ -393,6 +403,8 @@ class VectorUnit
friend void vu_update_pipelines(VectorUnit& vu, int cycles);
friend uint8_t* exec_block_vu(VU_JIT64& jit, VectorUnit& vu);
friend uint8_t* exec_block_ee(EE_JIT64& jit, EmotionEngine& ee);

#pragma warning(default:4324)
};

template <typename T>
Expand Down
1 change: 0 additions & 1 deletion src/core/ee/vu_jit64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ uint64_t VU_JIT64::get_vf_addr(VectorUnit &vu, int index)
default:
Errors::die("[VU_JIT64] get_vf_addr error: Unrecognized reg %d", index);
}
return 0;
}

void VU_JIT64::clamp_vfreg(uint8_t field, REG_64 xmm_reg)
Expand Down
4 changes: 4 additions & 0 deletions src/core/ee/vu_jit64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,16 @@ class VU_JIT64
VU_JitTranslator ir;
VUJitPrologue prologue_block;


// Prevent warnings due to padding inserted due to use of alignas (for VU_GPR)
#pragma warning(disable:4324)
//Set to 0x7FFFFFFF, repeated four times
VU_GPR abs_constant;

VU_GPR max_flt_constant, min_flt_constant;

VU_GPR ftoi_table[4], itof_table[4];
#pragma warning(default:4324)

uint32_t saved_mxcsr;
uint32_t vu_mxcsr;
Expand Down
6 changes: 5 additions & 1 deletion src/core/gsthread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,15 @@ uint32_t addr_PSMCT4(uint32_t block, uint32_t width, uint32_t x, uint32_t y);

struct VertexF
{
union {
union
{
// Suppress warning about nameless struct
#pragma warning(disable:4201)
struct
{
float x,y,w,r,g,b,a,q,u,v,s,t,fog;
};
#pragma warning(default:4201)
float data[13];
};
double z;
Expand Down
Loading