diff options
author | Fangrui Song <i@maskray.me> | 2025-06-15 16:51:08 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2025-06-15 16:51:09 -0700 |
commit | f11dd116e0aa8cf35bdb82dba0a3a926538c05c2 (patch) | |
tree | d45b4136983bcc9a42172f7426e0be5e0c8a47ce | |
parent | 51b63bbee56c2253643f41c53bc3592af261b82d (diff) | |
download | llvm-f11dd116e0aa8cf35bdb82dba0a3a926538c05c2.zip llvm-f11dd116e0aa8cf35bdb82dba0a3a926538c05c2.tar.gz llvm-f11dd116e0aa8cf35bdb82dba0a3a926538c05c2.tar.bz2 |
RISCV: Replace RISCVMCExpr with MCSpecifierExpr
-rw-r--r-- | bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp | 24 | ||||
-rw-r--r-- | llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 46 | ||||
-rw-r--r-- | llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.h | 1 | ||||
-rw-r--r-- | llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.h | 38 | ||||
-rw-r--r-- | llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/Target/RISCV/RISCVTargetObjectFile.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/Target/RISCV/RISCVTargetObjectFile.h | 3 |
12 files changed, 45 insertions, 107 deletions
diff --git a/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp b/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp index cf30ad2..c7d664a 100644 --- a/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp +++ b/bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp @@ -33,8 +33,8 @@ public: bool equals(const MCSpecifierExpr &A, const MCSpecifierExpr &B, CompFuncTy Comp) const override { - const auto &RISCVExprA = cast<RISCVMCExpr>(A); - const auto &RISCVExprB = cast<RISCVMCExpr>(B); + const auto &RISCVExprA = cast<MCSpecifierExpr>(A); + const auto &RISCVExprB = cast<MCSpecifierExpr>(B); if (RISCVExprA.getSpecifier() != RISCVExprB.getSpecifier()) return false; @@ -245,7 +245,7 @@ public: MCContext *Ctx) { Inst.setOpcode(Opcode); Inst.clear(); - Inst.addOperand(MCOperand::createExpr(RISCVMCExpr::create( + Inst.addOperand(MCOperand::createExpr(MCSpecifierExpr::create( MCSymbolRefExpr::create(Target, MCSymbolRefExpr::VK_None, *Ctx), ELF::R_RISCV_CALL_PLT, *Ctx))); } @@ -342,7 +342,7 @@ public: } const MCSymbol *getTargetSymbol(const MCExpr *Expr) const override { - auto *RISCVExpr = dyn_cast<RISCVMCExpr>(Expr); + auto *RISCVExpr = dyn_cast<MCSpecifierExpr>(Expr); if (RISCVExpr && RISCVExpr->getSubExpr()) return getTargetSymbol(RISCVExpr->getSubExpr()); @@ -435,19 +435,19 @@ public: case ELF::R_RISCV_TLS_GD_HI20: // The GOT is reused so no need to create GOT relocations case ELF::R_RISCV_PCREL_HI20: - return RISCVMCExpr::create(Expr, ELF::R_RISCV_PCREL_HI20, Ctx); + return MCSpecifierExpr::create(Expr, ELF::R_RISCV_PCREL_HI20, Ctx); case ELF::R_RISCV_PCREL_LO12_I: case ELF::R_RISCV_PCREL_LO12_S: - return RISCVMCExpr::create(Expr, RISCV::S_PCREL_LO, Ctx); + return MCSpecifierExpr::create(Expr, RISCV::S_PCREL_LO, Ctx); case ELF::R_RISCV_HI20: - return RISCVMCExpr::create(Expr, ELF::R_RISCV_HI20, Ctx); + return MCSpecifierExpr::create(Expr, ELF::R_RISCV_HI20, Ctx); case ELF::R_RISCV_LO12_I: case ELF::R_RISCV_LO12_S: - return RISCVMCExpr::create(Expr, RISCV::S_LO, Ctx); + return MCSpecifierExpr::create(Expr, RISCV::S_LO, Ctx); case ELF::R_RISCV_CALL: - return RISCVMCExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx); + return MCSpecifierExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx); case ELF::R_RISCV_CALL_PLT: - return RISCVMCExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx); + return MCSpecifierExpr::create(Expr, ELF::R_RISCV_CALL_PLT, Ctx); } } @@ -466,10 +466,10 @@ public: return false; const auto *ImmExpr = ImmOp.getExpr(); - if (!isa<RISCVMCExpr>(ImmExpr)) + if (!isa<MCSpecifierExpr>(ImmExpr)) return false; - switch (cast<RISCVMCExpr>(ImmExpr)->getSpecifier()) { + switch (cast<MCSpecifierExpr>(ImmExpr)->getSpecifier()) { default: return false; case ELF::R_RISCV_CALL_PLT: diff --git a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h index fa6cb75..00e681e 100644 --- a/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h +++ b/llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h @@ -117,10 +117,6 @@ public: MCSection *getStaticDtorSection(unsigned Priority, const MCSymbol *KeySym) const override; - virtual const MCExpr *createTargetMCExpr(const MCExpr *Expr, - uint8_t Specifier) const { - return nullptr; - } const MCExpr * lowerSymbolDifference(const MCSymbol *LHS, const MCSymbol *RHS, int64_t Addend, diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index b8c632d1..c804a17 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1219,7 +1219,7 @@ const MCExpr *TargetLoweringObjectFileELF::lowerSymbolDifference( if (Addend) Res = MCBinaryExpr::createAdd(Res, MCConstantExpr::create(Addend, Ctx), Ctx); - return createTargetMCExpr(Res, PLTPCRelativeSpecifier); + return MCSpecifierExpr::create(Res, PLTPCRelativeSpecifier, getContext()); } if (!PLTRelativeSpecifier) diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index 612ac42..510ca5f 100644 --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -137,7 +137,7 @@ class RISCVAsmParser : public MCTargetAsmParser { // Helper to emit a combination of AUIPC and SecondOpcode. Used to implement // helpers such as emitLoadLocalAddress and emitLoadAddress. void emitAuipcInstPair(MCRegister DestReg, MCRegister TmpReg, - const MCExpr *Symbol, RISCVMCExpr::Specifier VKHi, + const MCExpr *Symbol, RISCV::Specifier VKHi, unsigned SecondOpcode, SMLoc IDLoc, MCStreamer &Out); // Helper to emit pseudo instruction "lla" used in PC-rel addressing. @@ -295,8 +295,7 @@ public: #undef GET_OPERAND_DIAGNOSTIC_TYPES }; - static bool classifySymbolRef(const MCExpr *Expr, - RISCVMCExpr::Specifier &Kind); + static bool classifySymbolRef(const MCExpr *Expr, RISCV::Specifier &Kind); static bool isSymbolDiff(const MCExpr *Expr); RISCVAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser, @@ -544,7 +543,7 @@ public: if (evaluateConstantImm(getImm(), Imm)) return isShiftedInt<N - 1, 1>(fixImmediateForRV32(Imm, isRV64Imm())); - RISCVMCExpr::Specifier VK = RISCV::S_None; + RISCV::Specifier VK = RISCV::S_None; return RISCVAsmParser::classifySymbolRef(getImm(), VK) && VK == RISCV::S_None; } @@ -559,7 +558,7 @@ public: if (evaluateConstantImm(getImm(), Imm)) return isInt<N>(fixImmediateForRV32(Imm, isRV64Imm())); - RISCVMCExpr::Specifier VK = RISCV::S_None; + RISCV::Specifier VK = RISCV::S_None; return RISCVAsmParser::classifySymbolRef(getImm(), VK) && VK == RISCV::S_None; } @@ -572,7 +571,7 @@ public: if (!isImm() || evaluateConstantImm(getImm(), Imm)) return false; - RISCVMCExpr::Specifier VK = RISCV::S_None; + RISCV::Specifier VK = RISCV::S_None; return RISCVAsmParser::classifySymbolRef(getImm(), VK) && VK == RISCV::S_None; } @@ -583,7 +582,7 @@ public: if (!isImm() || evaluateConstantImm(getImm(), Imm)) return false; - RISCVMCExpr::Specifier VK = RISCV::S_None; + RISCV::Specifier VK = RISCV::S_None; return RISCVAsmParser::classifySymbolRef(getImm(), VK) && VK == ELF::R_RISCV_CALL_PLT; } @@ -594,7 +593,7 @@ public: if (!isImm() || evaluateConstantImm(getImm(), Imm)) return false; - RISCVMCExpr::Specifier VK = RISCV::S_None; + RISCV::Specifier VK = RISCV::S_None; return RISCVAsmParser::classifySymbolRef(getImm(), VK) && VK == ELF::R_RISCV_CALL_PLT; } @@ -605,7 +604,7 @@ public: if (!isImm() || evaluateConstantImm(getImm(), Imm)) return false; - RISCVMCExpr::Specifier VK = RISCV::S_None; + RISCV::Specifier VK = RISCV::S_None; return RISCVAsmParser::classifySymbolRef(getImm(), VK) && VK == ELF::R_RISCV_TPREL_ADD; } @@ -616,7 +615,7 @@ public: if (!isImm() || evaluateConstantImm(getImm(), Imm)) return false; - RISCVMCExpr::Specifier VK = RISCV::S_None; + RISCV::Specifier VK = RISCV::S_None; return RISCVAsmParser::classifySymbolRef(getImm(), VK) && VK == ELF::R_RISCV_TLSDESC_CALL; } @@ -870,7 +869,7 @@ public: if (evaluateConstantImm(getImm(), Imm)) return isInt<12>(fixImmediateForRV32(Imm, isRV64Imm())); - RISCVMCExpr::Specifier VK = RISCV::S_None; + RISCV::Specifier VK = RISCV::S_None; return RISCVAsmParser::classifySymbolRef(getImm(), VK) && (VK == RISCV::S_LO || VK == RISCV::S_PCREL_LO || VK == RISCV::S_TPREL_LO || VK == ELF::R_RISCV_TLSDESC_LOAD_LO12 || @@ -902,7 +901,7 @@ public: if (evaluateConstantImm(getImm(), Imm)) return isInt<20>(fixImmediateForRV32(Imm, isRV64Imm())); - RISCVMCExpr::Specifier VK = RISCV::S_None; + RISCV::Specifier VK = RISCV::S_None; return RISCVAsmParser::classifySymbolRef(getImm(), VK) && VK == RISCV::S_QC_ABS20; } @@ -915,7 +914,7 @@ public: if (evaluateConstantImm(getImm(), Imm)) return isUInt<20>(Imm); - RISCVMCExpr::Specifier VK = RISCV::S_None; + RISCV::Specifier VK = RISCV::S_None; return RISCVAsmParser::classifySymbolRef(getImm(), VK) && (VK == ELF::R_RISCV_HI20 || VK == ELF::R_RISCV_TPREL_HI20); } @@ -928,7 +927,7 @@ public: if (evaluateConstantImm(getImm(), Imm)) return isUInt<20>(Imm); - RISCVMCExpr::Specifier VK = RISCV::S_None; + RISCV::Specifier VK = RISCV::S_None; return RISCVAsmParser::classifySymbolRef(getImm(), VK) && (VK == ELF::R_RISCV_PCREL_HI20 || VK == ELF::R_RISCV_GOT_HI20 || VK == ELF::R_RISCV_TLS_GOT_HI20 || VK == ELF::R_RISCV_TLS_GD_HI20 || @@ -2099,7 +2098,7 @@ bool RISCVAsmParser::parseExprWithSpecifier(const MCExpr *&Res, SMLoc &E) { if (getParser().parseParenExpression(SubExpr, E)) return true; - Res = RISCVMCExpr::create(SubExpr, Spec, getContext()); + Res = MCSpecifierExpr::create(SubExpr, Spec, getContext()); return false; } @@ -2183,11 +2182,11 @@ ParseStatus RISCVAsmParser::parseCallSymbol(OperandVector &Operands) { } SMLoc E = SMLoc::getFromPointer(S.getPointer() + Identifier.size()); - RISCVMCExpr::Specifier Kind = ELF::R_RISCV_CALL_PLT; + RISCV::Specifier Kind = ELF::R_RISCV_CALL_PLT; MCSymbol *Sym = getContext().getOrCreateSymbol(Identifier); Res = MCSymbolRefExpr::create(Sym, getContext()); - Res = RISCVMCExpr::create(Res, Kind, getContext()); + Res = MCSpecifierExpr::create(Res, Kind, getContext()); Operands.push_back(RISCVOperand::createImm(Res, S, E, isRV64())); return ParseStatus::Success; } @@ -2203,7 +2202,7 @@ ParseStatus RISCVAsmParser::parsePseudoJumpSymbol(OperandVector &Operands) { if (Res->getKind() != MCExpr::ExprKind::SymbolRef) return Error(S, "operand must be a valid jump target"); - Res = RISCVMCExpr::create(Res, ELF::R_RISCV_CALL_PLT, getContext()); + Res = MCSpecifierExpr::create(Res, ELF::R_RISCV_CALL_PLT, getContext()); Operands.push_back(RISCVOperand::createImm(Res, S, E, isRV64())); return ParseStatus::Success; } @@ -2918,10 +2917,9 @@ bool RISCVAsmParser::parseInstruction(ParseInstructionInfo &Info, } bool RISCVAsmParser::classifySymbolRef(const MCExpr *Expr, - RISCVMCExpr::Specifier &Kind) { + RISCV::Specifier &Kind) { Kind = RISCV::S_None; - - if (const RISCVMCExpr *RE = dyn_cast<RISCVMCExpr>(Expr)) { + if (const auto *RE = dyn_cast<MCSpecifierExpr>(Expr)) { Kind = RE->getSpecifier(); Expr = RE->getSubExpr(); } @@ -3434,7 +3432,7 @@ void RISCVAsmParser::emitLoadImm(MCRegister DestReg, int64_t Value, void RISCVAsmParser::emitAuipcInstPair(MCRegister DestReg, MCRegister TmpReg, const MCExpr *Symbol, - RISCVMCExpr::Specifier VKHi, + RISCV::Specifier VKHi, unsigned SecondOpcode, SMLoc IDLoc, MCStreamer &Out) { // A pair of instructions for PC-relative addressing; expands to @@ -3445,11 +3443,11 @@ void RISCVAsmParser::emitAuipcInstPair(MCRegister DestReg, MCRegister TmpReg, MCSymbol *TmpLabel = Ctx.createNamedTempSymbol("pcrel_hi"); Out.emitLabel(TmpLabel); - const RISCVMCExpr *SymbolHi = RISCVMCExpr::create(Symbol, VKHi, Ctx); + const auto *SymbolHi = MCSpecifierExpr::create(Symbol, VKHi, Ctx); emitToStreamer(Out, MCInstBuilder(RISCV::AUIPC).addReg(TmpReg).addExpr(SymbolHi)); - const MCExpr *RefToLinkTmpLabel = RISCVMCExpr::create( + const MCExpr *RefToLinkTmpLabel = MCSpecifierExpr::create( MCSymbolRefExpr::create(TmpLabel, Ctx), RISCV::S_PCREL_LO, Ctx); emitToStreamer(Out, MCInstBuilder(SecondOpcode) diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp index 88b1d21..090d331 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp @@ -44,7 +44,7 @@ const MCExpr *RISCVMCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym, MCContext &Ctx = Streamer.getContext(); const MCExpr *ME = MCSymbolRefExpr::create(Sym, Ctx); assert(Encoding & dwarf::DW_EH_PE_sdata4 && "Unexpected encoding"); - return RISCVMCExpr::create(ME, ELF::R_RISCV_32_PCREL, Ctx); + return MCSpecifierExpr::create(ME, ELF::R_RISCV_32_PCREL, Ctx); } void RISCVMCAsmInfo::printSpecifierExpr(raw_ostream &OS, diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.h index 05f04a6..097e94b 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.h +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.h @@ -13,7 +13,6 @@ #ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCASMINFO_H #define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCASMINFO_H -#include "RISCVMCExpr.h" #include "llvm/MC/MCAsmInfoELF.h" #include "llvm/MC/MCFixup.h" diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp index 03c6701..1185e35 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp @@ -177,7 +177,7 @@ void RISCVMCCodeEmitter::expandTLSDESCCall(const MCInst &MI, MCOperand SrcSymbol = MI.getOperand(3); assert(SrcSymbol.isExpr() && "Expected expression as first input to TLSDESCCALL"); - const RISCVMCExpr *Expr = dyn_cast<RISCVMCExpr>(SrcSymbol.getExpr()); + const auto *Expr = dyn_cast<MCSpecifierExpr>(SrcSymbol.getExpr()); MCRegister Link = MI.getOperand(0).getReg(); MCRegister Dest = MI.getOperand(1).getReg(); int64_t Imm = MI.getOperand(2).getImm(); @@ -205,7 +205,7 @@ void RISCVMCCodeEmitter::expandAddTPRel(const MCInst &MI, assert(SrcSymbol.isExpr() && "Expected expression as third input to TP-relative add"); - const RISCVMCExpr *Expr = dyn_cast<RISCVMCExpr>(SrcSymbol.getExpr()); + const auto *Expr = dyn_cast<MCSpecifierExpr>(SrcSymbol.getExpr()); assert(Expr && Expr->getSpecifier() == ELF::R_RISCV_TPREL_ADD && "Expected tprel_add relocation on TP-relative symbol"); @@ -566,7 +566,7 @@ uint64_t RISCVMCCodeEmitter::getImmOpValue(const MCInst &MI, unsigned OpNo, unsigned FixupKind = RISCV::fixup_riscv_invalid; bool RelaxCandidate = false; if (Kind == MCExpr::Specifier) { - const RISCVMCExpr *RVExpr = cast<RISCVMCExpr>(Expr); + const auto *RVExpr = cast<MCSpecifierExpr>(Expr); FixupKind = RVExpr->getSpecifier(); switch (RVExpr->getSpecifier()) { default: diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp index 1f6f940..baa508a 100644 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp @@ -11,7 +11,6 @@ // //===----------------------------------------------------------------------===// -#include "RISCVMCExpr.h" #include "MCTargetDesc/RISCVAsmBackend.h" #include "MCTargetDesc/RISCVMCAsmInfo.h" #include "RISCVFixupKinds.h" @@ -27,11 +26,6 @@ using namespace llvm; #define DEBUG_TYPE "riscvmcexpr" -const RISCVMCExpr *RISCVMCExpr::create(const MCExpr *Expr, Specifier S, - MCContext &Ctx) { - return new (Ctx) RISCVMCExpr(Expr, S); -} - RISCV::Specifier RISCV::parseSpecifierName(StringRef name) { return StringSwitch<RISCV::Specifier>(name) .Case("lo", RISCV::S_LO) diff --git a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.h b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.h deleted file mode 100644 index 3e842ab..0000000 --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.h +++ /dev/null @@ -1,38 +0,0 @@ -//===-- RISCVMCExpr.h - RISC-V specific MC expression classes----*- C++ -*-===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -// This file describes RISC-V specific MCExprs, used for modifiers like -// "%hi" or "%lo" etc., -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCEXPR_H -#define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVMCEXPR_H - -#include "llvm/MC/MCExpr.h" -#include "llvm/MC/MCFixup.h" - -namespace llvm { - -class StringRef; - -class RISCVMCExpr : public MCSpecifierExpr { -public: - using Specifier = uint16_t; - -private: - explicit RISCVMCExpr(const MCExpr *Expr, Specifier S) - : MCSpecifierExpr(Expr, S) {} - -public: - static const RISCVMCExpr *create(const MCExpr *Expr, Specifier S, - MCContext &Ctx); -}; -} // end namespace llvm. - -#endif diff --git a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp index 2c636c4..83e9b4b 100644 --- a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp +++ b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp @@ -630,7 +630,7 @@ void RISCVAsmPrinter::LowerHWASAN_CHECK_MEMACCESS(const MachineInstr &MI) { Sym = OutContext.getOrCreateSymbol(SymName); } auto Res = MCSymbolRefExpr::create(Sym, OutContext); - auto Expr = RISCVMCExpr::create(Res, ELF::R_RISCV_CALL_PLT, OutContext); + auto Expr = MCSpecifierExpr::create(Res, ELF::R_RISCV_CALL_PLT, OutContext); EmitToStreamer(*OutStreamer, MCInstBuilder(RISCV::PseudoCALL).addExpr(Expr)); } @@ -741,8 +741,8 @@ void RISCVAsmPrinter::EmitHwasanMemaccessSymbols(Module &M) { const MCSymbolRefExpr *HwasanTagMismatchV2Ref = MCSymbolRefExpr::create(HwasanTagMismatchV2Sym, OutContext); - auto Expr = RISCVMCExpr::create(HwasanTagMismatchV2Ref, ELF::R_RISCV_CALL_PLT, - OutContext); + auto Expr = MCSpecifierExpr::create(HwasanTagMismatchV2Ref, + ELF::R_RISCV_CALL_PLT, OutContext); for (auto &P : HwasanMemaccessSymbols) { unsigned Reg = std::get<0>(P.first); @@ -957,7 +957,7 @@ void RISCVAsmPrinter::emitNoteGnuProperty(const Module &M) { static MCOperand lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym, const AsmPrinter &AP) { MCContext &Ctx = AP.OutContext; - RISCVMCExpr::Specifier Kind; + RISCV::Specifier Kind; switch (MO.getTargetFlags()) { default: @@ -1019,7 +1019,7 @@ static MCOperand lowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym, ME, MCConstantExpr::create(MO.getOffset(), Ctx), Ctx); if (Kind != RISCV::S_None) - ME = RISCVMCExpr::create(ME, Kind, Ctx); + ME = MCSpecifierExpr::create(ME, Kind, Ctx); return MCOperand::createExpr(ME); } diff --git a/llvm/lib/Target/RISCV/RISCVTargetObjectFile.cpp b/llvm/lib/Target/RISCV/RISCVTargetObjectFile.cpp index 3cb5c7e..bc90cf8 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetObjectFile.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetObjectFile.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "RISCVTargetObjectFile.h" -#include "MCTargetDesc/RISCVMCExpr.h" #include "MCTargetDesc/RISCVMCObjectFileInfo.h" #include "RISCVTargetMachine.h" #include "llvm/BinaryFormat/ELF.h" @@ -53,7 +52,7 @@ const MCExpr *RISCVELFTargetObjectFile::getIndirectSymViaGOTPCRel( const MCExpr *Res = MCSymbolRefExpr::create(Sym, Ctx); Res = MCBinaryExpr::createAdd( Res, MCConstantExpr::create(Offset + MV.getConstant(), Ctx), Ctx); - return RISCVMCExpr::create(Res, ELF::R_RISCV_GOT32_PCREL, Ctx); + return MCSpecifierExpr::create(Res, ELF::R_RISCV_GOT32_PCREL, Ctx); } // A address must be loaded from a small section if its size is less than the @@ -180,10 +179,3 @@ MCSection *RISCVELFTargetObjectFile::getSectionForConstant( return TargetLoweringObjectFileELF::getSectionForConstant(DL, Kind, C, Alignment); } - -const MCExpr * -RISCVELFTargetObjectFile::createTargetMCExpr(const MCExpr *Expr, - uint8_t Specifier) const { - return RISCVMCExpr::create(Expr, RISCVMCExpr::Specifier(Specifier), - getContext()); -} diff --git a/llvm/lib/Target/RISCV/RISCVTargetObjectFile.h b/llvm/lib/Target/RISCV/RISCVTargetObjectFile.h index b6da3f4..ff7e3e4 100644 --- a/llvm/lib/Target/RISCV/RISCVTargetObjectFile.h +++ b/llvm/lib/Target/RISCV/RISCVTargetObjectFile.h @@ -48,9 +48,6 @@ public: bool isInSmallSection(uint64_t Size) const; - const MCExpr *createTargetMCExpr(const MCExpr *Expr, - uint8_t Specifier) const override; - const MCExpr *getIndirectSymViaGOTPCRel(const GlobalValue *GV, const MCSymbol *Sym, const MCValue &MV, int64_t Offset, |