1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=csky -verify-machineinstrs -csky-no-aliases -no-integrated-as < %s \
3 ; RUN: | FileCheck -check-prefix=CSKY %s
5 @gi = external global i32
6 @mi = external global i64
8 define i32 @constraint_r(i32 %a) nounwind {
9 ; CSKY-LABEL: constraint_r:
11 ; CSKY-NEXT: subi16 sp, sp, 4
12 ; CSKY-NEXT: lrw32 a1, [.LCPI0_0]
13 ; CSKY-NEXT: ld16.w a1, (a1, 0)
15 ; CSKY-NEXT: add a0, a0, a1
17 ; CSKY-NEXT: addi16 sp, sp, 4
19 ; CSKY-NEXT: .p2align 1
21 ; CSKY-NEXT: .p2align 2
22 ; CSKY-NEXT: .LCPI0_0:
24 %1 = load i32, ptr @gi
25 %2 = tail call i32 asm "add $0, $1, $2", "=r,r,r"(i32 %a, i32 %1)
29 define i64 @constraint_r_i64(i32 %a) nounwind {
30 ; CSKY-LABEL: constraint_r_i64:
32 ; CSKY-NEXT: subi16 sp, sp, 4
33 ; CSKY-NEXT: lrw32 a3, [.LCPI1_0]
34 ; CSKY-NEXT: ld16.w a1, (a3, 0)
35 ; CSKY-NEXT: ld16.w a2, (a3, 4)
37 ; CSKY-NEXT: mula.s32 a1, a0, a0
39 ; CSKY-NEXT: mov16 a0, a1
40 ; CSKY-NEXT: mov16 a1, a2
41 ; CSKY-NEXT: addi16 sp, sp, 4
43 ; CSKY-NEXT: .p2align 1
45 ; CSKY-NEXT: .p2align 2
46 ; CSKY-NEXT: .LCPI1_0:
48 %1 = load i64, ptr @mi
49 %2 = call i64 asm "mula.s32 $0, $1, $2", "=r,r,r,0"(i32 %a, i32 %a, i64 %1)
53 define i32 @constraint_a(i32 %a) nounwind {
54 ; CSKY-LABEL: constraint_a:
56 ; CSKY-NEXT: subi16 sp, sp, 4
57 ; CSKY-NEXT: lrw32 a1, [.LCPI2_0]
58 ; CSKY-NEXT: ld16.w a1, (a1, 0)
60 ; CSKY-NEXT: add a0, a0, a1
62 ; CSKY-NEXT: addi16 sp, sp, 4
64 ; CSKY-NEXT: .p2align 1
66 ; CSKY-NEXT: .p2align 2
67 ; CSKY-NEXT: .LCPI2_0:
69 %1 = load i32, ptr @gi
70 %2 = tail call i32 asm "add $0, $1, $2", "=a,a,a"(i32 %a, i32 %1)
74 define i32 @constraint_b(i32 %a) nounwind {
75 ; CSKY-LABEL: constraint_b:
77 ; CSKY-NEXT: subi16 sp, sp, 4
78 ; CSKY-NEXT: lrw32 a1, [.LCPI3_0]
79 ; CSKY-NEXT: ld16.w a1, (a1, 0)
81 ; CSKY-NEXT: add a0, a0, a1
83 ; CSKY-NEXT: addi16 sp, sp, 4
85 ; CSKY-NEXT: .p2align 1
87 ; CSKY-NEXT: .p2align 2
88 ; CSKY-NEXT: .LCPI3_0:
90 %1 = load i32, ptr @gi
91 %2 = tail call i32 asm "add $0, $1, $2", "=b,b,b"(i32 %a, i32 %1)
95 define i32 @constraint_z(i32 %a) nounwind {
96 ; CSKY-LABEL: constraint_z:
98 ; CSKY-NEXT: subi16 sp, sp, 4
99 ; CSKY-NEXT: mov16 sp, a0
100 ; CSKY-NEXT: lrw32 a0, [.LCPI4_0]
101 ; CSKY-NEXT: ld16.w a0, (a0, 0)
103 ; CSKY-NEXT: add a0, sp, a0
105 ; CSKY-NEXT: addi16 sp, sp, 4
107 ; CSKY-NEXT: .p2align 1
108 ; CSKY-NEXT: # %bb.1:
109 ; CSKY-NEXT: .p2align 2
110 ; CSKY-NEXT: .LCPI4_0:
111 ; CSKY-NEXT: .long gi
112 %1 = load i32, ptr @gi
113 %2 = tail call i32 asm "add $0, $1, $2", "=r,z,r"(i32 %a, i32 %1)
117 define i32 @constraint_c(i32 %a, i32 %b) nounwind {
118 ; CSKY-LABEL: constraint_c:
120 ; CSKY-NEXT: subi16 sp, sp, 4
121 ; CSKY-NEXT: lrw32 a1, [.LCPI5_0]
122 ; CSKY-NEXT: ld16.w a1, (a1, 0)
124 ; CSKY-NEXT: addc a0, a0, a1
126 ; CSKY-NEXT: addi16 sp, sp, 4
128 ; CSKY-NEXT: .p2align 1
129 ; CSKY-NEXT: # %bb.1:
130 ; CSKY-NEXT: .p2align 2
131 ; CSKY-NEXT: .LCPI5_0:
132 ; CSKY-NEXT: .long gi
133 %1 = load i32, ptr @gi
134 %2 = tail call i32 asm "addc $0, $1, $2", "=r,r,r,~{c}"(i32 %a, i32 %1)
138 define i32 @constraint_i(i32 %a) nounwind {
139 ; CSKY-LABEL: constraint_i:
141 ; CSKY-NEXT: subi16 sp, sp, 4
143 ; CSKY-NEXT: addi a0, a0, 113
145 ; CSKY-NEXT: addi16 sp, sp, 4
148 %1 = load i32, ptr @gi
149 %2 = tail call i32 asm "addi $0, $1, $2", "=r,r,i"(i32 %a, i32 113)
153 define void @constraint_m(ptr %a) nounwind {
154 ; CSKY-LABEL: constraint_m:
156 ; CSKY-NEXT: subi16 sp, sp, 4
159 ; CSKY-NEXT: addi16 sp, sp, 4
162 call void asm sideeffect "", "=*m"(ptr elementtype(i32) %a)
166 define i32 @constraint_m2(ptr %a) nounwind {
167 ; CSKY-LABEL: constraint_m2:
169 ; CSKY-NEXT: subi16 sp, sp, 4
171 ; CSKY-NEXT: ld.w a0, (a0, 0)
173 ; CSKY-NEXT: addi16 sp, sp, 4
176 %1 = tail call i32 asm "ld.w $0, $1", "=r,*m"(ptr elementtype(i32) %a)
180 define i32 @modifier_i_imm(i32 %a) nounwind {
181 ; CSKY-LABEL: modifier_i_imm:
183 ; CSKY-NEXT: subi16 sp, sp, 4
185 ; CSKY-NEXT: addi a0, a0, 1
187 ; CSKY-NEXT: addi16 sp, sp, 4
189 %1 = tail call i32 asm "addi $0, $1, $2", "=r,r,ri"(i32 %a, i32 1)
193 define void @operand_global() nounwind {
194 ; CSKY-LABEL: operand_global:
196 ; CSKY-NEXT: subi16 sp, sp, 4
198 ; CSKY-NEXT: .4byte gi
200 ; CSKY-NEXT: addi16 sp, sp, 4
203 tail call void asm sideeffect ".4byte $0", "i"(ptr @gi)
207 define void @operand_block_address() nounwind {
208 ; CSKY-LABEL: operand_block_address:
210 ; CSKY-NEXT: subi16 sp, sp, 4
212 ; CSKY-NEXT: br32 .Ltmp0
214 ; CSKY-NEXT: .Ltmp0: # Block address taken
215 ; CSKY-NEXT: # %bb.1: # %bb
216 ; CSKY-NEXT: addi16 sp, sp, 4
219 call void asm sideeffect "br32 $0", "i"(ptr blockaddress(@operand_block_address, %bb))
225 ; TODO: expand tests for more complex constraints, out of range immediates etc