[llvm] b64d7ba - [RISCV] Change the InstFormat for Zicbop prefetch instructions to InstFormatOther. (#148934)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 15 14:49:57 PDT 2025
Author: Craig Topper
Date: 2025-07-15T14:49:54-07:00
New Revision: b64d7baf9c0d37893ebabbe2539e725eb70b46e9
URL: https://github.com/llvm/llvm-project/commit/b64d7baf9c0d37893ebabbe2539e725eb70b46e9
DIFF: https://github.com/llvm/llvm-project/commit/b64d7baf9c0d37893ebabbe2539e725eb70b46e9.diff
LOG: [RISCV] Change the InstFormat for Zicbop prefetch instructions to InstFormatOther. (#148934)
The lower 5-bits of the immediate are not part of the address unlike
other InstFormatS instructions.
We use InstFormatS in RISCVRegisterInfo::needsFrameBaseReg and
RISCVRegisterInfo::getFrameIndexInstrOffset which is not aware of this
special encoding. Force the format to InstFormatOther so those functions
will ignore it.
InstFormatS is also used by relocation emission, but I don't believe we
ever emit these instructions with a relocation because of the encoding.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInstrFormats.td
llvm/lib/Target/RISCV/RISCVInstrInfoZicbo.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInstrFormats.td b/llvm/lib/Target/RISCV/RISCVInstrFormats.td
index b6b64b57b1b3e..e23001a3a0bff 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrFormats.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrFormats.td
@@ -193,7 +193,9 @@ class RVInstCommon<dag outs, dag ins, string opcodestr, string argstr,
let AsmString = opcodestr # !if(!empty(argstr), "", "\t" # argstr);
let Pattern = pattern;
- let TSFlags{4-0} = format.Value;
+ InstFormat Format = format;
+
+ let TSFlags{4-0} = Format.Value;
// Defaults
RISCVVConstraint RVVConstraint = NoConstraint;
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoZicbo.td b/llvm/lib/Target/RISCV/RISCVInstrInfoZicbo.td
index 878b85b141578..0723b2f568a79 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoZicbo.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoZicbo.td
@@ -41,6 +41,7 @@ class Prefetch_ri<bits<5> optype, string opcodestr>
opcodestr, "${imm12}(${rs1})"> {
let Inst{11-7} = 0b00000;
let rs2 = optype;
+ let Format = InstFormatOther; // this does not follow the normal S format.
}
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list