[llvm-commits] CVS: llvm/lib/CodeGen/RegAllocSimple.cpp

Chris Lattner lattner at cs.uiuc.edu
Sun Feb 15 15:39:01 PST 2004


Changes in directory llvm/lib/CodeGen:

RegAllocSimple.cpp updated: 1.51 -> 1.52

---
Log message:

Finegrainify namespacification
Remove one of the operands of a two operand instruction


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

Index: llvm/lib/CodeGen/RegAllocSimple.cpp
diff -u llvm/lib/CodeGen/RegAllocSimple.cpp:1.51 llvm/lib/CodeGen/RegAllocSimple.cpp:1.52
--- llvm/lib/CodeGen/RegAllocSimple.cpp:1.51	Sun Feb 15 15:37:17 2004
+++ llvm/lib/CodeGen/RegAllocSimple.cpp	Sun Feb 15 15:38:28 2004
@@ -25,8 +25,7 @@
 #include "Support/Debug.h"
 #include "Support/Statistic.h"
 #include <iostream>
-
-namespace llvm {
+using namespace llvm;
 
 namespace {
   Statistic<> NumSpilled ("ra-simple", "Number of registers spilled");
@@ -183,7 +182,9 @@
         unsigned physReg = Virt2PhysRegMap[virtualReg];
         if (physReg == 0) {
           if (op.isDef()) {
-            if (TM->getInstrInfo().isTwoAddrInstr(MI->getOpcode()) && i == 0) {
+            if (!TM->getInstrInfo().isTwoAddrInstr(MI->getOpcode()) || i) {
+              physReg = getFreeReg(virtualReg);
+            } else {
               // must be same register number as the first operand
               // This maps a = b + c into b += c, and saves b into a's spot
               assert(MI->getOperand(1).isRegister()  &&
@@ -192,8 +193,13 @@
                      "Two address instruction invalid!");
 
               physReg = MI->getOperand(1).getReg();
-            } else {
-              physReg = getFreeReg(virtualReg);
+
+              ++MI;
+              spillVirtReg(MBB, MI, virtualReg, physReg);
+              --MI;
+              MI->getOperand(1).setDef();
+              MI->RemoveOperand(0);
+              break; // This is the last operand to process
             }
             ++MI;
             spillVirtReg(MBB, MI, virtualReg, physReg);
@@ -231,8 +237,6 @@
   return true;
 }
 
-FunctionPass *createSimpleRegisterAllocator() {
+FunctionPass *llvm::createSimpleRegisterAllocator() {
   return new RegAllocSimple();
 }
-
-} // End llvm namespace





More information about the llvm-commits mailing list