mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-30 17:53:42 +01:00
x86jit: Implement a few more float ops, shuffle.
This commit is contained in:
1 parent
85c375fc60
commit
4b1c809886
7 files changed
+88
-17
No files matched your search
@@ -115,7 +115,7 @@ void RiscVJitBackend::CompIR_FCondAssign(IRInst inst) {
|
||||
MAX(SCRATCH1, SCRATCH1, SCRATCH2);
|
||||
SetJumpTarget(skipSwapCompare);
|
||||
} else {
|
||||
RiscVReg isSrc1LowerReg = regs_.GetAndLockTempR();
|
||||
RiscVReg isSrc1LowerReg = regs_.GetAndLockTempGPR();
|
||||
SLT(isSrc1LowerReg, SCRATCH1, SCRATCH2);
|
||||
// Flip the flag (to reverse the min/max) based on if both were negative.
|
||||
XOR(isSrc1LowerReg, isSrc1LowerReg, R_RA);
|
||||
|
||||
@@ -235,7 +235,7 @@ RiscVReg RiscVRegCache::TryMapTempImm(IRReg r) {
|
||||
return INVALID_REG;
|
||||
}
|
||||
|
||||
RiscVReg RiscVRegCache::GetAndLockTempR() {
|
||||
RiscVReg RiscVRegCache::GetAndLockTempGPR() {
|
||||
RiscVReg reg = (RiscVReg)AllocateReg(MIPSLoc::REG, MIPSMap::INIT);
|
||||
if (reg != INVALID_REG) {
|
||||
nr[reg].tempLockIRIndex = irIndex_;
|
||||
@@ -243,7 +243,7 @@ RiscVReg RiscVRegCache::GetAndLockTempR() {
|
||||
return reg;
|
||||
}
|
||||
|
||||
RiscVReg RiscVRegCache::MapWithFPRTemp(IRInst &inst) {
|
||||
RiscVReg RiscVRegCache::MapWithFPRTemp(const IRInst &inst) {
|
||||
return (RiscVReg)MapWithTemp(inst, MIPSLoc::FREG);
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
RiscVGen::RiscVReg MapGPRAsPointer(IRReg reg);
|
||||
RiscVGen::RiscVReg MapFPR(IRReg reg, MIPSMap mapFlags = MIPSMap::INIT);
|
||||
|
||||
RiscVGen::RiscVReg MapWithFPRTemp(IRInst &inst);
|
||||
RiscVGen::RiscVReg MapWithFPRTemp(const IRInst &inst);
|
||||
|
||||
bool IsNormalized32(IRReg reg);
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
|
||||
void FlushBeforeCall();
|
||||
|
||||
RiscVGen::RiscVReg GetAndLockTempR();
|
||||
RiscVGen::RiscVReg GetAndLockTempGPR();
|
||||
|
||||
RiscVGen::RiscVReg R(IRReg preg); // Returns a cached register, while checking that it's NOT mapped as a pointer
|
||||
RiscVGen::RiscVReg RPtr(IRReg preg); // Returns a cached register, if it has been mapped as a pointer
|
||||
|
||||
@@ -298,7 +298,22 @@ void X64JitBackend::CompIR_FCompare(IRInst inst) {
|
||||
break;
|
||||
|
||||
case IROp::FCmovVfpuCC:
|
||||
CompIR_Generic(inst);
|
||||
regs_.MapWithExtra(inst, { { 'G', IRREG_VFPU_CC, 1, MIPSMap::INIT } });
|
||||
if (regs_.HasLowSubregister(regs_.RX(IRREG_VFPU_CC))) {
|
||||
TEST(8, regs_.R(IRREG_VFPU_CC), Imm8(1 << (inst.src2 & 7)));
|
||||
} else {
|
||||
TEST(32, regs_.R(IRREG_VFPU_CC), Imm32(1 << (inst.src2 & 7)));
|
||||
}
|
||||
|
||||
if ((inst.src2 >> 7) & 1) {
|
||||
FixupBranch skip = J_CC(CC_Z);
|
||||
MOVAPS(regs_.FX(inst.dest), regs_.F(inst.src1));
|
||||
SetJumpTarget(skip);
|
||||
} else {
|
||||
FixupBranch skip = J_CC(CC_NZ);
|
||||
MOVAPS(regs_.FX(inst.dest), regs_.F(inst.src1));
|
||||
SetJumpTarget(skip);
|
||||
}
|
||||
break;
|
||||
|
||||
case IROp::FCmpVfpuBit:
|
||||
@@ -462,7 +477,7 @@ void X64JitBackend::CompIR_FCondAssign(IRInst inst) {
|
||||
X64Reg tempReg = INVALID_REG;
|
||||
switch (inst.op) {
|
||||
case IROp::FMin:
|
||||
tempReg = regs_.GetAndLockTempR();
|
||||
tempReg = regs_.GetAndLockTempGPR();
|
||||
regs_.Map(inst);
|
||||
UCOMISS(regs_.FX(inst.src1), regs_.F(inst.src1));
|
||||
skipNAN = J_CC(CC_NP, true);
|
||||
@@ -499,7 +514,7 @@ void X64JitBackend::CompIR_FCondAssign(IRInst inst) {
|
||||
break;
|
||||
|
||||
case IROp::FMax:
|
||||
tempReg = regs_.GetAndLockTempR();
|
||||
tempReg = regs_.GetAndLockTempGPR();
|
||||
regs_.Map(inst);
|
||||
UCOMISS(regs_.FX(inst.src1), regs_.F(inst.src1));
|
||||
skipNAN = J_CC(CC_NP, true);
|
||||
@@ -546,7 +561,14 @@ void X64JitBackend::CompIR_FCvt(IRInst inst) {
|
||||
|
||||
switch (inst.op) {
|
||||
case IROp::FCvtWS:
|
||||
CompIR_Generic(inst);
|
||||
break;
|
||||
|
||||
case IROp::FCvtSW:
|
||||
regs_.Map(inst);
|
||||
CVTDQ2PS(regs_.FX(inst.dest), regs_.F(inst.src1));
|
||||
break;
|
||||
|
||||
case IROp::FCvtScaledWS:
|
||||
case IROp::FCvtScaledSW:
|
||||
CompIR_Generic(inst);
|
||||
@@ -563,7 +585,41 @@ void X64JitBackend::CompIR_FRound(IRInst inst) {
|
||||
|
||||
switch (inst.op) {
|
||||
case IROp::FRound:
|
||||
CompIR_Generic(inst);
|
||||
break;
|
||||
|
||||
case IROp::FTrunc:
|
||||
{
|
||||
regs_.SpillLockFPR(inst.dest, inst.src1);
|
||||
X64Reg tempZero = regs_.GetAndLockTempFPR();
|
||||
regs_.Map(inst);
|
||||
|
||||
CVTTSS2SI(SCRATCH1, regs_.F(inst.src1));
|
||||
|
||||
// Did we get an indefinite integer value?
|
||||
CMP(32, R(SCRATCH1), Imm32(0x80000000));
|
||||
FixupBranch wasExact = J_CC(CC_NE);
|
||||
|
||||
XORPS(tempZero, R(tempZero));
|
||||
if (inst.dest == inst.src1) {
|
||||
CMPSS(regs_.FX(inst.dest), R(tempZero), CMP_LT);
|
||||
} else if (cpu_info.bAVX) {
|
||||
VCMPSS(regs_.FX(inst.dest), regs_.FX(inst.src1), R(tempZero), CMP_LT);
|
||||
} else {
|
||||
MOVAPS(regs_.FX(inst.dest), regs_.F(inst.src1));
|
||||
CMPSS(regs_.FX(inst.dest), R(tempZero), CMP_LT);
|
||||
}
|
||||
|
||||
// At this point, -inf = 0xffffffff, inf/nan = 0x00000000.
|
||||
// We want -inf to be 0x80000000 inf/nan to be 0x7fffffff, so we flip those bits.
|
||||
MOVD_xmm(R(SCRATCH1), regs_.FX(inst.dest));
|
||||
XOR(32, R(SCRATCH1), Imm32(0x7fffffff));
|
||||
|
||||
SetJumpTarget(wasExact);
|
||||
MOVD_xmm(regs_.FX(inst.dest), R(SCRATCH1));
|
||||
break;
|
||||
}
|
||||
|
||||
case IROp::FCeil:
|
||||
case IROp::FFloor:
|
||||
CompIR_Generic(inst);
|
||||
|
||||
@@ -212,7 +212,14 @@ void X64JitBackend::CompIR_VecAssign(IRInst inst) {
|
||||
break;
|
||||
|
||||
case IROp::Vec4Shuffle:
|
||||
CompIR_Generic(inst);
|
||||
regs_.Map(inst);
|
||||
if (cpu_info.bAVX) {
|
||||
VPERMILPS(128, regs_.FX(inst.dest), regs_.F(inst.src1), inst.src2);
|
||||
} else {
|
||||
if (inst.dest != inst.src1)
|
||||
MOVAPS(regs_.FX(inst.dest), regs_.F(inst.src1));
|
||||
SHUFPS(regs_.FX(inst.dest), regs_.F(inst.dest), inst.src2);
|
||||
}
|
||||
break;
|
||||
|
||||
case IROp::Vec4Blend:
|
||||
|
||||
@@ -179,12 +179,20 @@ X64Reg X64IRRegCache::TryMapTempImm(IRReg r, X64Map flags) {
|
||||
return INVALID_REG;
|
||||
}
|
||||
|
||||
X64Reg X64IRRegCache::GetAndLockTempR() {
|
||||
X64Reg reg = FromNativeReg(AllocateReg(MIPSLoc::REG, MIPSMap::INIT));
|
||||
if (reg != INVALID_REG) {
|
||||
X64Reg X64IRRegCache::GetAndLockTempGPR() {
|
||||
IRNativeReg reg = AllocateReg(MIPSLoc::REG, MIPSMap::INIT);
|
||||
if (reg != -1) {
|
||||
nr[reg].tempLockIRIndex = irIndex_;
|
||||
}
|
||||
return reg;
|
||||
return FromNativeReg(reg);
|
||||
}
|
||||
|
||||
X64Reg X64IRRegCache::GetAndLockTempFPR() {
|
||||
IRNativeReg reg = AllocateReg(MIPSLoc::FREG, MIPSMap::INIT);
|
||||
if (reg != -1) {
|
||||
nr[reg].tempLockIRIndex = irIndex_;
|
||||
}
|
||||
return FromNativeReg(reg);
|
||||
}
|
||||
|
||||
void X64IRRegCache::ReserveAndLockXGPR(Gen::X64Reg r) {
|
||||
@@ -194,7 +202,7 @@ void X64IRRegCache::ReserveAndLockXGPR(Gen::X64Reg r) {
|
||||
nr[r].tempLockIRIndex = irIndex_;
|
||||
}
|
||||
|
||||
X64Reg X64IRRegCache::MapWithFPRTemp(IRInst &inst) {
|
||||
X64Reg X64IRRegCache::MapWithFPRTemp(const IRInst &inst) {
|
||||
return FromNativeReg(MapWithTemp(inst, MIPSLoc::FREG));
|
||||
}
|
||||
|
||||
@@ -282,7 +290,6 @@ void X64IRRegCache::AdjustNativeRegAsPtr(IRNativeReg nreg, bool state) {
|
||||
emit_->AND(PTRBITS, ::R(r), Imm32(Memory::MEMVIEW32_MASK));
|
||||
emit_->ADD(PTRBITS, ::R(r), ImmPtr(Memory::base));
|
||||
#else
|
||||
// Clear the top bits to be safe.
|
||||
emit_->ADD(PTRBITS, ::R(r), ::R(MEMBASEREG));
|
||||
#endif
|
||||
} else {
|
||||
|
||||
@@ -81,13 +81,14 @@ public:
|
||||
Gen::X64Reg MapFPR(IRReg reg, MIPSMap mapFlags = MIPSMap::INIT);
|
||||
Gen::X64Reg MapVec4(IRReg first, MIPSMap mapFlags = MIPSMap::INIT);
|
||||
|
||||
Gen::X64Reg MapWithFPRTemp(IRInst &inst);
|
||||
Gen::X64Reg MapWithFPRTemp(const IRInst &inst);
|
||||
|
||||
void MapWithFlags(IRInst inst, X64IRJitConstants::X64Map destFlags, X64IRJitConstants::X64Map src1Flags = X64IRJitConstants::X64Map::NONE, X64IRJitConstants::X64Map src2Flags = X64IRJitConstants::X64Map::NONE);
|
||||
|
||||
void FlushBeforeCall();
|
||||
|
||||
Gen::X64Reg GetAndLockTempR();
|
||||
Gen::X64Reg GetAndLockTempGPR();
|
||||
Gen::X64Reg GetAndLockTempFPR();
|
||||
void ReserveAndLockXGPR(Gen::X64Reg r);
|
||||
|
||||
Gen::OpArg R(IRReg preg);
|
||||
|
||||
Reference in new issue
Block a user