r235231 - Change AArch64 i128 returns to use [2 x i64] when possible.

Pete Cooper peter_cooper at apple.com
Fri Apr 17 15:16:24 PDT 2015


Author: pete
Date: Fri Apr 17 17:16:24 2015
New Revision: 235231

URL: http://llvm.org/viewvc/llvm-project?rev=235231&view=rev
Log:
Change AArch64 i128 returns to use [2 x i64] when possible.

Something like { void*, void * } would be passed to a function as a [2 x i64], but returned as an i128.  This patch unifies the 2 behaviours so that we also return it as a [2 x i64].

This is better for the quality of the IR, and the size of the final LLVM binary as we tend to want to insert/extract values from these types and do so with the insert/extract instructions is less IR than shifting, truncating, and or'ing values.

Reviewed by Tim Northover.

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

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=235231&r1=235230&r2=235231&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri Apr 17 17:16:24 2015
@@ -4044,7 +4044,15 @@ ABIArgInfo AArch64ABIInfo::classifyRetur
   // Aggregates <= 16 bytes are returned directly in registers or on the stack.
   uint64_t Size = getContext().getTypeSize(RetTy);
   if (Size <= 128) {
+    unsigned Alignment = getContext().getTypeAlign(RetTy);
     Size = 64 * ((Size + 63) / 64); // round up to multiple of 8 bytes
+
+    // We use a pair of i64 for 16-byte aggregate with 8-byte alignment.
+    // For aggregates with 16-byte alignment, we use i128.
+    if (Alignment < 128 && Size == 128) {
+      llvm::Type *BaseTy = llvm::Type::getInt64Ty(getVMContext());
+      return ABIArgInfo::getDirect(llvm::ArrayType::get(BaseTy, Size / 64));
+    }
     return ABIArgInfo::getDirect(llvm::IntegerType::get(getVMContext(), Size));
   }
 

Modified: cfe/trunk/test/CodeGen/arm64-arguments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm64-arguments.c?rev=235231&r1=235230&r2=235231&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/arm64-arguments.c (original)
+++ cfe/trunk/test/CodeGen/arm64-arguments.c Fri Apr 17 17:16:24 2015
@@ -92,7 +92,7 @@ struct s21 f21(void) {}
 // CHECK: define i64 @f22()
 // CHECK: define i64 @f23()
 // CHECK: define i64 @f24()
-// CHECK: define i128 @f25()
+// CHECK: define [2 x i64] @f25()
 // CHECK: define { float, float } @f26()
 // CHECK: define { double, double } @f27()
 _Complex char       f22(void) {}





More information about the cfe-commits mailing list