@@ -280,7 +280,7 @@ class RISCVAsmParser : public MCTargetAsmParser {
280280 std::unique_ptr<RISCVOperand> defaultFRMArgLegacyOp () const ;
281281
282282public:
283- enum RISCVMatchResultTy {
283+ enum RISCVMatchResultTy : unsigned {
284284 Match_Dummy = FIRST_TARGET_MATCH_RESULT_TY,
285285#define GET_OPERAND_DIAGNOSTIC_TYPES
286286#include " RISCVGenAsmMatcher.inc"
@@ -1527,10 +1527,6 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
15271527 std::numeric_limits<uint32_t >::max (),
15281528 " operand either must be a bare symbol name or an immediate integer in "
15291529 " the range" );
1530- case Match_InvalidImmZero: {
1531- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1532- return Error (ErrorLoc, " immediate must be zero" );
1533- }
15341530 case Match_InvalidUImmLog2XLen:
15351531 if (isRV64 ())
15361532 return generateImmOutOfRangeError (Operands, ErrorInfo, 0 , (1 << 6 ) - 1 );
@@ -1657,47 +1653,10 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
16571653 " operand must be a valid system register "
16581654 " name or an integer in the range" );
16591655 }
1660- case Match_InvalidLoadFPImm: {
1661- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1662- return Error (ErrorLoc, " operand must be a valid floating-point constant" );
1663- }
1664- case Match_InvalidBareSymbol: {
1665- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1666- return Error (ErrorLoc, " operand must be a bare symbol name" );
1667- }
1668- case Match_InvalidPseudoJumpSymbol: {
1669- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1670- return Error (ErrorLoc, " operand must be a valid jump target" );
1671- }
1672- case Match_InvalidCallSymbol: {
1673- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1674- return Error (ErrorLoc, " operand must be a bare symbol name" );
1675- }
1676- case Match_InvalidTPRelAddSymbol: {
1677- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1678- return Error (ErrorLoc, " operand must be a symbol with %tprel_add modifier" );
1679- }
1680- case Match_InvalidTLSDESCCallSymbol: {
1681- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1682- return Error (ErrorLoc,
1683- " operand must be a symbol with %tlsdesc_call modifier" );
1684- }
1685- case Match_InvalidRTZArg: {
1686- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1687- return Error (ErrorLoc, " operand must be 'rtz' floating-point rounding mode" );
1688- }
16891656 case Match_InvalidVTypeI: {
16901657 SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
16911658 return generateVTypeError (ErrorLoc);
16921659 }
1693- case Match_InvalidVMaskRegister: {
1694- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1695- return Error (ErrorLoc, " operand must be v0.t" );
1696- }
1697- case Match_InvalidVMaskCarryInRegister: {
1698- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1699- return Error (ErrorLoc, " operand must be v0" );
1700- }
17011660 case Match_InvalidSImm5Plus1: {
17021661 return generateImmOutOfRangeError (Operands, ErrorInfo, -(1 << 4 ) + 1 ,
17031662 (1 << 4 ),
@@ -1706,26 +1665,14 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
17061665 case Match_InvalidSImm26:
17071666 return generateImmOutOfRangeError (Operands, ErrorInfo, -(1 << 25 ),
17081667 (1 << 25 ) - 1 );
1709- case Match_InvalidRlist: {
1710- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1711- return Error (
1712- ErrorLoc,
1713- " operand must be {ra [, s0[-sN]]} or {x1 [, x8[-x9][, x18[-xN]]]}" );
1714- }
1715- case Match_InvalidStackAdj: {
1716- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1717- return Error (
1718- ErrorLoc,
1719- " stack adjustment is invalid for this instruction and register list; "
1720- " refer to Zc spec for a detailed range of stack adjustment" );
1721- }
17221668 case Match_InvalidRnumArg: {
17231669 return generateImmOutOfRangeError (Operands, ErrorInfo, 0 , 10 );
17241670 }
1725- case Match_InvalidRegReg: {
1726- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1727- return Error (ErrorLoc, " operands must be register and register" );
17281671 }
1672+
1673+ if (const char *MatchDiag = getMatchKindDiag ((RISCVMatchResultTy)Result)) {
1674+ SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1675+ return Error (ErrorLoc, MatchDiag);
17291676 }
17301677
17311678 llvm_unreachable (" Unknown match type detected!" );
0 commit comments