1; RUN: llc < %s -emulated-tls -mtriple=mipsel-linux-android -relocation-model=pic \
2; RUN:     | FileCheck -check-prefix=MIPS_32 %s
3; RUN: llc < %s -emulated-tls -mtriple=mips64el-linux-android -relocation-model=pic \
4; RUN:     | FileCheck -check-prefix=MIPS_64 %s
5
6; RUN: llc < %s -mtriple=mipsel-linux-android -relocation-model=pic \
7; RUN:     | FileCheck -check-prefix=MIPS_32 %s
8; RUN: llc < %s -mtriple=mips64el-linux-android -relocation-model=pic \
9; RUN:     | FileCheck -check-prefix=MIPS_64 %s
10
11; Make sure that TLS symbols are emitted in expected order.
12
13@external_x = external thread_local global i32, align 8
14@external_y = thread_local global i8 7, align 2
15@internal_y = internal thread_local global i64 9, align 16
16
17define i32* @get_external_x() {
18entry:
19  ret i32* @external_x
20}
21
22define i8* @get_external_y() {
23entry:
24  ret i8* @external_y
25}
26
27define i64* @get_internal_y() {
28entry:
29  ret i64* @internal_y
30}
31
32; MIPS_32-LABEL: get_external_y:
33; MIPS_32-LABEL: get_internal_y:
34; MIPS_32:     lw {{.+}}(__emutls_v.internal_y
35; MIPS_32:     lw {{.+}}call16(__emutls_get_address
36; MIPS_32-NOT:  __emutls_t.external_x
37; MIPS_32-NOT:  __emutls_v.external_x:
38; MIPS_32:       .data
39; MIPS_32:       .p2align 2
40; MIPS_32-LABEL: __emutls_v.external_y:
41; MIPS_32:       .section .rodata,
42; MIPS_32-LABEL: __emutls_t.external_y:
43; MIPS_32-NEXT:  .byte 7
44; MIPS_32:       .data
45; MIPS_32:       .p2align 2
46; MIPS_32-LABEL: __emutls_v.internal_y:
47; MIPS_32-NEXT:  .4byte 8
48; MIPS_32-NEXT:  .4byte 16
49; MIPS_32-NEXT:  .4byte 0
50; MIPS_32-NEXT:  .4byte __emutls_t.internal_y
51; MIPS_32-LABEL: __emutls_t.internal_y:
52; MIPS_32-NEXT:  .8byte 9
53
54; MIPS_64-LABEL: get_external_x:
55; MIPS_64-LABEL: get_external_y:
56; MIPS_64-LABEL: get_internal_y:
57; MIPS_64:     ld {{.+}}(__emutls_v.internal_y
58; MIPS_64:     ld {{.+}}call16(__emutls_get_address
59; MIPS_64-NOT:  __emutls_t.external_x
60; MIPS_64-NOT:  __emutls_v.external_x:
61; MIPS_64-LABEL: __emutls_v.external_y:
62; MIPS_64-NOT:   __emutls_v.external_x:
63; MIPS_64:       .section .rodata,
64; MIPS_64-LABEL: __emutls_t.external_y:
65; MIPS_64-NEXT:  .byte 7
66; MIPS_64:       .data
67; MIPS_64:       .p2align 3
68; MIPS_64-LABEL: __emutls_v.internal_y:
69; MIPS_64-NEXT:  .8byte 8
70; MIPS_64-NEXT:  .8byte 16
71; MIPS_64-NEXT:  .8byte 0
72; MIPS_64-NEXT:  .8byte __emutls_t.internal_y
73; MIPS_64:       .section .rodata,
74; MIPS_64-LABEL: __emutls_t.internal_y:
75; MIPS_64-NEXT:  .8byte 9
76