1 ; RUN: llc < %s -march=avr | FileCheck %s
3 declare void @foo(ptr, ptr, ptr)
5 define void @test1(i16 %x) {
7 ; Frame setup, with frame pointer
11 ; allocate first dynalloca
12 ; CHECK: in {{.*}}, 61
13 ; CHECK: in {{.*}}, 62
18 ; CHECK-NEXT: out 62, {{.*}}
19 ; CHECK-NEXT: out 63, r0
20 ; CHECK-NEXT: out 61, {{.*}}
22 ; CHECK: std Z+13, {{.*}}
23 ; CHECK: std Z+12, {{.*}}
24 ; CHECK: std Z+7, {{.*}}
29 ; CHECK-NEXT: out 62, r29
30 ; CHECK-NEXT: out 63, r0
31 ; CHECK-NEXT: out 61, r28
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], ptr %a, i16 0, i16 2
37 store i16 3, ptr %arrayidx
38 %arrayidx2 = getelementptr inbounds i16, ptr %vla, i16 6
39 store i16 4, ptr %arrayidx2
40 %arrayidx3 = getelementptr inbounds i8, ptr %vla1, i16 7
41 store i8 44, ptr %arrayidx3
42 %arraydecay = getelementptr inbounds [8 x i16], ptr %a, i16 0, i16 0
43 call void @foo(ptr %arraydecay, ptr %vla, ptr %vla1)
47 declare void @foo2(ptr, i64, i64, i64)
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:
56 ; Allocate stack space for call
57 ; CHECK: in {{.*}}, 61
58 ; CHECK: in {{.*}}, 62
63 ; CHECK-NEXT: out 62, {{.*}}
64 ; CHECK-NEXT: out 63, r0
65 ; CHECK-NEXT: out 61, {{.*}}
66 ; Store values on the stack
79 ; CHECK-NEXT: in r30, 61
80 ; CHECK-NEXT: in r31, 62
81 ; CHECK-NEXT: adiw r30, 8
82 ; CHECK-NEXT: in r0, 63
84 ; CHECK-NEXT: out 62, r31
85 ; CHECK-NEXT: out 63, r0
86 ; CHECK-NEXT: out 61, r30
90 ; CHECK-NEXT: out 62, r29
91 ; CHECK-NEXT: out 63, r0
92 ; CHECK-NEXT: out 61, r28
93 %vla = alloca i16, i16 %x
94 call void @foo2(ptr %vla, i64 0, i64 0, i64 0)
98 ; Test a function with a variable sized object but without any other need for a
100 ; Allocas that are not placed in the entry block are considered variable sized
101 ; (they could be in a loop).
102 define void @dynalloca3() {
103 ; CHECK-LABEL: dynalloca3:
106 ; CHECK-NEXT: in r29, 62
107 ; Allocate memory for the alloca
108 ; CHECK-NEXT: in r24, 61
109 ; CHECK-NEXT: in r25, 62
110 ; CHECK-NEXT: sbiw r24, 8
111 ; CHECK-NEXT: in r0, 63
113 ; CHECK-NEXT: out 62, r25
114 ; CHECK-NEXT: out 63, r0
115 ; CHECK-NEXT: out 61, r24
116 ; Restore frame pointer
117 ; CHECK-NEXT: in r0, 63
119 ; CHECK-NEXT: out 62, r29
120 ; CHECK-NEXT: out 63, r0
121 ; CHECK-NEXT: out 61, r28