blob: b416f1f6a5ed93c89ec63a351d7ff0b3f3402bec [file] [log] [blame]
Matthias Braund2fc0d42016-10-03 21:58:20 +00001; RUN: llc -mtriple=mipsel-- -disable-mips-delay-filler -relocation-model=pic < %s | \
Daniel Sanders0d972702016-06-24 12:23:17 +00002; RUN: FileCheck %s -check-prefixes=PIC,CHECK
Matthias Braund2fc0d42016-10-03 21:58:20 +00003; RUN: llc -mtriple=mipsel-- -relocation-model=static -disable-mips-delay-filler < \
Daniel Sanders0d972702016-06-24 12:23:17 +00004; RUN: %s | FileCheck %s -check-prefixes=STATIC,CHECK
Matthias Braund2fc0d42016-10-03 21:58:20 +00005; RUN: llc -mtriple=mipsel-- -relocation-model=static -disable-mips-delay-filler \
Akira Hatanaka9d957842012-08-22 02:51:28 +00006; RUN: -mips-fix-global-base-reg=false < %s | \
Daniel Sanders0d972702016-06-24 12:23:17 +00007; RUN: FileCheck %s -check-prefixes=STATICGP,CHECK
Bruno Cardoso Lopesbf3c1252011-05-31 02:53:58 +00008
9@t1 = thread_local global i32 0, align 4
10
11define i32 @f1() nounwind {
12entry:
David Blaikiea79ac142015-02-27 21:17:42 +000013 %tmp = load i32, i32* @t1, align 4
Bruno Cardoso Lopesbf3c1252011-05-31 02:53:58 +000014 ret i32 %tmp
15
Stephen Lind24ab202013-07-14 06:24:09 +000016; PIC-LABEL: f1:
Akira Hatanaka66bc4192013-07-12 23:33:22 +000017; PIC-DAG: addu $[[R0:[a-z0-9]+]], $2, $25
18; PIC-DAG: lw $25, %call16(__tls_get_addr)($[[R0]])
19; PIC-DAG: addiu $4, $[[R0]], %tlsgd(t1)
20; PIC-DAG: jalr $25
21; PIC-DAG: lw $2, 0($2)
Bruno Cardoso Lopesbf3c1252011-05-31 02:53:58 +000022
Stephen Lind24ab202013-07-14 06:24:09 +000023; STATIC-LABEL: f1:
Bruno Cardoso Lopesbf3c1252011-05-31 02:53:58 +000024; STATIC: lui $[[R0:[0-9]+]], %tprel_hi(t1)
25; STATIC: addiu $[[R1:[0-9]+]], $[[R0]], %tprel_lo(t1)
Rafael Espindolad8526082014-11-04 22:15:05 +000026; STATIC: rdhwr $3, $29
Bruno Cardoso Lopesbf3c1252011-05-31 02:53:58 +000027; STATIC: addu $[[R2:[0-9]+]], $3, $[[R1]]
28; STATIC: lw $2, 0($[[R2]])
29}
30
31
32@t2 = external thread_local global i32
33
34define i32 @f2() nounwind {
35entry:
David Blaikiea79ac142015-02-27 21:17:42 +000036 %tmp = load i32, i32* @t2, align 4
Bruno Cardoso Lopesbf3c1252011-05-31 02:53:58 +000037 ret i32 %tmp
38
Stephen Lind24ab202013-07-14 06:24:09 +000039; PIC-LABEL: f2:
Akira Hatanaka66bc4192013-07-12 23:33:22 +000040; PIC-DAG: addu $[[R0:[a-z0-9]+]], $2, $25
41; PIC-DAG: lw $25, %call16(__tls_get_addr)($[[R0]])
42; PIC-DAG: addiu $4, $[[R0]], %tlsgd(t2)
43; PIC-DAG: jalr $25
44; PIC-DAG: lw $2, 0($2)
Bruno Cardoso Lopesbf3c1252011-05-31 02:53:58 +000045
Stephen Lind24ab202013-07-14 06:24:09 +000046; STATICGP-LABEL: f2:
Akira Hatanakab049aef2012-02-24 22:34:47 +000047; STATICGP: lui $[[R0:[0-9]+]], %hi(__gnu_local_gp)
48; STATICGP: addiu $[[GP:[0-9]+]], $[[R0]], %lo(__gnu_local_gp)
49; STATICGP: lw ${{[0-9]+}}, %gottprel(t2)($[[GP]])
Akira Hatanaka66bc4192013-07-12 23:33:22 +000050
Stephen Lind24ab202013-07-14 06:24:09 +000051; STATIC-LABEL: f2:
Akira Hatanakad918f772012-05-12 00:17:17 +000052; STATIC: lui $[[R0:[0-9]+]], %hi(__gnu_local_gp)
Akira Hatanaka763ab852012-05-12 03:25:16 +000053; STATIC: addiu $[[GP:[0-9]+]], $[[R0]], %lo(__gnu_local_gp)
Rafael Espindolad8526082014-11-04 22:15:05 +000054; STATIC: rdhwr $3, $29
Akira Hatanaka763ab852012-05-12 03:25:16 +000055; STATIC: lw $[[R0:[0-9]+]], %gottprel(t2)($[[GP]])
Bruno Cardoso Lopesbf3c1252011-05-31 02:53:58 +000056; STATIC: addu $[[R1:[0-9]+]], $3, $[[R0]]
57; STATIC: lw $2, 0($[[R1]])
58}
Akira Hatanakabff84e12011-12-14 18:26:41 +000059
60@f3.i = internal thread_local unnamed_addr global i32 1, align 4
61
62define i32 @f3() nounwind {
63entry:
Stephen Lind24ab202013-07-14 06:24:09 +000064; CHECK-LABEL: f3:
Akira Hatanakabff84e12011-12-14 18:26:41 +000065
Akira Hatanaka763ab852012-05-12 03:25:16 +000066; PIC: addiu $4, ${{[a-z0-9]+}}, %tlsldm(f3.i)
Akira Hatanakabff84e12011-12-14 18:26:41 +000067; PIC: jalr $25
68; PIC: lui $[[R0:[0-9]+]], %dtprel_hi(f3.i)
69; PIC: addu $[[R1:[0-9]+]], $[[R0]], $2
Akira Hatanaka3c9f3362011-12-19 19:28:37 +000070; PIC: lw ${{[0-9]+}}, %dtprel_lo(f3.i)($[[R1]])
Akira Hatanakabff84e12011-12-14 18:26:41 +000071
David Blaikiea79ac142015-02-27 21:17:42 +000072 %0 = load i32, i32* @f3.i, align 4
Akira Hatanakabff84e12011-12-14 18:26:41 +000073 %inc = add nsw i32 %0, 1
74 store i32 %inc, i32* @f3.i, align 4
75 ret i32 %inc
76}
77