Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV] Implement MC relaxations for compressed instructions.
Summary: This patch implements relaxation for RISCV in the MC layer. The following relaxations are currently handled: 1) Relax C_BEQZ to BEQ and C_BNEZ to BNEZ in RISCV. 2) Relax and C_J $imm to JAL x0, $imm and CJAL to JAL ra, $imm. Reviewers: asb, llvm-commits, efriedma Reviewed By: asb Subscribers: shiva0217 Differential Revision: https://reviews.llvm.org/D43055 llvm-svn: 326626
- Loading branch information
Sameer AbuAsal
committed
Mar 2, 2018
1 parent
e403c86
commit 2646a41
Showing
5 changed files
with
231 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+c < %s \ | ||
# RUN: | llvm-objdump -d - | FileCheck -check-prefix=INSTR %s | ||
|
||
FAR_JUMP_NEGATIVE: | ||
c.nop | ||
.space 2000 | ||
|
||
FAR_BRANCH_NEGATIVE: | ||
c.nop | ||
.space 256 | ||
|
||
NEAR_NEGATIVE: | ||
c.nop | ||
|
||
start: | ||
c.bnez a0, NEAR | ||
#INSTR: c.bnez a0, 72 | ||
c.bnez a0, NEAR_NEGATIVE | ||
#INSTR: c.bnez a0, -4 | ||
c.bnez a0, FAR_BRANCH | ||
#INSTR-NEXT: bnez a0, 326 | ||
c.bnez a0, FAR_BRANCH_NEGATIVE | ||
#INSTR-NEXT: bnez a0, -268 | ||
c.bnez a0, FAR_JUMP | ||
#INSTR-NEXT: bnez a0, 2320 | ||
c.bnez a0, FAR_JUMP_NEGATIVE | ||
#INSTR-NEXT: bnez a0, -2278 | ||
|
||
c.beqz a0, NEAR | ||
#INSTR-NEXT: c.beqz a0, 52 | ||
c.beqz a0, NEAR_NEGATIVE | ||
#INSTR-NEXT: c.beqz a0, -24 | ||
c.beqz a0, FAR_BRANCH | ||
#INSTR-NEXT: beqz a0, 306 | ||
c.beqz a0, FAR_BRANCH_NEGATIVE | ||
#INSTR-NEXT: beqz a0, -288 | ||
c.beqz a0, FAR_JUMP | ||
#INSTR-NEXT: beqz a0, 2300 | ||
c.beqz a0, FAR_JUMP_NEGATIVE | ||
#INSTR-NEXT: beqz a0, -2298 | ||
|
||
c.j NEAR | ||
#INSTR-NEXT: c.j 32 | ||
c.j NEAR_NEGATIVE | ||
#INSTR-NEXT: c.j -44 | ||
c.j FAR_BRANCH | ||
#INSTR-NEXT: c.j 286 | ||
c.j FAR_BRANCH_NEGATIVE | ||
#INSTR-NEXT: c.j -306 | ||
c.j FAR_JUMP | ||
#INSTR-NEXT: j 2284 | ||
c.j FAR_JUMP_NEGATIVE | ||
#INSTR-NEXT: j -2314 | ||
|
||
c.jal NEAR | ||
#INSTR: c.jal 16 | ||
c.jal NEAR_NEGATIVE | ||
#INSTR: c.jal -60 | ||
c.jal FAR_BRANCH | ||
#INSTR-NEXT: c.jal 270 | ||
c.jal FAR_BRANCH_NEGATIVE | ||
#INSTR-NEXT: c.jal -322 | ||
c.jal FAR_JUMP | ||
#INSTR-NEXT: jal 2268 | ||
c.jal FAR_JUMP_NEGATIVE | ||
#INSTR-NEXT: jal -2330 | ||
|
||
NEAR: | ||
c.nop | ||
.space 256 | ||
FAR_BRANCH: | ||
c.nop | ||
.space 2000 | ||
FAR_JUMP: | ||
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,64 @@ | ||
# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+c < %s \ | ||
# RUN: | llvm-objdump -d - | FileCheck -check-prefix=INSTR %s | ||
|
||
FAR_JUMP_NEGATIVE: | ||
c.nop | ||
.space 2000 | ||
|
||
FAR_BRANCH_NEGATIVE: | ||
c.nop | ||
.space 256 | ||
|
||
NEAR_NEGATIVE: | ||
c.nop | ||
|
||
start: | ||
c.bnez a0, NEAR | ||
#INSTR: c.bnez a0, 56 | ||
c.bnez a0, NEAR_NEGATIVE | ||
#INSTR: c.bnez a0, -4 | ||
c.bnez a0, FAR_BRANCH | ||
#INSTR-NEXT: bnez a0, 310 | ||
c.bnez a0, FAR_BRANCH_NEGATIVE | ||
#INSTR-NEXT: bnez a0, -268 | ||
c.bnez a0, FAR_JUMP | ||
#INSTR-NEXT: bnez a0, 2304 | ||
c.bnez a0, FAR_JUMP_NEGATIVE | ||
#INSTR-NEXT: bnez a0, -2278 | ||
|
||
c.beqz a0, NEAR | ||
#INSTR-NEXT: c.beqz a0, 36 | ||
c.beqz a0, NEAR_NEGATIVE | ||
#INSTR-NEXT: c.beqz a0, -24 | ||
c.beqz a0, FAR_BRANCH | ||
#INSTR-NEXT: beqz a0, 290 | ||
c.beqz a0, FAR_BRANCH_NEGATIVE | ||
#INSTR-NEXT: beqz a0, -288 | ||
c.beqz a0, FAR_JUMP | ||
#INSTR-NEXT: beqz a0, 2284 | ||
c.beqz a0, FAR_JUMP_NEGATIVE | ||
#INSTR-NEXT: beqz a0, -2298 | ||
|
||
c.j NEAR | ||
#INSTR-NEXT: c.j 16 | ||
c.j NEAR_NEGATIVE | ||
#INSTR-NEXT: c.j -44 | ||
c.j FAR_BRANCH | ||
#INSTR-NEXT: c.j 270 | ||
c.j FAR_BRANCH_NEGATIVE | ||
#INSTR-NEXT: c.j -306 | ||
c.j FAR_JUMP | ||
#INSTR-NEXT: j 2268 | ||
c.j FAR_JUMP_NEGATIVE | ||
#INSTR-NEXT: j -2314 | ||
|
||
NEAR: | ||
c.nop | ||
|
||
.space 256 | ||
FAR_BRANCH: | ||
c.nop | ||
|
||
.space 2000 | ||
FAR_JUMP: | ||
c.nop |