annotate llvm/test/CodeGen/SPARC/inlineasm.ll @ 266:00f31e85ec16 default tip

Added tag current for changeset 31d058e83c98
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 14 Oct 2023 10:13:55 +0900
parents 1f2b6ac9f198
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 ; RUN: llc -march=sparc <%s | FileCheck %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 ; CHECK-LABEL: test_constraint_r
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
4 ; CHECK: add %i1, %i0, %i0
150
anatofuz
parents:
diff changeset
5 define i32 @test_constraint_r(i32 %a, i32 %b) {
anatofuz
parents:
diff changeset
6 entry:
anatofuz
parents:
diff changeset
7 %0 = tail call i32 asm sideeffect "add $2, $1, $0", "=r,r,r"(i32 %a, i32 %b)
anatofuz
parents:
diff changeset
8 ret i32 %0
anatofuz
parents:
diff changeset
9 }
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 ;; Check tests only that the constraints are accepted without a compiler failure.
anatofuz
parents:
diff changeset
12 ; CHECK-LABEL: test_constraints_nro:
anatofuz
parents:
diff changeset
13 %struct.anon = type { i32, i32 }
anatofuz
parents:
diff changeset
14 @v = external global %struct.anon, align 4
anatofuz
parents:
diff changeset
15 define void @test_constraints_nro() {
anatofuz
parents:
diff changeset
16 entry:
anatofuz
parents:
diff changeset
17 %0 = load i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @v, i32 0, i32 0);
anatofuz
parents:
diff changeset
18 %1 = load i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @v, i32 0, i32 1);
anatofuz
parents:
diff changeset
19 tail call void asm sideeffect "", "nro,nro"(i32 %0, i32 %1)
anatofuz
parents:
diff changeset
20 ret void
anatofuz
parents:
diff changeset
21 }
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 ; CHECK-LABEL: test_constraint_I:
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
24 ; CHECK: add %i0, 1023, %i0
150
anatofuz
parents:
diff changeset
25 define i32 @test_constraint_I(i32 %a) {
anatofuz
parents:
diff changeset
26 entry:
anatofuz
parents:
diff changeset
27 %0 = tail call i32 asm sideeffect "add $1, $2, $0", "=r,r,rI"(i32 %a, i32 1023)
anatofuz
parents:
diff changeset
28 ret i32 %0
anatofuz
parents:
diff changeset
29 }
anatofuz
parents:
diff changeset
30
anatofuz
parents:
diff changeset
31 ; CHECK-LABEL: test_constraint_I_neg:
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
32 ; CHECK: add %i0, -4096, %i0
150
anatofuz
parents:
diff changeset
33 define i32 @test_constraint_I_neg(i32 %a) {
anatofuz
parents:
diff changeset
34 entry:
anatofuz
parents:
diff changeset
35 %0 = tail call i32 asm sideeffect "add $1, $2, $0", "=r,r,rI"(i32 %a, i32 -4096)
anatofuz
parents:
diff changeset
36 ret i32 %0
anatofuz
parents:
diff changeset
37 }
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 ; CHECK-LABEL: test_constraint_I_largeimm:
anatofuz
parents:
diff changeset
40 ; CHECK: sethi 9, [[R0:%[gilo][0-7]]]
anatofuz
parents:
diff changeset
41 ; CHECK: or [[R0]], 784, [[R1:%[gilo][0-7]]]
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
42 ; CHECK: add %i0, [[R1]], %i0
150
anatofuz
parents:
diff changeset
43 define i32 @test_constraint_I_largeimm(i32 %a) {
anatofuz
parents:
diff changeset
44 entry:
anatofuz
parents:
diff changeset
45 %0 = tail call i32 asm sideeffect "add $1, $2, $0", "=r,r,rI"(i32 %a, i32 10000)
anatofuz
parents:
diff changeset
46 ret i32 %0
anatofuz
parents:
diff changeset
47 }
anatofuz
parents:
diff changeset
48
anatofuz
parents:
diff changeset
49 ; CHECK-LABEL: test_constraint_reg:
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
50 ; CHECK: ldda [%i1] 43, %g2
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
51 ; CHECK: ldda [%i1] 43, %g4
150
anatofuz
parents:
diff changeset
52 define void @test_constraint_reg(i32 %s, i32* %ptr) {
anatofuz
parents:
diff changeset
53 entry:
anatofuz
parents:
diff changeset
54 %0 = tail call i64 asm sideeffect "ldda [$1] $2, $0", "={r2},r,n"(i32* %ptr, i32 43)
anatofuz
parents:
diff changeset
55 %1 = tail call i64 asm sideeffect "ldda [$1] $2, $0", "={g4},r,n"(i32* %ptr, i32 43)
anatofuz
parents:
diff changeset
56 ret void
anatofuz
parents:
diff changeset
57 }
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 ;; Ensure that i64 args to asm are allocated to the IntPair register class.
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
60 ;; Also checks that there's no register renaming for leaf proc if it has inline asm.
150
anatofuz
parents:
diff changeset
61 ; CHECK-LABEL: test_constraint_r_i64:
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
62 ; CHECK: mov %i0, %i5
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
63 ; CHECK: sra %i5, 31, %i4
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
64 ; CHECK: std %i4, [%i1]
150
anatofuz
parents:
diff changeset
65 define i32 @test_constraint_r_i64(i32 %foo, i64* %out, i32 %o) {
anatofuz
parents:
diff changeset
66 entry:
anatofuz
parents:
diff changeset
67 %conv = sext i32 %foo to i64
anatofuz
parents:
diff changeset
68 tail call void asm sideeffect "std $0, [$1]", "r,r,~{memory}"(i64 %conv, i64* %out)
anatofuz
parents:
diff changeset
69 ret i32 %o
anatofuz
parents:
diff changeset
70 }
anatofuz
parents:
diff changeset
71
anatofuz
parents:
diff changeset
72 ;; Same test without leaf-proc opt
anatofuz
parents:
diff changeset
73 ; CHECK-LABEL: test_constraint_r_i64_noleaf:
anatofuz
parents:
diff changeset
74 ; CHECK: mov %i0, %i5
anatofuz
parents:
diff changeset
75 ; CHECK: sra %i5, 31, %i4
anatofuz
parents:
diff changeset
76 ; CHECK: std %i4, [%i1]
anatofuz
parents:
diff changeset
77 define i32 @test_constraint_r_i64_noleaf(i32 %foo, i64* %out, i32 %o) #0 {
anatofuz
parents:
diff changeset
78 entry:
anatofuz
parents:
diff changeset
79 %conv = sext i32 %foo to i64
anatofuz
parents:
diff changeset
80 tail call void asm sideeffect "std $0, [$1]", "r,r,~{memory}"(i64 %conv, i64* %out)
anatofuz
parents:
diff changeset
81 ret i32 %o
anatofuz
parents:
diff changeset
82 }
anatofuz
parents:
diff changeset
83 attributes #0 = { "frame-pointer"="all" }
anatofuz
parents:
diff changeset
84
anatofuz
parents:
diff changeset
85 ;; Ensures that tied in and out gets allocated properly.
anatofuz
parents:
diff changeset
86 ; CHECK-LABEL: test_i64_inout:
252
1f2b6ac9f198 LLVM16-1
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 236
diff changeset
87 ; CHECK: mov 5, %i3
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
88 ; CHECK: mov %g0, %i2
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
89 ; CHECK: xor %i2, %g0, %i2
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
90 ; CHECK: mov %i2, %i0
150
anatofuz
parents:
diff changeset
91 ; CHECK: ret
anatofuz
parents:
diff changeset
92 define i64 @test_i64_inout() {
anatofuz
parents:
diff changeset
93 entry:
anatofuz
parents:
diff changeset
94 %0 = call i64 asm sideeffect "xor $1, %g0, $0", "=r,0,~{i1}"(i64 5);
anatofuz
parents:
diff changeset
95 ret i64 %0
anatofuz
parents:
diff changeset
96 }
anatofuz
parents:
diff changeset
97
anatofuz
parents:
diff changeset
98
anatofuz
parents:
diff changeset
99 ;; Ensures that inline-asm accepts and uses 'f' and 'e' register constraints.
anatofuz
parents:
diff changeset
100 ; CHECK-LABEL: fadds:
anatofuz
parents:
diff changeset
101 ; CHECK: fadds %f0, %f1, %f0
anatofuz
parents:
diff changeset
102 define float @fadds(float, float) local_unnamed_addr #2 {
anatofuz
parents:
diff changeset
103 entry:
anatofuz
parents:
diff changeset
104 %2 = tail call float asm sideeffect "fadds $1, $2, $0;", "=f,f,e"(float %0, float %1) #7
anatofuz
parents:
diff changeset
105 ret float %2
anatofuz
parents:
diff changeset
106 }
anatofuz
parents:
diff changeset
107
anatofuz
parents:
diff changeset
108 ; CHECK-LABEL: faddd:
anatofuz
parents:
diff changeset
109 ; CHECK: faddd %f0, %f2, %f0
anatofuz
parents:
diff changeset
110 define double @faddd(double, double) local_unnamed_addr #2 {
anatofuz
parents:
diff changeset
111 entry:
anatofuz
parents:
diff changeset
112 %2 = tail call double asm sideeffect "faddd $1, $2, $0;", "=f,f,e"(double %0, double %1) #7
anatofuz
parents:
diff changeset
113 ret double %2
anatofuz
parents:
diff changeset
114 }
anatofuz
parents:
diff changeset
115
anatofuz
parents:
diff changeset
116 ; CHECK-LABEL: test_addressing_mode_i64:
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
117 ; CHECK: std %l0, [%i0]
150
anatofuz
parents:
diff changeset
118 define void @test_addressing_mode_i64(i64* %out) {
anatofuz
parents:
diff changeset
119 entry:
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
120 call void asm "std %l0, $0", "=*m,r"(i64* elementtype(i64) nonnull %out, i64 0)
150
anatofuz
parents:
diff changeset
121 ret void
anatofuz
parents:
diff changeset
122 }
anatofuz
parents:
diff changeset
123
anatofuz
parents:
diff changeset
124 ; CHECK-LABEL: test_constraint_float_reg:
anatofuz
parents:
diff changeset
125 ; CHECK: fadds %f20, %f20, %f20
anatofuz
parents:
diff changeset
126 ; CHECK: faddd %f20, %f20, %f20
anatofuz
parents:
diff changeset
127 define void @test_constraint_float_reg() {
anatofuz
parents:
diff changeset
128 entry:
anatofuz
parents:
diff changeset
129 tail call void asm sideeffect "fadds $0,$1,$2", "{f20},{f20},{f20}"(float 6.0, float 7.0, float 8.0)
anatofuz
parents:
diff changeset
130 tail call void asm sideeffect "faddd $0,$1,$2", "{f20},{f20},{f20}"(double 9.0, double 10.0, double 11.0)
anatofuz
parents:
diff changeset
131 ret void
anatofuz
parents:
diff changeset
132 }
anatofuz
parents:
diff changeset
133
anatofuz
parents:
diff changeset
134 ; CHECK-LABEL: test_constraint_f_e_i32_i64:
236
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
135 ; CHECK: ld [%i0+%lo(.LCPI13_0)], %f0
c4bab56944e8 LLVM 16
kono
parents: 150
diff changeset
136 ; CHECK: ldd [%i0+%lo(.LCPI13_1)], %f2
150
anatofuz
parents:
diff changeset
137 ; CHECK: fadds %f0, %f0, %f0
anatofuz
parents:
diff changeset
138 ; CHECK: faddd %f2, %f2, %f0
anatofuz
parents:
diff changeset
139
anatofuz
parents:
diff changeset
140 define void @test_constraint_f_e_i32_i64() {
anatofuz
parents:
diff changeset
141 entry:
anatofuz
parents:
diff changeset
142 %0 = call float asm sideeffect "fadds $1, $2, $0", "=f,f,e"(i32 0, i32 0)
anatofuz
parents:
diff changeset
143 %1 = call double asm sideeffect "faddd $1, $2, $0", "=f,f,e"(i64 0, i64 0)
anatofuz
parents:
diff changeset
144 ret void
anatofuz
parents:
diff changeset
145 }