1 ; RUN: llc -march=mipsel < %s | FileCheck %s -check-prefix=PIC
2 ; RUN: llc -march=mipsel -relocation-model=static < %s \
3 ; RUN: | FileCheck %s -check-prefix=STATIC
4 ; RUN: llc -march=mipsel -relocation-model=static < %s \
5 ; RUN: -mips-fix-global-base-reg=false | FileCheck %s -check-prefix=STATICGP
7 @t1 = thread_local global i32 0, align 4
9 define i32 @f1() nounwind {
11 %tmp = load i32* @t1, align 4
16 ; PIC: addu $[[R0:[a-z0-9]+]], $2, $25
17 ; PIC: lw $25, %call16(__tls_get_addr)($[[R0]])
18 ; PIC: addiu $4, $[[R0]], %tlsgd(t1)
22 ; STATIC: rdhwr $3, $29
23 ; STATIC: lui $[[R0:[0-9]+]], %tprel_hi(t1)
24 ; STATIC: addiu $[[R1:[0-9]+]], $[[R0]], %tprel_lo(t1)
25 ; STATIC: addu $[[R2:[0-9]+]], $3, $[[R1]]
26 ; STATIC: lw $2, 0($[[R2]])
30 @t2 = external thread_local global i32
32 define i32 @f2() nounwind {
34 %tmp = load i32* @t2, align 4
39 ; PIC: addu $[[R0:[a-z0-9]+]], $2, $25
40 ; PIC: lw $25, %call16(__tls_get_addr)($[[R0]])
41 ; PIC: addiu $4, $[[R0]], %tlsgd(t2)
45 ; STATICGP: lui $[[R0:[0-9]+]], %hi(__gnu_local_gp)
46 ; STATICGP: addiu $[[GP:[0-9]+]], $[[R0]], %lo(__gnu_local_gp)
47 ; STATICGP: lw ${{[0-9]+}}, %gottprel(t2)($[[GP]])
48 ; STATIC: lui $[[R0:[0-9]+]], %hi(__gnu_local_gp)
49 ; STATIC: addiu $[[GP:[0-9]+]], $[[R0]], %lo(__gnu_local_gp)
50 ; STATIC: rdhwr $3, $29
51 ; STATIC: lw $[[R0:[0-9]+]], %gottprel(t2)($[[GP]])
52 ; STATIC: addu $[[R1:[0-9]+]], $3, $[[R0]]
53 ; STATIC: lw $2, 0($[[R1]])
56 @f3.i = internal thread_local unnamed_addr global i32 1, align 4
58 define i32 @f3() nounwind {
62 ; PIC: addiu $4, ${{[a-z0-9]+}}, %tlsldm(f3.i)
64 ; PIC: lui $[[R0:[0-9]+]], %dtprel_hi(f3.i)
65 ; PIC: addu $[[R1:[0-9]+]], $[[R0]], $2
66 ; PIC: lw ${{[0-9]+}}, %dtprel_lo(f3.i)($[[R1]])
68 %0 = load i32* @f3.i, align 4
69 %inc = add nsw i32 %0, 1
70 store i32 %inc, i32* @f3.i, align 4