[llvm-commits] CVS: llvm/lib/Target/Sparc/PreSelection.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Oct 21 11:10:04 PDT 2003


Changes in directory llvm/lib/Target/Sparc:

PreSelection.cpp updated: 1.20 -> 1.21

---
Log message:

Pull the PHI special case into it's own visit* method


---
Diffs of the changes:  (+12 -9)

Index: llvm/lib/Target/Sparc/PreSelection.cpp
diff -u llvm/lib/Target/Sparc/PreSelection.cpp:1.20 llvm/lib/Target/Sparc/PreSelection.cpp:1.21
--- llvm/lib/Target/Sparc/PreSelection.cpp:1.20	Tue Oct 21 11:06:07 2003
+++ llvm/lib/Target/Sparc/PreSelection.cpp	Tue Oct 21 11:09:23 2003
@@ -73,6 +73,7 @@
     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 @@
 //  
 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!
 }
 
 





More information about the llvm-commits mailing list