[llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Fri Jun 25 23:57:09 PDT 2004


Changes in directory reopt/lib/LightWtProfiling:

UnpackTraceFunction.cpp updated: 1.88 -> 1.89

---
Log message:

In addLiveOutCopy, support copying a live-out from a spill slot on
TraceFn's stack to a MatrixFn register.  Other minor refactorings.


---
Diffs of the changes:  (+23 -19)

Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp
diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.88 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.89
--- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.88	Fri Jun 25 02:22:23 2004
+++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp	Fri Jun 25 23:56:14 2004
@@ -332,12 +332,13 @@
          std::cerr << "copyConstantToRegister Output: " << **i << "\n");
 }
 
-void UnpackTraceFunction::addLiveOutCopy (MachineFunction &MF, MachineBasicBlock &MBB,
-                                          const AllocInfo &Source, const AllocInfo &Target,
-                                          Value *liveOutValue, Value *liveOutTraceValue) {
+void UnpackTraceFunction::addLiveOutCopy (MachineFunction &MF,
+       MachineBasicBlock &MBB, const AllocInfo &Source,
+       const AllocInfo &Target, Value *liveOutValue, Value *liveOutTraceValue) {
   const SparcV9RegInfo &TRI = *TM->getRegInfo ();
   std::vector<MachineInstr *> mvec;
-  static const unsigned sp = SparcV9::o6, g1 = SparcV9::g1, g2 = SparcV9::g2;
+  static const unsigned sp = SparcV9::o6, fp = SparcV9::i6, g1 = SparcV9::g1,
+    g2 = SparcV9::g2;
   
   assert (Target.AllocState == AllocInfo::Allocated
           && "Live-out values must be in regs in the matrixFn");
@@ -347,25 +348,28 @@
            << RegStr (Target.Placement) << " to RegsToSave set\n");
     RegsToSave.insert (Target.Placement);
   }
+  unsigned R = g1, RegType;
+  // We don't need to use a temp reg. if the live-out value is already
+  // in a register in the TraceFn.
+  if (Source.AllocState == AllocInfo::Allocated)
+    R = Source.Placement;
+  RegType = TRI.getRegType (R);
   if (Source.AllocState == AllocInfo::NotAllocated) {
-    assert (liveOutValue);
-    assert (isa<Constant> (liveOutTraceValue)
-            && "Can't handle non-constant, non-allocated live-out value in traceFn");
-    copyConstantToRegister (MF, cast<Constant> (liveOutTraceValue), g1, g2, mvec);
-    unsigned R = g1;
-    unsigned RegType = TRI.getRegType (R);
+    assert (liveOutValue && isa<Constant> (liveOutTraceValue)
+            && "Non-allocated live-out value in TraceFn must be constant");
     DEBUG (std::cerr << "addLiveOutCopy: " << liveOutValue->getName()
            << " is a constant in TraceFn\n");
-    TRI.cpReg2MemMI (mvec, R, sp, stackOffsetForReg (Target.Placement),
-                     RegType, g2);
-  } else {
-    assert (Source.AllocState == AllocInfo::Allocated
-            && "Can't handle live-out value spilled in traceFn");
-    unsigned R = Source.Placement;
-    unsigned RegType = TRI.getRegType (R);
-    TRI.cpReg2MemMI (mvec, R, sp, stackOffsetForReg (Target.Placement),
-                     RegType, g2);
+    // Copy the constant to the register.
+    copyConstantToRegister (MF, cast<Constant> (liveOutTraceValue), g1,
+                            g2, mvec);
+  } else if (Source.AllocState == AllocInfo::Spilled) {
+    // Copy live-out value from TraceFn's stack to the register.
+    TRI.cpMem2RegMI (mvec, fp, Source.Placement, R, RegType, g2);
   }
+  // Copy the live-out value from the register to the place on the
+  // stack from which it will be restored to MatrixFn's register.
+  TRI.cpReg2MemMI (mvec, R, sp, stackOffsetForReg (Target.Placement),
+                   RegType, g2);
   for (std::vector<MachineInstr *>::iterator vi = mvec.begin (),
        ve = mvec.end (); vi != ve; ++vi)
     MBB.push_back (*vi);





More information about the llvm-commits mailing list