3 # RUN: llvm-mc --filetype=obj --triple=loongarch32 --defsym ELF32=1 %s -o %t.32.o
4 # RUN: llvm-mc --filetype=obj --triple=loongarch64 %s -o %t.64.o
6 # RUN: ld.lld %t.32.o -o %t.32
7 # RUN: llvm-nm -p %t.32 | FileCheck --check-prefixes=NM %s
8 # RUN: llvm-objdump -d --no-show-raw-insn %t.32 | FileCheck --check-prefixes=LE,LE32 %s
10 # RUN: ld.lld %t.64.o -o %t.64
11 # RUN: llvm-objdump -d --no-show-raw-insn %t.64 | FileCheck --check-prefixes=LE,LE64 %s
13 # RUN: not ld.lld -shared %t.32.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR --implicit-check-not=error:
15 # ERR: error: relocation R_LARCH_TLS_LE_HI20 against .LANCHOR0 cannot be used with -shared
16 # ERR: error: relocation R_LARCH_TLS_LE_LO12 against .LANCHOR0 cannot be used with -shared
17 # ERR: error: relocation R_LARCH_TLS_LE_HI20 against a cannot be used with -shared
18 # ERR: error: relocation R_LARCH_TLS_LE_LO12 against a cannot be used with -shared
19 # ERR: error: relocation R_LARCH_TLS_LE_HI20_R against .LANCHOR0 cannot be used with -shared
20 # ERR: error: relocation R_LARCH_TLS_LE_LO12_R against .LANCHOR0 cannot be used with -shared
21 # ERR: error: relocation R_LARCH_TLS_LE_HI20_R against a cannot be used with -shared
22 # ERR: error: relocation R_LARCH_TLS_LE_LO12_R against a cannot be used with -shared
24 # NM: {{0*}}00000008 b .LANCHOR0
25 # NM: {{0*}}00000800 B a
27 ## .LANCHOR0@tprel = 8
30 # LE-NEXT: ori $a0, $a0, 8
31 # LE-NEXT: lu12i.w $a1, 0
32 # LE-NEXT: ori $a1, $a1, 2048
34 # LE32: add.w $a0, $a0, $tp
35 # LE32-NEXT: addi.w $a0, $a0, 8
36 # LE32-NEXT: lu12i.w $a0, 1
37 # LE32-NEXT: add.w $a0, $a0, $tp
38 # LE32-NEXT: addi.w $a0, $a0, -2048
40 # LE64: add.d $a0, $a0, $tp
41 # LE64-NEXT: addi.d $a0, $a0, 8
42 # LE64-NEXT: lu12i.w $a0, 1
43 # LE64-NEXT: add.d $a0, $a0, $tp
44 # LE64-NEXT: addi.d $a0, $a0, -2048
48 .macro add dst, src1, src2, src3
50 add.w \
dst, \src1
, \src2
, \src3
52 add.d \
dst, \src1
, \src2
, \src3
55 .macro addi dst, src1, src2
57 addi.w \
dst, \src1
, \src2
59 addi.d \
dst, \src1
, \src2
66 la.tls.le $a0
, .LANCHOR0
69 lu12i.w $a0
, %le_hi20_r
(.LANCHOR0)
70 add $a0
, $a0
, $tp
, %le_add_r
(.LANCHOR0)
71 addi $a0
, $a0
, %le_lo12_r
(.LANCHOR0)
73 lu12i.w $a0
, %le_hi20_r
(a)
74 add $a0
, $a0
, $tp
, %le_add_r
(a)
75 addi $a0
, $a0
, %le_lo12_r
(a)
77 .section .tbss,"awT",@nobits