1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 --relocation-model=static < %s | FileCheck %s --check-prefix=LA32NOPIC
3 ; RUN: llc --mtriple=loongarch32 --relocation-model=pic < %s | FileCheck %s --check-prefix=LA32PIC
4 ; RUN: llc --mtriple=loongarch64 --relocation-model=static < %s | FileCheck %s --check-prefix=LA64NOPIC
5 ; RUN: llc --mtriple=loongarch64 --relocation-model=pic < %s | FileCheck %s --check-prefix=LA64PIC
6 ; RUN: llc --mtriple=loongarch64 --code-model=large --relocation-model=static < %s | FileCheck %s --check-prefix=LA64LARGENOPIC
7 ; RUN: llc --mtriple=loongarch64 --code-model=large --relocation-model=pic < %s | FileCheck %s --check-prefix=LA64LARGEPIC
9 @g = dso_local global i32 zeroinitializer, align 4
10 @G = global i32 zeroinitializer, align 4
12 define void @foo() nounwind {
13 ; LA32NOPIC-LABEL: foo:
15 ; LA32NOPIC-NEXT: pcalau12i $a0, %got_pc_hi20(G)
16 ; LA32NOPIC-NEXT: ld.w $a0, $a0, %got_pc_lo12(G)
17 ; LA32NOPIC-NEXT: ld.w $a0, $a0, 0
18 ; LA32NOPIC-NEXT: pcalau12i $a0, %pc_hi20(g)
19 ; LA32NOPIC-NEXT: addi.w $a0, $a0, %pc_lo12(g)
20 ; LA32NOPIC-NEXT: ld.w $a0, $a0, 0
25 ; LA32PIC-NEXT: pcalau12i $a0, %got_pc_hi20(G)
26 ; LA32PIC-NEXT: ld.w $a0, $a0, %got_pc_lo12(G)
27 ; LA32PIC-NEXT: ld.w $a0, $a0, 0
28 ; LA32PIC-NEXT: pcalau12i $a0, %pc_hi20(.Lg$local)
29 ; LA32PIC-NEXT: addi.w $a0, $a0, %pc_lo12(.Lg$local)
30 ; LA32PIC-NEXT: ld.w $a0, $a0, 0
33 ; LA64NOPIC-LABEL: foo:
35 ; LA64NOPIC-NEXT: pcalau12i $a0, %got_pc_hi20(G)
36 ; LA64NOPIC-NEXT: ld.d $a0, $a0, %got_pc_lo12(G)
37 ; LA64NOPIC-NEXT: ld.w $a0, $a0, 0
38 ; LA64NOPIC-NEXT: pcalau12i $a0, %pc_hi20(g)
39 ; LA64NOPIC-NEXT: addi.d $a0, $a0, %pc_lo12(g)
40 ; LA64NOPIC-NEXT: ld.w $a0, $a0, 0
45 ; LA64PIC-NEXT: pcalau12i $a0, %got_pc_hi20(G)
46 ; LA64PIC-NEXT: ld.d $a0, $a0, %got_pc_lo12(G)
47 ; LA64PIC-NEXT: ld.w $a0, $a0, 0
48 ; LA64PIC-NEXT: pcalau12i $a0, %pc_hi20(.Lg$local)
49 ; LA64PIC-NEXT: addi.d $a0, $a0, %pc_lo12(.Lg$local)
50 ; LA64PIC-NEXT: ld.w $a0, $a0, 0
53 ; LA64LARGENOPIC-LABEL: foo:
54 ; LA64LARGENOPIC: # %bb.0:
55 ; LA64LARGENOPIC-NEXT: pcalau12i $a0, %got_pc_hi20(G)
56 ; LA64LARGENOPIC-NEXT: addi.d $a1, $zero, %got_pc_lo12(G)
57 ; LA64LARGENOPIC-NEXT: lu32i.d $a1, %got64_pc_lo20(G)
58 ; LA64LARGENOPIC-NEXT: lu52i.d $a1, $a1, %got64_pc_hi12(G)
59 ; LA64LARGENOPIC-NEXT: ldx.d $a0, $a1, $a0
60 ; LA64LARGENOPIC-NEXT: ld.w $a0, $a0, 0
61 ; LA64LARGENOPIC-NEXT: pcalau12i $a0, %pc_hi20(g)
62 ; LA64LARGENOPIC-NEXT: addi.d $a1, $zero, %pc_lo12(g)
63 ; LA64LARGENOPIC-NEXT: lu32i.d $a1, %pc64_lo20(g)
64 ; LA64LARGENOPIC-NEXT: lu52i.d $a1, $a1, %pc64_hi12(g)
65 ; LA64LARGENOPIC-NEXT: add.d $a0, $a1, $a0
66 ; LA64LARGENOPIC-NEXT: ld.w $a0, $a0, 0
67 ; LA64LARGENOPIC-NEXT: ret
69 ; LA64LARGEPIC-LABEL: foo:
70 ; LA64LARGEPIC: # %bb.0:
71 ; LA64LARGEPIC-NEXT: pcalau12i $a0, %got_pc_hi20(G)
72 ; LA64LARGEPIC-NEXT: addi.d $a1, $zero, %got_pc_lo12(G)
73 ; LA64LARGEPIC-NEXT: lu32i.d $a1, %got64_pc_lo20(G)
74 ; LA64LARGEPIC-NEXT: lu52i.d $a1, $a1, %got64_pc_hi12(G)
75 ; LA64LARGEPIC-NEXT: ldx.d $a0, $a1, $a0
76 ; LA64LARGEPIC-NEXT: ld.w $a0, $a0, 0
77 ; LA64LARGEPIC-NEXT: pcalau12i $a0, %pc_hi20(.Lg$local)
78 ; LA64LARGEPIC-NEXT: addi.d $a1, $zero, %pc_lo12(.Lg$local)
79 ; LA64LARGEPIC-NEXT: lu32i.d $a1, %pc64_lo20(.Lg$local)
80 ; LA64LARGEPIC-NEXT: lu52i.d $a1, $a1, %pc64_hi12(.Lg$local)
81 ; LA64LARGEPIC-NEXT: add.d $a0, $a1, $a0
82 ; LA64LARGEPIC-NEXT: ld.w $a0, $a0, 0
83 ; LA64LARGEPIC-NEXT: ret
84 %V = load volatile i32, ptr @G
85 %v = load volatile i32, ptr @g