1
1
# REQUIRES: loongarch
2
+ # RUN: rm -rf %t && split-file %s %t && cd %t
2
3
3
- # RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax % s -o %t .32.o
4
- # RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax % s -o %t .64.o
4
+ # RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax a. s -o a .32.o
5
+ # RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax a. s -o a .64.o
5
6
6
- # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 %t .32.o -o %t .32
7
- # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 %t .64.o -o %t .64
8
- # RUN: llvm-objdump -td --no-show-raw-insn %t .32 | FileCheck --check-prefixes=RELAX %s
9
- # RUN: llvm-objdump -td --no-show-raw-insn %t .64 | FileCheck --check-prefixes=RELAX %s
7
+ # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 a .32.o -o a .32
8
+ # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 a .64.o -o a .64
9
+ # RUN: llvm-objdump -td --no-show-raw-insn a .32 | FileCheck --check-prefixes=RELAX %s
10
+ # RUN: llvm-objdump -td --no-show-raw-insn a .64 | FileCheck --check-prefixes=RELAX %s
10
11
11
- # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 %t .32.o -shared -o %t .32s
12
- # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 %t .64.o -shared -o %t .64s
13
- # RUN: llvm-objdump -td --no-show-raw-insn %t .32s | FileCheck --check-prefixes=RELAX %s
14
- # RUN: llvm-objdump -td --no-show-raw-insn %t .64s | FileCheck --check-prefixes=RELAX %s
12
+ # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 a .32.o -shared -o a .32s
13
+ # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 a .64.o -shared -o a .64s
14
+ # RUN: llvm-objdump -td --no-show-raw-insn a .32s | FileCheck --check-prefixes=RELAX %s
15
+ # RUN: llvm-objdump -td --no-show-raw-insn a .64s | FileCheck --check-prefixes=RELAX %s
15
16
16
- # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x410000 %t .32.o -o %t .32o
17
- # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x410000 %t .64.o -o %t .64o
18
- # RUN: llvm-objdump -td --no-show-raw-insn %t .32o | FileCheck --check-prefixes=NORELAX32 %s
19
- # RUN: llvm-objdump -td --no-show-raw-insn %t .64o | FileCheck --check-prefixes=NORELAX64 %s
17
+ # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x410000 a .32.o -o a .32o
18
+ # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x410000 a .64.o -o a .64o
19
+ # RUN: llvm-objdump -td --no-show-raw-insn a .32o | FileCheck --check-prefixes=NORELAX32 %s
20
+ # RUN: llvm-objdump -td --no-show-raw-insn a .64o | FileCheck --check-prefixes=NORELAX64 %s
20
21
21
22
# RELAX-LABEL: <_start>:
22
23
## offset = 0x14000 - 0x10000 = 4096<<2
49
50
# NORELAX64-NEXT: pcalau12i $a0, 1024
50
51
# NORELAX64-NEXT: ld.d $a0, $a0, 8
51
52
53
+
54
+ ## GOT references with non-zero addends. No relaxation.
55
+ # RUN: llvm-mc --filetype=obj --triple=loongarch32 -mattr=+relax nonzero.s -o nonzero.32.o
56
+ # RUN: llvm-mc --filetype=obj --triple=loongarch64 -mattr=+relax nonzero.s -o nonzero.64.o
57
+ # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 nonzero.32.o -o nonzero.32
58
+ # RUN: ld.lld --section-start=.text=0x10000 --section-start=.data=0x14000 nonzero.64.o -o nonzero.64
59
+ # RUN: llvm-objdump -td --no-show-raw-insn nonzero.32 | FileCheck --check-prefixes=NONZERO32 %s
60
+ # RUN: llvm-objdump -td --no-show-raw-insn nonzero.64 | FileCheck --check-prefixes=NONZERO64 %s
61
+
62
+ # NONZERO32-LABEL: <_start>:
63
+ # NONZERO32-NEXT: 10000: pcalau12i $a0, 4
64
+ # NONZERO32-NEXT: ld.w $a0, $a0, 8
65
+
66
+ # NONZERO64-LABEL: <_start>:
67
+ # NONZERO64-NEXT: 10000: pcalau12i $a0, 4
68
+ # NONZERO64-NEXT: ld.d $a0, $a0, 12
69
+
70
+
71
+ #--- a.s
52
72
.section .text
53
73
.global _start
54
74
_start:
@@ -60,3 +80,14 @@ _start:
60
80
.section .data
61
81
sym:
62
82
.zero 4
83
+
84
+
85
+ #--- nonzero.s
86
+ .section .text
87
+ .global _start
88
+ _start:
89
+ la.got $a0, sym+4
90
+
91
+ .section .data
92
+ sym:
93
+ .zero 4
0 commit comments