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

Chris Lattner lattner at cs.uiuc.edu
Sun Dec 15 13:08:01 PST 2002


Changes in directory llvm/lib/CodeGen:

RegAllocSimple.cpp updated: 1.16 -> 1.17

---
Log message:

* Remove some unneccesary instance variables
* Make allocateStackSpaceFor only allocate the right amount of space



---
Diffs of the changes:

Index: llvm/lib/CodeGen/RegAllocSimple.cpp
diff -u llvm/lib/CodeGen/RegAllocSimple.cpp:1.16 llvm/lib/CodeGen/RegAllocSimple.cpp:1.17
--- llvm/lib/CodeGen/RegAllocSimple.cpp:1.16	Sun Dec 15 12:38:59 2002
+++ llvm/lib/CodeGen/RegAllocSimple.cpp	Sun Dec 15 13:07:34 2002
@@ -38,11 +38,9 @@
 namespace {
   struct RegAllocSimple : public FunctionPass {
     TargetMachine &TM;
-    MachineBasicBlock *CurrMBB;
     MachineFunction *MF;
-    unsigned maxOffset;
     const MRegisterInfo *RegInfo;
-    unsigned NumBytesAllocated, ByteAlignment;
+    unsigned NumBytesAllocated;
     
     // Maps SSA Regs => offsets on the stack where these values are stored
     std::map<unsigned, unsigned> VirtReg2OffsetMap;
@@ -62,9 +60,8 @@
     std::map<unsigned, unsigned> RegsUsed;
     std::map<const TargetRegisterClass*, unsigned> RegClassIdx;
 
-    RegAllocSimple(TargetMachine &tm) : TM(tm), CurrMBB(0), maxOffset(0), 
+    RegAllocSimple(TargetMachine &tm) : TM(tm),
                                         RegInfo(tm.getRegisterInfo()),
-                                        ByteAlignment(4),
                                         PhysRegClasses(RegInfo)
     {
       RegsUsed[RegInfo->getFramePointer()] = 1;
@@ -109,7 +106,7 @@
     void cleanupAfterFunction() {
       VirtReg2OffsetMap.clear();
       SSA2PhysRegMap.clear();
-      NumBytesAllocated = ByteAlignment;
+      NumBytesAllocated = 4;   /* FIXME: This is X86 specific */
     }
 
     /// Moves value from memory into that register
@@ -144,19 +141,19 @@
                                             const TargetRegisterClass *regClass)
 {
   if (VirtReg2OffsetMap.find(VirtReg) == VirtReg2OffsetMap.end()) {
-#if 0
-    unsigned size = regClass->getDataSize();
-    unsigned over = NumBytesAllocated - (NumBytesAllocated % ByteAlignment);
-    if (size >= ByteAlignment - over) {
-      // need to pad by (ByteAlignment - over)
-      NumBytesAllocated += ByteAlignment - over;
-    }
-    VirtReg2OffsetMap[VirtReg] = NumBytesAllocated;
-    NumBytesAllocated += size;
-#endif
-    // FIXME: forcing each arg to take 4 bytes on the stack
+    unsigned RegSize = regClass->getDataSize();
+
+    // Align NumBytesAllocated.  We should be using TargetData alignment stuff
+    // to determine this, but we don't know the LLVM type associated with the
+    // virtual register.  Instead, just align to a multiple of the size for now.
+    NumBytesAllocated += RegSize-1;
+    NumBytesAllocated = NumBytesAllocated/RegSize*RegSize;
+
+    // Assign the slot...
     VirtReg2OffsetMap[VirtReg] = NumBytesAllocated;
-    NumBytesAllocated += ByteAlignment;
+
+    // Reserve the space!
+    NumBytesAllocated += RegSize;
   }
   return VirtReg2OffsetMap[VirtReg];
 }
@@ -241,7 +238,7 @@
   for (MachineFunction::iterator MBB = Fn.begin(), MBBe = Fn.end();
        MBB != MBBe; ++MBB)
   {
-    CurrMBB = &(*MBB);
+    MachineBasicBlock *CurrMBB = &(*MBB);
 
     // Handle PHI instructions specially: add moves to each pred block
     while (MBB->front()->getOpcode() == 0) {





More information about the llvm-commits mailing list