@@ -280,7 +280,7 @@ class RISCVAsmParser : public MCTargetAsmParser {
280
280
std::unique_ptr<RISCVOperand> defaultFRMArgLegacyOp () const ;
281
281
282
282
public:
283
- enum RISCVMatchResultTy {
283
+ enum RISCVMatchResultTy : unsigned {
284
284
Match_Dummy = FIRST_TARGET_MATCH_RESULT_TY,
285
285
#define GET_OPERAND_DIAGNOSTIC_TYPES
286
286
#include " RISCVGenAsmMatcher.inc"
@@ -1527,10 +1527,6 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
1527
1527
std::numeric_limits<uint32_t >::max (),
1528
1528
" operand either must be a bare symbol name or an immediate integer in "
1529
1529
" the range" );
1530
- case Match_InvalidImmZero: {
1531
- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1532
- return Error (ErrorLoc, " immediate must be zero" );
1533
- }
1534
1530
case Match_InvalidUImmLog2XLen:
1535
1531
if (isRV64 ())
1536
1532
return generateImmOutOfRangeError (Operands, ErrorInfo, 0 , (1 << 6 ) - 1 );
@@ -1657,47 +1653,10 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
1657
1653
" operand must be a valid system register "
1658
1654
" name or an integer in the range" );
1659
1655
}
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
- }
1689
1656
case Match_InvalidVTypeI: {
1690
1657
SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1691
1658
return generateVTypeError (ErrorLoc);
1692
1659
}
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
- }
1701
1660
case Match_InvalidSImm5Plus1: {
1702
1661
return generateImmOutOfRangeError (Operands, ErrorInfo, -(1 << 4 ) + 1 ,
1703
1662
(1 << 4 ),
@@ -1706,26 +1665,14 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
1706
1665
case Match_InvalidSImm26:
1707
1666
return generateImmOutOfRangeError (Operands, ErrorInfo, -(1 << 25 ),
1708
1667
(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
- }
1722
1668
case Match_InvalidRnumArg: {
1723
1669
return generateImmOutOfRangeError (Operands, ErrorInfo, 0 , 10 );
1724
1670
}
1725
- case Match_InvalidRegReg: {
1726
- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1727
- return Error (ErrorLoc, " operands must be register and register" );
1728
1671
}
1672
+
1673
+ if (const char *MatchDiag = getMatchKindDiag ((RISCVMatchResultTy)Result)) {
1674
+ SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1675
+ return Error (ErrorLoc, MatchDiag);
1729
1676
}
1730
1677
1731
1678
llvm_unreachable (" Unknown match type detected!" );
0 commit comments