Extend the IL for selecting TLS models (PR9788)
[oota-llvm.git] / test / CodeGen / ARM / tls-models.ll
1 ; RUN: llc -march=arm -mtriple=arm-linux-gnueabi < %s | FileCheck -check-prefix=CHECK-NONPIC %s
2 ; RUN: llc -march=arm -mtriple=arm-linux-gnueabi -relocation-model=pic < %s | FileCheck -check-prefix=CHECK-PIC %s
3
4
5 @external_gd = external thread_local global i32
6 @internal_gd = internal thread_local global i32 42
7
8 @external_ld = external thread_local(localdynamic) global i32
9 @internal_ld = internal thread_local(localdynamic) global i32 42
10
11 @external_ie = external thread_local(initialexec) global i32
12 @internal_ie = internal thread_local(initialexec) global i32 42
13
14 @external_le = external thread_local(localexec) global i32
15 @internal_le = internal thread_local(localexec) global i32 42
16
17 ; ----- no model specified -----
18
19 define i32* @f1() {
20 entry:
21   ret i32* @external_gd
22
23   ; Non-PIC code can use initial-exec, PIC code has to use general dynamic.
24   ; CHECK-NONPIC:   f1:
25   ; CHECK-NONPIC:   external_gd(gottpoff)
26   ; CHECK-PIC:      f1:
27   ; CHECK-PIC:      external_gd(tlsgd)
28 }
29
30 define i32* @f2() {
31 entry:
32   ret i32* @internal_gd
33
34   ; Non-PIC code can use local exec, PIC code can use local dynamic,
35   ; but that is not implemented, so falls back to general dynamic.
36   ; CHECK-NONPIC:   f2:
37   ; CHECK-NONPIC:   internal_gd(tpoff)
38   ; CHECK-PIC:      f2:
39   ; CHECK-PIC:      internal_gd(tlsgd)
40 }
41
42
43 ; ----- localdynamic specified -----
44
45 define i32* @f3() {
46 entry:
47   ret i32* @external_ld
48
49   ; Non-PIC code can use initial exec, PIC should use local dynamic,
50   ; but that is not implemented, so falls back to general dynamic.
51   ; CHECK-NONPIC:   f3:
52   ; CHECK-NONPIC:   external_ld(gottpoff)
53   ; CHECK-PIC:      f3:
54   ; CHECK-PIC:      external_ld(tlsgd)
55 }
56
57 define i32* @f4() {
58 entry:
59   ret i32* @internal_ld
60
61   ; Non-PIC code can use local exec, PIC code can use local dynamic,
62   ; but that is not implemented, so it falls back to general dynamic.
63   ; CHECK-NONPIC:   f4:
64   ; CHECK-NONPIC:   internal_ld(tpoff)
65   ; CHECK-PIC:      f4:
66   ; CHECK-PIC:      internal_ld(tlsgd)
67 }
68
69
70 ; ----- initialexec specified -----
71
72 define i32* @f5() {
73 entry:
74   ret i32* @external_ie
75
76   ; Non-PIC and PIC code will use initial exec as specified.
77   ; CHECK-NONPIC:   f5:
78   ; CHECK-NONPIC:   external_ie(gottpoff)
79   ; CHECK-PIC:      f5:
80   ; CHECK-PIC:      external_ie(gottpoff)
81 }
82
83 define i32* @f6() {
84 entry:
85   ret i32* @internal_ie
86
87   ; Non-PIC code can use local exec, PIC code use initial exec as specified.
88   ; CHECK-NONPIC:   f6:
89   ; CHECK-NONPIC:   internal_ie(tpoff)
90   ; CHECK-PIC:      f6:
91   ; CHECK-PIC:      internal_ie(gottpoff)
92 }
93
94
95 ; ----- localexec specified -----
96
97 define i32* @f7() {
98 entry:
99   ret i32* @external_le
100
101   ; Non-PIC and PIC code will use local exec as specified.
102   ; CHECK-NONPIC:   f7:
103   ; CHECK-NONPIC:   external_le(tpoff)
104   ; CHECK-PIC:      f7:
105   ; CHECK-PIC:      external_le(tpoff)
106 }
107
108 define i32* @f8() {
109 entry:
110   ret i32* @internal_le
111
112   ; Non-PIC and PIC code will use local exec as specified.
113   ; CHECK-NONPIC:   f8:
114   ; CHECK-NONPIC:   internal_le(tpoff)
115   ; CHECK-PIC:      f8:
116   ; CHECK-PIC:      internal_le(tpoff)
117 }