diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-21 16:09:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-21 16:09:23 +0000 |
commit | 4c62e79c595ba046e500ac7be4de241f9614ee86 (patch) | |
tree | 4a1c66476ab93fe873ee025b2847009dc190ef98 /lib/Target | |
parent | d48a1d797ff7b69e4e348c56c158a95538eefce8 (diff) | |
download | llvm-4c62e79c595ba046e500ac7be4de241f9614ee86.tar.gz llvm-4c62e79c595ba046e500ac7be4de241f9614ee86.tar.bz2 llvm-4c62e79c595ba046e500ac7be4de241f9614ee86.tar.xz |
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
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/SparcV9/SparcV9PreSelection.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/Target/SparcV9/SparcV9PreSelection.cpp b/lib/Target/SparcV9/SparcV9PreSelection.cpp index 014725a73f..d4f4398b4a 100644 --- a/lib/Target/SparcV9/SparcV9PreSelection.cpp +++ b/lib/Target/SparcV9/SparcV9PreSelection.cpp @@ -73,6 +73,7 @@ namespace { void visitInstruction(Instruction &I); // common work for every instr. void visitGetElementPtrInst(GetElementPtrInst &I); void visitCallInst(CallInst &I); + void visitPHINode(PHINode &PN); // Helper functions for visiting operands of every instruction // @@ -210,19 +211,21 @@ PreSelection::visitOneOperand(Instruction &I, Value* Op, unsigned opNum, // inline void PreSelection::visitOperands(Instruction &I, int firstOp) { // For any instruction other than PHI, copies go just before the instr. + for (unsigned i = firstOp, e = I.getNumOperands(); i != e; ++i) + visitOneOperand(I, I.getOperand(i), i, I); +} + + +void PreSelection::visitPHINode(PHINode &PN) { // For a PHI, operand copies must be before the terminator of the // appropriate predecessor basic block. Remaining logic is simple // so just handle PHIs and other instructions separately. // - if (PHINode* phi = dyn_cast<PHINode>(&I)) { - for (unsigned i=firstOp, N=phi->getNumIncomingValues(); i != N; ++i) - visitOneOperand(I, phi->getIncomingValue(i), - phi->getOperandNumForIncomingValue(i), - * phi->getIncomingBlock(i)->getTerminator()); - } else { - for (unsigned i=firstOp, N=lastOp; i != I.getNumOperands(); ++i) - visitOneOperand(I, I.getOperand(i), i, I); - } + for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) + visitOneOperand(I, PN.getIncomingValue(i), + PN.getOperandNumForIncomingValue(i), + *PN.getIncomingBlock(i)->getTerminator()); + // do not call visitOperands! } |