MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / _allocGPRtoXMMreg

Function _allocGPRtoXMMreg

pcsx2/x86/iCore.cpp:284–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282}
283
284int _allocGPRtoXMMreg(int gprreg, int mode)
285{
286#define MODE_STRING(x) ((((x) & MODE_READ)) ? (((x)&MODE_WRITE) ? "readwrite" : "read") : "write")
287
288 // is this already in a gpr?
289 const int hostx86reg = _checkX86reg(X86TYPE_GPR, gprreg, MODE_READ);
290
291 for (u32 i = 0; i < iREGCNT_XMM; i++)
292 {
293 if (!xmmregs[i].inuse || xmmregs[i].type != XMMTYPE_GPRREG || xmmregs[i].reg != gprreg)
294 continue;
295
296 if (!(xmmregs[i].mode & (MODE_READ | MODE_WRITE)) && (mode & MODE_READ))
297 pxFailRel("Somehow ended up with an allocated register without mode");
298
299 if (mode & MODE_WRITE && hostx86reg >= 0)
300 {
301 RALOG("Invalidating cached guest GPR reg %d in host reg GPR %d due to XMM transition\n", gprreg, hostx86reg);
302 x86regs[hostx86reg].inuse = 0;
303 }
304
305 if (mode & MODE_WRITE)
306 {
307 if (GPR_IS_CONST1(gprreg))
308 {
309 RALOG("Clearing constant value for guest GPR reg %d on XMM reconfig\n", gprreg);
310 GPR_DEL_CONST(gprreg);
311 }
312 if (hostx86reg >= 0)
313 {
314 // x86 register should be up to date, because if it was written, it should've been invalidated
315 pxAssert(!(x86regs[hostx86reg].mode & MODE_WRITE));
316 _freeX86regWithoutWriteback(hostx86reg);
317 }
318 }
319
320 xmmregs[i].counter = g_xmmAllocCounter++; // update counter
321 xmmregs[i].needed = true;
322 xmmregs[i].mode |= mode;
323 return i;
324 }
325
326 const int xmmreg = _getFreeXMMreg();
327 RALOG("Allocating host XMM %d to guest GPR %d in %s mode\n", xmmreg, gprreg, GetModeString(mode));
328
329 xmmregs[xmmreg].inuse = 1;
330 xmmregs[xmmreg].type = XMMTYPE_GPRREG;
331 xmmregs[xmmreg].reg = gprreg;
332 xmmregs[xmmreg].mode = mode;
333 xmmregs[xmmreg].needed = 1;
334 xmmregs[xmmreg].counter = g_xmmAllocCounter++;
335
336 if (mode & MODE_READ)
337 {
338 if (gprreg == 0)
339 {
340 xPXOR(xRegisterSSE(xmmreg), xRegisterSSE(xmmreg));
341 }

Callers 11

_checkXMMregFunction · 0.85
_allocIfUsedGPRtoXMMFunction · 0.85
_eeMoveGPRtoRFunction · 0.85
_eeMoveGPRtoMFunction · 0.85
eeRecompileCodeXMMFunction · 0.85
recWritebackHILOFunction · 0.85
recWritebackConstHILOFunction · 0.85
recMFHILOFunction · 0.85
recMTHILOFunction · 0.85
recLoadQuadFunction · 0.85
recStoreFunction · 0.85

Calls 6

_checkX86regFunction · 0.85
_getFreeXMMregFunction · 0.85
xRegisterSSEClass · 0.85
xRegister64Class · 0.85
QMethod · 0.45

Tested by

no test coverage detected