-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RISC-V: Fix .option arch compatibility with zc*
This fixes an issue whereby .option arch with the zc extensions can result in gas refusing to accept otherwise valid instructions because the base C extension is not enabled.
- Loading branch information
1 parent
25ea490
commit 4c301b7
Showing
5 changed files
with
116 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#as: -march=rv32i | ||
#source: zc-zca-option-march.s | ||
#objdump: -d -Mno-aliases | ||
|
||
.*:[ ]+file format .* | ||
|
||
|
||
Disassembly of section .text: | ||
|
||
0+000 <testcase>: | ||
[ ]+0:[ ]+0001[ ]+c.addi[ ]+zero,0 | ||
#... |
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,6 @@ | ||
.attribute 5, "rv32i" | ||
.option rvc | ||
.option arch, +zca | ||
.option norvc | ||
testcase: | ||
c.nop |
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,46 @@ | ||
.macro PADDIING_32_BYTES | ||
.option push | ||
.option arch, -zcmt | ||
.option arch, -zca | ||
nop | ||
nop | ||
nop | ||
nop | ||
nop | ||
nop | ||
nop | ||
nop | ||
.option pop | ||
.endm | ||
|
||
.macro PADDIING_256_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
.endm | ||
|
||
.macro PADDIING_2048_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
.endm | ||
|
||
.option relax | ||
target: | ||
c.bnez s0, target | ||
jal Far | ||
c.bnez s0, Far | ||
PADDIING_2048_BYTES | ||
PADDIING_2048_BYTES | ||
Far: | ||
ret |
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,50 @@ | ||
.macro PADDIING_32_BYTES | ||
.option push | ||
.option arch, -zcmt | ||
.option arch, -zca | ||
nop | ||
nop | ||
nop | ||
nop | ||
nop | ||
nop | ||
nop | ||
nop | ||
.option pop | ||
.endm | ||
|
||
.macro PADDIING_256_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
PADDIING_32_BYTES | ||
.endm | ||
|
||
.macro PADDIING_2048_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
PADDIING_256_BYTES | ||
.endm | ||
|
||
.option norelax | ||
target: | ||
c.beqz s0, C_BRANCH_RANGE | ||
C_BRANCH_RANGE: | ||
c.bnez s0, EXPAND_TO_BRANCH | ||
PADDIING_256_BYTES | ||
EXPAND_TO_BRANCH: | ||
c.bnez s0, FLIP_C_BRANCH_AND_JUMP | ||
PADDIING_2048_BYTES | ||
PADDIING_2048_BYTES | ||
FLIP_C_BRANCH_AND_JUMP: | ||
c.beqz s0, -4 | ||
ret |