Skip to content

Commit b64d7ba

Browse files
authored
[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.
1 parent bec508a commit b64d7ba

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

llvm/lib/Target/RISCV/RISCVInstrFormats.td

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,9 @@ class RVInstCommon<dag outs, dag ins, string opcodestr, string argstr,
193193
let AsmString = opcodestr # !if(!empty(argstr), "", "\t" # argstr);
194194
let Pattern = pattern;
195195

196-
let TSFlags{4-0} = format.Value;
196+
InstFormat Format = format;
197+
198+
let TSFlags{4-0} = Format.Value;
197199

198200
// Defaults
199201
RISCVVConstraint RVVConstraint = NoConstraint;

llvm/lib/Target/RISCV/RISCVInstrInfoZicbo.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Prefetch_ri<bits<5> optype, string opcodestr>
4141
opcodestr, "${imm12}(${rs1})"> {
4242
let Inst{11-7} = 0b00000;
4343
let rs2 = optype;
44+
let Format = InstFormatOther; // this does not follow the normal S format.
4445
}
4546

4647
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)