@@ -229,9 +229,7 @@ class RISCVAsmParser : public MCTargetAsmParser {
229229 ParseStatus parseZeroOffsetMemOp (OperandVector &Operands);
230230 ParseStatus parseOperandWithModifier (OperandVector &Operands);
231231 ParseStatus parseBareSymbol (OperandVector &Operands);
232- template <bool IsCap = false >
233232 ParseStatus parseCallSymbol (OperandVector &Operands);
234- template <bool IsCap = false >
235233 ParseStatus parsePseudoJumpSymbol (OperandVector &Operands);
236234 ParseStatus parseJALOffset (OperandVector &Operands);
237235 ParseStatus parseVTypeI (OperandVector &Operands);
@@ -569,16 +567,6 @@ struct RISCVOperand final : public MCParsedAsmOperand {
569567 VK == RISCVMCExpr::VK_RISCV_CALL_PLT);
570568 }
571569
572- bool isCCallSymbol () const {
573- int64_t Imm;
574- RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None;
575- // Must be of 'immediate' type but not a constant.
576- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK))
577- return false ;
578- return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
579- VK == RISCVMCExpr::VK_RISCV_CCALL;
580- }
581-
582570 bool isPseudoJumpSymbol () const {
583571 int64_t Imm;
584572 RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None;
@@ -589,16 +577,6 @@ struct RISCVOperand final : public MCParsedAsmOperand {
589577 VK == RISCVMCExpr::VK_RISCV_CALL;
590578 }
591579
592- bool isPseudoCJumpSymbol () const {
593- int64_t Imm;
594- RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None;
595- // Must be of 'immediate' type but not a constant.
596- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK))
597- return false ;
598- return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
599- VK == RISCVMCExpr::VK_RISCV_CCALL;
600- }
601-
602580 bool isTPRelAddSymbol () const {
603581 int64_t Imm;
604582 RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None;
@@ -609,16 +587,6 @@ struct RISCVOperand final : public MCParsedAsmOperand {
609587 VK == RISCVMCExpr::VK_RISCV_TPREL_ADD;
610588 }
611589
612- bool isTPRelCIncOffsetSymbol () const {
613- int64_t Imm;
614- RISCVMCExpr::VariantKind VK = RISCVMCExpr::VK_RISCV_None;
615- // Must be of 'immediate' type but not a constant.
616- if (!isImm () || evaluateConstantImm (getImm (), Imm, VK))
617- return false ;
618- return RISCVAsmParser::classifySymbolRef (getImm (), VK) &&
619- VK == RISCVMCExpr::VK_RISCV_TPREL_CINCOFFSET;
620- }
621-
622590 bool isCSRSystemRegister () const { return isSystemRegister (); }
623591
624592 bool isVTypeImm (unsigned N) const {
@@ -1008,19 +976,13 @@ struct RISCVOperand final : public MCParsedAsmOperand {
1008976 return IsValid && (VK == RISCVMCExpr::VK_RISCV_PCREL_HI ||
1009977 VK == RISCVMCExpr::VK_RISCV_GOT_HI ||
1010978 VK == RISCVMCExpr::VK_RISCV_TLS_GOT_HI ||
1011- VK == RISCVMCExpr::VK_RISCV_TLS_GD_HI ||
1012- VK == RISCVMCExpr::VK_RISCV_CAPTAB_PCREL_HI ||
1013- VK == RISCVMCExpr::VK_RISCV_TLS_IE_CAPTAB_PCREL_HI ||
1014- VK == RISCVMCExpr::VK_RISCV_TLS_GD_CAPTAB_PCREL_HI);
979+ VK == RISCVMCExpr::VK_RISCV_TLS_GD_HI);
1015980 } else {
1016981 return isUInt<20 >(Imm) && (VK == RISCVMCExpr::VK_RISCV_None ||
1017982 VK == RISCVMCExpr::VK_RISCV_PCREL_HI ||
1018983 VK == RISCVMCExpr::VK_RISCV_GOT_HI ||
1019984 VK == RISCVMCExpr::VK_RISCV_TLS_GOT_HI ||
1020- VK == RISCVMCExpr::VK_RISCV_TLS_GD_HI ||
1021- VK == RISCVMCExpr::VK_RISCV_CAPTAB_PCREL_HI ||
1022- VK == RISCVMCExpr::VK_RISCV_TLS_IE_CAPTAB_PCREL_HI ||
1023- VK == RISCVMCExpr::VK_RISCV_TLS_GD_CAPTAB_PCREL_HI);
985+ VK == RISCVMCExpr::VK_RISCV_TLS_GD_HI);
1024986 }
1025987 }
1026988
@@ -1665,24 +1627,18 @@ bool RISCVAsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
16651627 SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
16661628 return Error (ErrorLoc, " operand must be a bare symbol name" );
16671629 }
1668- case Match_InvalidPseudoJumpSymbol:
1669- case Match_InvalidPseudoCJumpSymbol: {
1630+ case Match_InvalidPseudoJumpSymbol: {
16701631 SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
16711632 return Error (ErrorLoc, " operand must be a valid jump target" );
16721633 }
1673- case Match_InvalidCallSymbol:
1674- case Match_InvalidCCallSymbol: {
1634+ case Match_InvalidCallSymbol: {
16751635 SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
16761636 return Error (ErrorLoc, " operand must be a bare symbol name" );
16771637 }
16781638 case Match_InvalidTPRelAddSymbol: {
16791639 SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
16801640 return Error (ErrorLoc, " operand must be a symbol with %tprel_add modifier" );
16811641 }
1682- case Match_InvalidTPRelCIncOffsetSymbol: {
1683- SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
1684- return Error (ErrorLoc, " operand must be a symbol with %tprel_cincoffset modifier" );
1685- }
16861642 case Match_InvalidRTZArg: {
16871643 SMLoc ErrorLoc = ((RISCVOperand &)*Operands[ErrorInfo]).getStartLoc ();
16881644 return Error (ErrorLoc, " operand must be 'rtz' floating-point rounding mode" );
@@ -2250,7 +2206,6 @@ ParseStatus RISCVAsmParser::parseBareSymbol(OperandVector &Operands) {
22502206 return ParseStatus::Success;
22512207}
22522208
2253- template <bool IsCap>
22542209ParseStatus RISCVAsmParser::parseCallSymbol (OperandVector &Operands) {
22552210 SMLoc S = getLoc ();
22562211 const MCExpr *Res;
@@ -2268,17 +2223,12 @@ ParseStatus RISCVAsmParser::parseCallSymbol(OperandVector &Operands) {
22682223
22692224 SMLoc E = SMLoc::getFromPointer (S.getPointer () + Identifier.size ());
22702225
2271- RISCVMCExpr::VariantKind Kind;
2272- if (IsCap) {
2273- Kind = RISCVMCExpr::VK_RISCV_CCALL;
2274- // Both relocations are the same for RISC-V, so CHERI-RISC-V only provides
2275- // a single relocation, but be friendly and permit the redundant suffix.
2276- Identifier.consume_back (" @plt" );
2277- } else {
2278- Kind = RISCVMCExpr::VK_RISCV_CALL;
2279- if (Identifier.consume_back (" @plt" ))
2280- Kind = RISCVMCExpr::VK_RISCV_CALL_PLT;
2281- }
2226+ RISCVMCExpr::VariantKind Kind = RISCVMCExpr::VK_RISCV_CALL;
2227+ // CHERI-RISC-V always uses the fixed relocation but never prints the suffix.
2228+ // However, we allow the redundant suffix to be provided anyway.
2229+ if (Identifier.consume_back (" @plt" ) &&
2230+ !getSTI ().hasFeature (RISCV::FeatureCapMode))
2231+ Kind = RISCVMCExpr::VK_RISCV_CALL_PLT;
22822232
22832233 MCSymbol *Sym = getContext ().getOrCreateSymbol (Identifier);
22842234 Res = MCSymbolRefExpr::create (Sym, MCSymbolRefExpr::VK_None, getContext ());
@@ -2287,7 +2237,6 @@ ParseStatus RISCVAsmParser::parseCallSymbol(OperandVector &Operands) {
22872237 return ParseStatus::Success;
22882238}
22892239
2290- template <bool IsCap>
22912240ParseStatus RISCVAsmParser::parsePseudoJumpSymbol (OperandVector &Operands) {
22922241 SMLoc S = getLoc ();
22932242 SMLoc E;
@@ -2301,9 +2250,7 @@ ParseStatus RISCVAsmParser::parsePseudoJumpSymbol(OperandVector &Operands) {
23012250 MCSymbolRefExpr::VariantKind::VK_PLT)
23022251 return Error (S, " operand must be a valid jump target" );
23032252
2304- RISCVMCExpr::VariantKind Kind =
2305- IsCap ? RISCVMCExpr::VK_RISCV_CCALL : RISCVMCExpr::VK_RISCV_CALL;
2306- Res = RISCVMCExpr::create (Res, Kind, getContext ());
2253+ Res = RISCVMCExpr::create (Res, RISCVMCExpr::VK_RISCV_CALL, getContext ());
23072254 Operands.push_back (RISCVOperand::createImm (Res, S, E, isRV64 ()));
23082255 return ParseStatus::Success;
23092256}
@@ -3704,14 +3651,13 @@ void RISCVAsmParser::emitCapLoadGlobalCap(MCInst &Inst, SMLoc IDLoc,
37043651 // captable-indirect addressing of global symbols in the PC-relative ABI:
37053652 // clgc rdest, symbol
37063653 // expands to
3707- // TmpLabel: AUIPCC cdest, %captab_pcrel_hi (symbol)
3654+ // TmpLabel: AUIPCC cdest, %got_pcrel_hi (symbol)
37083655 // CLC cdest, %pcrel_lo(TmpLabel)(cdest)
37093656 MCOperand DestReg = Inst.getOperand (0 );
37103657 const MCExpr *Symbol = Inst.getOperand (1 ).getExpr ();
37113658 unsigned SecondOpcode = isRV64 () ? RISCV::CLC_128 : RISCV::CLC_64;
3712- emitAuipccInstPair (DestReg, DestReg, Symbol,
3713- RISCVMCExpr::VK_RISCV_CAPTAB_PCREL_HI, SecondOpcode,
3714- IDLoc, Out);
3659+ emitAuipccInstPair (DestReg, DestReg, Symbol, RISCVMCExpr::VK_RISCV_GOT_HI,
3660+ SecondOpcode, IDLoc, Out);
37153661}
37163662
37173663void RISCVAsmParser::emitCapLoadTLSIEAddress (MCInst &Inst, SMLoc IDLoc,
@@ -3720,15 +3666,14 @@ void RISCVAsmParser::emitCapLoadTLSIEAddress(MCInst &Inst, SMLoc IDLoc,
37203666 // in initial-exec TLS model addressing of global symbols:
37213667 // cla.tls.ie rdest, symbol
37223668 // expands to
3723- // TmpLabel: AUIPCC cdest, %tls_ie_captab_pcrel_hi (symbol)
3669+ // TmpLabel: AUIPCC cdest, %tls_ie_pcrel_hi (symbol)
37243670 // CLx rdest, %pcrel_lo(TmpLabel)(cdest)
37253671 MCOperand DestReg = Inst.getOperand (0 );
37263672 MCOperand TmpReg = MCOperand::createReg (convertGPRToGPCR (DestReg.getReg ()));
37273673 const MCExpr *Symbol = Inst.getOperand (1 ).getExpr ();
37283674 unsigned SecondOpcode = isRV64 () ? RISCV::CLD : RISCV::CLW;
3729- emitAuipccInstPair (DestReg, TmpReg, Symbol,
3730- RISCVMCExpr::VK_RISCV_TLS_IE_CAPTAB_PCREL_HI, SecondOpcode,
3731- IDLoc, Out);
3675+ emitAuipccInstPair (DestReg, TmpReg, Symbol, RISCVMCExpr::VK_RISCV_TLS_GOT_HI,
3676+ SecondOpcode, IDLoc, Out);
37323677}
37333678
37343679void RISCVAsmParser::emitCapLoadTLSGDCap (MCInst &Inst, SMLoc IDLoc,
@@ -3741,8 +3686,7 @@ void RISCVAsmParser::emitCapLoadTLSGDCap(MCInst &Inst, SMLoc IDLoc,
37413686 // CINCOFFSET cdest, cdest, %pcrel_lo(TmpLabel)
37423687 MCOperand DestReg = Inst.getOperand (0 );
37433688 const MCExpr *Symbol = Inst.getOperand (1 ).getExpr ();
3744- emitAuipccInstPair (DestReg, DestReg, Symbol,
3745- RISCVMCExpr::VK_RISCV_TLS_GD_CAPTAB_PCREL_HI,
3689+ emitAuipccInstPair (DestReg, DestReg, Symbol, RISCVMCExpr::VK_RISCV_TLS_GD_HI,
37463690 RISCV::CIncOffsetImm, IDLoc, Out);
37473691}
37483692
@@ -3754,7 +3698,7 @@ bool RISCVAsmParser::checkPseudoCIncOffsetTPRel(MCInst &Inst,
37543698 if (Inst.getOperand (1 ).getReg () != RISCV::C4) {
37553699 SMLoc ErrorLoc = ((RISCVOperand &)*Operands[2 ]).getStartLoc ();
37563700 return Error (ErrorLoc, " the first input operand must be ctp/c4 when using "
3757- " %tprel_cincoffset modifier" );
3701+ " %tprel_add modifier" );
37583702 }
37593703
37603704 return false ;
0 commit comments