[cfe-commits] r112211 - in /cfe/trunk: lib/CodeGen/TargetInfo.cpp test/CodeGen/x86_32-arguments.c

Chris Lattner sabre at nondot.org
Thu Aug 26 13:05:13 PDT 2010


Author: lattner
Date: Thu Aug 26 15:05:13 2010
New Revision: 112211

URL: http://llvm.org/viewvc/llvm-project?rev=112211&view=rev
Log:
fix 2xi16 to pass as i32 instead of <2 x i16>.  The former passes in
memory (as required) the later now passes in an xmm register.  This
fixes gcc.dg/compat/vector_1 on x86-32.

Modified:
    cfe/trunk/lib/CodeGen/TargetInfo.cpp
    cfe/trunk/test/CodeGen/x86_32-arguments.c

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=112211&r1=112210&r2=112211&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Thu Aug 26 15:05:13 2010
@@ -589,6 +589,25 @@
     return getIndirectResult(Ty);
   }
 
+  if (const VectorType *VT = Ty->getAs<VectorType>()) {
+    // On Darwin, some vectors are returned in registers.
+    if (IsDarwinVectorABI) {
+      uint64_t Size = getContext().getTypeSize(Ty);
+      
+       // Always return in register if it fits in a general purpose
+      // register, or if it is 64 bits and has a single element.
+      if ((Size == 8 || Size == 16 || Size == 32) ||
+          (Size == 64 && VT->getNumElements() == 1))
+        return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(),
+                                                            Size));
+      
+      return ABIArgInfo::getIndirect(0);
+    }
+    
+    return ABIArgInfo::getDirect();
+  }
+  
+  
   if (const EnumType *EnumTy = Ty->getAs<EnumType>())
     Ty = EnumTy->getDecl()->getIntegerType();
 

Modified: cfe/trunk/test/CodeGen/x86_32-arguments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_32-arguments.c?rev=112211&r1=112210&r2=112211&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/x86_32-arguments.c (original)
+++ cfe/trunk/test/CodeGen/x86_32-arguments.c Thu Aug 26 15:05:13 2010
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fblocks -triple i386-apple-darwin9 -emit-llvm -o %t %s
+// RUN: %clang_cc1 -w -fblocks -triple i386-apple-darwin9 -emit-llvm -o %t %s
 // RUN: FileCheck < %t %s
 
 // CHECK: define signext i8 @f0()
@@ -214,3 +214,9 @@
   int y;
 };
 void f53(struct s53 x) {}
+
+typedef unsigned short v2i16 __attribute__((__vector_size__(4)));
+
+// CHECK: define i32 @f54(i32 %arg.coerce)
+v2i16 f54(v2i16 arg) { return arg+arg; }
+





More information about the cfe-commits mailing list