Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -faltivec -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s |
Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 2 | |
| 3 | #include <stdarg.h> |
| 4 | |
| 5 | struct test1 { int x; int y; }; |
| 6 | struct test2 { int x; int y; } __attribute__((aligned (16))); |
| 7 | struct test3 { int x; int y; } __attribute__((aligned (32))); |
| 8 | struct test4 { int x; int y; int z; }; |
Ulrich Weigand | 601957f | 2014-07-21 00:56:36 +0000 | [diff] [blame] | 9 | struct test5 { int x[17]; }; |
| 10 | struct test6 { int x[17]; } __attribute__((aligned (16))); |
| 11 | struct test7 { int x[17]; } __attribute__((aligned (32))); |
Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 12 | |
Ulrich Weigand | 601957f | 2014-07-21 00:56:36 +0000 | [diff] [blame] | 13 | // CHECK: define void @test1(i32 signext %x, i64 %y.coerce) |
Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 14 | void test1 (int x, struct test1 y) |
| 15 | { |
| 16 | } |
| 17 | |
Ulrich Weigand | 601957f | 2014-07-21 00:56:36 +0000 | [diff] [blame] | 18 | // CHECK: define void @test2(i32 signext %x, [1 x i128] %y.coerce) |
Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 19 | void test2 (int x, struct test2 y) |
| 20 | { |
| 21 | } |
| 22 | |
Ulrich Weigand | 601957f | 2014-07-21 00:56:36 +0000 | [diff] [blame] | 23 | // CHECK: define void @test3(i32 signext %x, [2 x i128] %y.coerce) |
Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 24 | void test3 (int x, struct test3 y) |
| 25 | { |
| 26 | } |
| 27 | |
Ulrich Weigand | 601957f | 2014-07-21 00:56:36 +0000 | [diff] [blame] | 28 | // CHECK: define void @test4(i32 signext %x, [2 x i64] %y.coerce) |
Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 29 | void test4 (int x, struct test4 y) |
| 30 | { |
| 31 | } |
| 32 | |
Ulrich Weigand | 601957f | 2014-07-21 00:56:36 +0000 | [diff] [blame] | 33 | // CHECK: define void @test5(i32 signext %x, %struct.test5* byval align 8 %y) |
| 34 | void test5 (int x, struct test5 y) |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | // CHECK: define void @test6(i32 signext %x, %struct.test6* byval align 16 %y) |
| 39 | void test6 (int x, struct test6 y) |
| 40 | { |
| 41 | } |
| 42 | |
| 43 | // This case requires run-time realignment of the incoming struct |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 44 | // CHECK-LABEL: define void @test7(i32 signext %x, %struct.test7* byval align 16) |
Ulrich Weigand | 601957f | 2014-07-21 00:56:36 +0000 | [diff] [blame] | 45 | // CHECK: %y = alloca %struct.test7, align 32 |
| 46 | // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64 |
| 47 | void test7 (int x, struct test7 y) |
| 48 | { |
| 49 | } |
| 50 | |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 51 | // CHECK-LABEL: define void @test1va(%struct.test1* noalias sret %agg.result, i32 signext %x, ...) |
| 52 | // CHECK: %y = alloca %struct.test1, align 4 |
David Blaikie | a953f28 | 2015-02-27 21:19:58 +0000 | [diff] [blame] | 53 | // CHECK: %[[CUR:[^ ]+]] = load i8*, i8** %ap |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 54 | // CHECK: %[[NEXT:[^ ]+]] = getelementptr inbounds i8, i8* %[[CUR]], i64 8 |
Ulrich Weigand | b415325 | 2014-07-10 19:19:03 +0000 | [diff] [blame] | 55 | // CHECK: store i8* %[[NEXT]], i8** %ap |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 56 | // CHECK: [[T0:%.*]] = bitcast i8* %[[CUR]] to %struct.test1* |
| 57 | // CHECK: [[DEST:%.*]] = bitcast %struct.test1* %y to i8* |
| 58 | // CHECK: [[SRC:%.*]] = bitcast %struct.test1* [[T0]] to i8* |
Pete Cooper | 3b39e88 | 2015-11-19 05:55:59 +0000 | [diff] [blame] | 59 | // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DEST]], i8* [[SRC]], i64 8, i32 4, i1 false) |
Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 60 | struct test1 test1va (int x, ...) |
| 61 | { |
| 62 | struct test1 y; |
| 63 | va_list ap; |
| 64 | va_start(ap, x); |
| 65 | y = va_arg (ap, struct test1); |
| 66 | va_end(ap); |
| 67 | return y; |
| 68 | } |
| 69 | |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 70 | // CHECK-LABEL: define void @test2va(%struct.test2* noalias sret %agg.result, i32 signext %x, ...) |
| 71 | // CHECK: %y = alloca %struct.test2, align 16 |
David Blaikie | a953f28 | 2015-02-27 21:19:58 +0000 | [diff] [blame] | 72 | // CHECK: %[[CUR:[^ ]+]] = load i8*, i8** %ap |
Ulrich Weigand | b415325 | 2014-07-10 19:19:03 +0000 | [diff] [blame] | 73 | // CHECK: %[[TMP0:[^ ]+]] = ptrtoint i8* %[[CUR]] to i64 |
| 74 | // CHECK: %[[TMP1:[^ ]+]] = add i64 %[[TMP0]], 15 |
| 75 | // CHECK: %[[TMP2:[^ ]+]] = and i64 %[[TMP1]], -16 |
| 76 | // CHECK: %[[ALIGN:[^ ]+]] = inttoptr i64 %[[TMP2]] to i8* |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 77 | // CHECK: %[[NEXT:[^ ]+]] = getelementptr inbounds i8, i8* %[[ALIGN]], i64 16 |
Ulrich Weigand | b415325 | 2014-07-10 19:19:03 +0000 | [diff] [blame] | 78 | // CHECK: store i8* %[[NEXT]], i8** %ap |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 79 | // CHECK: [[T0:%.*]] = bitcast i8* %[[ALIGN]] to %struct.test2* |
| 80 | // CHECK: [[DEST:%.*]] = bitcast %struct.test2* %y to i8* |
| 81 | // CHECK: [[SRC:%.*]] = bitcast %struct.test2* [[T0]] to i8* |
Pete Cooper | 3b39e88 | 2015-11-19 05:55:59 +0000 | [diff] [blame] | 82 | // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DEST]], i8* [[SRC]], i64 16, i32 16, i1 false) |
Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 83 | struct test2 test2va (int x, ...) |
| 84 | { |
| 85 | struct test2 y; |
| 86 | va_list ap; |
| 87 | va_start(ap, x); |
| 88 | y = va_arg (ap, struct test2); |
| 89 | va_end(ap); |
| 90 | return y; |
| 91 | } |
| 92 | |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 93 | // CHECK-LABEL: define void @test3va(%struct.test3* noalias sret %agg.result, i32 signext %x, ...) |
| 94 | // CHECK: %y = alloca %struct.test3, align 32 |
David Blaikie | a953f28 | 2015-02-27 21:19:58 +0000 | [diff] [blame] | 95 | // CHECK: %[[CUR:[^ ]+]] = load i8*, i8** %ap |
Ulrich Weigand | b415325 | 2014-07-10 19:19:03 +0000 | [diff] [blame] | 96 | // CHECK: %[[TMP0:[^ ]+]] = ptrtoint i8* %[[CUR]] to i64 |
| 97 | // CHECK: %[[TMP1:[^ ]+]] = add i64 %[[TMP0]], 15 |
| 98 | // CHECK: %[[TMP2:[^ ]+]] = and i64 %[[TMP1]], -16 |
| 99 | // CHECK: %[[ALIGN:[^ ]+]] = inttoptr i64 %[[TMP2]] to i8* |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 100 | // CHECK: %[[NEXT:[^ ]+]] = getelementptr inbounds i8, i8* %[[ALIGN]], i64 32 |
Ulrich Weigand | b415325 | 2014-07-10 19:19:03 +0000 | [diff] [blame] | 101 | // CHECK: store i8* %[[NEXT]], i8** %ap |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 102 | // CHECK: [[T0:%.*]] = bitcast i8* %[[ALIGN]] to %struct.test3* |
| 103 | // CHECK: [[DEST:%.*]] = bitcast %struct.test3* %y to i8* |
| 104 | // CHECK: [[SRC:%.*]] = bitcast %struct.test3* [[T0]] to i8* |
Pete Cooper | 3b39e88 | 2015-11-19 05:55:59 +0000 | [diff] [blame] | 105 | // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DEST]], i8* [[SRC]], i64 32, i32 16, i1 false) |
Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 106 | struct test3 test3va (int x, ...) |
| 107 | { |
| 108 | struct test3 y; |
| 109 | va_list ap; |
| 110 | va_start(ap, x); |
| 111 | y = va_arg (ap, struct test3); |
| 112 | va_end(ap); |
| 113 | return y; |
| 114 | } |
| 115 | |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 116 | // CHECK-LABEL: define void @test4va(%struct.test4* noalias sret %agg.result, i32 signext %x, ...) |
| 117 | // CHECK: %y = alloca %struct.test4, align 4 |
David Blaikie | a953f28 | 2015-02-27 21:19:58 +0000 | [diff] [blame] | 118 | // CHECK: %[[CUR:[^ ]+]] = load i8*, i8** %ap |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 119 | // CHECK: %[[NEXT:[^ ]+]] = getelementptr inbounds i8, i8* %[[CUR]], i64 16 |
Ulrich Weigand | b415325 | 2014-07-10 19:19:03 +0000 | [diff] [blame] | 120 | // CHECK: store i8* %[[NEXT]], i8** %ap |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 121 | // CHECK: [[T0:%.*]] = bitcast i8* %[[CUR]] to %struct.test4* |
| 122 | // CHECK: [[DEST:%.*]] = bitcast %struct.test4* %y to i8* |
| 123 | // CHECK: [[SRC:%.*]] = bitcast %struct.test4* [[T0]] to i8* |
Pete Cooper | 3b39e88 | 2015-11-19 05:55:59 +0000 | [diff] [blame] | 124 | // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DEST]], i8* [[SRC]], i64 12, i32 4, i1 false) |
Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 125 | struct test4 test4va (int x, ...) |
| 126 | { |
| 127 | struct test4 y; |
| 128 | va_list ap; |
| 129 | va_start(ap, x); |
| 130 | y = va_arg (ap, struct test4); |
| 131 | va_end(ap); |
| 132 | return y; |
| 133 | } |
| 134 | |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 135 | // CHECK-LABEL: define void @testva_longdouble(%struct.test_longdouble* noalias sret %agg.result, i32 signext %x, ...) |
| 136 | // CHECK: %y = alloca %struct.test_longdouble, align 16 |
David Blaikie | a953f28 | 2015-02-27 21:19:58 +0000 | [diff] [blame] | 137 | // CHECK: %[[CUR:[^ ]+]] = load i8*, i8** %ap |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 138 | // CHECK: %[[NEXT:[^ ]+]] = getelementptr inbounds i8, i8* %[[CUR]], i64 16 |
Ulrich Weigand | b415325 | 2014-07-10 19:19:03 +0000 | [diff] [blame] | 139 | // CHECK: store i8* %[[NEXT]], i8** %ap |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 140 | // CHECK: [[T0:%.*]] = bitcast i8* %[[CUR]] to %struct.test_longdouble* |
| 141 | // CHECK: [[DEST:%.*]] = bitcast %struct.test_longdouble* %y to i8* |
| 142 | // CHECK: [[SRC:%.*]] = bitcast %struct.test_longdouble* [[T0]] to i8* |
Pete Cooper | 3b39e88 | 2015-11-19 05:55:59 +0000 | [diff] [blame] | 143 | // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DEST]], i8* [[SRC]], i64 16, i32 8, i1 false) |
Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 144 | struct test_longdouble { long double x; }; |
| 145 | struct test_longdouble testva_longdouble (int x, ...) |
| 146 | { |
| 147 | struct test_longdouble y; |
| 148 | va_list ap; |
| 149 | va_start(ap, x); |
| 150 | y = va_arg (ap, struct test_longdouble); |
| 151 | va_end(ap); |
| 152 | return y; |
| 153 | } |
| 154 | |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 155 | // CHECK-LABEL: define void @testva_vector(%struct.test_vector* noalias sret %agg.result, i32 signext %x, ...) |
| 156 | // CHECK: %y = alloca %struct.test_vector, align 16 |
David Blaikie | a953f28 | 2015-02-27 21:19:58 +0000 | [diff] [blame] | 157 | // CHECK: %[[CUR:[^ ]+]] = load i8*, i8** %ap |
Ulrich Weigand | b415325 | 2014-07-10 19:19:03 +0000 | [diff] [blame] | 158 | // CHECK: %[[TMP0:[^ ]+]] = ptrtoint i8* %[[CUR]] to i64 |
| 159 | // CHECK: %[[TMP1:[^ ]+]] = add i64 %[[TMP0]], 15 |
| 160 | // CHECK: %[[TMP2:[^ ]+]] = and i64 %[[TMP1]], -16 |
| 161 | // CHECK: %[[ALIGN:[^ ]+]] = inttoptr i64 %[[TMP2]] to i8* |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 162 | // CHECK: %[[NEXT:[^ ]+]] = getelementptr inbounds i8, i8* %[[ALIGN]], i64 16 |
Ulrich Weigand | b415325 | 2014-07-10 19:19:03 +0000 | [diff] [blame] | 163 | // CHECK: store i8* %[[NEXT]], i8** %ap |
John McCall | 7f416cc | 2015-09-08 08:05:57 +0000 | [diff] [blame] | 164 | // CHECK: [[T0:%.*]] = bitcast i8* %[[ALIGN]] to %struct.test_vector* |
| 165 | // CHECK: [[DEST:%.*]] = bitcast %struct.test_vector* %y to i8* |
| 166 | // CHECK: [[SRC:%.*]] = bitcast %struct.test_vector* [[T0]] to i8* |
Pete Cooper | 3b39e88 | 2015-11-19 05:55:59 +0000 | [diff] [blame] | 167 | // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DEST]], i8* [[SRC]], i64 16, i32 16, i1 false) |
Ulrich Weigand | 581badc | 2014-07-10 17:20:07 +0000 | [diff] [blame] | 168 | struct test_vector { vector int x; }; |
| 169 | struct test_vector testva_vector (int x, ...) |
| 170 | { |
| 171 | struct test_vector y; |
| 172 | va_list ap; |
| 173 | va_start(ap, x); |
| 174 | y = va_arg (ap, struct test_vector); |
| 175 | va_end(ap); |
| 176 | return y; |
| 177 | } |
| 178 | |