@@ -524,15 +524,8 @@ struct RISCVOperand final : public MCParsedAsmOperand {
524
524
bool isGPRAsFPR32 () const { return isGPRF32 () && Reg.IsGPRAsFPR ; }
525
525
bool isGPRPairAsFPR64 () const { return isGPRPair () && Reg.IsGPRAsFPR ; }
526
526
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) {
534
528
if (auto CE = dyn_cast<MCConstantExpr>(Expr)) {
535
- VK = RISCVMCExpr::VK_None;
536
529
Imm = CE->getValue ();
537
530
return true ;
538
531
}
@@ -547,7 +540,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
547
540
RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
548
541
if (!isImm ())
549
542
return false ;
550
- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
543
+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
551
544
bool IsValid;
552
545
if (!IsConstantImm)
553
546
IsValid = RISCVAsmParser::classifySymbolRef (getImm (), VK);
@@ -562,7 +555,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
562
555
int64_t Imm;
563
556
RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
564
557
// Must be of 'immediate' type but not a constant.
565
- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK ))
558
+ if (!isImm () || evaluateConstantImm (getImm (), Imm))
566
559
return false ;
567
560
return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
568
561
VK == RISCVMCExpr::VK_None;
@@ -572,7 +565,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
572
565
int64_t Imm;
573
566
RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
574
567
// Must be of 'immediate' type but not a constant.
575
- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK ))
568
+ if (!isImm () || evaluateConstantImm (getImm (), Imm))
576
569
return false ;
577
570
return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
578
571
(VK == RISCVMCExpr::VK_CALL || VK == RISCVMCExpr::VK_CALL_PLT);
@@ -582,7 +575,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
582
575
int64_t Imm;
583
576
RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
584
577
// Must be of 'immediate' type but not a constant.
585
- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK ))
578
+ if (!isImm () || evaluateConstantImm (getImm (), Imm))
586
579
return false ;
587
580
return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
588
581
VK == RISCVMCExpr::VK_CALL;
@@ -592,7 +585,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
592
585
int64_t Imm;
593
586
RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
594
587
// Must be of 'immediate' type but not a constant.
595
- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK ))
588
+ if (!isImm () || evaluateConstantImm (getImm (), Imm))
596
589
return false ;
597
590
return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
598
591
VK == RISCVMCExpr::VK_TPREL_ADD;
@@ -602,7 +595,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
602
595
int64_t Imm;
603
596
RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
604
597
// Must be of 'immediate' type but not a constant.
605
- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK ))
598
+ if (!isImm () || evaluateConstantImm (getImm (), Imm))
606
599
return false ;
607
600
return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
608
601
VK == RISCVMCExpr::VK_TLSDESC_CALL;
@@ -650,7 +643,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
650
643
RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
651
644
if (!isImm ())
652
645
return false ;
653
- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
646
+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
654
647
if (VK == RISCVMCExpr::VK_LO || VK == RISCVMCExpr::VK_PCREL_LO ||
655
648
VK == RISCVMCExpr::VK_TLSDESC_LOAD_LO ||
656
649
VK == RISCVMCExpr::VK_TLSDESC_ADD_LO)
@@ -667,41 +660,36 @@ struct RISCVOperand final : public MCParsedAsmOperand {
667
660
668
661
bool isImmXLenLI_Restricted () const {
669
662
int64_t Imm;
670
- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
671
663
if (!isImm ())
672
664
return false ;
673
- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
665
+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
674
666
// 'la imm' supports constant immediates only.
675
- return IsConstantImm && (VK == RISCVMCExpr::VK_None) &&
667
+ return IsConstantImm &&
676
668
(isRV64Imm () || (isInt<32 >(Imm) || isUInt<32 >(Imm)));
677
669
}
678
670
679
671
template <unsigned N> bool isUImm () const {
680
672
int64_t Imm;
681
- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
682
673
if (!isImm ())
683
674
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);
686
677
}
687
678
688
679
template <unsigned N, unsigned S> bool isUImmShifted () const {
689
680
int64_t Imm;
690
- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
691
681
if (!isImm ())
692
682
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);
696
685
}
697
686
698
687
template <class Pred > bool isUImmPred (Pred p) const {
699
688
int64_t Imm;
700
- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
701
689
if (!isImm ())
702
690
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);
705
693
}
706
694
707
695
bool isUImmLog2XLen () const {
@@ -789,22 +777,18 @@ struct RISCVOperand final : public MCParsedAsmOperand {
789
777
790
778
template <unsigned N> bool isSImm () const {
791
779
int64_t Imm;
792
- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
793
780
if (!isImm ())
794
781
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 ()));
798
784
}
799
785
800
786
template <class Pred > bool isSImmPred (Pred p) const {
801
787
int64_t Imm;
802
- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
803
788
if (!isImm ())
804
789
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 ()));
808
792
}
809
793
810
794
bool isSImm5 () const { return isSImm<5 >(); }
@@ -865,7 +849,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
865
849
bool IsValid;
866
850
if (!isImm ())
867
851
return false ;
868
- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
852
+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
869
853
if (!IsConstantImm)
870
854
IsValid = RISCVAsmParser::classifySymbolRef (getImm (), VK);
871
855
else
@@ -905,7 +889,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
905
889
bool IsValid;
906
890
if (!isImm ())
907
891
return false ;
908
- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
892
+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
909
893
if (!IsConstantImm) {
910
894
IsValid = RISCVAsmParser::classifySymbolRef (getImm (), VK);
911
895
return IsValid &&
@@ -923,7 +907,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
923
907
bool IsValid;
924
908
if (!isImm ())
925
909
return false ;
926
- bool IsConstantImm = evaluateConstantImm (getImm (), Imm, VK );
910
+ bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
927
911
if (!IsConstantImm) {
928
912
IsValid = RISCVAsmParser::classifySymbolRef (getImm (), VK);
929
913
return IsValid &&
@@ -1163,8 +1147,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
1163
1147
static void addExpr (MCInst &Inst, const MCExpr *Expr, bool IsRV64Imm) {
1164
1148
assert (Expr && " Expr shouldn't be null!" );
1165
1149
int64_t Imm = 0 ;
1166
- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
1167
- bool IsConstant = evaluateConstantImm (Expr, Imm, VK);
1150
+ bool IsConstant = evaluateConstantImm (Expr, Imm);
1168
1151
1169
1152
if (IsConstant)
1170
1153
Inst.addOperand (
@@ -1213,9 +1196,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
1213
1196
assert (N == 1 && " Invalid number of operands!" );
1214
1197
int64_t Imm = 0 ;
1215
1198
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);
1219
1200
assert (IsConstantImm && " Invalid VTypeI Operand!" );
1220
1201
} else {
1221
1202
Imm = getVType ();
0 commit comments