[llvm] [RISCV] Update DecoderMethod and MCOperandPredicate spimm. (PR #76061)
Yeting Kuo via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 20 06:58:52 PST 2023
https://github.com/yetingk created https://github.com/llvm/llvm-project/pull/76061
The spimm operand is an immediate whose only 4-5th bits could be setted.
>From 4c117ab40202b336fe95a4ce81cea0411bc9778c Mon Sep 17 00:00:00 2001
From: Yeting Kuo <yeting.kuo at sifive.com>
Date: Wed, 20 Dec 2023 06:19:57 -0800
Subject: [PATCH] [RISCV] Update DecoderMethod and MCOperandPredicate spimm.
The spimm operand is an immediate whose only 4-5th bit could be setted.
---
llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp | 4 ++--
llvm/lib/Target/RISCV/RISCVInstrInfoZc.td | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index 53e2b6b4d94ea0..5c4dbb2249a116 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
@@ -462,10 +462,10 @@ static DecodeStatus decodeRegReg(MCInst &Inst, uint32_t Insn, uint64_t Address,
return MCDisassembler::Success;
}
-// spimm is based on rlist now.
static DecodeStatus decodeZcmpSpimm(MCInst &Inst, unsigned Imm,
uint64_t Address, const void *Decoder) {
- // TODO: check if spimm matches rlist
+ if (!isShiftedUInt<2, 4>(Imm))
+ return MCDisassembler::Fail;
Inst.addOperand(MCOperand::createImm(Imm));
return MCDisassembler::Success;
}
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
index a78f3624446871..2b3f08bc4a1a4f 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
@@ -70,7 +70,7 @@ def spimm : Operand<OtherVT> {
int64_t Imm;
if (!MCOp.evaluateAsConstantImm(Imm))
return false;
- return isShiftedUInt<5, 4>(Imm);
+ return isShiftedUInt<2, 4>(Imm);
}];
}
More information about the llvm-commits
mailing list