1 ; RUN: llc -mtriple thumbv7--windows-itanium %s -o - | FileCheck %s
3 @i = thread_local global i32 0
4 @j = external thread_local global i32
5 @k = internal thread_local global i32 0
6 @l = hidden thread_local global i32 0
7 @m = external hidden thread_local global i32
8 @n = thread_local global i16 0
9 @o = thread_local global i8 0
12 %1 = load i32, i32* @i
16 ; CHECK: mrc p15, #0, [[TEB:r[0-9]]], c13, c0, #2
18 ; CHECK: movw [[TLS_INDEX:r[0-9]]], :lower16:_tls_index
19 ; CHECK-NEXT: movt [[TLS_INDEX]], :upper16:_tls_index
20 ; CHECK-NEXT: ldr [[INDEX:r[0-9]]], {{\[}}[[TLS_INDEX]]]
21 ; CHECK-NEXT: ldr [[TLS_POINTER:r[0-9]]], {{\[}}[[TEB]], #44]
22 ; CHECK-NEXT: ldr{{.w}} [[TLS:r[0-9]]], {{\[}}[[TLS_POINTER]], [[INDEX]], lsl #2]
24 ; CHECK-NEXT: ldr [[SLOT:r[0-9]]], [[CPI:\.LCPI[0-9]+_[0-9]+]]
26 ; CHECK-NEXT: ldr r0, {{\[}}[[TLS]], [[SLOT]]]
29 ; CHECK-NEXT: .long i(SECREL32)
32 %1 = load i32, i32* @j
36 ; CHECK: mrc p15, #0, [[TEB:r[0-9]]], c13, c0, #2
38 ; CHECK: movw [[TLS_INDEX:r[0-9]]], :lower16:_tls_index
39 ; CHECK-NEXT: movt [[TLS_INDEX]], :upper16:_tls_index
40 ; CHECK-NEXT: ldr [[INDEX:r[0-9]]], {{\[}}[[TLS_INDEX]]]
41 ; CHECK-NEXT: ldr [[TLS_POINTER:r[0-9]]], {{\[}}[[TEB]], #44]
42 ; CHECK-NEXT: ldr{{.w}} [[TLS:r[0-9]]], {{\[}}[[TLS_POINTER]], [[INDEX]], lsl #2]
44 ; CHECK-NEXT: ldr [[SLOT:r[0-9]]], [[CPI:\.LCPI[0-9]+_[0-9]+]]
46 ; CHECK-NEXT: ldr r0, {{\[}}[[TLS]], [[SLOT]]]
49 ; CHECK-NEXT: .long j(SECREL32)
52 %1 = load i32, i32* @k
56 ; CHECK: mrc p15, #0, [[TEB:r[0-9]]], c13, c0, #2
58 ; CHECK: movw [[TLS_INDEX:r[0-9]]], :lower16:_tls_index
59 ; CHECK-NEXT: movt [[TLS_INDEX]], :upper16:_tls_index
60 ; CHECK-NEXT: ldr [[INDEX:r[0-9]]], {{\[}}[[TLS_INDEX]]]
61 ; CHECK-NEXT: ldr [[TLS_POINTER:r[0-9]]], {{\[}}[[TEB]], #44]
62 ; CHECK-NEXT: ldr{{.w}} [[TLS:r[0-9]]], {{\[}}[[TLS_POINTER]], [[INDEX]], lsl #2]
64 ; CHECK-NEXT: ldr [[SLOT:r[0-9]]], [[CPI:\.LCPI[0-9]+_[0-9]+]]
66 ; CHECK-NEXT: ldr r0, {{\[}}[[TLS]], [[SLOT]]]
69 ; CHECK-NEXT: .long k(SECREL32)
72 %1 = load i32, i32* @l
76 ; CHECK: mrc p15, #0, [[TEB:r[0-9]]], c13, c0, #2
78 ; CHECK: movw [[TLS_INDEX:r[0-9]]], :lower16:_tls_index
79 ; CHECK-NEXT: movt [[TLS_INDEX]], :upper16:_tls_index
80 ; CHECK-NEXT: ldr [[INDEX:r[0-9]]], {{\[}}[[TLS_INDEX]]]
81 ; CHECK-NEXT: ldr [[TLS_POINTER:r[0-9]]], {{\[}}[[TEB]], #44]
82 ; CHECK-NEXT: ldr{{.w}} [[TLS:r[0-9]]], {{\[}}[[TLS_POINTER]], [[INDEX]], lsl #2]
84 ; CHECK-NEXT: ldr [[SLOT:r[0-9]]], [[CPI:\.LCPI[0-9]+_[0-9]+]]
86 ; CHECK-NEXT: ldr r0, {{\[}}[[TLS]], [[SLOT]]]
89 ; CHECK-NEXT: .long l(SECREL32)
92 %1 = load i32, i32* @m
96 ; CHECK: mrc p15, #0, [[TEB:r[0-9]]], c13, c0, #2
98 ; CHECK: movw [[TLS_INDEX:r[0-9]]], :lower16:_tls_index
99 ; CHECK-NEXT: movt [[TLS_INDEX]], :upper16:_tls_index
100 ; CHECK-NEXT: ldr [[INDEX:r[0-9]]], {{\[}}[[TLS_INDEX]]]
101 ; CHECK-NEXT: ldr [[TLS_POINTER:r[0-9]]], {{\[}}[[TEB]], #44]
102 ; CHECK-NEXT: ldr{{.w}} [[TLS:r[0-9]]], {{\[}}[[TLS_POINTER]], [[INDEX]], lsl #2]
104 ; CHECK-NEXT: ldr [[SLOT:r[0-9]]], [[CPI:\.LCPI[0-9]+_[0-9]+]]
106 ; CHECK-NEXT: ldr r0, {{\[}}[[TLS]], [[SLOT]]]
109 ; CHECK: .long m(SECREL32)
112 %1 = load i16, i16* @n
116 ; CHECK: mrc p15, #0, [[TEB:r[0-9]]], c13, c0, #2
118 ; CHECK: movw [[TLS_INDEX:r[0-9]]], :lower16:_tls_index
119 ; CHECK-NEXT: movt [[TLS_INDEX]], :upper16:_tls_index
120 ; CHECK-NEXT: ldr [[INDEX:r[0-9]]], {{\[}}[[TLS_INDEX]]]
121 ; CHECK-NEXT: ldr [[TLS_POINTER:r[0-9]]], {{\[}}[[TEB]], #44]
122 ; CHECK-NEXT: ldr{{.w}} [[TLS:r[0-9]]], {{\[}}[[TLS_POINTER]], [[INDEX]], lsl #2]
124 ; CHECK-NEXT: ldr [[SLOT:r[0-9]]], [[CPI:\.LCPI[0-9]+_[0-9]+]]
126 ; CHECK-NEXT: ldrh r0, {{\[}}[[TLS]], [[SLOT]]]
129 ; CHECK: .long n(SECREL32)
136 ; CHECK: mrc p15, #0, [[TEB:r[0-9]]], c13, c0, #2
138 ; CHECK: movw [[TLS_INDEX:r[0-9]]], :lower16:_tls_index
139 ; CHECK-NEXT: movt [[TLS_INDEX]], :upper16:_tls_index
140 ; CHECK-NEXT: ldr [[INDEX:r[0-9]]], {{\[}}[[TLS_INDEX]]]
141 ; CHECK-NEXT: ldr [[TLS_POINTER:r[0-9]]], {{\[}}[[TEB]], #44]
142 ; CHECK-NEXT: ldr{{.w}} [[TLS:r[0-9]]], {{\[}}[[TLS_POINTER]], [[INDEX]], lsl #2]
144 ; CHECK-NEXT: ldr [[SLOT:r[0-9]]], [[CPI:\.LCPI[0-9]+_[0-9]+]]
146 ; CHECK-NEXT: ldrb r0, {{\[}}[[TLS]], [[SLOT]]]
149 ; CHECK-NEXT: .long o(SECREL32)