1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -target-abi ilp32e -verify-machineinstrs < %s \
3 ; RUN: | FileCheck -check-prefix=ILP32E %s
4 ; RUN: llc -mtriple=riscv32 -target-abi ilp32e -frame-pointer=all -verify-machineinstrs < %s \
5 ; RUN: | FileCheck -check-prefix=ILP32E-WITHFP %s
7 declare void @llvm.va_start(ptr)
8 declare void @llvm.va_end(ptr)
11 define i32 @caller(i32 %a) {
12 ; ILP32E-LABEL: caller:
13 ; ILP32E: # %bb.0: # %entry
14 ; ILP32E-NEXT: addi sp, sp, -8
15 ; ILP32E-NEXT: .cfi_def_cfa_offset 8
16 ; ILP32E-NEXT: sw ra, 4(sp) # 4-byte Folded Spill
17 ; ILP32E-NEXT: sw s0, 0(sp) # 4-byte Folded Spill
18 ; ILP32E-NEXT: .cfi_offset ra, -4
19 ; ILP32E-NEXT: .cfi_offset s0, -8
20 ; ILP32E-NEXT: mv s0, a0
21 ; ILP32E-NEXT: li a0, 1
22 ; ILP32E-NEXT: lui a2, 262144
23 ; ILP32E-NEXT: li a1, 0
24 ; ILP32E-NEXT: call va_double
25 ; ILP32E-NEXT: mv a0, s0
26 ; ILP32E-NEXT: lw ra, 4(sp) # 4-byte Folded Reload
27 ; ILP32E-NEXT: lw s0, 0(sp) # 4-byte Folded Reload
28 ; ILP32E-NEXT: addi sp, sp, 8
31 ; ILP32E-WITHFP-LABEL: caller:
32 ; ILP32E-WITHFP: # %bb.0: # %entry
33 ; ILP32E-WITHFP-NEXT: addi sp, sp, -12
34 ; ILP32E-WITHFP-NEXT: .cfi_def_cfa_offset 12
35 ; ILP32E-WITHFP-NEXT: sw ra, 8(sp) # 4-byte Folded Spill
36 ; ILP32E-WITHFP-NEXT: sw s0, 4(sp) # 4-byte Folded Spill
37 ; ILP32E-WITHFP-NEXT: sw s1, 0(sp) # 4-byte Folded Spill
38 ; ILP32E-WITHFP-NEXT: .cfi_offset ra, -4
39 ; ILP32E-WITHFP-NEXT: .cfi_offset s0, -8
40 ; ILP32E-WITHFP-NEXT: .cfi_offset s1, -12
41 ; ILP32E-WITHFP-NEXT: addi s0, sp, 12
42 ; ILP32E-WITHFP-NEXT: .cfi_def_cfa s0, 0
43 ; ILP32E-WITHFP-NEXT: mv s1, a0
44 ; ILP32E-WITHFP-NEXT: li a0, 1
45 ; ILP32E-WITHFP-NEXT: lui a2, 262144
46 ; ILP32E-WITHFP-NEXT: li a1, 0
47 ; ILP32E-WITHFP-NEXT: call va_double
48 ; ILP32E-WITHFP-NEXT: mv a0, s1
49 ; ILP32E-WITHFP-NEXT: lw ra, 8(sp) # 4-byte Folded Reload
50 ; ILP32E-WITHFP-NEXT: lw s0, 4(sp) # 4-byte Folded Reload
51 ; ILP32E-WITHFP-NEXT: lw s1, 0(sp) # 4-byte Folded Reload
52 ; ILP32E-WITHFP-NEXT: addi sp, sp, 12
53 ; ILP32E-WITHFP-NEXT: ret
55 call void (i32, ...) @va_double(i32 1, double 2.000000e+00)
59 define void @va_double(i32 %n, ...) {
60 ; ILP32E-LABEL: va_double:
61 ; ILP32E: # %bb.0: # %entry
62 ; ILP32E-NEXT: addi sp, sp, -32
63 ; ILP32E-NEXT: .cfi_def_cfa_offset 32
64 ; ILP32E-NEXT: sw ra, 4(sp) # 4-byte Folded Spill
65 ; ILP32E-NEXT: .cfi_offset ra, -28
66 ; ILP32E-NEXT: sw a5, 28(sp)
67 ; ILP32E-NEXT: sw a4, 24(sp)
68 ; ILP32E-NEXT: sw a3, 20(sp)
69 ; ILP32E-NEXT: sw a2, 16(sp)
70 ; ILP32E-NEXT: sw a1, 12(sp)
71 ; ILP32E-NEXT: addi a0, sp, 12
72 ; ILP32E-NEXT: sw a0, 0(sp)
73 ; ILP32E-NEXT: addi a0, sp, 19
74 ; ILP32E-NEXT: andi a1, a0, -8
75 ; ILP32E-NEXT: addi a0, a1, 8
76 ; ILP32E-NEXT: sw a0, 0(sp)
77 ; ILP32E-NEXT: lw a0, 0(a1)
78 ; ILP32E-NEXT: lw a1, 4(a1)
79 ; ILP32E-NEXT: lui a3, 262144
80 ; ILP32E-NEXT: li a2, 0
81 ; ILP32E-NEXT: call __eqdf2
82 ; ILP32E-NEXT: bnez a0, .LBB1_2
83 ; ILP32E-NEXT: # %bb.1: # %if.end
84 ; ILP32E-NEXT: lw ra, 4(sp) # 4-byte Folded Reload
85 ; ILP32E-NEXT: addi sp, sp, 32
87 ; ILP32E-NEXT: .LBB1_2: # %if.then
88 ; ILP32E-NEXT: call abort
90 ; ILP32E-WITHFP-LABEL: va_double:
91 ; ILP32E-WITHFP: # %bb.0: # %entry
92 ; ILP32E-WITHFP-NEXT: addi sp, sp, -36
93 ; ILP32E-WITHFP-NEXT: .cfi_def_cfa_offset 36
94 ; ILP32E-WITHFP-NEXT: sw ra, 8(sp) # 4-byte Folded Spill
95 ; ILP32E-WITHFP-NEXT: sw s0, 4(sp) # 4-byte Folded Spill
96 ; ILP32E-WITHFP-NEXT: .cfi_offset ra, -28
97 ; ILP32E-WITHFP-NEXT: .cfi_offset s0, -32
98 ; ILP32E-WITHFP-NEXT: addi s0, sp, 12
99 ; ILP32E-WITHFP-NEXT: .cfi_def_cfa s0, 24
100 ; ILP32E-WITHFP-NEXT: sw a5, 20(s0)
101 ; ILP32E-WITHFP-NEXT: sw a4, 16(s0)
102 ; ILP32E-WITHFP-NEXT: sw a3, 12(s0)
103 ; ILP32E-WITHFP-NEXT: sw a2, 8(s0)
104 ; ILP32E-WITHFP-NEXT: sw a1, 4(s0)
105 ; ILP32E-WITHFP-NEXT: addi a0, s0, 4
106 ; ILP32E-WITHFP-NEXT: sw a0, -12(s0)
107 ; ILP32E-WITHFP-NEXT: addi a0, s0, 11
108 ; ILP32E-WITHFP-NEXT: andi a1, a0, -8
109 ; ILP32E-WITHFP-NEXT: addi a0, a1, 8
110 ; ILP32E-WITHFP-NEXT: sw a0, -12(s0)
111 ; ILP32E-WITHFP-NEXT: lw a0, 0(a1)
112 ; ILP32E-WITHFP-NEXT: lw a1, 4(a1)
113 ; ILP32E-WITHFP-NEXT: lui a3, 262144
114 ; ILP32E-WITHFP-NEXT: li a2, 0
115 ; ILP32E-WITHFP-NEXT: call __eqdf2
116 ; ILP32E-WITHFP-NEXT: bnez a0, .LBB1_2
117 ; ILP32E-WITHFP-NEXT: # %bb.1: # %if.end
118 ; ILP32E-WITHFP-NEXT: lw ra, 8(sp) # 4-byte Folded Reload
119 ; ILP32E-WITHFP-NEXT: lw s0, 4(sp) # 4-byte Folded Reload
120 ; ILP32E-WITHFP-NEXT: addi sp, sp, 36
121 ; ILP32E-WITHFP-NEXT: ret
122 ; ILP32E-WITHFP-NEXT: .LBB1_2: # %if.then
123 ; ILP32E-WITHFP-NEXT: call abort
125 %args = alloca ptr, align 4
126 %args1 = bitcast ptr %args to ptr
127 call void @llvm.va_start(ptr %args1)
128 %argp.cur = load ptr, ptr %args, align 4
129 %0 = ptrtoint ptr %argp.cur to i32
132 %argp.cur.aligned = inttoptr i32 %2 to ptr
133 %argp.next = getelementptr inbounds i8, ptr %argp.cur.aligned, i32 8
134 store ptr %argp.next, ptr %args, align 4
135 %3 = bitcast ptr %argp.cur.aligned to ptr
136 %4 = load double, ptr %3, align 8
137 %cmp = fcmp une double %4, 2.000000e+00
138 br i1 %cmp, label %if.then, label %if.end
145 %args2 = bitcast ptr %args to ptr
146 call void @llvm.va_end(ptr %args2)