forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[LoongArch] Support .option directive
The .option can accept 4 parameters like the LoongArch's gnu as: push, pop, relax and norelax. Reviewed By: heiher, SixWeining Pull Request: llvm#110404
- Loading branch information
1 parent
07c6fd7
commit fec88c0
Showing
9 changed files
with
283 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# RUN: not llvm-mc --triple=loongarch64 %s 2>&1 \ | ||
# RUN: | FileCheck --implicit-check-not=error: %s | ||
|
||
# CHECK: :[[#@LINE+1]]:8: error: expected identifier | ||
.option | ||
|
||
# CHECK: :[[#@LINE+1]]:9: error: expected identifier | ||
.option 123 | ||
|
||
# CHECK: :[[#@LINE+1]]:9: error: expected identifier | ||
.option "str" | ||
|
||
# CHECK: :[[#@LINE+1]]:12: warning: unknown option, expected 'push', 'pop', 'relax' or 'norelax' | ||
.option bar | ||
|
||
# CHECK: :[[#@LINE+1]]:12: error: .option pop with no .option push | ||
.option pop | ||
|
||
# CHECK: :[[#@LINE+1]]:14: error: expected newline | ||
.option push 123 | ||
|
||
# CHECK: :[[#@LINE+1]]:13: error: expected newline | ||
.option pop 123 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# RUN: llvm-mc --triple=loongarch64 --mattr=-relax %s \ | ||
# RUN: | FileCheck --check-prefix=CHECK-ASM %s | ||
# RUN: llvm-mc --triple=loongarch64 --mattr=-relax --filetype=obj %s \ | ||
# RUN: | llvm-readobj -r - | FileCheck --check-prefix=CHECK-RELOC %s | ||
|
||
## Test the operation of the push and pop assembler directives when | ||
## using .option relax. Checks that using .option pop correctly restores | ||
## all target features to their state at the point where .option pop was | ||
## last used. | ||
|
||
# CHECK-ASM: .option push | ||
.option push # relax = false | ||
|
||
# CHECK-ASM: .option relax | ||
.option relax # relax = true | ||
|
||
# CHECK-ASM: pcalau12i $a0, %pc_hi20(sym1) | ||
# CHECK-ASM-NEXT: addi.d $a0, $a0, %pc_lo12(sym1) | ||
# CHECK-RELOC: R_LARCH_PCALA_HI20 sym1 0x0 | ||
# CHECK-RELOC-NEXT: R_LARCH_RELAX - 0x0 | ||
# CHECK-RELOC-NEXT: R_LARCH_PCALA_LO12 sym1 0x0 | ||
# CHECK-RELOC-NEXT: R_LARCH_RELAX - 0x0 | ||
la.pcrel $a0, sym1 | ||
|
||
# CHECK-ASM: .option push | ||
.option push # relax = true | ||
|
||
# CHECK-ASM: .option norelax | ||
.option norelax # relax = false | ||
|
||
# CHECK-ASM: pcalau12i $a0, %pc_hi20(sym2) | ||
# CHECK-ASM-NEXT: addi.d $a0, $a0, %pc_lo12(sym2) | ||
# CHECK-RELOC-NEXT: R_LARCH_PCALA_HI20 sym2 0x0 | ||
# CHECK-RELOC-NOT: R_LARCH_RELAX - 0x0 | ||
# CHECK-RELOC-NEXT: R_LARCH_PCALA_LO12 sym2 0x0 | ||
# CHECK-RELOC-NOT: R_LARCH_RELAX - 0x0 | ||
la.pcrel $a0, sym2 | ||
|
||
# CHECK-ASM: .option pop | ||
.option pop # relax = true | ||
|
||
# CHECK-ASM: pcalau12i $a0, %pc_hi20(sym3) | ||
# CHECK-ASM-NEXT: addi.d $a0, $a0, %pc_lo12(sym3) | ||
# CHECK-RELOC: R_LARCH_PCALA_HI20 sym3 0x0 | ||
# CHECK-RELOC-NEXT: R_LARCH_RELAX - 0x0 | ||
# CHECK-RELOC-NEXT: R_LARCH_PCALA_LO12 sym3 0x0 | ||
# CHECK-RELOC-NEXT: R_LARCH_RELAX - 0x0 | ||
la.pcrel $a0, sym3 | ||
|
||
# CHECK-ASM: .option pop | ||
.option pop # relax = false | ||
|
||
la.pcrel $a0, sym4 | ||
# CHECK-ASM: pcalau12i $a0, %pc_hi20(sym4) | ||
# CHECK-ASM-NEXT: addi.d $a0, $a0, %pc_lo12(sym4) | ||
# CHECK-RELOC-NEXT: R_LARCH_PCALA_HI20 sym4 0x0 | ||
# CHECK-RELOC-NOT: R_LARCH_RELAX - 0x0 | ||
# CHECK-RELOC-NEXT: R_LARCH_PCALA_LO12 sym4 0x0 | ||
# CHECK-RELOC-NOT: R_LARCH_RELAX - 0x0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# RUN: llvm-mc --triple=loongarch64 %s | FileCheck --check-prefix=CHECK-ASM %s | ||
# RUN: llvm-mc -filetype=obj --triple=loongarch64 %s \ | ||
# RUN: | llvm-readobj -r - | FileCheck -check-prefix=CHECK-RELOC %s | ||
|
||
## Check .option relax causes R_LARCH_RELAX to be emitted, and .option | ||
## norelax suppresses it. | ||
|
||
# CHECK-ASM: .option relax | ||
.option relax | ||
|
||
# CHECK-ASM: pcalau12i $a0, %pc_hi20(sym1) | ||
# CHECK-ASM-NEXT: addi.d $a0, $a0, %pc_lo12(sym1) | ||
|
||
# CHECK-RELOC: R_LARCH_PCALA_HI20 sym1 0x0 | ||
# CHECK-RELOC-NEXT: R_LARCH_RELAX - 0x0 | ||
# CHECK-RELOC-NEXT: R_LARCH_PCALA_LO12 sym1 0x0 | ||
# CHECK-RELOC-NEXT: R_LARCH_RELAX - 0x0 | ||
la.pcrel $a0, sym1 | ||
|
||
# CHECK-ASM: .option norelax | ||
.option norelax | ||
|
||
# CHECK-ASM: pcalau12i $a0, %pc_hi20(sym2) | ||
# CHECK-ASM-NEXT: addi.d $a0, $a0, %pc_lo12(sym2) | ||
|
||
# CHECK-RELOC-NEXT: R_LARCH_PCALA_HI20 sym2 0x0 | ||
# CHECK-RELOC-NOT: R_LARCH_RELAX - 0x0 | ||
# CHECK-RELOC-NEXT: R_LARCH_PCALA_LO12 sym2 0x0 | ||
# CHECK-RELOC-NOT: R_LARCH_RELAX - 0x0 | ||
la.pcrel $a0, sym2 |