[llvm] 9bb7a38 - [RISCV][NFC] Use uncompressInst to relax instructions
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 17 22:34:34 PST 2023
Author: wangpc
Date: 2023-01-18T14:34:06+08:00
New Revision: 9bb7a38a6943dd3805b1c133f25cf1459416fbed
URL: https://github.com/llvm/llvm-project/commit/9bb7a38a6943dd3805b1c133f25cf1459416fbed
DIFF: https://github.com/llvm/llvm-project/commit/9bb7a38a6943dd3805b1c133f25cf1459416fbed.diff
LOG: [RISCV][NFC] Use uncompressInst to relax instructions
As the TODO said, we can just use generated uncompressInst to
relax instructions.
Reviewed By: craig.topper, kito-cheng
Differential Revision: https://reviews.llvm.org/D141834
Added:
Modified:
llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
index 150b9e71f161..892c406f1e68 100644
--- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
+++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
@@ -167,36 +167,17 @@ bool RISCVAsmBackend::fixupNeedsRelaxationAdvanced(const MCFixup &Fixup,
void RISCVAsmBackend::relaxInstruction(MCInst &Inst,
const MCSubtargetInfo &STI) const {
- // TODO: replace this with call to auto generated uncompressinstr() function.
MCInst Res;
switch (Inst.getOpcode()) {
default:
llvm_unreachable("Opcode not expected!");
case RISCV::C_BEQZ:
- // c.beqz $rs1, $imm -> beq $rs1, X0, $imm.
- Res.setOpcode(RISCV::BEQ);
- Res.addOperand(Inst.getOperand(0));
- Res.addOperand(MCOperand::createReg(RISCV::X0));
- Res.addOperand(Inst.getOperand(1));
- break;
case RISCV::C_BNEZ:
- // c.bnez $rs1, $imm -> bne $rs1, X0, $imm.
- Res.setOpcode(RISCV::BNE);
- Res.addOperand(Inst.getOperand(0));
- Res.addOperand(MCOperand::createReg(RISCV::X0));
- Res.addOperand(Inst.getOperand(1));
- break;
case RISCV::C_J:
- // c.j $imm -> jal X0, $imm.
- Res.setOpcode(RISCV::JAL);
- Res.addOperand(MCOperand::createReg(RISCV::X0));
- Res.addOperand(Inst.getOperand(0));
- break;
case RISCV::C_JAL:
- // c.jal $imm -> jal X1, $imm.
- Res.setOpcode(RISCV::JAL);
- Res.addOperand(MCOperand::createReg(RISCV::X1));
- Res.addOperand(Inst.getOperand(0));
+ bool Success = RISCVRVC::uncompress(Res, Inst, STI);
+ assert(Success && "Can't uncompress instruction");
+ (void)Success;
break;
}
Inst = std::move(Res);
More information about the llvm-commits
mailing list