Skip to content

Commit 919bbfb

Browse files
committed
[RISCV] Check for register where immediate should be in RISCVInstrInfo::verifyInstruction.
The generic verifier will do this if the operand type is OPERAND_IMMEDIATE, but we use our own custom operand types. Immediate operands are still allowed to be globals, constant pools, blockaddress, etc. so we can't check !isImm(). Fix the same typo as llvm#120246 which is now detected by this.
1 parent 659dbb6 commit 919bbfb

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,6 +2451,10 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
24512451
if (OpType >= RISCVOp::OPERAND_FIRST_RISCV_IMM &&
24522452
OpType <= RISCVOp::OPERAND_LAST_RISCV_IMM) {
24532453
const MachineOperand &MO = MI.getOperand(Index);
2454+
if (MO.isReg()) {
2455+
ErrInfo = "Expected a non-register operand.";
2456+
return false;
2457+
}
24542458
if (MO.isImm()) {
24552459
int64_t Imm = MO.getImm();
24562460
bool Ok;

llvm/lib/Target/RISCV/RISCVInstrInfoXCV.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ let Predicates = [HasVendorXCVmem, IsRV32], AddedComplexity = 1 in {
698698
def : CVStriPat<post_store, CV_SW_ri_inc>;
699699

700700
def : CVStrriPat<post_truncsti8, CV_SB_rr_inc>;
701-
def : CVStrriPat<post_truncsti16, CV_SH_ri_inc>;
701+
def : CVStrriPat<post_truncsti16, CV_SH_rr_inc>;
702702
def : CVStrriPat<post_store, CV_SW_rr_inc>;
703703

704704
def : CVStrrPat<truncstorei8, CV_SB_rr>;

0 commit comments

Comments
 (0)