@@ -555,50 +555,55 @@ struct RISCVOperand final : public MCParsedAsmOperand {
555555
556556 bool isBareSymbol () const {
557557 int64_t Imm;
558- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
559558 // Must be of 'immediate' type but not a constant.
560559 if (!isImm () || evaluateConstantImm (getImm (), Imm))
561560 return false ;
561+
562+ RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
562563 return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
563564 VK == RISCVMCExpr::VK_None;
564565 }
565566
566567 bool isCallSymbol () const {
567568 int64_t Imm;
568- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
569569 // Must be of 'immediate' type but not a constant.
570570 if (!isImm () || evaluateConstantImm (getImm (), Imm))
571571 return false ;
572+
573+ RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
572574 return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
573575 (VK == RISCVMCExpr::VK_CALL || VK == RISCVMCExpr::VK_CALL_PLT);
574576 }
575577
576578 bool isPseudoJumpSymbol () const {
577579 int64_t Imm;
578- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
579580 // Must be of 'immediate' type but not a constant.
580581 if (!isImm () || evaluateConstantImm (getImm (), Imm))
581582 return false ;
583+
584+ RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
582585 return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
583586 VK == RISCVMCExpr::VK_CALL;
584587 }
585588
586589 bool isTPRelAddSymbol () const {
587590 int64_t Imm;
588- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
589591 // Must be of 'immediate' type but not a constant.
590592 if (!isImm () || evaluateConstantImm (getImm (), Imm))
591593 return false ;
594+
595+ RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
592596 return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
593597 VK == RISCVMCExpr::VK_TPREL_ADD;
594598 }
595599
596600 bool isTLSDESCCallSymbol () const {
597601 int64_t Imm;
598- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
599602 // Must be of 'immediate' type but not a constant.
600603 if (!isImm () || evaluateConstantImm (getImm (), Imm))
601604 return false ;
605+
606+ RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
602607 return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
603608 VK == RISCVMCExpr::VK_TLSDESC_CALL;
604609 }
@@ -838,19 +843,17 @@ struct RISCVOperand final : public MCParsedAsmOperand {
838843 }
839844
840845 bool isSImm12 () const {
841- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
842- int64_t Imm;
843- bool IsValid;
844846 if (!isImm ())
845847 return false ;
846- bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
847- if (!IsConstantImm)
848- IsValid = RISCVAsmParser::classifySymbolRef (getImm (), VK);
849- else
850- IsValid = isInt<12 >(fixImmediateForRV32 (Imm, isRV64Imm ()));
851- return IsValid &&
852- (IsConstantImm || VK == RISCVMCExpr::VK_LO ||
853- VK == RISCVMCExpr::VK_PCREL_LO || VK == RISCVMCExpr::VK_TPREL_LO ||
848+
849+ int64_t Imm;
850+ if (evaluateConstantImm (getImm (), Imm))
851+ return isInt<12 >(fixImmediateForRV32 (Imm, isRV64Imm ()));
852+
853+ RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
854+ return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
855+ (VK == RISCVMCExpr::VK_LO || VK == RISCVMCExpr::VK_PCREL_LO ||
856+ VK == RISCVMCExpr::VK_TPREL_LO ||
854857 VK == RISCVMCExpr::VK_TLSDESC_LOAD_LO ||
855858 VK == RISCVMCExpr::VK_TLSDESC_ADD_LO);
856859 }
@@ -873,26 +876,27 @@ struct RISCVOperand final : public MCParsedAsmOperand {
873876 }
874877
875878 bool isUImm20LUI () const {
876- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
877- int64_t Imm;
878879 if (!isImm ())
879880 return false ;
880- bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
881- if (IsConstantImm)
881+
882+ int64_t Imm;
883+ if (evaluateConstantImm (getImm (), Imm))
882884 return isUInt<20 >(Imm);
885+
886+ RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
883887 return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
884888 (VK == RISCVMCExpr::VK_HI || VK == RISCVMCExpr::VK_TPREL_HI);
885889 }
886890
887891 bool isUImm20AUIPC () const {
888- RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
889- int64_t Imm;
890892 if (!isImm ())
891893 return false ;
892- bool IsConstantImm = evaluateConstantImm (getImm (), Imm);
893- if (IsConstantImm)
894+
895+ int64_t Imm;
896+ if (evaluateConstantImm (getImm (), Imm))
894897 return isUInt<20 >(Imm);
895898
899+ RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
896900 return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
897901 (VK == RISCVMCExpr::VK_PCREL_HI || VK == RISCVMCExpr::VK_GOT_HI ||
898902 VK == RISCVMCExpr::VK_TLS_GOT_HI ||
0 commit comments