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