xref: /aosp_15_r20/external/llvm/test/CodeGen/SystemZ/la-03.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Test loads of symbolic addresses in PIC code.
2*9880d681SAndroid Build Coastguard Worker;
3*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=s390x-linux-gnu -relocation-model=pic | FileCheck %s
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker@ev = external global i32
6*9880d681SAndroid Build Coastguard Worker@dv = global i32 0
7*9880d681SAndroid Build Coastguard Worker@pv = protected global i32 0
8*9880d681SAndroid Build Coastguard Worker@hv = hidden global i32 0
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdeclare void @ef()
11*9880d681SAndroid Build Coastguard Workerdefine void @df() {
12*9880d681SAndroid Build Coastguard Worker  ret void
13*9880d681SAndroid Build Coastguard Worker}
14*9880d681SAndroid Build Coastguard Workerdefine protected void @pf() {
15*9880d681SAndroid Build Coastguard Worker  ret void
16*9880d681SAndroid Build Coastguard Worker}
17*9880d681SAndroid Build Coastguard Workerdefine hidden void @hf() {
18*9880d681SAndroid Build Coastguard Worker  ret void
19*9880d681SAndroid Build Coastguard Worker}
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker; Test loads of external variables, which must go via the GOT.
22*9880d681SAndroid Build Coastguard Workerdefine i32 *@f1() {
23*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f1:
24*9880d681SAndroid Build Coastguard Worker; CHECK: lgrl %r2, ev@GOT
25*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
26*9880d681SAndroid Build Coastguard Worker  ret i32 *@ev
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker; Check loads of locally-defined normal-visibility variables, which might
30*9880d681SAndroid Build Coastguard Worker; be overridden.  The load must go via the GOT.
31*9880d681SAndroid Build Coastguard Workerdefine i32 *@f2() {
32*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f2:
33*9880d681SAndroid Build Coastguard Worker; CHECK: lgrl %r2, dv@GOT
34*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
35*9880d681SAndroid Build Coastguard Worker  ret i32 *@dv
36*9880d681SAndroid Build Coastguard Worker}
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Worker; Check loads of protected variables, which in the small code model
39*9880d681SAndroid Build Coastguard Worker; must be in range of LARL.
40*9880d681SAndroid Build Coastguard Workerdefine i32 *@f3() {
41*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f3:
42*9880d681SAndroid Build Coastguard Worker; CHECK: larl %r2, pv
43*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
44*9880d681SAndroid Build Coastguard Worker  ret i32 *@pv
45*9880d681SAndroid Build Coastguard Worker}
46*9880d681SAndroid Build Coastguard Worker
47*9880d681SAndroid Build Coastguard Worker; ...likewise hidden variables.
48*9880d681SAndroid Build Coastguard Workerdefine i32 *@f4() {
49*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f4:
50*9880d681SAndroid Build Coastguard Worker; CHECK: larl %r2, hv
51*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
52*9880d681SAndroid Build Coastguard Worker  ret i32 *@hv
53*9880d681SAndroid Build Coastguard Worker}
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker; Like f1, but for functions.
56*9880d681SAndroid Build Coastguard Workerdefine void() *@f5() {
57*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f5:
58*9880d681SAndroid Build Coastguard Worker; CHECK: lgrl %r2, ef@GOT
59*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
60*9880d681SAndroid Build Coastguard Worker  ret void() *@ef
61*9880d681SAndroid Build Coastguard Worker}
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Worker; Like f2, but for functions.
64*9880d681SAndroid Build Coastguard Workerdefine void() *@f6() {
65*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f6:
66*9880d681SAndroid Build Coastguard Worker; CHECK: lgrl %r2, df@GOT
67*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
68*9880d681SAndroid Build Coastguard Worker  ret void() *@df
69*9880d681SAndroid Build Coastguard Worker}
70*9880d681SAndroid Build Coastguard Worker
71*9880d681SAndroid Build Coastguard Worker; Like f3, but for functions.
72*9880d681SAndroid Build Coastguard Workerdefine void() *@f7() {
73*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f7:
74*9880d681SAndroid Build Coastguard Worker; CHECK: larl %r2, pf
75*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
76*9880d681SAndroid Build Coastguard Worker  ret void() *@pf
77*9880d681SAndroid Build Coastguard Worker}
78*9880d681SAndroid Build Coastguard Worker
79*9880d681SAndroid Build Coastguard Worker; Like f4, but for functions.
80*9880d681SAndroid Build Coastguard Workerdefine void() *@f8() {
81*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: f8:
82*9880d681SAndroid Build Coastguard Worker; CHECK: larl %r2, hf
83*9880d681SAndroid Build Coastguard Worker; CHECK: br %r14
84*9880d681SAndroid Build Coastguard Worker  ret void() *@hf
85*9880d681SAndroid Build Coastguard Worker}
86