]> granicus.if.org Git - clang/commitdiff
fix 2xi16 to pass as i32 instead of <2 x i16>. The former passes in
authorChris Lattner <sabre@nondot.org>
Thu, 26 Aug 2010 20:05:13 +0000 (20:05 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 26 Aug 2010 20:05:13 +0000 (20:05 +0000)
memory (as required) the later now passes in an xmm register.  This
fixes gcc.dg/compat/vector_1 on x86-32.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112211 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetInfo.cpp
test/CodeGen/x86_32-arguments.c

index 958f740bec38342b02e1d8684a1b5101eee9ebe4..05bea0cf85972daa2a71c0258b008b7a029e5471 100644 (file)
@@ -589,6 +589,25 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty) const {
     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();
 
index 01c3e236f3bdc7bcd98fdf59f24ed9faec51e557..4f2a6a3a38e46619bfa19cda2b7d19b52f8e4f93 100644 (file)
@@ -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 @@ struct __attribute__((aligned(32))) s53 {
   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; }
+