diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -2932,8 +2932,7 @@ } const MCInstrDesc &MCID = MII.get(Opcode); - RISCVII::VConstraintType Constraints = RISCVII::getConstraint(MCID.TSFlags); - if (Constraints == RISCVII::NoConstraint) + if (!(MCID.TSFlags & RISCVII::ConstraintMask)) return false; if (Opcode == RISCV::VC_V_XVW || Opcode == RISCV::VC_V_IVW || @@ -2941,13 +2940,13 @@ // Operands Opcode, Dst, uimm, Dst, Rs2, Rs1 for VC_V_XVW. unsigned VCIXDst = Inst.getOperand(0).getReg(); SMLoc VCIXDstLoc = Operands[2]->getStartLoc(); - if (Constraints & RISCVII::VS1Constraint) { + if (MCID.TSFlags & RISCVII::VS1Constraint) { unsigned VCIXRs1 = Inst.getOperand(Inst.getNumOperands() - 1).getReg(); if (VCIXDst == VCIXRs1) return Error(VCIXDstLoc, "The destination vector register group cannot" " overlap the source vector register group."); } - if (Constraints & RISCVII::VS2Constraint) { + if (MCID.TSFlags & RISCVII::VS2Constraint) { unsigned VCIXRs2 = Inst.getOperand(Inst.getNumOperands() - 2).getReg(); if (VCIXDst == VCIXRs2) return Error(VCIXDstLoc, "The destination vector register group cannot" @@ -2959,19 +2958,19 @@ unsigned DestReg = Inst.getOperand(0).getReg(); // Operands[1] will be the first operand, DestReg. SMLoc Loc = Operands[1]->getStartLoc(); - if (Constraints & RISCVII::VS2Constraint) { + if (MCID.TSFlags & RISCVII::VS2Constraint) { unsigned CheckReg = Inst.getOperand(1).getReg(); if (DestReg == CheckReg) return Error(Loc, "The destination vector register group cannot overlap" " the source vector register group."); } - if ((Constraints & RISCVII::VS1Constraint) && (Inst.getOperand(2).isReg())) { + if ((MCID.TSFlags & RISCVII::VS1Constraint) && (Inst.getOperand(2).isReg())) { unsigned CheckReg = Inst.getOperand(2).getReg(); if (DestReg == CheckReg) return Error(Loc, "The destination vector register group cannot overlap" " the source vector register group."); } - if ((Constraints & RISCVII::VMConstraint) && (DestReg == RISCV::V0)) { + if ((MCID.TSFlags & RISCVII::VMConstraint) && (DestReg == RISCV::V0)) { // vadc, vsbc are special cases. These instructions have no mask register. // The destination register could not be V0. if (Opcode == RISCV::VADC_VVM || Opcode == RISCV::VADC_VXM || diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h @@ -56,6 +56,9 @@ InstFormatShift = 0, ConstraintShift = InstFormatShift + 5, + VS2Constraint = 0b001 << ConstraintShift, + VS1Constraint = 0b010 << ConstraintShift, + VMConstraint = 0b100 << ConstraintShift, ConstraintMask = 0b111 << ConstraintShift, VLMulShift = ConstraintShift + 3, @@ -112,13 +115,6 @@ }; // Match with the definitions in RISCVInstrFormats.td -enum VConstraintType { - NoConstraint = 0, - VS2Constraint = 0b001, - VS1Constraint = 0b010, - VMConstraint = 0b100, -}; - enum VLMUL : uint8_t { LMUL_1 = 0, LMUL_2, @@ -141,11 +137,6 @@ static inline unsigned getFormat(uint64_t TSFlags) { return (TSFlags & InstFormatMask) >> InstFormatShift; } -/// \returns the constraint for the instruction. -static inline VConstraintType getConstraint(uint64_t TSFlags) { - return static_cast((TSFlags & ConstraintMask) >> - ConstraintShift); -} /// \returns the LMUL for the instruction. static inline VLMUL getLMul(uint64_t TSFlags) { return static_cast((TSFlags & VLMulMask) >> VLMulShift);