Skip to content

Commit 3f40dbb

Browse files
committed
[PowerPC][AIX] Enable passing vectors in variadic functions.
Differential Revision: https://reviews.llvm.org/D97474
1 parent 040c1b4 commit 3f40dbb

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

clang/lib/CodeGen/TargetInfo.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4563,10 +4563,6 @@ Address AIXABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
45634563
if (Ty->isAnyComplexType())
45644564
llvm::report_fatal_error("complex type is not supported on AIX yet");
45654565

4566-
if (Ty->isVectorType())
4567-
llvm::report_fatal_error(
4568-
"vector types are not yet supported for variadic functions on AIX");
4569-
45704566
auto TypeInfo = getContext().getTypeInfoInChars(Ty);
45714567
TypeInfo.Align = getParamTypeAlignment(Ty);
45724568

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// REQUIRES: powerpc-registered-target
2+
// RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -target-feature +altivec -target-cpu pwr7 -o - %s | FileCheck %s --check-prefixes=CHECK,AIX32
3+
// RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm -target-feature +altivec -target-cpu pwr7 -o - %s | FileCheck %s --check-prefixes=CHECK,AIX64
4+
5+
vector double vector_varargs(int count, ...) {
6+
__builtin_va_list arg_list;
7+
__builtin_va_start(arg_list, count);
8+
9+
vector double ret;
10+
11+
for (int i = 0; i != count; ++i) {
12+
ret = __builtin_va_arg(arg_list, vector double);
13+
}
14+
15+
__builtin_va_end(arg_list);
16+
return ret;
17+
}
18+
19+
// CHECK: %arg_list = alloca i8*
20+
// CHECK: %arg_list1 = bitcast i8** %arg_list to i8*
21+
// CHECK: call void @llvm.va_start(i8* %arg_list1)
22+
23+
// AIX32: for.body:
24+
// AIX32-NEXT: %argp.cur = load i8*, i8** %arg_list, align 4
25+
// AIX32-NEXT: %2 = ptrtoint i8* %argp.cur to i32
26+
// AIX32-NEXT: %3 = add i32 %2, 15
27+
// AIX32-NEXT: %4 = and i32 %3, -16
28+
// AIX32-NEXT: %argp.cur.aligned = inttoptr i32 %4 to i8*
29+
// AIX32-NEXT: %argp.next = getelementptr inbounds i8, i8* %argp.cur.aligned, i32 16
30+
// AIX32-NEXT: store i8* %argp.next, i8** %arg_list, align 4
31+
// AIX32-NEXT: %5 = bitcast i8* %argp.cur.aligned to <2 x double>*
32+
// AIX32-NEXT: %6 = load <2 x double>, <2 x double>* %5, align 16
33+
// AIX32-NEXT: store <2 x double> %6, <2 x double>* %ret, align 16
34+
// AIX32-NEXT: br label %for.inc
35+
36+
// AIX64: for.body:
37+
// AIX64-NEXT: %argp.cur = load i8*, i8** %arg_list, align 8
38+
// AIX64-NEXT: %2 = ptrtoint i8* %argp.cur to i64
39+
// AIX64-NEXT: %3 = add i64 %2, 15
40+
// AIX64-NEXT: %4 = and i64 %3, -16
41+
// AIX64-NEXT: %argp.cur.aligned = inttoptr i64 %4 to i8*
42+
// AIX64-NEXT: %argp.next = getelementptr inbounds i8, i8* %argp.cur.aligned, i64 16
43+
// AIX64-NEXT: store i8* %argp.next, i8** %arg_list, align 8
44+
// AIX64-NEXT: %5 = bitcast i8* %argp.cur.aligned to <2 x double>*
45+
// AIX64-NEXT: %6 = load <2 x double>, <2 x double>* %5, align 16
46+
// AIX64-NEXT: store <2 x double> %6, <2 x double>* %ret, align 16
47+
// AIX64-NEXT: br label %for.inc
48+
49+
50+
// CHECK: for.end:
51+
// CHECK: %arg_list2 = bitcast i8** %arg_list to i8*
52+
// CHECK: call void @llvm.va_end(i8* %arg_list2)

0 commit comments

Comments
 (0)