mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 19:12:56 +02:00
[RISCV][NFC] Make logic in RISCVMCCodeEmitter::getImmOpValue more defensive
As pointed out by @sabuasal in a comment on D23568, the logic in RISCVMCCodeEmitter::getImmOpValue could be more defensive. Although with the current instruction definitions it is always the case that `VK_RISCV_LO` is always used with either an I- or S-format instruction, this may not always be the case in the future. Add a check to ensure we will get an assertion in debug builds if that changes. llvm-svn: 325775
This commit is contained in:
parent
77280b7136
commit
c7bfc8b20e
@ -161,16 +161,24 @@ unsigned RISCVMCCodeEmitter::getImmOpValue(const MCInst &MI, unsigned OpNo,
|
||||
case RISCVMCExpr::VK_RISCV_Invalid:
|
||||
llvm_unreachable("Unhandled fixup kind!");
|
||||
case RISCVMCExpr::VK_RISCV_LO:
|
||||
FixupKind = MIFrm == RISCVII::InstFormatI ? RISCV::fixup_riscv_lo12_i
|
||||
: RISCV::fixup_riscv_lo12_s;
|
||||
if (MIFrm == RISCVII::InstFormatI)
|
||||
FixupKind = RISCV::fixup_riscv_lo12_i;
|
||||
else if (MIFrm == RISCVII::InstFormatS)
|
||||
FixupKind = RISCV::fixup_riscv_lo12_s;
|
||||
else
|
||||
llvm_unreachable("VK_RISCV_LO used with unexpected instruction format");
|
||||
break;
|
||||
case RISCVMCExpr::VK_RISCV_HI:
|
||||
FixupKind = RISCV::fixup_riscv_hi20;
|
||||
break;
|
||||
case RISCVMCExpr::VK_RISCV_PCREL_LO:
|
||||
FixupKind = MIFrm == RISCVII::InstFormatI
|
||||
? RISCV::fixup_riscv_pcrel_lo12_i
|
||||
: RISCV::fixup_riscv_pcrel_lo12_s;
|
||||
if (MIFrm == RISCVII::InstFormatI)
|
||||
FixupKind = RISCV::fixup_riscv_pcrel_lo12_i;
|
||||
else if (MIFrm == RISCVII::InstFormatS)
|
||||
FixupKind = RISCV::fixup_riscv_pcrel_lo12_s;
|
||||
else
|
||||
llvm_unreachable(
|
||||
"VK_RISCV_PCREL_LO used with unexpected instruction format");
|
||||
break;
|
||||
case RISCVMCExpr::VK_RISCV_PCREL_HI:
|
||||
FixupKind = RISCV::fixup_riscv_pcrel_hi20;
|
||||
|
Loading…
Reference in New Issue
Block a user