[llvm] [LoongArch] Support parsing the `%le_{hi20,add,lo12}_r` modifiers (PR #99485)
Lu Weining via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 18 22:32:28 PDT 2024
================
@@ -346,6 +359,37 @@ void LoongArchMCCodeEmitter::expandToVectorLDI(
support::endian::write(CB, Binary, llvm::endianness::little);
}
+void LoongArchMCCodeEmitter::expandAddTPRel(const MCInst &MI,
+ SmallVectorImpl<char> &CB,
+ SmallVectorImpl<MCFixup> &Fixups,
+ const MCSubtargetInfo &STI) const {
+ MCOperand Rd = MI.getOperand(0);
+ MCOperand Rj = MI.getOperand(1);
+ MCOperand Rk = MI.getOperand(2);
+ MCOperand Symbol = MI.getOperand(3);
+ assert(Symbol.isExpr() &&
+ "Expected expression as third input to TP-relative add");
+
+ const LoongArchMCExpr *Expr = dyn_cast<LoongArchMCExpr>(Symbol.getExpr());
+ assert(Expr &&
+ Expr->getKind() == LoongArchMCExpr::VK_LoongArch_TLS_LE_ADD_R &&
+ "Expected %le_add_r relocation on TP-relative symbol");
+
+ // Emit the correct %le_add_r relocation for the symbol.
+ Fixups.push_back(MCFixup::create(
+ 0, Expr, MCFixupKind(LoongArch::fixup_loongarch_tls_le_add_r),
+ MI.getLoc()));
+
----------------
SixWeining wrote:
Shall we leave a TODO for emitting fixup_loongarch_relax when linker relaxation is enabled?
https://github.com/llvm/llvm-project/pull/99485
More information about the llvm-commits
mailing list