1 ; RUN: llc -mattr=sram,movw,addsubiw < %s -march=avr | FileCheck %s
3 declare void @llvm.va_start(i8*)
4 declare i16 @vsprintf(i8* nocapture, i8* nocapture, i8*)
5 declare void @llvm.va_end(i8*)
7 define i16 @varargs1(i8* nocapture %x, ...) {
8 ; CHECK-LABEL: varargs1:
10 ; CHECK: subi r20, 217
11 ; CHECK: sbci r21, 255
12 ; CHECK: movw r24, r28
14 ; CHECK: ldd r22, Y+37
15 ; CHECK: ldd r23, Y+38
17 %buffer = alloca [32 x i8]
19 %ap1 = bitcast i8** %ap to i8*
20 call void @llvm.va_start(i8* %ap1)
21 %arraydecay = getelementptr inbounds [32 x i8], [32 x i8]* %buffer, i16 0, i16 0
22 %1 = load i8*, i8** %ap
23 %call = call i16 @vsprintf(i8* %arraydecay, i8* %x, i8* %1)
24 call void @llvm.va_end(i8* %ap1)
28 define i16 @varargs2(i8* nocapture %x, ...) {
29 ; CHECK-LABEL: varargs2:
30 ; CHECK: ldd r24, [[REG:X|Y|Z]]+{{[0-9]+}}
31 ; CHECK: ldd r25, [[REG]]+{{[0-9]+}}
33 %ap1 = bitcast i8** %ap to i8*
34 call void @llvm.va_start(i8* %ap1)
35 %1 = va_arg i8** %ap, i16
36 call void @llvm.va_end(i8* %ap1)
40 declare void @var1223(i16, ...)
41 define void @varargcall() {
42 ; CHECK-LABEL: varargcall:
43 ; CHECK: ldi [[REG1:r[0-9]+]], 189
44 ; CHECK: ldi [[REG2:r[0-9]+]], 205
45 ; CHECK: push [[REG2]]
46 ; CHECK: push [[REG1]]
47 ; CHECK: ldi [[REG1:r[0-9]+]], 191
48 ; CHECK: ldi [[REG2:r[0-9]+]], 223
49 ; CHECK: push [[REG2]]
50 ; CHECK: push [[REG1]]
51 ; CHECK: ldi [[REG1:r[0-9]+]], 205
52 ; CHECK: ldi [[REG2:r[0-9]+]], 171
53 ; CHECK: push [[REG2]]
54 ; CHECK: push [[REG1]]
57 tail call void (i16, ...) @var1223(i16 -21555, i16 -12867, i16 -8257)