• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: llc -mattr=sram,movw,addsubiw < %s -march=avr | FileCheck %s
2
3declare void @llvm.va_start(i8*)
4declare i16 @vsprintf(i8* nocapture, i8* nocapture, i8*)
5declare void @llvm.va_end(i8*)
6
7define i16 @varargs1(i8* nocapture %x, ...) {
8; CHECK-LABEL: varargs1:
9; CHECK: movw r20, r28
10; CHECK: subi r20, 215
11; CHECK: sbci r21, 255
12; CHECK: movw r24, r28
13; CHECK: adiw r24, 3
14; CHECK: ldd r22, Y+39
15; CHECK: ldd r23, Y+40
16; CHECK: call
17  %buffer = alloca [32 x i8]
18  %ap = alloca 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)
25  ret i16 0
26}
27
28define 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]+}}
32  %ap = alloca i8*
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)
37  ret i16 %1
38}
39
40declare void @var1223(i16, ...)
41define void @varargcall() {
42; CHECK-LABEL: varargcall:
43; CHECK: ldi [[REG1:r[0-9]+]], 189
44; CHECK: ldi [[REG2:r[0-9]+]], 205
45; CHECK: std Z+3, [[REG1]]
46; CHECK: std Z+4, [[REG2]]
47; CHECK: ldi [[REG1:r[0-9]+]], 191
48; CHECK: ldi [[REG2:r[0-9]+]], 223
49; CHECK: std Z+5, [[REG1]]
50; CHECK: std Z+6, [[REG2]]
51; CHECK: ldi [[REG1:r[0-9]+]], 205
52; CHECK: ldi [[REG2:r[0-9]+]], 171
53; CHECK: std Z+1, [[REG1]]
54; CHECK: std Z+2, [[REG2]]
55; CHECK: call
56; CHECK: adiw r30, 6
57  tail call void (i16, ...) @var1223(i16 -21555, i16 -12867, i16 -8257)
58  ret void
59}
60