[llvm-commits] [dragonegg] r94885 - /dragonegg/trunk/llvm-abi.h

Duncan Sands baldrick at free.fr
Sat Jan 30 05:43:42 PST 2010


Author: baldrick
Date: Sat Jan 30 07:43:42 2010
New Revision: 94885

URL: http://llvm.org/viewvc/llvm-project?rev=94885&view=rev
Log:
Port llvm-gcc commit 93374 (bwilson) from llvm-gcc:
Fix some trailing whitespace in my previous change, and make the same fixes
to the SVR4ABI version of PassInIntegerRegisters.

Modified:
    dragonegg/trunk/llvm-abi.h

Modified: dragonegg/trunk/llvm-abi.h
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/llvm-abi.h?rev=94885&r1=94884&r2=94885&view=diff

==============================================================================
--- dragonegg/trunk/llvm-abi.h (original)
+++ dragonegg/trunk/llvm-abi.h Sat Jan 30 07:43:42 2010
@@ -626,7 +626,7 @@
     unsigned ElementSize = UseInt64 ? 8:4;
     unsigned ArraySize = Size / ElementSize;
 
-    // Put as much of the aggregate as possible into an array. 
+    // Put as much of the aggregate as possible into an array.
     const Type *ATy = NULL;
     const Type *ArrayElementType = NULL;
     if (ArraySize) {
@@ -655,7 +655,7 @@
       if (Size != getTargetData().getTypeAllocSize(LastEltTy))
         LastEltRealSize = Size;
     }
-    
+
     const StructType *STy = StructType::get(getGlobalContext(), Elts, false);
 
     unsigned i = 0;
@@ -1065,8 +1065,9 @@
     // from Int64 alignment. ARM backend needs this.
     unsigned Align = TYPE_ALIGN(type)/8;
     unsigned Int64Align =
-        getTargetData().getABITypeAlignment(Type::getInt64Ty(getGlobalContext()));
-    bool UseInt64 = DontCheckAlignment ? true : (Align >= Int64Align);
+      getTargetData().getABITypeAlignment(Type::getInt64Ty(getGlobalContext()));
+    bool UseInt64 = (getTargetData().isLegalInteger(64) &&
+                     (DontCheckAlignment || Align >= Int64Align));
 
     // FIXME: In cases where we can, we should use the original struct.
     // Consider cases like { int, int } and {int, short} for example!  This will
@@ -1076,29 +1077,36 @@
     unsigned ElementSize = UseInt64 ? 8:4;
     unsigned ArraySize = Size / ElementSize;
 
+    // Put as much of the aggregate as possible into an array.
     const Type *ATy = NULL;
     const Type *ArrayElementType = NULL;
     if (ArraySize) {
       Size = Size % ElementSize;
-      ArrayElementType = (UseInt64) ?
-          Type::getInt64Ty(getGlobalContext()) : Type::getInt32Ty(getGlobalContext());
+      ArrayElementType = (UseInt64 ?
+                          Type::getInt64Ty(getGlobalContext()) :
+                          Type::getInt32Ty(getGlobalContext()));
       ATy = ArrayType::get(ArrayElementType, ArraySize);
       Elts.push_back(ATy);
     }
 
-    if (Size >= 4) {
-      Elts.push_back(Type::getInt32Ty(getGlobalContext()));
-      Size -= 4;
-    }
-    if (Size >= 2) {
-      Elts.push_back(Type::getInt16Ty(getGlobalContext()));
-      Size -= 2;
-    }
-    if (Size >= 1) {
-      Elts.push_back(Type::getInt8Ty(getGlobalContext()));
-      Size -= 1;
+    // Pass any leftover bytes as a separate element following the array.
+    unsigned LastEltRealSize = 0;
+    const llvm::Type *LastEltTy = 0;
+    if (Size > 4) {
+      LastEltTy = Type::getInt64Ty(getGlobalContext());
+    } else if (Size > 2) {
+      LastEltTy = Type::getInt32Ty(getGlobalContext());
+    } else if (Size > 1) {
+      LastEltTy = Type::getInt16Ty(getGlobalContext());
+    } else if (Size > 0) {
+      LastEltTy = Type::getInt8Ty(getGlobalContext());
+    }
+    if (LastEltTy) {
+      Elts.push_back(LastEltTy);
+      if (Size != getTargetData().getTypeAllocSize(LastEltTy))
+        LastEltRealSize = Size;
     }
-    assert(Size == 0 && "Didn't cover value?");
+
     const StructType *STy = StructType::get(getGlobalContext(), Elts, false);
 
     unsigned i = 0;
@@ -1113,10 +1121,10 @@
       C.ExitField();
       ++i;
     }
-    for (unsigned e = Elts.size(); i != e; ++i) {
+    if (LastEltTy) {
       C.EnterField(i, STy);
-      C.HandleScalarArgument(Elts[i], 0);
-      ScalarElts.push_back(Elts[i]);
+      C.HandleScalarArgument(LastEltTy, 0, LastEltRealSize);
+      ScalarElts.push_back(LastEltTy);
       C.ExitField();
     }
   }





More information about the llvm-commits mailing list