[llvm] [PowerPC] 32-bit large code-model support for toc-data (PR #85129)
Zaara Syeda via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 12:03:09 PDT 2024
================
@@ -6144,23 +6142,44 @@ void PPCDAGToDAGISel::Select(SDNode *N) {
" ELF/AIX or 32-bit AIX in the following.");
// Transforms the ISD::TOC_ENTRY node for 32-bit AIX large code model mode
- // or 64-bit medium (ELF-only) or large (ELF and AIX) code model code. We
- // generate two instructions as described below. The first source operand
- // is a symbol reference. If it must be toc-referenced according to
+ // or 64-bit medium (ELF-only) or large (ELF and AIX) code model code non
+ // toc-data symbols.
+ // We generate two instructions as described below. The first source
+ // operand is a symbol reference. If it must be toc-referenced according to
// Subtarget, we generate:
// [32-bit AIX]
// LWZtocL(@sym, ADDIStocHA(%r2, @sym))
// [64-bit ELF/AIX]
// LDtocL(@sym, ADDIStocHA8(%x2, @sym))
// Otherwise we generate:
// ADDItocL8(ADDIStocHA8(%x2, @sym), @sym)
+
+ // For large code model toc-data symbols we generate:
+ // [32-bit AIX]
+ // ADDItocL(ADDIStocHA(%x2, @sym), @sym)
+ // [64-bit AIX]
+ // ADDItocL8(ADDIStocHA8(%x2, @sym), @sym)
+
SDValue GA = N->getOperand(0);
SDValue TOCbase = N->getOperand(1);
EVT VT = isPPC64 ? MVT::i64 : MVT::i32;
SDNode *Tmp = CurDAG->getMachineNode(
isPPC64 ? PPC::ADDIStocHA8 : PPC::ADDIStocHA, dl, VT, TOCbase, GA);
+ // On AIX if the symbol has the toc-data attribute it will be defined
+ // in the TOC entry, so we use an ADDItocL similar to the medium code
+ // model ELF abi.
+ if (isAIXABI && hasTocDataAttr(GA)) {
+ if (isPPC64)
+ report_fatal_error(
+ "64-bit large code model toc-data not yet supported");
+
+ ReplaceNode(N, CurDAG->getMachineNode(PPC::ADDItocL, dl, VT,
+ SDValue(Tmp, 0), GA));
+ return;
+ }
+
----------------
syzaara wrote:
Line 6195 is handling the Linux medium code model path. For tocdata 64-bit with large code model, I will have a follow up patch to use ADDItocL8 (with the appropriate enhancements made in PPCAsmPrinter.cpp). ADDItocL8 will then be used on line 6175 above.
I plan to post the 64-bit support next once this 32-bit patch is approved and merged.
https://github.com/llvm/llvm-project/pull/85129
More information about the llvm-commits
mailing list