[llvm] df8795c - [CSKY] Fix warning in CSKYMCCodeEmitter::getImmJMPIX.
Jim Lin via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 3 22:59:53 PDT 2024
Author: Jim Lin
Date: 2024-10-04T13:52:32+08:00
New Revision: df8795c082100cf9f63cd73db1d8bfabd2d5d710
URL: https://github.com/llvm/llvm-project/commit/df8795c082100cf9f63cd73db1d8bfabd2d5d710
DIFF: https://github.com/llvm/llvm-project/commit/df8795c082100cf9f63cd73db1d8bfabd2d5d710.diff
LOG: [CSKY] Fix warning in CSKYMCCodeEmitter::getImmJMPIX.
Use llvm_unreachable instead of assert and replace if-else with switch-case.
Fix https://github.com/llvm/llvm-project/issues/97456.
Added:
Modified:
llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCCodeEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCCodeEmitter.cpp b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCCodeEmitter.cpp
index fc5ddde07f62f7..acee2916de17cd 100644
--- a/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCCodeEmitter.cpp
+++ b/llvm/lib/Target/CSKY/MCTargetDesc/CSKYMCCodeEmitter.cpp
@@ -278,16 +278,18 @@ CSKYMCCodeEmitter::getRegisterSeqOpValue(const MCInst &MI, unsigned Op,
unsigned CSKYMCCodeEmitter::getImmJMPIX(const MCInst &MI, unsigned Idx,
SmallVectorImpl<MCFixup> &Fixups,
const MCSubtargetInfo &STI) const {
- if (MI.getOperand(Idx).getImm() == 16)
+ switch (MI.getOperand(Idx).getImm()) {
+ default:
+ llvm_unreachable("Unhandled jmpix imm!");
+ case 16:
return 0;
- else if (MI.getOperand(Idx).getImm() == 24)
+ case 24:
return 1;
- else if (MI.getOperand(Idx).getImm() == 32)
+ case 32:
return 2;
- else if (MI.getOperand(Idx).getImm() == 40)
+ case 40:
return 3;
- else
- assert(0);
+ }
}
MCFixupKind CSKYMCCodeEmitter::getTargetFixup(const MCExpr *Expr) const {
More information about the llvm-commits
mailing list