1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=csky -csky-no-aliases -relocation-model=pic -mattr=+2e3 < %s \
3 ; RUN: | FileCheck -check-prefix=CSKY-PIC %s
4 ; RUN: llc -mtriple=csky -csky-no-aliases -mattr=+2e3 < %s | FileCheck -check-prefix=CSKY-NOPIC %s
6 ; Check that TLS symbols are lowered correctly based on the specified
7 ; model. Make sure they're external to avoid them all being optimised to Local
8 ; Exec for the executable.
10 @unspecified = external thread_local global i32
11 @ld = external thread_local(localdynamic) global i32
12 @ie = external thread_local(initialexec) global i32
13 @le = external thread_local(localexec) global i32
18 define i32* @f1() nounwind {
20 ; CSKY-PIC: # %bb.0: # %entry
21 ; CSKY-PIC-NEXT: subi16 sp, sp, 8
22 ; CSKY-PIC-NEXT: st32.w rgb, (sp, 4) # 4-byte Folded Spill
23 ; CSKY-PIC-NEXT: st32.w lr, (sp, 0) # 4-byte Folded Spill
24 ; CSKY-PIC-NEXT: lrw32 rgb, [.LCPI0_0]
25 ; CSKY-PIC-NEXT: .LPC0_1:
26 ; CSKY-PIC-NEXT: lrw32 a0, [.LCPI0_1]
27 ; CSKY-PIC-NEXT: grs32 a1, .LPC0_1
28 ; CSKY-PIC-NEXT: addu16 a0, a1
29 ; CSKY-PIC-NEXT: lrw32 a1, [.LCPI0_2]
30 ; CSKY-PIC-NEXT: ldr32.w a1, (rgb, a1 << 0)
31 ; CSKY-PIC-NEXT: jsr16 a1
32 ; CSKY-PIC-NEXT: ld32.w lr, (sp, 0) # 4-byte Folded Reload
33 ; CSKY-PIC-NEXT: ld32.w rgb, (sp, 4) # 4-byte Folded Reload
34 ; CSKY-PIC-NEXT: addi16 sp, sp, 8
35 ; CSKY-PIC-NEXT: rts16
36 ; CSKY-PIC-NEXT: .p2align 1
37 ; CSKY-PIC-NEXT: # %bb.1:
38 ; CSKY-PIC-NEXT: .p2align 2
39 ; CSKY-PIC-NEXT: .LCPI0_0:
40 ; CSKY-PIC-NEXT: .long _GLOBAL_OFFSET_TABLE_
41 ; CSKY-PIC-NEXT: .LCPI0_1:
42 ; CSKY-PIC-NEXT: .Ltmp0:
43 ; CSKY-PIC-NEXT: .long unspecified-(.LPC0_1-.Ltmp0)@TLSGD32
44 ; CSKY-PIC-NEXT: .LCPI0_2:
45 ; CSKY-PIC-NEXT: .long __tls_get_addr@PLT
47 ; CSKY-NOPIC-LABEL: f1:
48 ; CSKY-NOPIC: # %bb.0: # %entry
49 ; CSKY-NOPIC-NEXT: .LPC0_1:
50 ; CSKY-NOPIC-NEXT: lrw32 a0, [.LCPI0_0]
51 ; CSKY-NOPIC-NEXT: grs32 a1, .LPC0_1
52 ; CSKY-NOPIC-NEXT: ldr32.w a0, (a0, a1 << 0)
53 ; CSKY-NOPIC-NEXT: addu32 a0, a0, tls
54 ; CSKY-NOPIC-NEXT: rts16
55 ; CSKY-NOPIC-NEXT: .p2align 1
56 ; CSKY-NOPIC-NEXT: # %bb.1:
57 ; CSKY-NOPIC-NEXT: .p2align 2
58 ; CSKY-NOPIC-NEXT: .LCPI0_0:
59 ; CSKY-NOPIC-NEXT: .Ltmp0:
60 ; CSKY-NOPIC-NEXT: .long unspecified-(.LPC0_1-.Ltmp0)@GOTTPOFF
66 ; localdynamic specified
68 define i32* @f2() nounwind {
70 ; CSKY-PIC: # %bb.0: # %entry
71 ; CSKY-PIC-NEXT: subi16 sp, sp, 8
72 ; CSKY-PIC-NEXT: st32.w rgb, (sp, 4) # 4-byte Folded Spill
73 ; CSKY-PIC-NEXT: st32.w lr, (sp, 0) # 4-byte Folded Spill
74 ; CSKY-PIC-NEXT: lrw32 rgb, [.LCPI1_0]
75 ; CSKY-PIC-NEXT: .LPC1_1:
76 ; CSKY-PIC-NEXT: lrw32 a0, [.LCPI1_1]
77 ; CSKY-PIC-NEXT: grs32 a1, .LPC1_1
78 ; CSKY-PIC-NEXT: addu16 a0, a1
79 ; CSKY-PIC-NEXT: lrw32 a1, [.LCPI1_2]
80 ; CSKY-PIC-NEXT: ldr32.w a1, (rgb, a1 << 0)
81 ; CSKY-PIC-NEXT: jsr16 a1
82 ; CSKY-PIC-NEXT: ld32.w lr, (sp, 0) # 4-byte Folded Reload
83 ; CSKY-PIC-NEXT: ld32.w rgb, (sp, 4) # 4-byte Folded Reload
84 ; CSKY-PIC-NEXT: addi16 sp, sp, 8
85 ; CSKY-PIC-NEXT: rts16
86 ; CSKY-PIC-NEXT: .p2align 1
87 ; CSKY-PIC-NEXT: # %bb.1:
88 ; CSKY-PIC-NEXT: .p2align 2
89 ; CSKY-PIC-NEXT: .LCPI1_0:
90 ; CSKY-PIC-NEXT: .long _GLOBAL_OFFSET_TABLE_
91 ; CSKY-PIC-NEXT: .LCPI1_1:
92 ; CSKY-PIC-NEXT: .Ltmp1:
93 ; CSKY-PIC-NEXT: .long ld-(.LPC1_1-.Ltmp1)@TLSGD32
94 ; CSKY-PIC-NEXT: .LCPI1_2:
95 ; CSKY-PIC-NEXT: .long __tls_get_addr@PLT
97 ; CSKY-NOPIC-LABEL: f2:
98 ; CSKY-NOPIC: # %bb.0: # %entry
99 ; CSKY-NOPIC-NEXT: .LPC1_1:
100 ; CSKY-NOPIC-NEXT: lrw32 a0, [.LCPI1_0]
101 ; CSKY-NOPIC-NEXT: grs32 a1, .LPC1_1
102 ; CSKY-NOPIC-NEXT: ldr32.w a0, (a0, a1 << 0)
103 ; CSKY-NOPIC-NEXT: addu32 a0, a0, tls
104 ; CSKY-NOPIC-NEXT: rts16
105 ; CSKY-NOPIC-NEXT: .p2align 1
106 ; CSKY-NOPIC-NEXT: # %bb.1:
107 ; CSKY-NOPIC-NEXT: .p2align 2
108 ; CSKY-NOPIC-NEXT: .LCPI1_0:
109 ; CSKY-NOPIC-NEXT: .Ltmp1:
110 ; CSKY-NOPIC-NEXT: .long ld-(.LPC1_1-.Ltmp1)@GOTTPOFF
116 ; initialexec specified
118 define i32* @f3() nounwind {
119 ; CSKY-PIC-LABEL: f3:
120 ; CSKY-PIC: # %bb.0: # %entry
121 ; CSKY-PIC-NEXT: .LPC2_1:
122 ; CSKY-PIC-NEXT: lrw32 a0, [.LCPI2_0]
123 ; CSKY-PIC-NEXT: grs32 a1, .LPC2_1
124 ; CSKY-PIC-NEXT: ldr32.w a0, (a0, a1 << 0)
125 ; CSKY-PIC-NEXT: addu32 a0, a0, tls
126 ; CSKY-PIC-NEXT: rts16
127 ; CSKY-PIC-NEXT: .p2align 1
128 ; CSKY-PIC-NEXT: # %bb.1:
129 ; CSKY-PIC-NEXT: .p2align 2
130 ; CSKY-PIC-NEXT: .LCPI2_0:
131 ; CSKY-PIC-NEXT: .Ltmp2:
132 ; CSKY-PIC-NEXT: .long ie-(.LPC2_1-.Ltmp2)@GOTTPOFF
134 ; CSKY-NOPIC-LABEL: f3:
135 ; CSKY-NOPIC: # %bb.0: # %entry
136 ; CSKY-NOPIC-NEXT: .LPC2_1:
137 ; CSKY-NOPIC-NEXT: lrw32 a0, [.LCPI2_0]
138 ; CSKY-NOPIC-NEXT: grs32 a1, .LPC2_1
139 ; CSKY-NOPIC-NEXT: ldr32.w a0, (a0, a1 << 0)
140 ; CSKY-NOPIC-NEXT: addu32 a0, a0, tls
141 ; CSKY-NOPIC-NEXT: rts16
142 ; CSKY-NOPIC-NEXT: .p2align 1
143 ; CSKY-NOPIC-NEXT: # %bb.1:
144 ; CSKY-NOPIC-NEXT: .p2align 2
145 ; CSKY-NOPIC-NEXT: .LCPI2_0:
146 ; CSKY-NOPIC-NEXT: .Ltmp2:
147 ; CSKY-NOPIC-NEXT: .long ie-(.LPC2_1-.Ltmp2)@GOTTPOFF
153 ; localexec specified
155 define i32* @f4() nounwind {
156 ; CSKY-PIC-LABEL: f4:
157 ; CSKY-PIC: # %bb.0: # %entry
158 ; CSKY-PIC-NEXT: lrw32 a0, [.LCPI3_0]
159 ; CSKY-PIC-NEXT: addu32 a0, a0, tls
160 ; CSKY-PIC-NEXT: rts16
161 ; CSKY-PIC-NEXT: .p2align 1
162 ; CSKY-PIC-NEXT: # %bb.1:
163 ; CSKY-PIC-NEXT: .p2align 2
164 ; CSKY-PIC-NEXT: .LCPI3_0:
165 ; CSKY-PIC-NEXT: .long le@TPOFF
167 ; CSKY-NOPIC-LABEL: f4:
168 ; CSKY-NOPIC: # %bb.0: # %entry
169 ; CSKY-NOPIC-NEXT: lrw32 a0, [.LCPI3_0]
170 ; CSKY-NOPIC-NEXT: addu32 a0, a0, tls
171 ; CSKY-NOPIC-NEXT: rts16
172 ; CSKY-NOPIC-NEXT: .p2align 1
173 ; CSKY-NOPIC-NEXT: # %bb.1:
174 ; CSKY-NOPIC-NEXT: .p2align 2
175 ; CSKY-NOPIC-NEXT: .LCPI3_0:
176 ; CSKY-NOPIC-NEXT: .long le@TPOFF