@@ -2568,7 +2568,7 @@ bool RISCVInstrInfo::verifyInstruction(const MachineInstr &MI,
2568
2568
Ok = (Imm & (RISCVII::TAIL_AGNOSTIC | RISCVII::MASK_AGNOSTIC)) == Imm;
2569
2569
break ;
2570
2570
case RISCVOp::OPERAND_SEW:
2571
- Ok = Imm == 0 || (Imm >= 3 && Imm <= 6 );
2571
+ Ok = Imm == 0 || (isUInt< 5 >( Imm) && RISCVVType::isValidSEW ( 1 << Imm) );
2572
2572
break ;
2573
2573
case RISCVOp::OPERAND_VEC_RM:
2574
2574
assert (RISCVII::hasRoundModeOp (Desc.TSFlags ));
@@ -3188,29 +3188,28 @@ std::string RISCVInstrInfo::createMIROperandComment(
3188
3188
if (!Op.isImm ())
3189
3189
return std::string ();
3190
3190
3191
+ const MCInstrDesc &Desc = MI.getDesc ();
3192
+ if (OpIdx >= Desc.getNumOperands ())
3193
+ return std::string ();
3194
+
3191
3195
std::string Comment;
3192
3196
raw_string_ostream OS (Comment);
3193
3197
3194
- uint64_t TSFlags = MI. getDesc (). TSFlags ;
3198
+ const MCOperandInfo &OpInfo = Desc. operands ()[OpIdx] ;
3195
3199
3196
3200
// Print the full VType operand of vsetvli/vsetivli instructions, and the SEW
3197
3201
// 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 ();
3204
3205
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 ();
3208
3208
unsigned SEW = Log2SEW ? 1 << Log2SEW : 8 ;
3209
3209
assert (RISCVVType::isValidSEW (SEW) && " Unexpected SEW" );
3210
3210
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 ();
3214
3213
assert (Policy <= (RISCVII::TAIL_AGNOSTIC | RISCVII::MASK_AGNOSTIC) &&
3215
3214
" Invalid Policy Value" );
3216
3215
OS << (Policy & RISCVII::TAIL_AGNOSTIC ? " ta" : " tu" ) << " , "
0 commit comments