Index: llvm/lib/Target/RISCV/RISCVInstrInfo.cpp =================================================================== --- llvm/lib/Target/RISCV/RISCVInstrInfo.cpp +++ llvm/lib/Target/RISCV/RISCVInstrInfo.cpp @@ -1220,6 +1220,25 @@ } } + const uint64_t TSFlags = Desc.TSFlags; + if (RISCVII::hasSEWOp(TSFlags)) { + unsigned OpIdx = RISCVII::getSEWOpNum(Desc); + unsigned Log2SEW = MI.getOperand(OpIdx).getImm(); + unsigned SEW = Log2SEW ? 1 << Log2SEW : 8; + if (!RISCVVType::isValidSEW(SEW)) { + ErrInfo = "Unexpected SEW value"; + return false; + } + } + if (RISCVII::hasVecPolicyOp(TSFlags)) { + unsigned OpIdx = RISCVII::getVecPolicyOpNum(Desc); + unsigned Policy = MI.getOperand(OpIdx).getImm(); + if (Policy > (RISCVII::TAIL_AGNOSTIC | RISCVII::MASK_AGNOSTIC)) { + ErrInfo = "Invalid Policy Value"; + return false; + } + } + return true; }