120
|
1 ; RUN: llc < %s -march=avr | FileCheck %s
|
|
2
|
|
3 declare void @foo(i16*, i16*, i8*)
|
|
4
|
|
5 define void @test1(i16 %x) {
|
|
6 ; CHECK-LABEL: test1:
|
|
7 ; CHECK: out 61, r28
|
|
8 ; SP copy
|
|
9 ; CHECK-NEXT: in [[SPCOPY1:r[0-9]+]], 61
|
|
10 ; CHECK-NEXT: in [[SPCOPY2:r[0-9]+]], 62
|
|
11 ; allocate first dynalloca
|
|
12 ; CHECK: in {{.*}}, 61
|
|
13 ; CHECK: in {{.*}}, 62
|
|
14 ; CHECK: sub
|
|
15 ; CHECK: sbc
|
|
16 ; CHECK: in r0, 63
|
|
17 ; CHECK-NEXT: cli
|
|
18 ; CHECK-NEXT: out 62, {{.*}}
|
|
19 ; CHECK-NEXT: out 63, r0
|
|
20 ; CHECK-NEXT: out 61, {{.*}}
|
|
21 ; Test writes
|
|
22 ; CHECK: std Z+12, {{.*}}
|
|
23 ; CHECK: std Z+13, {{.*}}
|
|
24 ; CHECK: std Z+7, {{.*}}
|
|
25 ; CHECK-NOT: std
|
|
26 ; Test SP restore
|
|
27 ; CHECK: in r0, 63
|
|
28 ; CHECK-NEXT: cli
|
|
29 ; CHECK-NEXT: out 62, [[SPCOPY2]]
|
|
30 ; CHECK-NEXT: out 63, r0
|
|
31 ; CHECK-NEXT: out 61, [[SPCOPY1]]
|
|
32 %a = alloca [8 x i16]
|
|
33 %vla = alloca i16, i16 %x
|
|
34 %add = shl nsw i16 %x, 1
|
|
35 %vla1 = alloca i8, i16 %add
|
|
36 %arrayidx = getelementptr inbounds [8 x i16], [8 x i16]* %a, i16 0, i16 2
|
|
37 store i16 3, i16* %arrayidx
|
|
38 %arrayidx2 = getelementptr inbounds i16, i16* %vla, i16 6
|
|
39 store i16 4, i16* %arrayidx2
|
|
40 %arrayidx3 = getelementptr inbounds i8, i8* %vla1, i16 7
|
|
41 store i8 44, i8* %arrayidx3
|
|
42 %arraydecay = getelementptr inbounds [8 x i16], [8 x i16]* %a, i16 0, i16 0
|
|
43 call void @foo(i16* %arraydecay, i16* %vla, i8* %vla1)
|
|
44 ret void
|
|
45 }
|
|
46
|
|
47 declare void @foo2(i16*, i64, i64, i64)
|
|
48
|
|
49 ; Test that arguments are passed through pushes into the call instead of
|
|
50 ; allocating the call frame space in the prologue. Also test that SP is restored
|
|
51 ; after the call frame is restored and not before.
|
|
52 define void @dynalloca2(i16 %x) {
|
|
53 ; CHECK-LABEL: dynalloca2:
|
|
54 ; CHECK: in [[SPCOPY1:r[0-9]+]], 61
|
|
55 ; CHECK: in [[SPCOPY2:r[0-9]+]], 62
|
|
56 ; CHECK: push
|
|
57 ; CHECK-NOT: st
|
|
58 ; CHECK-NOT: std
|
|
59 ; CHECK: call
|
|
60 ; Call frame restore
|
|
61 ; CHECK-NEXT: in r30, 61
|
|
62 ; CHECK-NEXT: in r31, 62
|
|
63 ; CHECK-NEXT: adiw r30, 8
|
|
64 ; CHECK-NEXT: in r0, 63
|
|
65 ; CHECK-NEXT: cli
|
|
66 ; CHECK-NEXT: out 62, r31
|
|
67 ; CHECK-NEXT: out 63, r0
|
|
68 ; CHECK-NEXT: out 61, r30
|
|
69 ; SP restore
|
|
70 ; CHECK: in r0, 63
|
|
71 ; CHECK-NEXT: cli
|
121
|
72 ; CHECK-NEXT: out 62, r7
|
120
|
73 ; CHECK-NEXT: out 63, r0
|
121
|
74 ; CHECK-NEXT: out 61, r6
|
120
|
75 %vla = alloca i16, i16 %x
|
|
76 call void @foo2(i16* %vla, i64 0, i64 0, i64 0)
|
|
77 ret void
|
|
78 }
|