blob: f345acf453d7f82a00a11d8184fd34fc7ee43863 [file] [log] [blame]
Tim Northover00ed9962014-03-29 10:18:08 +00001; RUN: llc -mtriple=arm64-linux-gnu -enable-misched=false < %s | FileCheck %s
2
3@var = global i32 0, align 4
4
Pete Cooper2bbbd8b52015-04-17 21:31:25 +00005; CHECK-LABEL: @test_i128_align
Tim Northover00ed9962014-03-29 10:18:08 +00006define i128 @test_i128_align(i32, i128 %arg, i32 %after) {
7 store i32 %after, i32* @var, align 4
8; CHECK: str w4, [{{x[0-9]+}}, :lo12:var]
9
10 ret i128 %arg
11; CHECK: mov x0, x2
12; CHECK: mov x1, x3
13}
14
Pete Cooper2bbbd8b52015-04-17 21:31:25 +000015; CHECK-LABEL: @test_i64x2_align
16define [2 x i64] @test_i64x2_align(i32, [2 x i64] %arg, i32 %after) {
17 store i32 %after, i32* @var, align 4
18; CHECK: str w3, [{{x[0-9]+}}, :lo12:var]
19
20 ret [2 x i64] %arg
21; CHECK: mov x0, x1
22; CHECK: mov x1, x2
23}
24
Tim Northover00ed9962014-03-29 10:18:08 +000025@var64 = global i64 0, align 8
26
27 ; Check stack slots are 64-bit at all times.
28define void @test_stack_slots([8 x i32], i1 %bool, i8 %char, i16 %short,
29 i32 %int, i64 %long) {
30 ; Part of last store. Blasted scheduler.
31; CHECK: ldr [[LONG:x[0-9]+]], [sp, #32]
32
33 %ext_bool = zext i1 %bool to i64
34 store volatile i64 %ext_bool, i64* @var64, align 8
James Molloyccc7f982014-05-07 11:28:36 +000035; CHECK: ldrb w[[EXT:[0-9]+]], [sp]
Tim Northover00ed9962014-03-29 10:18:08 +000036; CHECK: and x[[EXTED:[0-9]+]], x[[EXT]], #0x1
37; CHECK: str x[[EXTED]], [{{x[0-9]+}}, :lo12:var64]
38
39 %ext_char = zext i8 %char to i64
40 store volatile i64 %ext_char, i64* @var64, align 8
41; CHECK: ldrb w[[EXT:[0-9]+]], [sp, #8]
42; CHECK: str x[[EXT]], [{{x[0-9]+}}, :lo12:var64]
43
44 %ext_short = zext i16 %short to i64
45 store volatile i64 %ext_short, i64* @var64, align 8
46; CHECK: ldrh w[[EXT:[0-9]+]], [sp, #16]
47; CHECK: str x[[EXT]], [{{x[0-9]+}}, :lo12:var64]
48
49 %ext_int = zext i32 %int to i64
50 store volatile i64 %ext_int, i64* @var64, align 8
James Molloyccc7f982014-05-07 11:28:36 +000051; CHECK: ldr{{b?}} w[[EXT:[0-9]+]], [sp, #24]
Tim Northover00ed9962014-03-29 10:18:08 +000052; CHECK: str x[[EXT]], [{{x[0-9]+}}, :lo12:var64]
53
54 store volatile i64 %long, i64* @var64, align 8
55; CHECK: str [[LONG]], [{{x[0-9]+}}, :lo12:var64]
56
57 ret void
58}
59
60; Make sure the callee does extensions (in the absence of zext/sext
61; keyword on args) while we're here.
62
63define void @test_extension(i1 %bool, i8 %char, i16 %short, i32 %int) {
64 %ext_bool = zext i1 %bool to i64
65 store volatile i64 %ext_bool, i64* @var64
66; CHECK: and [[EXT:x[0-9]+]], x0, #0x1
67; CHECK: str [[EXT]], [{{x[0-9]+}}, :lo12:var64]
68
69 %ext_char = sext i8 %char to i64
70 store volatile i64 %ext_char, i64* @var64
Jim Grosbach0fba6d92014-04-17 20:47:31 +000071; CHECK: sxtb [[EXT:x[0-9]+]], w1
Tim Northover00ed9962014-03-29 10:18:08 +000072; CHECK: str [[EXT]], [{{x[0-9]+}}, :lo12:var64]
73
74 %ext_short = zext i16 %short to i64
75 store volatile i64 %ext_short, i64* @var64
76; CHECK: and [[EXT:x[0-9]+]], x2, #0xffff
77; CHECK: str [[EXT]], [{{x[0-9]+}}, :lo12:var64]
78
79 %ext_int = zext i32 %int to i64
80 store volatile i64 %ext_int, i64* @var64
Tim Northover2a9d8012015-07-29 21:34:32 +000081; CHECK: mov w[[EXT:[0-9]+]], w3
82; CHECK: str x[[EXT]], [{{x[0-9]+}}, :lo12:var64]
Tim Northover00ed9962014-03-29 10:18:08 +000083
84 ret void
85}
86
87declare void @variadic(i32 %a, ...)
88
89 ; Under AAPCS variadic functions have the same calling convention as
90 ; others. The extra arguments should go in registers rather than on the stack.
91define void @test_variadic() {
David Blaikie23af6482015-04-16 23:24:18 +000092 call void(i32, ...) @variadic(i32 0, i64 1, double 2.0)
Tim Northover00ed9962014-03-29 10:18:08 +000093; CHECK: fmov d0, #2.0
Tim Northover18f68f62014-04-16 11:52:51 +000094; CHECK: orr w1, wzr, #0x1
Tim Northover00ed9962014-03-29 10:18:08 +000095; CHECK: bl variadic
96 ret void
97}
Tim Northover97c5b6f2014-04-16 09:03:25 +000098
99; We weren't marking x7 as used after deciding that the i128 didn't fit into
100; registers and putting the first half on the stack, so the *second* half went
101; into x7. Yuck!
102define i128 @test_i128_shadow([7 x i64] %x0_x6, i128 %sp) {
103; CHECK-LABEL: test_i128_shadow:
104; CHECK: ldp x0, x1, [sp]
105
106 ret i128 %sp
107}
Jiangning Liu533b5602014-04-25 12:07:03 +0000108
109; This test is to check if fp128 can be correctly handled on stack.
110define fp128 @test_fp128([8 x float] %arg0, fp128 %arg1) {
111; CHECK-LABEL: test_fp128:
112; CHECK: ldr {{q[0-9]+}}, [sp]
113 ret fp128 %arg1
114}
Jiangning Liucc4f38b2014-06-03 03:25:09 +0000115
116; Check if VPR can be correctly pass by stack.
117define <2 x double> @test_vreg_stack([8 x <2 x double>], <2 x double> %varg_stack) {
118entry:
119; CHECK-LABEL: test_vreg_stack:
120; CHECK: ldr {{q[0-9]+}}, [sp]
121 ret <2 x double> %varg_stack;
122}
Oliver Stannard6eda6ff2014-07-11 13:33:46 +0000123
124; Check that f16 can be passed and returned (ACLE 2.0 extension)
125define half @test_half(float, half %arg) {
126; CHECK-LABEL: test_half:
Oliver Stannard89d15422014-08-27 16:16:04 +0000127; CHECK: mov v0.16b, v1.16b
Oliver Stannard6eda6ff2014-07-11 13:33:46 +0000128 ret half %arg;
129}
130
131; Check that f16 constants are materialized correctly
132define half @test_half_const() {
133; CHECK-LABEL: test_half_const:
134; CHECK: ldr h0, [x{{[0-9]+}}, :lo12:{{.*}}]
135 ret half 0xH4248
136}
Oliver Stannard89d15422014-08-27 16:16:04 +0000137
138; Check that v4f16 can be passed and returned in registers
139define <4 x half> @test_v4_half_register(float, <4 x half> %arg) {
140; CHECK-LABEL: test_v4_half_register:
141; CHECK: mov v0.16b, v1.16b
142 ret <4 x half> %arg;
143}
144
145; Check that v8f16 can be passed and returned in registers
146define <8 x half> @test_v8_half_register(float, <8 x half> %arg) {
147; CHECK-LABEL: test_v8_half_register:
148; CHECK: mov v0.16b, v1.16b
149 ret <8 x half> %arg;
150}
151
152; Check that v4f16 can be passed and returned on the stack
153define <4 x half> @test_v4_half_stack([8 x <2 x double>], <4 x half> %arg) {
154; CHECK-LABEL: test_v4_half_stack:
155; CHECK: ldr d0, [sp]
156 ret <4 x half> %arg;
157}
158
159; Check that v8f16 can be passed and returned on the stack
160define <8 x half> @test_v8_half_stack([8 x <2 x double>], <8 x half> %arg) {
161; CHECK-LABEL: test_v8_half_stack:
162; CHECK: ldr q0, [sp]
163 ret <8 x half> %arg;
164}