xref: /aosp_15_r20/external/llvm/test/CodeGen/SPARC/inlineasm.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=sparc <%s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_constraint_r
4*9880d681SAndroid Build Coastguard Worker; CHECK:       add %o1, %o0, %o0
5*9880d681SAndroid Build Coastguard Workerdefine i32 @test_constraint_r(i32 %a, i32 %b) {
6*9880d681SAndroid Build Coastguard Workerentry:
7*9880d681SAndroid Build Coastguard Worker  %0 = tail call i32 asm sideeffect "add $2, $1, $0", "=r,r,r"(i32 %a, i32 %b)
8*9880d681SAndroid Build Coastguard Worker  ret i32 %0
9*9880d681SAndroid Build Coastguard Worker}
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker;; Check tests only that the constraints are accepted without a compiler failure.
12*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_constraints_nro:
13*9880d681SAndroid Build Coastguard Worker%struct.anon = type { i32, i32 }
14*9880d681SAndroid Build Coastguard Worker@v = external global %struct.anon, align 4
15*9880d681SAndroid Build Coastguard Workerdefine void @test_constraints_nro() {
16*9880d681SAndroid Build Coastguard Workerentry:
17*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @v, i32 0, i32 0);
18*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* getelementptr inbounds (%struct.anon, %struct.anon* @v, i32 0, i32 1);
19*9880d681SAndroid Build Coastguard Worker  tail call void asm sideeffect "", "nro,nro"(i32 %0, i32 %1)
20*9880d681SAndroid Build Coastguard Worker  ret void
21*9880d681SAndroid Build Coastguard Worker}
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_constraint_I:
24*9880d681SAndroid Build Coastguard Worker; CHECK:       add %o0, 1023, %o0
25*9880d681SAndroid Build Coastguard Workerdefine i32 @test_constraint_I(i32 %a) {
26*9880d681SAndroid Build Coastguard Workerentry:
27*9880d681SAndroid Build Coastguard Worker  %0 = tail call i32 asm sideeffect "add $1, $2, $0", "=r,r,rI"(i32 %a, i32 1023)
28*9880d681SAndroid Build Coastguard Worker  ret i32 %0
29*9880d681SAndroid Build Coastguard Worker}
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_constraint_I_neg:
32*9880d681SAndroid Build Coastguard Worker; CHECK:       add %o0, -4096, %o0
33*9880d681SAndroid Build Coastguard Workerdefine i32 @test_constraint_I_neg(i32 %a) {
34*9880d681SAndroid Build Coastguard Workerentry:
35*9880d681SAndroid Build Coastguard Worker  %0 = tail call i32 asm sideeffect "add $1, $2, $0", "=r,r,rI"(i32 %a, i32 -4096)
36*9880d681SAndroid Build Coastguard Worker  ret i32 %0
37*9880d681SAndroid Build Coastguard Worker}
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_constraint_I_largeimm:
40*9880d681SAndroid Build Coastguard Worker; CHECK:       sethi 9, [[R0:%[gilo][0-7]]]
41*9880d681SAndroid Build Coastguard Worker; CHECK:       or [[R0]], 784, [[R1:%[gilo][0-7]]]
42*9880d681SAndroid Build Coastguard Worker; CHECK:       add %o0, [[R1]], %o0
43*9880d681SAndroid Build Coastguard Workerdefine i32 @test_constraint_I_largeimm(i32 %a) {
44*9880d681SAndroid Build Coastguard Workerentry:
45*9880d681SAndroid Build Coastguard Worker  %0 = tail call i32 asm sideeffect "add $1, $2, $0", "=r,r,rI"(i32 %a, i32 10000)
46*9880d681SAndroid Build Coastguard Worker  ret i32 %0
47*9880d681SAndroid Build Coastguard Worker}
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_constraint_reg:
50*9880d681SAndroid Build Coastguard Worker; CHECK:       ldda [%o1] 43, %g2
51*9880d681SAndroid Build Coastguard Worker; CHECK:       ldda [%o1] 43, %g4
52*9880d681SAndroid Build Coastguard Workerdefine void @test_constraint_reg(i32 %s, i32* %ptr) {
53*9880d681SAndroid Build Coastguard Workerentry:
54*9880d681SAndroid Build Coastguard Worker  %0 = tail call i64 asm sideeffect "ldda [$1] $2, $0", "={r2},r,n"(i32* %ptr, i32 43)
55*9880d681SAndroid Build Coastguard Worker  %1 = tail call i64 asm sideeffect "ldda [$1] $2, $0", "={g4},r,n"(i32* %ptr, i32 43)
56*9880d681SAndroid Build Coastguard Worker  ret void
57*9880d681SAndroid Build Coastguard Worker}
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Worker;; Ensure that i64 args to asm are allocated to the IntPair register class.
60*9880d681SAndroid Build Coastguard Worker;; Also checks that register renaming for leaf proc works.
61*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_constraint_r_i64:
62*9880d681SAndroid Build Coastguard Worker; CHECK: mov %o0, %o5
63*9880d681SAndroid Build Coastguard Worker; CHECK: sra %o5, 31, %o4
64*9880d681SAndroid Build Coastguard Worker; CHECK: std %o4, [%o1]
65*9880d681SAndroid Build Coastguard Workerdefine i32 @test_constraint_r_i64(i32 %foo, i64* %out, i32 %o) {
66*9880d681SAndroid Build Coastguard Workerentry:
67*9880d681SAndroid Build Coastguard Worker  %conv = sext i32 %foo to i64
68*9880d681SAndroid Build Coastguard Worker  tail call void asm sideeffect "std $0, [$1]", "r,r,~{memory}"(i64 %conv, i64* %out)
69*9880d681SAndroid Build Coastguard Worker  ret i32 %o
70*9880d681SAndroid Build Coastguard Worker}
71*9880d681SAndroid Build Coastguard Worker
72*9880d681SAndroid Build Coastguard Worker;; Same test without leaf-proc opt
73*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_constraint_r_i64_noleaf:
74*9880d681SAndroid Build Coastguard Worker; CHECK: mov %i0, %i5
75*9880d681SAndroid Build Coastguard Worker; CHECK: sra %i5, 31, %i4
76*9880d681SAndroid Build Coastguard Worker; CHECK: std %i4, [%i1]
77*9880d681SAndroid Build Coastguard Workerdefine i32 @test_constraint_r_i64_noleaf(i32 %foo, i64* %out, i32 %o) #0 {
78*9880d681SAndroid Build Coastguard Workerentry:
79*9880d681SAndroid Build Coastguard Worker  %conv = sext i32 %foo to i64
80*9880d681SAndroid Build Coastguard Worker  tail call void asm sideeffect "std $0, [$1]", "r,r,~{memory}"(i64 %conv, i64* %out)
81*9880d681SAndroid Build Coastguard Worker  ret i32 %o
82*9880d681SAndroid Build Coastguard Worker}
83*9880d681SAndroid Build Coastguard Workerattributes #0 = { "no-frame-pointer-elim"="true" }
84*9880d681SAndroid Build Coastguard Worker
85*9880d681SAndroid Build Coastguard Worker;; Ensures that tied in and out gets allocated properly.
86*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_i64_inout:
87*9880d681SAndroid Build Coastguard Worker; CHECK: sethi 0, %o2
88*9880d681SAndroid Build Coastguard Worker; CHECK: mov 5, %o3
89*9880d681SAndroid Build Coastguard Worker; CHECK: xor %o2, %g0, %o2
90*9880d681SAndroid Build Coastguard Worker; CHECK: mov %o2, %o0
91*9880d681SAndroid Build Coastguard Worker; CHECK: ret
92*9880d681SAndroid Build Coastguard Workerdefine i64 @test_i64_inout() {
93*9880d681SAndroid Build Coastguard Workerentry:
94*9880d681SAndroid Build Coastguard Worker  %0 = call i64 asm sideeffect "xor $1, %g0, $0", "=r,0,~{i1}"(i64 5);
95*9880d681SAndroid Build Coastguard Worker  ret i64 %0
96*9880d681SAndroid Build Coastguard Worker}
97