[cfe-commits] r114618 - in /cfe/trunk: lib/CodeGen/TargetInfo.cpp test/CodeGen/arm-vector-arguments.c

Daniel Dunbar daniel at zuster.org
Wed Sep 22 18:54:28 PDT 2010


Author: ddunbar
Date: Wed Sep 22 20:54:28 2010
New Revision: 114618

URL: http://llvm.org/viewvc/llvm-project?rev=114618&view=rev
Log:
IRgen/ABI/ARM: Trust the backend to pass vectors correctly for the given ABI.
 - Therefore, we can lower out the NEON wrapper structs and pass the vectors
   directly. This makes a huge difference in the cleanliness of the IR after
   optimization.
 - I will trust, but verify, via future ABITest testing (for APCS-GNU, at
   least).

Added:
    cfe/trunk/test/CodeGen/arm-vector-arguments.c
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=114618&r1=114617&r2=114618&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Sep 22 20:54:28 2010
@@ -2272,6 +2272,17 @@
   if (isRecordWithNonTrivialDestructorOrCopyConstructor(Ty))
     return ABIArgInfo::getIndirect(0, /*ByVal=*/false);
 
+  // NEON vectors are implemented as (theoretically) opaque structures wrapping
+  // the underlying vector type. We trust the backend to pass the underlying
+  // vectors appropriately, so we can unwrap the structs which generally will
+  // lead to much cleaner IR.
+  if (const Type *SeltTy = isSingleElementStruct(Ty, getContext())) {
+    if (SeltTy->isVectorType())
+      return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0)));
+  }
+
+  // Otherwise, pass by coercing to a structure of the appropriate size.
+  //
   // FIXME: This is kind of nasty... but there isn't much choice because the ARM
   // backend doesn't support byval.
   // FIXME: This doesn't handle alignment > 64 bits.

Added: cfe/trunk/test/CodeGen/arm-vector-arguments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-vector-arguments.c?rev=114618&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/arm-vector-arguments.c (added)
+++ cfe/trunk/test/CodeGen/arm-vector-arguments.c Wed Sep 22 20:54:28 2010
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple thumbv7-apple-darwin9 \
+// RUN:   -target-abi apcs-gnu \
+// RUN:   -target-cpu cortex-a8 \
+// RUN:   -mfloat-abi soft \
+// RUN:   -target-feature +soft-float-abi \
+// RUN:   -emit-llvm -w -o - %s | FileCheck %s
+
+#include <arm_neon.h>
+
+// CHECK: define void @f0(%struct.__simd128_int8_t* sret %agg.result, <16 x i8> %{{.*}}, <16 x i8> %{{.*}})
+int8x16_t f0(int8x16_t a0, int8x16_t a1) {
+  return vzipq_s8(a0, a1).val[0];
+}





More information about the cfe-commits mailing list