Skip to content

Commit

Permalink
[RISCV] Add OperandType for sew and vecpolicy operands. (llvm#114168)
Browse files Browse the repository at this point in the history
  • Loading branch information
topperc authored Oct 30, 2024
1 parent 62ff85f commit e7262c1
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 78 deletions.
6 changes: 5 additions & 1 deletion llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,11 @@ enum OperandType : unsigned {
OPERAND_RTZARG,
// Condition code used by select and short forward branch pseudos.
OPERAND_COND_CODE,
OPERAND_LAST_RISCV_IMM = OPERAND_COND_CODE,
// Vector policy operand.
OPERAND_VEC_POLICY,
// Vector SEW operand.
OPERAND_SEW,
OPERAND_LAST_RISCV_IMM = OPERAND_SEW,
// Operand is either a register or uimm5, this is used by V extension pseudo
// instructions to represent a value that be passed as AVL to either vsetvli
// or vsetivli.
Expand Down
6 changes: 6 additions & 0 deletions llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2545,6 +2545,12 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
case RISCVOp::OPERAND_COND_CODE:
Ok = Imm >= 0 && Imm < RISCVCC::COND_INVALID;
break;
case RISCVOp::OPERAND_VEC_POLICY:
Ok = (Imm & (RISCVII::TAIL_AGNOSTIC | RISCVII::MASK_AGNOSTIC)) == Imm;
break;
case RISCVOp::OPERAND_SEW:
Ok = Imm == 0 || (Imm >= 3 && Imm <= 6);
break;
}
if (!Ok) {
ErrInfo = "Invalid immediate";
Expand Down
Loading

0 comments on commit e7262c1

Please sign in to comment.