[cfe-commits] r109724 - /cfe/trunk/lib/CodeGen/TargetInfo.cpp

Chris Lattner sabre at nondot.org
Wed Jul 28 19:20:19 PDT 2010


Author: lattner
Date: Wed Jul 28 21:20:19 2010
New Revision: 109724

URL: http://llvm.org/viewvc/llvm-project?rev=109724&view=rev
Log:
simplify Get8ByteTypeAtOffset by making it a member of X86_64ABIInfo

Modified:
    cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=109724&r1=109723&r2=109724&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jul 28 21:20:19 2010
@@ -721,6 +721,11 @@
   /// also be ComplexX87.
   void classify(QualType T, uint64_t OffsetBase, Class &Lo, Class &Hi) const;
 
+  const llvm::Type *Get8ByteTypeAtOffset(const llvm::Type *PrefType,
+                                         unsigned IROffset,
+                                         QualType SourceTy,
+                                         unsigned SourceOffset) const;
+  
   /// getCoerceResult - Given a source type \arg Ty and an LLVM type
   /// to coerce to, chose the best way to pass Ty in the same place
   /// that \arg CoerceTo would be passed, but while keeping the
@@ -1197,13 +1202,9 @@
 /// SourceTy is the source level type for the entire argument.  SourceOffset is
 /// an offset into this that we're processing (which is always either 0 or 8).
 ///
-static const llvm::Type *Get8ByteTypeAtOffset(const llvm::Type *PrefType,
-                                              unsigned IROffset,
-                                              QualType SourceTy,
-                                              unsigned SourceOffset,
-                                              const llvm::TargetData &TD,
-                                              llvm::LLVMContext &VMContext,
-                                              ASTContext &Context) {
+const llvm::Type *X86_64ABIInfo::
+Get8ByteTypeAtOffset(const llvm::Type *PrefType, unsigned IROffset,
+                     QualType SourceTy, unsigned SourceOffset) const {
   // Pointers are always 8-bytes at offset 0.
   if (IROffset == 0 && PrefType && isa<llvm::PointerType>(PrefType))
     return PrefType;
@@ -1214,28 +1215,29 @@
   if (const llvm::StructType *STy =
           dyn_cast_or_null<llvm::StructType>(PrefType)) {
     // If this is a struct, recurse into the field at the specified offset.
-    const llvm::StructLayout *SL = TD.getStructLayout(STy);
+    const llvm::StructLayout *SL = getTargetData().getStructLayout(STy);
     if (IROffset < SL->getSizeInBytes()) {
       unsigned FieldIdx = SL->getElementContainingOffset(IROffset);
       IROffset -= SL->getElementOffset(FieldIdx);
       
       return Get8ByteTypeAtOffset(STy->getElementType(FieldIdx), IROffset,
-                                  SourceTy, SourceOffset, TD,VMContext,Context);
+                                  SourceTy, SourceOffset);
     }      
   }
   
   // Okay, we don't have any better idea of what to pass, so we pass this in an
   // integer register that isn't too big to fit the rest of the struct.
-  uint64_t TySizeInBytes = Context.getTypeSizeInChars(SourceTy).getQuantity();
+  uint64_t TySizeInBytes =
+    getContext().getTypeSizeInChars(SourceTy).getQuantity();
 
   // It is always safe to classify this as an integer type up to i64 that
   // isn't larger than the structure.
   switch (unsigned(TySizeInBytes-SourceOffset)) {
-  case 1:  return llvm::Type::getInt8Ty(VMContext);
-  case 2:  return llvm::Type::getInt16Ty(VMContext);
+  case 1:  return llvm::Type::getInt8Ty(getVMContext());
+  case 2:  return llvm::Type::getInt16Ty(getVMContext());
   case 3:
-  case 4:  return llvm::Type::getInt32Ty(VMContext);
-  default: return llvm::Type::getInt64Ty(VMContext);
+  case 4:  return llvm::Type::getInt32Ty(getVMContext());
+  default: return llvm::Type::getInt64Ty(getVMContext());
   }  
 }
 
@@ -1268,8 +1270,7 @@
     // AMD64-ABI 3.2.3p4: Rule 3. If the class is INTEGER, the next
     // available register of the sequence %rax, %rdx is used.
   case Integer:
-    ResType = Get8ByteTypeAtOffset(0, 0, RetTy, 0, getTargetData(),
-                                   getVMContext(), getContext());
+    ResType = Get8ByteTypeAtOffset(0, 0, RetTy, 0);
     break;
 
     // AMD64-ABI 3.2.3p4: Rule 4. If the class is SSE, the next
@@ -1308,9 +1309,7 @@
     break;
 
   case Integer: {
-    const llvm::Type *HiType = 
-      Get8ByteTypeAtOffset(0, 8, RetTy, 8, getTargetData(), getVMContext(),
-                           getContext());
+    const llvm::Type *HiType =  Get8ByteTypeAtOffset(0, 8, RetTy, 8);
     ResType = llvm::StructType::get(getVMContext(), ResType, HiType, NULL);
     break;
   }
@@ -1386,8 +1385,7 @@
     ++neededInt;
       
     // Pick an 8-byte type based on the preferred type.
-    ResType = Get8ByteTypeAtOffset(PrefType, 0, Ty, 0, getTargetData(),
-                                   getVMContext(), getContext());
+    ResType = Get8ByteTypeAtOffset(PrefType, 0, Ty, 0);
     break;
 
     // AMD64-ABI 3.2.3p3: Rule 3. If the class is SSE, the next
@@ -1415,9 +1413,7 @@
     ++neededInt;
 
     // Pick an 8-byte type based on the preferred type.
-    const llvm::Type *HiType =
-      Get8ByteTypeAtOffset(PrefType, 8, Ty, 8, getTargetData(),
-                           getVMContext(), getContext());
+    const llvm::Type *HiType = Get8ByteTypeAtOffset(PrefType, 8, Ty, 8);
     ResType = llvm::StructType::get(getVMContext(), ResType, HiType, NULL);
     break;
   }





More information about the cfe-commits mailing list