option-mix.s
3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# RUN: llvm-mc %s -triple=riscv32 | FileCheck -check-prefixes=ASM %s
# RUN: llvm-mc %s -triple=riscv64 | FileCheck -check-prefixes=ASM %s
# RUN: llvm-mc %s -triple=riscv32 -mattr=+relax | FileCheck -check-prefix=ASM %s
# RUN: llvm-mc %s -triple=riscv64 -mattr=+relax | FileCheck -check-prefix=ASM %s
# RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
# RUN: | llvm-objdump -d -M no-aliases - | FileCheck --check-prefixes=DISASM,DISASM-NORELAX %s
# RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
# RUN: | llvm-objdump -d -M no-aliases - | FileCheck --check-prefixes=DISASM,DISASM-NORELAX %s
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+relax < %s \
# RUN: | llvm-objdump -d -M no-aliases - | FileCheck --check-prefixes=DISASM,DISASM-RELAX %s
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+relax < %s \
# RUN: | llvm-objdump -d -M no-aliases - | FileCheck --check-prefixes=DISASM,DISASM-RELAX %s
# Checks change of options does not cause error: could not find corresponding %pcrel_hi
# when assembling pseudoinstruction and its extended form. Also checks that we
# evaluate the correct value for local symbols in such a situation.
.option push
.option norelax
la a0, a_symbol
.option pop
la a1, another_symbol
# ASM-LABEL: .Lpcrel_hi0{{>?}}:
# ASM-NEXT: auipc a0, %pcrel_hi(a_symbol)
# ASM-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi0)
# ASM-LABEL: .Lpcrel_hi1{{>?}}:
# ASM-NEXT: auipc a1, %pcrel_hi(another_symbol)
# ASM-NEXT: addi a1, a1, %pcrel_lo(.Lpcrel_hi1)
# DISASM-LABEL: <.Lpcrel_hi0>:
# DISASM-NEXT: auipc a0, 0
# DISASM-NEXT: addi a0, a0, 0
# DISASM-LABEL: <.Lpcrel_hi1>:
# DISASM-NEXT: auipc a1, 0
# DISASM-NEXT: addi a1, a1, 0
.option push
.option norelax
1:auipc a0, %pcrel_hi(a_symbol)
addi a0, a0, %pcrel_lo(1b)
.option pop
2:auipc a1, %pcrel_hi(another_symbol)
addi a1, a1, %pcrel_lo(2b)
# ASM-LABEL: .Ltmp0{{>?}}:
# ASM-NEXT: auipc a0, %pcrel_hi(a_symbol)
# ASM-NEXT: addi a0, a0, %pcrel_lo(.Ltmp0)
# ASM-LABEL: .Ltmp1{{>?}}:
# ASM-NEXT: auipc a1, %pcrel_hi(another_symbol)
# ASM-NEXT: addi a1, a1, %pcrel_lo(.Ltmp1)
# DISASM-LABEL: .Ltmp0{{>?}}:
# DISASM-NEXT: auipc a0, 0
# DISASM-NEXT: addi a0, a0, 0
# DISASM-LABEL: .Ltmp1{{>?}}:
# DISASM-NEXT: auipc a1, 0
# DISASM-NEXT: addi a1, a1, 0
.option push
.option norelax
la a0, a_symbol
.option pop
la a1, local_symbol1
local_symbol1:
nop
# ASM-LABEL: .Lpcrel_hi2{{>?}}:
# ASM-NEXT: auipc a0, %pcrel_hi(a_symbol)
# ASM-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi2)
# ASM-LABEL: .Lpcrel_hi3{{>?}}:
# ASM-NEXT: auipc a1, %pcrel_hi(local_symbol1)
# ASM-NEXT: addi a1, a1, %pcrel_lo(.Lpcrel_hi3)
# DISASM-LABEL: .Lpcrel_hi2{{>?}}:
# DISASM-NEXT: auipc a0, 0
# DISASM-NEXT: addi a0, a0, 0
# DISASM-NORELAX-NEXT: auipc a1, 0
# DISASM-NORELAX-NEXT: addi a1, a1, 8
# DISASM-RELAX-LABEL: .Lpcrel_hi3{{>?}}:
# DISASM-RELAX-NEXT: auipc a1, 0
# DISASM-RELAX-NEXT: addi a1, a1, 0
.option push
.option norelax
1:auipc a0, %pcrel_hi(a_symbol)
addi a0, a0, %pcrel_lo(1b)
.option pop
2:auipc a1, %pcrel_hi(local_symbol2)
addi a1, a1, %pcrel_lo(2b)
local_symbol2:
nop
# ASM-LABEL: .Ltmp2{{>?}}:
# ASM-NEXT: auipc a0, %pcrel_hi(a_symbol)
# ASM-NEXT: addi a0, a0, %pcrel_lo(.Ltmp2)
# ASM-LABEL: .Ltmp3{{>?}}:
# ASM-NEXT: auipc a1, %pcrel_hi(local_symbol2)
# ASM-NEXT: addi a1, a1, %pcrel_lo(.Ltmp3)
# DISASM-LABEL: .Ltmp2{{>?}}:
# DISASM-NEXT: auipc a0, 0
# DISASM-NEXT: addi a0, a0, 0
# DISASM-NORELAX-NEXT: auipc a1, 0
# DISASM-NORELAX-NEXT: addi a1, a1, 8
# DISASM-RELAX-LABEL: .Ltmp3{{>?}}:
# DISASM-RELAX-NEXT: auipc a1, 0
# DISASM-RELAX-NEXT: addi a1, a1, 0