@@ -524,15 +524,8 @@ struct RISCVOperand final : public MCParsedAsmOperand {
524524 bool isGPRAsFPR32 () const { return isGPRF32 () && Reg.IsGPRAsFPR ; }
525525 bool isGPRPairAsFPR64 () const { return isGPRPair () && Reg.IsGPRAsFPR ; }
526526
527- static bool evaluateConstantImm (const MCExpr *Expr, int64_t &Imm,
528- RISCVMCExpr::Specifier &VK) {
529- if (auto *RE = dyn_cast<RISCVMCExpr>(Expr)) {
530- VK = RE->getSpecifier ();
531- return RE->evaluateAsConstant (Imm);
532- }
533-
527+ static bool evaluateConstantImm (const MCExpr *Expr, int64_t &Imm) {
534528 if (auto CE = dyn_cast<MCConstantExpr>(Expr)) {
535- VK = RISCVMCExpr::VK_None;
536529 Imm = CE->getValue ();
537530 return true ;
538531 }
@@ -547,7 +540,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
547540 RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
548541 if (!isImm ())
549542 return false ;
550- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
543+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
551544 bool IsValid;
552545 if (!IsConstantImm)
553546 IsValid = RISCVAsmParser::classifySymbolRef (getImm (), VK);
@@ -562,7 +555,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
562555 int64_t Imm;
563556 RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
564557 // Must be of 'immediate' type but not a constant.
565- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK ))
558+ if (!isImm () || evaluateConstantImm (getImm (), Imm))
566559 return false ;
567560 return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
568561 VK == RISCVMCExpr::VK_None;
@@ -572,7 +565,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
572565 int64_t Imm;
573566 RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
574567 // Must be of 'immediate' type but not a constant.
575- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK ))
568+ if (!isImm () || evaluateConstantImm (getImm (), Imm))
576569 return false ;
577570 return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
578571 (VK == RISCVMCExpr::VK_CALL || VK == RISCVMCExpr::VK_CALL_PLT);
@@ -582,7 +575,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
582575 int64_t Imm;
583576 RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
584577 // Must be of 'immediate' type but not a constant.
585- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK ))
578+ if (!isImm () || evaluateConstantImm (getImm (), Imm))
586579 return false ;
587580 return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
588581 VK == RISCVMCExpr::VK_CALL;
@@ -592,7 +585,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
592585 int64_t Imm;
593586 RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
594587 // Must be of 'immediate' type but not a constant.
595- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK ))
588+ if (!isImm () || evaluateConstantImm (getImm (), Imm))
596589 return false ;
597590 return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
598591 VK == RISCVMCExpr::VK_TPREL_ADD;
@@ -602,7 +595,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
602595 int64_t Imm;
603596 RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
604597 // Must be of 'immediate' type but not a constant.
605- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK ))
598+ if (!isImm () || evaluateConstantImm (getImm (), Imm))
606599 return false ;
607600 return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
608601 VK == RISCVMCExpr::VK_TLSDESC_CALL;
@@ -650,7 +643,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
650643 RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
651644 if (!isImm ())
652645 return false ;
653- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
646+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
654647 if (VK == RISCVMCExpr::VK_LO || VK == RISCVMCExpr::VK_PCREL_LO ||
655648 VK == RISCVMCExpr::VK_TLSDESC_LOAD_LO ||
656649 VK == RISCVMCExpr::VK_TLSDESC_ADD_LO)
@@ -667,41 +660,36 @@ struct RISCVOperand final : public MCParsedAsmOperand {
667660
668661 bool isImmXLenLI_Restricted () const {
669662 int64_t Imm;
670- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
671663 if (!isImm ())
672664 return false ;
673- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
665+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
674666 // 'la imm' supports constant immediates only.
675- return IsConstantImm && (VK == RISCVMCExpr::VK_None) &&
667+ return IsConstantImm &&
676668 (isRV64Imm () || (isInt<32 >(Imm) || isUInt<32 >(Imm)));
677669 }
678670
679671 template <unsigned N> bool isUImm () const {
680672 int64_t Imm;
681- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
682673 if (!isImm ())
683674 return false ;
684- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
685- return IsConstantImm && isUInt<N>(Imm) && VK == RISCVMCExpr::VK_None ;
675+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
676+ return IsConstantImm && isUInt<N>(Imm);
686677 }
687678
688679 template <unsigned N, unsigned S> bool isUImmShifted () const {
689680 int64_t Imm;
690- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
691681 if (!isImm ())
692682 return false ;
693- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK);
694- return IsConstantImm && isShiftedUInt<N, S>(Imm) &&
695- VK == RISCVMCExpr::VK_None;
683+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
684+ return IsConstantImm && isShiftedUInt<N, S>(Imm);
696685 }
697686
698687 template <class Pred > bool isUImmPred (Pred p) const {
699688 int64_t Imm;
700- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
701689 if (!isImm ())
702690 return false ;
703- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
704- return IsConstantImm && p (Imm) && VK == RISCVMCExpr::VK_None ;
691+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
692+ return IsConstantImm && p (Imm);
705693 }
706694
707695 bool isUImmLog2XLen () const {
@@ -789,22 +777,18 @@ struct RISCVOperand final : public MCParsedAsmOperand {
789777
790778 template <unsigned N> bool isSImm () const {
791779 int64_t Imm;
792- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
793780 if (!isImm ())
794781 return false ;
795- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK);
796- return IsConstantImm && isInt<N>(fixImmediateForRV32 (Imm, isRV64Imm ())) &&
797- VK == RISCVMCExpr::VK_None;
782+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
783+ return IsConstantImm && isInt<N>(fixImmediateForRV32 (Imm, isRV64Imm ()));
798784 }
799785
800786 template <class Pred > bool isSImmPred (Pred p) const {
801787 int64_t Imm;
802- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
803788 if (!isImm ())
804789 return false ;
805- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK);
806- return IsConstantImm && p (fixImmediateForRV32 (Imm, isRV64Imm ())) &&
807- VK == RISCVMCExpr::VK_None;
790+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
791+ return IsConstantImm && p (fixImmediateForRV32 (Imm, isRV64Imm ()));
808792 }
809793
810794 bool isSImm5 () const { return isSImm<5 >(); }
@@ -865,7 +849,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
865849 bool IsValid;
866850 if (!isImm ())
867851 return false ;
868- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
852+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
869853 if (!IsConstantImm)
870854 IsValid = RISCVAsmParser::classifySymbolRef (getImm (), VK);
871855 else
@@ -905,7 +889,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
905889 bool IsValid;
906890 if (!isImm ())
907891 return false ;
908- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
892+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
909893 if (!IsConstantImm) {
910894 IsValid = RISCVAsmParser::classifySymbolRef (getImm (), VK);
911895 return IsValid &&
@@ -923,7 +907,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
923907 bool IsValid;
924908 if (!isImm ())
925909 return false ;
926- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
910+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
927911 if (!IsConstantImm) {
928912 IsValid = RISCVAsmParser::classifySymbolRef (getImm (), VK);
929913 return IsValid &&
@@ -1163,8 +1147,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
11631147 static void addExpr (MCInst &Inst, const MCExpr *Expr, bool IsRV64Imm) {
11641148 assert (Expr && " Expr shouldn't be null!" );
11651149 int64_t Imm = 0 ;
1166- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
1167- bool IsConstant = evaluateConstantImm (Expr, Imm, VK);
1150+ bool IsConstant = evaluateConstantImm (Expr, Imm);
11681151
11691152 if (IsConstant)
11701153 Inst.addOperand (
@@ -1213,9 +1196,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
12131196 assert (N == 1 && " Invalid number of operands!" );
12141197 int64_t Imm = 0 ;
12151198 if (Kind == KindTy::Immediate) {
1216- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
1217- [[maybe_unused]] bool IsConstantImm =
1218- evaluateConstantImm (getImm (), Imm, VK);
1199+ [[maybe_unused]] bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
12191200 assert (IsConstantImm && " Invalid VTypeI Operand!" );
12201201 } else {
12211202 Imm = getVType ();
0 commit comments