xref: /aosp_15_r20/external/llvm/test/CodeGen/Mips/global-address.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mipsel -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC-O32
2*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mipsel -relocation-model=static -mtriple=mipsel-linux-gnu < %s | FileCheck %s -check-prefix=STATIC-O32
3*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mips64el -mcpu=mips64r2 -target-abi n32 -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC-N32
4*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mips64el -mcpu=mips64r2 -target-abi n32 -relocation-model=static  -mtriple=mipsel-linux-gnu < %s | FileCheck %s -check-prefix=STATIC-N32
5*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mips64el -mcpu=mips64r2 -target-abi n64 -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC-N64
6*9880d681SAndroid Build Coastguard Worker; RUN: llc -march=mips64el -mcpu=mips64r2 -target-abi n64 -relocation-model=static < %s | FileCheck %s -check-prefix=STATIC-N64
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Worker@s1 = internal unnamed_addr global i32 8, align 4
9*9880d681SAndroid Build Coastguard Worker@g1 = external global i32
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Workerdefine void @foo() nounwind {
12*9880d681SAndroid Build Coastguard Workerentry:
13*9880d681SAndroid Build Coastguard Worker; PIC-O32: lw  $[[R0:[0-9]+]], %got(s1)
14*9880d681SAndroid Build Coastguard Worker; PIC-O32: lw  ${{[0-9]+}}, %lo(s1)($[[R0]])
15*9880d681SAndroid Build Coastguard Worker; PIC-O32: lw  ${{[0-9]+}}, %got(g1)
16*9880d681SAndroid Build Coastguard Worker; STATIC-O32: lui $[[R1:[0-9]+]], %hi(s1)
17*9880d681SAndroid Build Coastguard Worker; STATIC-O32: lw  ${{[0-9]+}}, %lo(s1)($[[R1]])
18*9880d681SAndroid Build Coastguard Worker; STATIC-O32: lui $[[R2:[0-9]+]], %hi(g1)
19*9880d681SAndroid Build Coastguard Worker; STATIC-O32: lw  ${{[0-9]+}}, %lo(g1)($[[R2]])
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker; PIC-N32: lw  $[[R0:[0-9]+]], %got_page(s1)
22*9880d681SAndroid Build Coastguard Worker; PIC-N32: lw  ${{[0-9]+}}, %got_ofst(s1)($[[R0]])
23*9880d681SAndroid Build Coastguard Worker; PIC-N32: lw  ${{[0-9]+}}, %got_disp(g1)
24*9880d681SAndroid Build Coastguard Worker; STATIC-N32: lui $[[R1:[0-9]+]], %hi(s1)
25*9880d681SAndroid Build Coastguard Worker; STATIC-N32: lw  ${{[0-9]+}}, %lo(s1)($[[R1]])
26*9880d681SAndroid Build Coastguard Worker; STATIC-N32: lui $[[R2:[0-9]+]], %hi(g1)
27*9880d681SAndroid Build Coastguard Worker; STATIC-N32: lw  ${{[0-9]+}}, %lo(g1)($[[R2]])
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Worker; PIC-N64: ld  $[[R0:[0-9]+]], %got_page(s1)
30*9880d681SAndroid Build Coastguard Worker; PIC-N64: lw  ${{[0-9]+}}, %got_ofst(s1)($[[R0]])
31*9880d681SAndroid Build Coastguard Worker; PIC-N64: ld  ${{[0-9]+}}, %got_disp(g1)
32*9880d681SAndroid Build Coastguard Worker; STATIC-N64: ld  $[[R1:[0-9]+]], %got_page(s1)
33*9880d681SAndroid Build Coastguard Worker; STATIC-N64: lw  ${{[0-9]+}}, %got_ofst(s1)($[[R1]])
34*9880d681SAndroid Build Coastguard Worker; STATIC-N64: ld  ${{[0-9]+}}, %got_disp(g1)
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* @s1, align 4
37*9880d681SAndroid Build Coastguard Worker  tail call void @foo1(i32 %0) nounwind
38*9880d681SAndroid Build Coastguard Worker  %1 = load i32, i32* @g1, align 4
39*9880d681SAndroid Build Coastguard Worker  store i32 %1, i32* @s1, align 4
40*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %1, 2
41*9880d681SAndroid Build Coastguard Worker  store i32 %add, i32* @g1, align 4
42*9880d681SAndroid Build Coastguard Worker  ret void
43*9880d681SAndroid Build Coastguard Worker}
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Workerdeclare void @foo1(i32)
46*9880d681SAndroid Build Coastguard Worker
47