[llvm-commits] CVS: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp ScheduleDAG.cpp SelectionDAGISel.cpp

Owen Anderson resistor at mac.com
Tue May 2 18:30:22 PDT 2006



Changes in directory llvm/lib/CodeGen/SelectionDAG:

LegalizeDAG.cpp updated: 1.370 -> 1.371
ScheduleDAG.cpp updated: 1.82 -> 1.83
SelectionDAGISel.cpp updated: 1.231 -> 1.232
---
Log message:

Refactor TargetMachine, pushing handling of TargetData into the target-specific subclasses.  This has one caller-visible change: getTargetData() now returns a pointer instead of a reference.

This fixes PR 759: http://llvm.cs.uiuc.edu/PR759 .



---
Diffs of the changes:  (+24 -24)

 LegalizeDAG.cpp      |    6 +++---
 ScheduleDAG.cpp      |    4 ++--
 SelectionDAGISel.cpp |   38 +++++++++++++++++++-------------------
 3 files changed, 24 insertions(+), 24 deletions(-)


Index: llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.370 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.371
--- llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp:1.370	Sat Apr 22 13:53:45 2006
+++ llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp	Tue May  2 20:29:56 2006
@@ -1986,7 +1986,7 @@
       // Otherwise, the target does not support this operation.  Lower the
       // operation to an explicit libcall as appropriate.
       MVT::ValueType IntPtr = TLI.getPointerTy();
-      const Type *IntPtrTy = TLI.getTargetData().getIntPtrType();
+      const Type *IntPtrTy = TLI.getTargetData()->getIntPtrType();
       std::vector<std::pair<SDOperand, const Type*> > Args;
 
       const char *FnName = 0;
@@ -2781,8 +2781,8 @@
         // slots and always reusing the same one.  We currently always create
         // new ones, as reuse may inhibit scheduling.
         const Type *Ty = MVT::getTypeForValueType(ExtraVT);
-        unsigned TySize = (unsigned)TLI.getTargetData().getTypeSize(Ty);
-        unsigned Align  = TLI.getTargetData().getTypeAlignment(Ty);
+        unsigned TySize = (unsigned)TLI.getTargetData()->getTypeSize(Ty);
+        unsigned Align  = TLI.getTargetData()->getTypeAlignment(Ty);
         MachineFunction &MF = DAG.getMachineFunction();
         int SSFI =
           MF.getFrameInfo()->CreateStackObject((unsigned)TySize, Align);


Index: llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.82 llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.83
--- llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp:1.82	Sat Apr 22 13:53:45 2006
+++ llvm/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp	Tue May  2 20:29:56 2006
@@ -130,10 +130,10 @@
         Align = 3;  // always 8-byte align doubles.
       else {
         Align = TM.getTargetData()
-          .getTypeAlignmentShift(CP->get()->getType());
+          ->getTypeAlignmentShift(CP->get()->getType());
         if (Align == 0) {
           // Alignment of packed types.  FIXME!
-          Align = TM.getTargetData().getTypeSize(CP->get()->getType());
+          Align = TM.getTargetData()->getTypeSize(CP->get()->getType());
           Align = Log2_64(Align);
         }
       }


Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.231 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.232
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.231	Fri Apr 28 13:54:11 2006
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp	Tue May  2 20:29:56 2006
@@ -225,9 +225,9 @@
     if (AllocaInst *AI = dyn_cast<AllocaInst>(I))
       if (ConstantUInt *CUI = dyn_cast<ConstantUInt>(AI->getArraySize())) {
         const Type *Ty = AI->getAllocatedType();
-        uint64_t TySize = TLI.getTargetData().getTypeSize(Ty);
+        uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
         unsigned Align = 
-          std::max((unsigned)TLI.getTargetData().getTypeAlignment(Ty),
+          std::max((unsigned)TLI.getTargetData()->getTypeAlignment(Ty),
                    AI->getAlignment());
 
         // If the alignment of the value is smaller than the size of the value,
@@ -394,7 +394,7 @@
   // implemented with a libcall, etc.
   TargetLowering &TLI;
   SelectionDAG &DAG;
-  const TargetData &TD;
+  const TargetData *TD;
 
   /// SwitchCases - Vector of CaseBlock structures used to communicate
   /// SwitchInst code generation information.
@@ -1202,7 +1202,7 @@
 void SelectionDAGLowering::visitGetElementPtr(User &I) {
   SDOperand N = getValue(I.getOperand(0));
   const Type *Ty = I.getOperand(0)->getType();
-  const Type *UIntPtrTy = TD.getIntPtrType();
+  const Type *UIntPtrTy = TD->getIntPtrType();
 
   for (GetElementPtrInst::op_iterator OI = I.op_begin()+1, E = I.op_end();
        OI != E; ++OI) {
@@ -1211,7 +1211,7 @@
       unsigned Field = cast<ConstantUInt>(Idx)->getValue();
       if (Field) {
         // N = N + Offset
-        uint64_t Offset = TD.getStructLayout(StTy)->MemberOffsets[Field];
+        uint64_t Offset = TD->getStructLayout(StTy)->MemberOffsets[Field];
         N = DAG.getNode(ISD::ADD, N.getValueType(), N,
                         getIntPtrConstant(Offset));
       }
@@ -1225,15 +1225,15 @@
 
         uint64_t Offs;
         if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(CI))
-          Offs = (int64_t)TD.getTypeSize(Ty)*CSI->getValue();
+          Offs = (int64_t)TD->getTypeSize(Ty)*CSI->getValue();
         else
-          Offs = TD.getTypeSize(Ty)*cast<ConstantUInt>(CI)->getValue();
+          Offs = TD->getTypeSize(Ty)*cast<ConstantUInt>(CI)->getValue();
         N = DAG.getNode(ISD::ADD, N.getValueType(), N, getIntPtrConstant(Offs));
         continue;
       }
       
       // N = N + Idx * ElementSize;
-      uint64_t ElementSize = TD.getTypeSize(Ty);
+      uint64_t ElementSize = TD->getTypeSize(Ty);
       SDOperand IdxN = getValue(Idx);
 
       // If the index is smaller or larger than intptr_t, truncate or extend
@@ -1271,8 +1271,8 @@
     return;   // getValue will auto-populate this.
 
   const Type *Ty = I.getAllocatedType();
-  uint64_t TySize = TLI.getTargetData().getTypeSize(Ty);
-  unsigned Align = std::max((unsigned)TLI.getTargetData().getTypeAlignment(Ty),
+  uint64_t TySize = TLI.getTargetData()->getTypeSize(Ty);
+  unsigned Align = std::max((unsigned)TLI.getTargetData()->getTypeAlignment(Ty),
                             I.getAlignment());
 
   SDOperand AllocSize = getValue(I.getArraySize());
@@ -2267,12 +2267,12 @@
     Src = DAG.getNode(ISD::ZERO_EXTEND, IntPtr, Src);
 
   // Scale the source by the type size.
-  uint64_t ElementSize = TD.getTypeSize(I.getType()->getElementType());
+  uint64_t ElementSize = TD->getTypeSize(I.getType()->getElementType());
   Src = DAG.getNode(ISD::MUL, Src.getValueType(),
                     Src, getIntPtrConstant(ElementSize));
 
   std::vector<std::pair<SDOperand, const Type*> > Args;
-  Args.push_back(std::make_pair(Src, TLI.getTargetData().getIntPtrType()));
+  Args.push_back(std::make_pair(Src, TLI.getTargetData()->getIntPtrType()));
 
   std::pair<SDOperand,SDOperand> Result =
     TLI.LowerCallTo(getRoot(), I.getType(), false, CallingConv::C, true,
@@ -2285,7 +2285,7 @@
 void SelectionDAGLowering::visitFree(FreeInst &I) {
   std::vector<std::pair<SDOperand, const Type*> > Args;
   Args.push_back(std::make_pair(getValue(I.getOperand(0)),
-                                TLI.getTargetData().getIntPtrType()));
+                                TLI.getTargetData()->getIntPtrType()));
   MVT::ValueType IntPtr = TLI.getPointerTy();
   std::pair<SDOperand,SDOperand> Result =
     TLI.LowerCallTo(getRoot(), Type::VoidTy, false, CallingConv::C, true,
@@ -2766,7 +2766,7 @@
 /// stores that use it.  In this case, decompose the GEP and move constant
 /// indices into blocks that use it.
 static void OptimizeGEPExpression(GetElementPtrInst *GEPI,
-                                  const TargetData &TD) {
+                                  const TargetData *TD) {
   // If this GEP is only used inside the block it is defined in, there is no
   // need to rewrite it.
   bool isUsedOutsideDefBB = false;
@@ -2797,7 +2797,7 @@
   // Otherwise, decompose the GEP instruction into multiplies and adds.  Sum the
   // constant offset (which we now know is non-zero) and deal with it later.
   uint64_t ConstantOffset = 0;
-  const Type *UIntPtrTy = TD.getIntPtrType();
+  const Type *UIntPtrTy = TD->getIntPtrType();
   Value *Ptr = new CastInst(GEPI->getOperand(0), UIntPtrTy, "", GEPI);
   const Type *Ty = GEPI->getOperand(0)->getType();
 
@@ -2807,7 +2807,7 @@
     if (const StructType *StTy = dyn_cast<StructType>(Ty)) {
       unsigned Field = cast<ConstantUInt>(Idx)->getValue();
       if (Field)
-        ConstantOffset += TD.getStructLayout(StTy)->MemberOffsets[Field];
+        ConstantOffset += TD->getStructLayout(StTy)->MemberOffsets[Field];
       Ty = StTy->getElementType(Field);
     } else {
       Ty = cast<SequentialType>(Ty)->getElementType();
@@ -2817,9 +2817,9 @@
         if (CI->getRawValue() == 0) continue;
         
         if (ConstantSInt *CSI = dyn_cast<ConstantSInt>(CI))
-          ConstantOffset += (int64_t)TD.getTypeSize(Ty)*CSI->getValue();
+          ConstantOffset += (int64_t)TD->getTypeSize(Ty)*CSI->getValue();
         else
-          ConstantOffset+=TD.getTypeSize(Ty)*cast<ConstantUInt>(CI)->getValue();
+          ConstantOffset+=TD->getTypeSize(Ty)*cast<ConstantUInt>(CI)->getValue();
         continue;
       }
       
@@ -2828,7 +2828,7 @@
       // Cast Idx to UIntPtrTy if needed.
       Idx = new CastInst(Idx, UIntPtrTy, "", GEPI);
       
-      uint64_t ElementSize = TD.getTypeSize(Ty);
+      uint64_t ElementSize = TD->getTypeSize(Ty);
       // Mask off bits that should not be set.
       ElementSize &= ~0ULL >> (64-UIntPtrTy->getPrimitiveSizeInBits());
       Constant *SizeCst = ConstantUInt::get(UIntPtrTy, ElementSize);






More information about the llvm-commits mailing list