[llvm] [RISCV] Vendor Relocations for Xqci extension (PR #135400)
Sam Elliott via llvm-commits
llvm-commits at lists.llvm.org
Wed May 28 11:35:58 PDT 2025
================
@@ -611,6 +612,44 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCFixup &Fixup,
isPCRelFixupResolved(AUIPCTarget.getAddSym(), *AUIPCDF);
}
+std::optional<StringRef>
+RISCVAsmBackend::getVendorIdentifierForFixup(unsigned FixupKind) const {
+ switch (FixupKind) {
+ case RISCV::fixup_riscv_qc_e_branch:
+ case RISCV::fixup_riscv_qc_abs20_u:
+ case RISCV::fixup_riscv_qc_e_32:
+ case RISCV::fixup_riscv_qc_e_jump_plt:
+ return "QUALCOMM";
+ }
+
+ return std::nullopt;
+}
+
+void RISCVAsmBackend::addVendorReloc(const MCFragment &F, const MCFixup &Fixup,
+ StringRef VendorIdentifier) {
+ MCContext &Ctx = Asm->getContext();
+
+ auto It = VendorSymbols.find(VendorIdentifier);
+ if (It == VendorSymbols.end()) {
+ MCSymbol *VendorSymbol = Ctx.createLocalSymbol(VendorIdentifier);
+ VendorSymbol->setVariableValue(MCConstantExpr::create(0, Ctx));
+ Asm->registerSymbol(*VendorSymbol);
+
+ It = VendorSymbols.try_emplace(VendorIdentifier, VendorSymbol).first;
+ }
+
+ MCSymbol *VendorSymbol = It->getValue();
+ const MCExpr *VendorExpr = MCSymbolRefExpr::create(VendorSymbol, Ctx);
+ MCFixup VendorFixup =
+ MCFixup::create(Fixup.getOffset(), VendorExpr,
+ FirstLiteralRelocationKind + ELF::R_RISCV_VENDOR);
----------------
lenary wrote:
Done
https://github.com/llvm/llvm-project/pull/135400
More information about the llvm-commits
mailing list