llvm.org GIT mirror llvm / 4c62e79
Pull the PHI special case into it's own visit* method git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9332 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
1 changed file(s) with 12 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
7272 void visitInstruction(Instruction &I); // common work for every instr.
7373 void visitGetElementPtrInst(GetElementPtrInst &I);
7474 void visitCallInst(CallInst &I);
75 void visitPHINode(PHINode &PN);
7576
7677 // Helper functions for visiting operands of every instruction
7778 //
209210 //
210211 inline void PreSelection::visitOperands(Instruction &I, int firstOp) {
211212 // For any instruction other than PHI, copies go just before the instr.
213 for (unsigned i = firstOp, e = I.getNumOperands(); i != e; ++i)
214 visitOneOperand(I, I.getOperand(i), i, I);
215 }
216
217
218 void PreSelection::visitPHINode(PHINode &PN) {
212219 // For a PHI, operand copies must be before the terminator of the
213220 // appropriate predecessor basic block. Remaining logic is simple
214221 // so just handle PHIs and other instructions separately.
215222 //
216 if (PHINode* phi = dyn_cast(&I)) {
217 for (unsigned i=firstOp, N=phi->getNumIncomingValues(); i != N; ++i)
218 visitOneOperand(I, phi->getIncomingValue(i),
219 phi->getOperandNumForIncomingValue(i),
220 * phi->getIncomingBlock(i)->getTerminator());
221 } else {
222 for (unsigned i=firstOp, N=lastOp; i != I.getNumOperands(); ++i)
223 visitOneOperand(I, I.getOperand(i), i, I);
224 }
223 for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i)
224 visitOneOperand(I, PN.getIncomingValue(i),
225 PN.getOperandNumForIncomingValue(i),
226 *PN.getIncomingBlock(i)->getTerminator());
227 // do not call visitOperands!
225228 }
226229
227230