1; RUN: llc < %s -march=sparc   -relocation-model=static -code-model=small  | FileCheck --check-prefix=abs32 %s
2; RUN: llc < %s -march=sparcv9 -relocation-model=static -code-model=small  | FileCheck --check-prefix=abs32 %s
3; RUN: llc < %s -march=sparcv9 -relocation-model=static -code-model=medium | FileCheck --check-prefix=abs44 %s
4; RUN: llc < %s -march=sparcv9 -relocation-model=static -code-model=large  | FileCheck --check-prefix=abs64 %s
5; RUN: llc < %s -march=sparc   -relocation-model=pic    -code-model=medium | FileCheck --check-prefix=v8pic32 %s
6; RUN: llc < %s -march=sparcv9 -relocation-model=pic    -code-model=medium | FileCheck --check-prefix=v9pic32 %s
7
8@G = external global i8
9
10define zeroext i8 @loadG() {
11  %tmp = load i8, i8* @G
12  ret i8 %tmp
13}
14
15; abs32: loadG
16; abs32: sethi %hi(G), %[[R:[gilo][0-7]]]
17; abs32: retl
18; abs32: ldub [%[[R]]+%lo(G)], %o0
19
20
21; abs44: loadG
22; abs44: sethi %h44(G), %[[R1:[gilo][0-7]]]
23; abs44: add %[[R1]], %m44(G), %[[R2:[gilo][0-7]]]
24; abs44: sllx %[[R2]], 12, %[[R3:[gilo][0-7]]]
25; abs44: retl
26; abs44: ldub [%[[R3]]+%l44(G)], %o0
27
28
29; abs64: loadG
30; abs64: sethi %hi(G), %[[R1:[gilo][0-7]]]
31; abs64: add %[[R1]], %lo(G), %[[R2:[gilo][0-7]]]
32; abs64: sethi %hh(G), %[[R3:[gilo][0-7]]]
33; abs64: add %[[R3]], %hm(G), %[[R4:[gilo][0-7]]]
34; abs64: sllx %[[R4]], 32, %[[R5:[gilo][0-7]]]
35; abs64: retl
36; abs64: ldub [%[[R5]]+%[[R2]]], %o0
37
38
39; v8pic32: loadG
40; v8pic32: _GLOBAL_OFFSET_TABLE_
41; v8pic32: sethi %hi(G), %[[R1:[gilo][0-7]]]
42; v8pic32: add %[[R1]], %lo(G), %[[Goffs:[gilo][0-7]]]
43; v8pic32: ld [%[[GOT:[gilo][0-7]]]+%[[Goffs]]], %[[Gaddr:[gilo][0-7]]]
44; v8pic32: ldub [%[[Gaddr]]], %i0
45; v8pic32: ret
46; v8pic32: restore
47
48
49; v9pic32: loadG
50; v9pic32: _GLOBAL_OFFSET_TABLE_
51; v9pic32: sethi %hi(G), %[[R1:[gilo][0-7]]]
52; v9pic32: add %[[R1]], %lo(G), %[[Goffs:[gilo][0-7]]]
53; v9pic32: ldx [%[[GOT:[gilo][0-7]]]+%[[Goffs]]], %[[Gaddr:[gilo][0-7]]]
54; v9pic32: ldub [%[[Gaddr]]], %i0
55; v9pic32: ret
56; v9pic32: restore
57
58