diff options
author | Xiangling Liao <Xiangling.Liao@ibm.com> | 2019-11-14 09:52:32 -0500 |
---|---|---|
committer | Xiangling Liao <Xiangling.Liao@ibm.com> | 2019-11-20 10:27:15 -0500 |
commit | ca33727abe4cd7202fe550972525bb23890da053 (patch) | |
tree | 5a9236b397280323632cafd69fc5170a4225d6cc /llvm/lib/CodeGen | |
parent | a03435ec8e219e236331780626351c74a95f1b6e (diff) | |
download | bcm5719-llvm-ca33727abe4cd7202fe550972525bb23890da053.tar.gz bcm5719-llvm-ca33727abe4cd7202fe550972525bb23890da053.zip |
[AIX] Lowering jump table, constant pool and block address in asm
This patch lowering jump table, constant pool and block address in assembly.
1. On AIX, jump table index is always relative;
2. Put CPI and JTI into ReadOnlySection until we support unique data sections;
3. Create the temp symbol for block address symbol;
4. Update MIR testcases and add related assembly part;
Differential Revision: https://reviews.llvm.org/D70243
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 15 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineModuleInfo.cpp | 13 | ||||
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 21 |
3 files changed, 45 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 8a4b4599f92..e2ef415e4d1 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1754,6 +1754,11 @@ void AsmPrinter::EmitConstantPool() { if (!Sym->isUndefined()) continue; + if (TM.getTargetTriple().isOSBinFormatXCOFF()) { + cast<MCSymbolXCOFF>(Sym)->setContainingCsect( + cast<MCSectionXCOFF>(CPSections[i].S)); + } + if (CurSection != CPSections[i].S) { OutStreamer->SwitchSection(CPSections[i].S); EmitAlignment(Align(CPSections[i].Alignment)); @@ -1843,10 +1848,16 @@ void AsmPrinter::EmitJumpTableInfo() { // second label is actually referenced by the code. if (JTInDiffSection && DL.hasLinkerPrivateGlobalPrefix()) // FIXME: This doesn't have to have any specific name, just any randomly - // named and numbered 'l' label would work. Simplify GetJTISymbol. + // named and numbered local label started with 'l' would work. Simplify + // GetJTISymbol. OutStreamer->EmitLabel(GetJTISymbol(JTI, true)); - OutStreamer->EmitLabel(GetJTISymbol(JTI)); + MCSymbol* JTISymbol = GetJTISymbol(JTI); + if (TM.getTargetTriple().isOSBinFormatXCOFF()) { + cast<MCSymbolXCOFF>(JTISymbol)->setContainingCsect( + cast<MCSectionXCOFF>(TLOF.getSectionForJumpTable(F, TM))); + } + OutStreamer->EmitLabel(JTISymbol); for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) EmitJumpTableEntry(MJTI, JTBBs[ii], JTI); diff --git a/llvm/lib/CodeGen/MachineModuleInfo.cpp b/llvm/lib/CodeGen/MachineModuleInfo.cpp index 48a72c8357e..0094a923e03 100644 --- a/llvm/lib/CodeGen/MachineModuleInfo.cpp +++ b/llvm/lib/CodeGen/MachineModuleInfo.cpp @@ -23,6 +23,7 @@ #include "llvm/InitializePasses.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCSymbol.h" +#include "llvm/MC/MCSymbolXCOFF.h" #include "llvm/Pass.h" #include "llvm/Support/Casting.h" #include "llvm/Support/ErrorHandling.h" @@ -117,7 +118,17 @@ ArrayRef<MCSymbol *> MMIAddrLabelMap::getAddrLabelSymbolToEmit(BasicBlock *BB) { BBCallbacks.back().setMap(this); Entry.Index = BBCallbacks.size() - 1; Entry.Fn = BB->getParent(); - Entry.Symbols.push_back(Context.createTempSymbol(!BB->hasAddressTaken())); + MCSymbol *Sym = Context.createTempSymbol(!BB->hasAddressTaken()); + if (Context.getObjectFileInfo()->getTargetTriple().isOSBinFormatXCOFF()) { + MCSymbol *FnEntryPointSym = + Context.lookupSymbol("." + Entry.Fn->getName()); + assert(FnEntryPointSym && "The function entry pointer symbol should have" + " already been initialized."); + MCSectionXCOFF *Csect = + cast<MCSymbolXCOFF>(FnEntryPointSym)->getContainingCsect(); + cast<MCSymbolXCOFF>(Sym)->setContainingCsect(Csect); + } + Entry.Symbols.push_back(Sym); return Entry.Symbols; } diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 2dc13e9a250..5d5f77b83ef 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1868,9 +1868,28 @@ MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal( report_fatal_error("XCOFF other section types not yet implemented."); } +MCSection *TargetLoweringObjectFileXCOFF::getSectionForJumpTable( + const Function &F, const TargetMachine &TM) const { + assert (!TM.getFunctionSections() && "Unique sections not supported on XCOFF" + " yet."); + assert (!F.getComdat() && "Comdat not supported on XCOFF."); + //TODO: Enable emiting jump table to unique sections when we support it. + return ReadOnlySection; +} + bool TargetLoweringObjectFileXCOFF::shouldPutJumpTableInFunctionSection( bool UsesLabelDifference, const Function &F) const { - report_fatal_error("TLOF XCOFF not yet implemented."); + return false; +} + +/// Given a mergeable constant with the specified size and relocation +/// information, return a section that it should be placed in. +MCSection *TargetLoweringObjectFileXCOFF::getSectionForConstant( + const DataLayout &DL, SectionKind Kind, const Constant *C, + unsigned &Align) const { + //TODO: Enable emiting constant pool to unique sections when we support it. + if (Kind.isReadOnly() && ReadOnlySection != nullptr) + return ReadOnlySection; } void TargetLoweringObjectFileXCOFF::Initialize(MCContext &Ctx, |