diff options
author | Chen Zheng <czhengsz@cn.ibm.com> | 2024-05-24 11:09:37 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-24 11:09:37 +0800 |
commit | cd9bab2e2acbdc22943703d5649dede72b09cad7 (patch) | |
tree | 140ebfa4fd9fc6b2cbddfe2f498d7a2ff92164b3 /llvm/lib/Target/PowerPC | |
parent | f9e9e599c0138b2403bc89934ddace0c2a8d84d6 (diff) | |
download | llvm-cd9bab2e2acbdc22943703d5649dede72b09cad7.zip llvm-cd9bab2e2acbdc22943703d5649dede72b09cad7.tar.gz llvm-cd9bab2e2acbdc22943703d5649dede72b09cad7.tar.bz2 |
[PowerPC] handle toc-data in load selection of fast-isel (#91916)
Support the address selection for toc-data globals in fast isel. This
benefits instruction selection for fast-isel for toc data symbol for
example for load selection. This also aligns the code generation
with/without -mtocdata.
Diffstat (limited to 'llvm/lib/Target/PowerPC')
-rw-r--r-- | llvm/lib/Target/PowerPC/PPCFastISel.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCFastISel.cpp b/llvm/lib/Target/PowerPC/PPCFastISel.cpp index 6e31cda..7350506 100644 --- a/llvm/lib/Target/PowerPC/PPCFastISel.cpp +++ b/llvm/lib/Target/PowerPC/PPCFastISel.cpp @@ -2074,16 +2074,15 @@ unsigned PPCFastISel::PPCMaterializeGV(const GlobalValue *GV, MVT VT) { if (GV->isThreadLocal()) return 0; - // If the global has the toc-data attribute then fallback to DAG-ISEL. - if (TM.getTargetTriple().isOSAIX()) - if (const GlobalVariable *Var = dyn_cast_or_null<GlobalVariable>(GV)) - if (Var->hasAttribute("toc-data")) - return false; - PPCFuncInfo->setUsesTOCBasePtr(); + bool IsAIXTocData = TM.getTargetTriple().isOSAIX() && + isa<GlobalVariable>(GV) && + cast<GlobalVariable>(GV)->hasAttribute("toc-data"); + // For small code model, generate a simple TOC load. if (CModel == CodeModel::Small) - BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, TII.get(PPC::LDtoc), + BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, + IsAIXTocData ? TII.get(PPC::ADDItoc8) : TII.get(PPC::LDtoc), DestReg) .addGlobalAddress(GV) .addReg(PPC::X2); @@ -2101,6 +2100,7 @@ unsigned PPCFastISel::PPCMaterializeGV(const GlobalValue *GV, MVT VT) { HighPartReg).addReg(PPC::X2).addGlobalAddress(GV); if (Subtarget->isGVIndirectSymbol(GV)) { + assert(!IsAIXTocData && "TOC data should always be direct."); BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, TII.get(PPC::LDtocL), DestReg).addGlobalAddress(GV).addReg(HighPartReg); } else { |