When allocating space on stack for writing a register,
authorVikram S. Adve <vadve@cs.uiuc.edu>
Mon, 12 Nov 2001 23:26:35 +0000 (23:26 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Mon, 12 Nov 2001 23:26:35 +0000 (23:26 +0000)
use the size of the register, not the size of the Value type,
to get the right alignment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1284 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
lib/Target/SparcV9/SparcV9Internals.h
lib/Target/SparcV9/SparcV9RegInfo.cpp
lib/Target/SparcV9/SparcV9TargetMachine.cpp

index bc825657344bde7af85a915bb8a89a5f9895d1e0..9133da5df49e2f9811bea70c201059d8f9b4bab2 100644 (file)
@@ -528,8 +528,10 @@ void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR,
   int SpillOff = LR->getSpillOffFromFP();
   RegClass *RC = LR->getRegClass();
   const LiveVarSet *LVSetBef =  LVI->getLiveVarSetBeforeMInst(MInst, BB);
+
+  /**** NOTE: THIS SHOULD USE THE RIGHT SIZE FOR THE REG BEING PUSHED ****/
   int TmpOff = 
-    mcInfo.pushTempValue(TM, TM.findOptimalStorageSize(LR->getType()));
+    mcInfo.pushTempValue(TM, 8 /* TM.findOptimalStorageSize(LR->getType()) */);
   
   MachineInstr *MIBef=NULL,  *AdIMid=NULL, *MIAft=NULL;
   int TmpReg;
index bc825657344bde7af85a915bb8a89a5f9895d1e0..9133da5df49e2f9811bea70c201059d8f9b4bab2 100644 (file)
@@ -528,8 +528,10 @@ void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR,
   int SpillOff = LR->getSpillOffFromFP();
   RegClass *RC = LR->getRegClass();
   const LiveVarSet *LVSetBef =  LVI->getLiveVarSetBeforeMInst(MInst, BB);
+
+  /**** NOTE: THIS SHOULD USE THE RIGHT SIZE FOR THE REG BEING PUSHED ****/
   int TmpOff = 
-    mcInfo.pushTempValue(TM, TM.findOptimalStorageSize(LR->getType()));
+    mcInfo.pushTempValue(TM, 8 /* TM.findOptimalStorageSize(LR->getType()) */);
   
   MachineInstr *MIBef=NULL,  *AdIMid=NULL, *MIAft=NULL;
   int TmpReg;
index 9b8fe177ef2753ca32638582630994477dbb5e65..53a4beb6cecf7c2d570a8a791f2a6fab76566d69 100644 (file)
@@ -1211,6 +1211,8 @@ protected:
 // 
 // Purpose:
 //   Interface to stack frame layout info for the UltraSPARC.
+//   Starting offsets for each area of the stack frame are aligned at
+//   a multiple of getStackFrameSizeAlignment().
 //---------------------------------------------------------------------------
 
 class UltraSparcFrameInfo: public MachineFrameInfo {
index 16e3b9f038093883840973d48f567951194e05c0..e59a3ab2b41025a7e97233e64ad52ea34198eccc 100644 (file)
@@ -709,9 +709,9 @@ void UltraSparcRegInfo::colorCallArgs(const MachineInstr *const CallMI,
        
        int TReg = PRA.getRegNotUsedByThisInst( LR->getRegClass(), CallMI );
 
-       int TmpOff = PRA.mcInfo.pushTempValue(target,
-                              target.findOptimalStorageSize(LR->getType()));
-                  // getStackOffsets().getNewTmpPosOffFromFP();
+    /**** NOTE: THIS SHOULD USE THE RIGHT SIZE FOR THE REG BEING PUSHED ****/
+       int TmpOff = PRA.mcInfo.pushTempValue(target, 8);
+                          // target.findOptimalStorageSize(LR->getType()));
         
        int argOffset = PRA.mcInfo.allocateOptionalArg(target, LR->getType()); 
         
@@ -1174,8 +1174,9 @@ void UltraSparcRegInfo::insertCallerSavingCode(const MachineInstr *MInst,
            // and add them to InstrnsBefore and InstrnsAfter of the
            // call instruction
 
-           int StackOff =  PRA.mcInfo.pushTempValue(target,
-                              target.findOptimalStorageSize(LR->getType()));
+    /**** NOTE: THIS SHOULD USE THE RIGHT SIZE FOR THE REG BEING PUSHED ****/
+           int StackOff =  PRA.mcInfo.pushTempValue(target, 8);
+                // target.findOptimalStorageSize(LR->getType()));
             
            MachineInstr *AdIBefCC, *AdIAftCC, *AdICpCC;
            MachineInstr *AdIBef, *AdIAft;
@@ -1548,6 +1549,7 @@ void UltraSparcRegInfo::moveInst2OrdVec(vector<MachineInstr *> &OrdVec,
          MachineInstr *AdIBef, *AdIAft;
              
          // TODO: Change 8 below
+    /**** NOTE: THIS SHOULD USE THE RIGHT SIZE FOR THE REG BEING PUSHED ****/
          const int StackOff =  PRA.mcInfo.pushTempValue(target, 8);
          
          // Save the UReg (%ox) on stack before it's destroyed
index b6bf94f81e32ebc79fb6c067c45af4a84f809117..20bad83dfc650b52b857613c921b6028696f655b 100644 (file)
@@ -193,7 +193,8 @@ UltraSparcSchedInfo::initializeResources()
 // 
 // Purpose:
 //   Interface to stack frame layout info for the UltraSPARC.
-//   Note that there is no machine-independent interface to this information
+//   Starting offsets for each area of the stack frame are aligned at
+//   a multiple of getStackFrameSizeAlignment().
 //---------------------------------------------------------------------------
 
 int
@@ -210,7 +211,9 @@ UltraSparcFrameInfo::getRegSpillAreaOffset(MachineCodeForMethod& mcInfo,
 {
   pos = false;                          // static stack area grows downwards
   unsigned int autoVarsSize = mcInfo.getAutomaticVarsSize();
-  return  StaticAreaOffsetFromFP - autoVarsSize;
+  if (int mod = autoVarsSize % getStackFrameSizeAlignment())  
+    autoVarsSize += (getStackFrameSizeAlignment() - mod);
+  return StaticAreaOffsetFromFP - autoVarsSize; 
 }
 
 int
@@ -220,7 +223,10 @@ UltraSparcFrameInfo::getTmpAreaOffset(MachineCodeForMethod& mcInfo,
   pos = false;                          // static stack area grows downwards
   unsigned int autoVarsSize = mcInfo.getAutomaticVarsSize();
   unsigned int spillAreaSize = mcInfo.getRegSpillsSize();
-  return StaticAreaOffsetFromFP - (autoVarsSize + spillAreaSize);
+  int offset = autoVarsSize + spillAreaSize;
+  if (int mod = offset % getStackFrameSizeAlignment())  
+    offset += (getStackFrameSizeAlignment() - mod);
+  return StaticAreaOffsetFromFP - offset;
 }
 
 int
@@ -229,7 +235,9 @@ UltraSparcFrameInfo::getDynamicAreaOffset(MachineCodeForMethod& mcInfo,
 {
   // dynamic stack area grows downwards starting at top of opt-args area
   unsigned int optArgsSize = mcInfo.getMaxOptionalArgsSize();
-  return optArgsSize + FirstOptionalOutgoingArgOffsetFromSP;
+  int offset = optArgsSize + FirstOptionalOutgoingArgOffsetFromSP;
+  assert(offset % getStackFrameSizeAlignment() == 0);
+  return offset;
 }