Skip to content

Commit 862074f

Browse files
committed
[LoongArch][NFC] Pre-commit tests for the adjacency of expanded pseudo-insns
1 parent 0848898 commit 862074f

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
; RUN: llc --mtriple=loongarch64 --relocation-model=pic \
2+
; RUN: --code-model=medium < %s | FileCheck --check-prefix=MEDIUM %s
3+
; RUN: llc --mtriple=loongarch64 --relocation-model=pic \
4+
; RUN: --code-model=large < %s | FileCheck --check-prefix=LARGE %s
5+
; RUN: llc --mtriple=loongarch64 --relocation-model=pic \
6+
; RUN: --enable-tlsdesc --code-model=large < %s | \
7+
; RUN: FileCheck --check-prefix=LARGEDESC %s
8+
9+
; Check the adjancency of pseudo-instruction expansions to ensure
10+
; compliance with psABI requirements:
11+
; https://github.com/loongson/la-abi-specs/releases/tag/v2.30
12+
13+
declare void @llvm.memset.p0.i64(ptr, i8, i64, i1)
14+
15+
define void @call_external_sym(ptr %dst) {
16+
; LARGE-LABEL: call_external_sym:
17+
; LARGE: pcalau12i [[REG1:\$[a-z0-9]+]], %pc_hi20(memset)
18+
; LARGE-NEXT: addi.d [[REG2:\$[a-z0-9]+]], $zero, %pc_lo12(memset)
19+
; LARGE-NEXT: lu32i.d [[REG2]], %pc64_lo20(memset)
20+
; LARGE-NEXT: lu52i.d [[REG2]], [[REG2]], %pc64_hi12(memset)
21+
entry:
22+
call void @llvm.memset.p0.i64(ptr %dst, i8 0, i64 1000, i1 false)
23+
ret void
24+
}
25+
26+
declare i32 @callee_tail(i32 %i)
27+
28+
define i32 @caller_call_tail(i32 %i) nounwind {
29+
; MEDIUM-LABEL: caller_call_tail:
30+
; MEDIUM: pcaddu18i $a1, %call36(callee_tail)
31+
; MEDIUM-NEXT: ld.d {{.*}}
32+
; MEDIUM-NEXT: ld.d {{.*}}
33+
; MEDIUM-NEXT: addi.d {{.*}}
34+
; MEDIUM-NEXT: jr $a1
35+
;
36+
; LARGE-LABEL: caller_call_tail:
37+
; LARGE: pcalau12i [[REG1:\$[a-z0-9]+]], %got_pc_hi20(callee_tail)
38+
; LARGE-NEXT: addi.d [[REG2:\$[a-z0-9]+]], $zero, %got_pc_lo12(callee_tail)
39+
; LARGE-NEXT: lu32i.d [[REG2]], %got64_pc_lo20(callee_tail)
40+
; LARGE-NEXT: lu52i.d [[REG2]], [[REG2]], %got64_pc_hi12(callee_tail)
41+
entry:
42+
call i32 @callee_tail(i32 %i)
43+
%r = tail call i32 @callee_tail(i32 %i)
44+
ret i32 %r
45+
}
46+
47+
@ie = external thread_local(initialexec) global i32
48+
49+
define void @test_la_tls_ie(i32 signext %n) {
50+
; LARGE-LABEL: test_la_tls_ie:
51+
; LARGE: pcalau12i [[REG1:\$[a-z0-9]+]], %ie_pc_hi20(ie)
52+
; LARGE-NEXT: addi.d [[REG2:\$[a-z0-9]+]], $zero, %ie_pc_lo12(ie)
53+
; LARGE-NEXT: lu32i.d [[REG2]], %ie64_pc_lo20(ie)
54+
; LARGE-NEXT: lu52i.d [[REG2]], [[REG2]], %ie64_pc_hi12(ie)
55+
entry:
56+
br label %loop
57+
58+
loop:
59+
%i = phi i32 [ %inc, %loop ], [ 0, %entry ]
60+
%0 = load volatile i32, ptr @ie, align 4
61+
%inc = add nuw nsw i32 %i, 1
62+
%cmp = icmp slt i32 %inc, %n
63+
br i1 %cmp, label %loop, label %ret
64+
65+
ret:
66+
ret void
67+
}
68+
69+
@ld = external thread_local(localdynamic) global i32
70+
71+
define void @test_la_tls_ld(i32 signext %n) {
72+
; LARGE-LABEL: test_la_tls_ld:
73+
; LARGE: pcalau12i [[REG1:\$[a-z0-9]+]], %ld_pc_hi20(ld)
74+
; LARGE-NEXT: addi.d [[REG2:\$[a-z0-9]+]], $zero, %got_pc_lo12(ld)
75+
; LARGE-NEXT: lu32i.d [[REG2]], %got64_pc_lo20(ld)
76+
; LARGE-NEXT: lu52i.d [[REG2]], [[REG2]], %got64_pc_hi12(ld)
77+
entry:
78+
br label %loop
79+
80+
loop:
81+
%i = phi i32 [ %inc, %loop ], [ 0, %entry ]
82+
%0 = load volatile i32, ptr @ld, align 4
83+
%inc = add nuw nsw i32 %i, 1
84+
%cmp = icmp slt i32 %inc, %n
85+
br i1 %cmp, label %loop, label %ret
86+
87+
ret:
88+
ret void
89+
}
90+
91+
@gd = external thread_local global i32
92+
93+
define void @test_la_tls_gd(i32 signext %n) nounwind {
94+
; LARGE-LABEL: test_la_tls_gd:
95+
; LARGE: pcalau12i [[REG1:\$[a-z0-9]+]], %gd_pc_hi20(gd)
96+
; LARGE-NEXT: addi.d [[REG2:\$[a-z0-9]+]], $zero, %got_pc_lo12(gd)
97+
; LARGE-NEXT: lu32i.d [[REG2]], %got64_pc_lo20(gd)
98+
; LARGE-NEXT: lu52i.d [[REG2]], [[REG2]], %got64_pc_hi12(gd)
99+
entry:
100+
br label %loop
101+
102+
loop:
103+
%i = phi i32 [ %inc, %loop ], [ 0, %entry ]
104+
%0 = load volatile i32, ptr @gd, align 4
105+
%inc = add nuw nsw i32 %i, 1
106+
%cmp = icmp slt i32 %inc, %n
107+
br i1 %cmp, label %loop, label %ret
108+
109+
ret:
110+
ret void
111+
}
112+
113+
@unspecified = external thread_local global i32
114+
115+
define ptr @test_la_tls_desc() nounwind {
116+
; LARGEDESC-LABEL: test_la_tls_desc:
117+
; LARGEDESC: pcalau12i [[REG1:\$[a-z0-9]+]], %desc_pc_hi20(unspecified)
118+
; LARGEDESC-NEXT: addi.d [[REG2:\$[a-z0-9]+]], $zero, %desc_pc_lo12(unspecified)
119+
; LARGEDESC-NEXT: lu32i.d [[REG2]], %desc64_pc_lo20(unspecified)
120+
; LARGEDESC-NEXT: lu52i.d [[REG2]], [[REG2]], %desc64_pc_hi12(unspecified)
121+
entry:
122+
ret ptr @unspecified
123+
}

0 commit comments

Comments
 (0)