This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| bool doPair(TContext &context, const TInst *uInst, const TInst *vInst, bool ignoreBankConflicts) | |
| { | |
| using namespace Pipe; | |
| using namespace OpType; | |
| const TOp& uOp = uInst->getOp(); | |
| const TOp& vOp = vInst->getOp(); | |
| TCorePipe uPairability = uOp.getCorePipe(); | |
| TCorePipe vPairability = vOp.getCorePipe(); | |
| /* We can only pair if the U-pipe's getting something that's pairable | |
| on U and the V-pipe's getting something that is pairable on V :) */ | |
| if ((uPairability == eUPairable || uPairability == eUVPairable) && | |
| (vPairability == eVPairable || vPairability == eUVPairable)) | |
| { | |
| /* Determine which arguments access memory (if any) and how many | |
| vector read ports are used. */ | |
| const TArg *uMem = NULL; | |
| const TArg *vMem = NULL; | |
| const int vecReadPorts = 3; | |
| int uPorts = countVecPortsAndGetMem(uInst, &uMem); | |
| int vPorts = countVecPortsAndGetMem(vInst, &vMem); | |
| /* If we exceed read port limit, can't pair! */ | |
| if (uPorts + vPorts > vecReadPorts) return false; | |
| /* Check for bank collisions. TODO what to do with non-{0,1} probabilities? */ | |
| if (!ignoreBankConflicts && | |
| computeBankCollisionProbability(context, uInst, uMem, vInst, vMem) == 1.0f) | |
| return false; | |
| /* VGATHER/VSCATTER are !pairable with any other memory instructions including prefetches */ | |
| if (uOp.getSchedOpType() == cGatherScatterOp && vMem) | |
| return false; | |
| /* VSTOREs can't pair with each other */ | |
| if (uOp.getSchedOpType() == cVStoreOp && vOp.getSchedOpType() == cVStoreOp) | |
| return false; | |
| /* Neither inst can contain a disp and an immediate simultaneously */ | |
| if (hasDispImmPair(uInst, uMem) || hasDispImmPair(vInst, vMem)) | |
| return false; | |
| /* Two 8b instructions can't pair with each other, and any inst >8b is unpairable */ | |
| tSizeClass uSize = getSizeClass(uInst, uMem); | |
| tSizeClass vSize = getSizeClass(vInst, vMem); | |
| if ((uSize == Size8b && vSize == Size8b) || uSize == SizeAbove8b || vSize == SizeAbove8b) | |
| return false; | |
| /* PUSH/POP are !pairable if their argument is either a [MEM] or the SR */ | |
| if (!isPushPopPairable(uInst)) return false; | |
| if (!isPushPopPairable(vInst)) return false; | |
| /* TEST REG,IMM is only pairable if REG = {AX, RAX}; [MEM],IMM is !pairable */ | |
| if (!isTestPairable(uInst)) return false; | |
| if (!isTestPairable(vInst)) return false; | |
| /* SHR/SAR/SHL/SAL are U-pairable with immediate count */ | |
| if (!isShiftUPairable(uInst)) return false; | |
| /* ROR, ROL, RCR, RCL are U-pairable with an immediate count == 1 */ | |
| if (!isRotateUPairable(uInst)) return false; | |
| /* TODO: JMP, CALL to a far location are NP */ | |
| } | |
| else /* Well, these can't pair */ | |
| return false; | |
| return true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment