1 ; RUN: llc -mtriple=mipsel-- -disable-mips-delay-filler \
2 ; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC32
3 ; RUN: llc -mtriple=mips64el-- -disable-mips-delay-filler \
4 ; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC64
6 ; RUN: llc -mtriple=mipsel-- -mattr=+micromips -disable-mips-delay-filler \
7 ; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=MM
9 @t1 = dso_preemptable thread_local global i32 0, align 4
11 define dso_preemptable i32 @f1() nounwind {
13 %tmp = load i32, ptr @t1, align 4
17 ; PIC32-DAG: addu $[[R0:[a-z0-9]+]], $2, $25
18 ; PIC32-DAG: addiu $4, $[[R0]], %tlsgd(t1)
19 ; PIC32-DAG: lw $25, %call16(__tls_get_addr)($[[R0]])
21 ; PIC32-DAG: lw $2, 0($2)
24 ; PIC64-DAG: daddiu $[[R0:[a-z0-9]+]], $1, %lo(%neg(%gp_rel(f1)))
25 ; PIC64-DAG: daddiu $4, $[[R0]], %tlsgd(t1)
26 ; PIC64-DAG: ld $25, %call16(__tls_get_addr)($[[R0]])
28 ; PIC64-DAG: lw $2, 0($2)
31 ; MM-DAG: addu $[[R0:[a-z0-9]+]], $2, $25
32 ; MM-DAG: addiu $4, $[[R0]], %tlsgd(t1)
33 ; MM-DAG: lw $25, %call16(__tls_get_addr)($[[R0]])
34 ; MM-DAG: move $gp, $2
36 ; MM-DAG: lw16 $2, 0($2)
39 @t2 = external thread_local global i32
41 define dso_preemptable i32 @f2() nounwind {
43 %tmp = load i32, ptr @t2, align 4
47 ; PIC32-DAG: addu $[[R0:[a-z0-9]+]], $2, $25
48 ; PIC32-DAG: addiu $4, $[[R0]], %tlsgd(t2)
49 ; PIC32-DAG: lw $25, %call16(__tls_get_addr)($[[R0]])
51 ; PIC32-DAG: lw $2, 0($2)
54 ; PIC64-DAG: daddiu $[[R0:[a-z0-9]+]], $1, %lo(%neg(%gp_rel(f2)))
55 ; PIC64-DAG: daddiu $4, $[[R0]], %tlsgd(t2)
56 ; PIC64-DAG: ld $25, %call16(__tls_get_addr)($[[R0]])
58 ; PIC64-DAG: lw $2, 0($2)
61 ; MM-DAG: addu $[[R0:[a-z0-9]+]], $2, $25
62 ; MM-DAG: lw $25, %call16(__tls_get_addr)($[[R0]])
63 ; MM-DAG: addiu $4, $[[R0]], %tlsgd(t2)
65 ; MM-DAG: lw16 $2, 0($2)
68 @f3.i = internal thread_local unnamed_addr global i32 1, align 4
70 define dso_preemptable i32 @f3() nounwind {
73 ; PIC32: addu $[[R0:[a-z0-9]+]], $2, $25
74 ; PIC32: addiu $4, $[[R0]], %tlsldm(f3.i)
75 ; PIC32: lw $25, %call16(__tls_get_addr)($[[R0]])
77 ; PIC32: lui $[[R0:[0-9]+]], %dtprel_hi(f3.i)
78 ; PIC32: addu $[[R1:[0-9]+]], $[[R0]], $2
79 ; PIC32: lw $[[R3:[0-9]+]], %dtprel_lo(f3.i)($[[R1]])
80 ; PIC32: addiu $[[R3]], $[[R3]], 1
81 ; PIC32: sw $[[R3]], %dtprel_lo(f3.i)($[[R1]])
84 ; PIC64: lui $[[R0:[a-z0-9]+]], %hi(%neg(%gp_rel(f3)))
85 ; PIC64: daddu $[[R0]], $[[R0]], $25
86 ; PIC64: daddiu $[[R1:[a-z0-9]+]], $[[R0]], %lo(%neg(%gp_rel(f3)))
87 ; PIC64: daddiu $4, $[[R1]], %tlsldm(f3.i)
88 ; PIC64: ld $25, %call16(__tls_get_addr)($[[R1]])
90 ; PIC64: lui $[[R0:[0-9]+]], %dtprel_hi(f3.i)
91 ; PIC64: daddu $[[R1:[0-9]+]], $[[R0]], $2
92 ; PIC64: lw $[[R2:[0-9]+]], %dtprel_lo(f3.i)($[[R1]])
93 ; PIC64: addiu $[[R2]], $[[R2]], 1
94 ; PIC64: sw $[[R2]], %dtprel_lo(f3.i)($[[R1]])
97 ; MM: addiu $4, ${{[a-z0-9]+}}, %tlsldm(f3.i)
99 ; MM: lui $[[R0:[0-9]+]], %dtprel_hi(f3.i)
100 ; MM: addu16 $[[R1:[0-9]+]], $[[R0]], $2
101 ; MM: lw ${{[0-9]+}}, %dtprel_lo(f3.i)($[[R1]])
103 %0 = load i32, ptr @f3.i, align 4
104 %inc = add nsw i32 %0, 1
105 store i32 %inc, ptr @f3.i, align 4