@@ -2568,7 +2568,7 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
25682568 Ok = (Imm & (RISCVII::TAIL_AGNOSTIC | RISCVII::MASK_AGNOSTIC)) == Imm;
25692569 break ;
25702570 case RISCVOp::OPERAND_SEW:
2571- Ok = Imm == 0 || (Imm >= 3 && Imm <= 6 );
2571+ Ok = Imm == 0 || (isUInt< 5 >( Imm) && RISCVVType::isValidSEW ( 1 << Imm) );
25722572 break ;
25732573 case RISCVOp::OPERAND_VEC_RM:
25742574 assert (RISCVII::hasRoundModeOp (Desc.TSFlags ));
@@ -3188,29 +3188,28 @@ std::string RISCVInstrInfo::createMIROperandComment(
31883188 if (!Op.isImm ())
31893189 return std::string ();
31903190
3191+ const MCInstrDesc &Desc = MI.getDesc ();
3192+ if (OpIdx >= Desc.getNumOperands ())
3193+ return std::string ();
3194+
31913195 std::string Comment;
31923196 raw_string_ostream OS (Comment);
31933197
3194- uint64_t TSFlags = MI. getDesc (). TSFlags ;
3198+ const MCOperandInfo &OpInfo = Desc. operands ()[OpIdx] ;
31953199
31963200 // Print the full VType operand of vsetvli/vsetivli instructions, and the SEW
31973201 // operand of vector codegen pseudos.
3198- if ((MI.getOpcode () == RISCV::VSETVLI || MI.getOpcode () == RISCV::VSETIVLI ||
3199- MI.getOpcode () == RISCV::PseudoVSETVLI ||
3200- MI.getOpcode () == RISCV::PseudoVSETIVLI ||
3201- MI.getOpcode () == RISCV::PseudoVSETVLIX0) &&
3202- OpIdx == 2 ) {
3203- unsigned Imm = MI.getOperand (OpIdx).getImm ();
3202+ if (OpInfo.OperandType == RISCVOp::OPERAND_VTYPEI10 ||
3203+ OpInfo.OperandType == RISCVOp::OPERAND_VTYPEI11) {
3204+ unsigned Imm = Op.getImm ();
32043205 RISCVVType::printVType (Imm, OS);
3205- } else if (RISCVII::hasSEWOp (TSFlags) &&
3206- OpIdx == RISCVII::getSEWOpNum (MI.getDesc ())) {
3207- unsigned Log2SEW = MI.getOperand (OpIdx).getImm ();
3206+ } else if (OpInfo.OperandType == RISCVOp::OPERAND_SEW) {
3207+ unsigned Log2SEW = Op.getImm ();
32083208 unsigned SEW = Log2SEW ? 1 << Log2SEW : 8 ;
32093209 assert (RISCVVType::isValidSEW (SEW) && " Unexpected SEW" );
32103210 OS << " e" << SEW;
3211- } else if (RISCVII::hasVecPolicyOp (TSFlags) &&
3212- OpIdx == RISCVII::getVecPolicyOpNum (MI.getDesc ())) {
3213- unsigned Policy = MI.getOperand (OpIdx).getImm ();
3211+ } else if (OpInfo.OperandType == RISCVOp::OPERAND_VEC_POLICY) {
3212+ unsigned Policy = Op.getImm ();
32143213 assert (Policy <= (RISCVII::TAIL_AGNOSTIC | RISCVII::MASK_AGNOSTIC) &&
32153214 " Invalid Policy Value" );
32163215 OS << (Policy & RISCVII::TAIL_AGNOSTIC ? " ta" : " tu" ) << " , "
0 commit comments