1; RUN: llc < %s -march=avr | FileCheck %s 2 3declare void @foo(i16*, i16*, i8*) 4 5define 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 47declare 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. 52define 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; Allocate stack space for call 57; CHECK: in {{.*}}, 61 58; CHECK: in {{.*}}, 62 59; CHECK: subi 60; CHECK: sbci 61; CHECK: in r0, 63 62; CHECK-NEXT: cli 63; CHECK-NEXT: out 62, {{.*}} 64; CHECK-NEXT: out 63, r0 65; CHECK-NEXT: out 61, {{.*}} 66; Store values on the stack 67; CHECK: ldi r16, 0 68; CHECK: ldi r17, 0 69; CHECK: std Z+5, r16 70; CHECK: std Z+6, r17 71; CHECK: std Z+7, r16 72; CHECK: std Z+8, r17 73; CHECK: std Z+3, r16 74; CHECK: std Z+4, r17 75; CHECK: std Z+1, r16 76; CHECK: std Z+2, r17 77; CHECK: call 78; Call frame restore 79; CHECK-NEXT: in r30, 61 80; CHECK-NEXT: in r31, 62 81; CHECK-NEXT: adiw r30, 8 82; CHECK-NEXT: in r0, 63 83; CHECK-NEXT: cli 84; CHECK-NEXT: out 62, r31 85; CHECK-NEXT: out 63, r0 86; CHECK-NEXT: out 61, r30 87; SP restore 88; CHECK: in r0, 63 89; CHECK-NEXT: cli 90; CHECK-NEXT: out 62, r7 91; CHECK-NEXT: out 63, r0 92; CHECK-NEXT: out 61, r6 93 %vla = alloca i16, i16 %x 94 call void @foo2(i16* %vla, i64 0, i64 0, i64 0) 95 ret void 96} 97