[clang] [llvm] [RISCV] Add Support of RISCV Zibimm Experimental Extension (PR #127463)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 17 19:30:39 PST 2025


================
@@ -400,6 +404,22 @@ RISCVMCCodeEmitter::getImmOpValueAsr1(const MCInst &MI, unsigned OpNo,
   return getImmOpValue(MI, OpNo, Fixups, STI);
 }
 
+uint64_t
+RISCVMCCodeEmitter::getImmOpValueZibimm(const MCInst &MI, unsigned OpNo,
+                                        SmallVectorImpl<MCFixup> &Fixups,
+                                        const MCSubtargetInfo &STI) const {
+  const MCOperand &MO = MI.getOperand(OpNo);
+
+  if (MO.isImm()) {
+    uint64_t Res = MO.getImm();
+    if (Res >= 1 && Res <= 31)
----------------
topperc wrote:

You only need to check for the -1 case. For any other value you can just return Res. The creator of the MCInst is required to make sure that the only possible values are -1, 1-31.

https://github.com/llvm/llvm-project/pull/127463


More information about the llvm-commits mailing list