1; RUN: llc < %s -code-model=small  | FileCheck -check-prefix CHECK-SMALL %s
2; RUN: llc < %s -code-model=kernel | FileCheck -check-prefix CHECK-KERNEL %s
3; RUN: not llc < %s -code-model=tiny 2>&1 | FileCheck -check-prefix CHECK-TINY %s
4
5target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
6target triple = "x86_64-unknown-linux-gnu"
7@data = external global [0 x i32]		; <[0 x i32]*> [#uses=5]
8
9; CHECK-TINY:    Target does not support the tiny CodeModel
10
11define i32 @foo() nounwind readonly {
12entry:
13; CHECK-SMALL-LABEL:  foo:
14; CHECK-SMALL:   movl data(%rip), %eax
15; CHECK-KERNEL-LABEL: foo:
16; CHECK-KERNEL:  movl data, %eax
17	%0 = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @data, i64 0, i64 0), align 4		; <i32> [#uses=1]
18	ret i32 %0
19}
20
21define i32 @foo2() nounwind readonly {
22entry:
23; CHECK-SMALL-LABEL:  foo2:
24; CHECK-SMALL:   movl data+40(%rip), %eax
25; CHECK-KERNEL-LABEL: foo2:
26; CHECK-KERNEL:  movl data+40, %eax
27	%0 = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @data, i32 0, i64 10), align 4		; <i32> [#uses=1]
28	ret i32 %0
29}
30
31define i32 @foo3() nounwind readonly {
32entry:
33; CHECK-SMALL-LABEL:  foo3:
34; CHECK-SMALL:   movl data-40(%rip), %eax
35; CHECK-KERNEL-LABEL: foo3:
36; CHECK-KERNEL:  movq $-40, %rax
37	%0 = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @data, i32 0, i64 -10), align 4		; <i32> [#uses=1]
38	ret i32 %0
39}
40
41define i32 @foo4() nounwind readonly {
42entry:
43; FIXME: We really can use movabsl here!
44; CHECK-SMALL-LABEL:  foo4:
45; CHECK-SMALL:   movl $16777216, %eax
46; CHECK-SMALL:   movl data(%rax), %eax
47; CHECK-KERNEL-LABEL: foo4:
48; CHECK-KERNEL:  movl data+16777216, %eax
49	%0 = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @data, i32 0, i64 4194304), align 4		; <i32> [#uses=1]
50	ret i32 %0
51}
52
53define i32 @foo1() nounwind readonly {
54entry:
55; CHECK-SMALL-LABEL:  foo1:
56; CHECK-SMALL:   movl data+16777212(%rip), %eax
57; CHECK-KERNEL-LABEL: foo1:
58; CHECK-KERNEL:  movl data+16777212, %eax
59        %0 = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @data, i32 0, i64 4194303), align 4            ; <i32> [#uses=1]
60        ret i32 %0
61}
62define i32 @foo5() nounwind readonly {
63entry:
64; CHECK-SMALL-LABEL:  foo5:
65; CHECK-SMALL:   movl data-16777216(%rip), %eax
66; CHECK-KERNEL-LABEL: foo5:
67; CHECK-KERNEL:  movq $-16777216, %rax
68	%0 = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @data, i32 0, i64 -4194304), align 4		; <i32> [#uses=1]
69	ret i32 %0
70}
71