1; RUN: llc < %s -mtriple=armv6-apple-darwin -relocation-model=static | FileCheck %s -check-prefix=DarwinStatic
2; RUN: llc < %s -mtriple=armv6-apple-darwin -relocation-model=dynamic-no-pic | FileCheck %s -check-prefix=DarwinDynamic
3; RUN: llc < %s -mtriple=armv6-apple-darwin -relocation-model=pic | FileCheck %s -check-prefix=DarwinPIC
4; RUN: llc < %s -mtriple=armv6-linux-gnueabi -relocation-model=pic | FileCheck %s -check-prefix=LinuxPIC
5
6@G = external global i32
7
8define i32 @test1() {
9	%tmp = load i32, i32* @G
10	ret i32 %tmp
11}
12
13; DarwinStatic: _test1:
14; DarwinStatic: 	ldr r0, LCPI0_0
15; DarwinStatic:	        ldr r0, [r0]
16; DarwinStatic:	        bx lr
17
18; DarwinStatic: 	.p2align	2
19; DarwinStatic:	LCPI0_0:
20; DarwinStatic: 	.long	{{_G$}}
21
22
23; DarwinDynamic: _test1:
24; DarwinDynamic: 	ldr r0, LCPI0_0
25; DarwinDynamic:        ldr r0, [r0]
26; DarwinDynamic:        ldr r0, [r0]
27; DarwinDynamic:        bx lr
28
29; DarwinDynamic: 	.p2align	2
30; DarwinDynamic:	LCPI0_0:
31; DarwinDynamic: 	.long	L_G$non_lazy_ptr
32
33; DarwinDynamic: 	.section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
34; DarwinDynamic:	.p2align	2
35; DarwinDynamic: L_G$non_lazy_ptr:
36; DarwinDynamic:	.indirect_symbol _G
37; DarwinDynamic:	.long	0
38
39
40
41; DarwinPIC: _test1:
42; DarwinPIC: 	ldr r0, LCPI0_0
43; DarwinPIC: LPC0_0:
44; DarwinPIC:    ldr r0, [pc, r0]
45; DarwinPIC:    ldr r0, [r0]
46; DarwinPIC-NOT: ldr
47; DarwinPIC:    bx lr
48
49; DarwinPIC: 	.p2align	2
50; DarwinPIC: LCPI0_0:
51; DarwinPIC: 	.long	L_G$non_lazy_ptr-(LPC0_0+8)
52
53; DarwinPIC: 	.section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers
54; DarwinPIC:	.p2align	2
55; DarwinPIC: L_G$non_lazy_ptr:
56; DarwinPIC:	.indirect_symbol _G
57; DarwinPIC:	.long	0
58
59
60
61; LinuxPIC-LABEL: test1:
62; LinuxPIC: 	ldr r0, .LCPI0_0
63	
64; LinuxPIC: .LPC0_0:
65; LinuxPIC: 	ldr r0, [pc, r0]
66; LinuxPIC: 	ldr r0, [r0]
67; LinuxPIC: 	bx lr
68
69; LinuxPIC: .p2align 2
70; LinuxPIC: .LCPI0_0:
71; LinuxPIC: .Ltmp0:
72; LinuxPIC:     .long   G(GOT_PREL)-((.LPC0_0+8)-.Ltmp0)
73