summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp55
-rw-r--r--llvm/lib/MC/MCAsmInfoXCOFF.cpp1
-rw-r--r--llvm/lib/MC/MCContext.cpp3
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp5
-rw-r--r--llvm/lib/MC/MCSectionXCOFF.cpp16
-rw-r--r--llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp33
-rw-r--r--llvm/lib/Target/PowerPC/PPCTargetMachine.cpp5
7 files changed, 112 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 23cb1c1d305..ba2c78c3b93 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -43,6 +43,7 @@
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCSectionWasm.h"
+#include "llvm/MC/MCSectionXCOFF.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolELF.h"
@@ -1819,3 +1820,57 @@ MCSection *TargetLoweringObjectFileWasm::getStaticDtorSection(
llvm_unreachable("@llvm.global_dtors should have been lowered already");
return nullptr;
}
+
+//===----------------------------------------------------------------------===//
+// XCOFF
+//===----------------------------------------------------------------------===//
+MCSection *TargetLoweringObjectFileXCOFF::getExplicitSectionGlobal(
+ const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
+ llvm_unreachable("XCOFF explicit sections not yet implemented.");
+}
+
+MCSection *TargetLoweringObjectFileXCOFF::SelectSectionForGlobal(
+ const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
+ assert(!TM.getFunctionSections() && !TM.getDataSections() &&
+ "XCOFF unique sections not yet implemented.");
+
+ // Common symbols go into a csect with matching name which will get mapped
+ // into the .bss section.
+ if (Kind.isCommon()) {
+ SmallString<128> Name;
+ getNameWithPrefix(Name, GO, TM);
+ return getContext().getXCOFFSection(Name, XCOFF::XMC_RW, XCOFF::XTY_CM,
+ Kind, /* BeginSymbolName */ nullptr);
+ }
+
+ report_fatal_error("XCOFF other section types not yet implemented.");
+}
+
+bool TargetLoweringObjectFileXCOFF::shouldPutJumpTableInFunctionSection(
+ bool UsesLabelDifference, const Function &F) const {
+ llvm_unreachable("TLOF XCOFF not yet implemented.");
+}
+
+void TargetLoweringObjectFileXCOFF::Initialize(MCContext &Ctx,
+ const TargetMachine &TgtM) {
+ TargetLoweringObjectFile::Initialize(Ctx, TgtM);
+ TTypeEncoding = 0;
+ PersonalityEncoding = 0;
+ LSDAEncoding = 0;
+}
+
+MCSection *TargetLoweringObjectFileXCOFF::getStaticCtorSection(
+ unsigned Priority, const MCSymbol *KeySym) const {
+ llvm_unreachable("XCOFF ctor section not yet implemented.");
+}
+
+MCSection *TargetLoweringObjectFileXCOFF::getStaticDtorSection(
+ unsigned Priority, const MCSymbol *KeySym) const {
+ llvm_unreachable("XCOFF dtor section not yet implemented.");
+}
+
+const MCExpr *TargetLoweringObjectFileXCOFF::lowerRelativeReference(
+ const GlobalValue *LHS, const GlobalValue *RHS,
+ const TargetMachine &TM) const {
+ llvm_unreachable("XCOFF not yet implemented.");
+}
diff --git a/llvm/lib/MC/MCAsmInfoXCOFF.cpp b/llvm/lib/MC/MCAsmInfoXCOFF.cpp
index 74c21f0c9e6..6a9bef6adff 100644
--- a/llvm/lib/MC/MCAsmInfoXCOFF.cpp
+++ b/llvm/lib/MC/MCAsmInfoXCOFF.cpp
@@ -15,4 +15,5 @@ void MCAsmInfoXCOFF::anchor() {}
MCAsmInfoXCOFF::MCAsmInfoXCOFF() {
IsLittleEndian = false;
HasDotTypeDotSizeDirective = false;
+ COMMDirectiveAlignmentIsInBytes = false;
}
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 0dc2e2d37ca..ecd12fdc689 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -531,6 +531,7 @@ MCSectionWasm *MCContext::getWasmSection(const Twine &Section, SectionKind Kind,
MCSectionXCOFF *MCContext::getXCOFFSection(StringRef Section,
XCOFF::StorageMappingClass SMC,
+ XCOFF::SymbolType Type,
SectionKind Kind,
const char *BeginSymName) {
// Do the lookup. If we have a hit, return it.
@@ -548,7 +549,7 @@ MCSectionXCOFF *MCContext::getXCOFFSection(StringRef Section,
Begin = createTempSymbol(BeginSymName, false);
MCSectionXCOFF *Result = new (XCOFFAllocator.Allocate())
- MCSectionXCOFF(CachedName, SMC, Kind, Begin);
+ MCSectionXCOFF(CachedName, SMC, Type, Kind, Begin);
Entry.second = Result;
auto *F = new MCDataFragment();
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index 9f555abe140..6dc0e38e8e8 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -767,8 +767,9 @@ void MCObjectFileInfo::initXCOFFMCObjectFileInfo(const Triple &T) {
// get placed into this csect. The choice of csect name is not a property of
// the ABI or object file format. For example, the XL compiler uses an unnamed
// csect for program code.
- TextSection = Ctx->getXCOFFSection(
- ".text", XCOFF::StorageMappingClass::XMC_PR, SectionKind::getText());
+ TextSection =
+ Ctx->getXCOFFSection(".text", XCOFF::StorageMappingClass::XMC_PR,
+ XCOFF::XTY_SD, SectionKind::getText());
}
void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC,
diff --git a/llvm/lib/MC/MCSectionXCOFF.cpp b/llvm/lib/MC/MCSectionXCOFF.cpp
index d1a63734502..740365f0476 100644
--- a/llvm/lib/MC/MCSectionXCOFF.cpp
+++ b/llvm/lib/MC/MCSectionXCOFF.cpp
@@ -19,15 +19,29 @@ void MCSectionXCOFF::PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T,
raw_ostream &OS,
const MCExpr *Subsection) const {
if (getKind().isText()) {
+ if (getMappingClass() != XCOFF::XMC_PR)
+ llvm_unreachable("Unsupported storage-mapping class for .text csect");
+
OS << "\t.csect " << getSectionName() << "["
<< "PR"
<< "]" << '\n';
return;
}
+ if (getKind().isCommon()) {
+ if (getMappingClass() != XCOFF::XMC_RW)
+ llvm_unreachable("Unsupported storage-mapping class for common csect");
+ if (getCSectType() != XCOFF::XTY_CM)
+ llvm_unreachable("wrong csect type for common csect");
+ // Don't have to print a directive for switching to section for commons.
+ // '.comm' and '.lcomm' directives for the variable will create the needed
+ // csect.
+ return;
+ }
+
report_fatal_error("Printing for this SectionKind is unimplemented.");
}
bool MCSectionXCOFF::UseCodeAlign() const { return getKind().isText(); }
-bool MCSectionXCOFF::isVirtualSection() const { return !getKind().isCommon(); }
+bool MCSectionXCOFF::isVirtualSection() const { return XCOFF::XTY_CM == Type; }
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index bd87ce06b4f..0646ddb73cd 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -51,9 +51,11 @@
#include "llvm/MC/MCInstBuilder.h"
#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSectionMachO.h"
+#include "llvm/MC/MCSectionXCOFF.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCSymbolELF.h"
+#include "llvm/MC/MCSymbolXCOFF.h"
#include "llvm/MC/SectionKind.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/CodeGen.h"
@@ -164,6 +166,8 @@ public:
: PPCAsmPrinter(TM, std::move(Streamer)) {}
StringRef getPassName() const override { return "AIX PPC Assembly Printer"; }
+
+ void EmitGlobalVariable(const GlobalVariable *GV) override;
};
} // end anonymous namespace
@@ -1643,6 +1647,35 @@ bool PPCDarwinAsmPrinter::doFinalization(Module &M) {
return AsmPrinter::doFinalization(M);
}
+void PPCAIXAsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
+ // Early error checking limiting what is supported.
+ if (GV->isThreadLocal())
+ report_fatal_error("Thread local not yet supported on AIX.");
+
+ if (GV->hasSection())
+ report_fatal_error("Custom section for Data not yet supported.");
+
+ if (GV->hasComdat())
+ report_fatal_error("COMDAT not yet supported on AIX.");
+
+ SectionKind GVKind = getObjFileLowering().getKindForGlobal(GV, TM);
+ if (!GVKind.isCommon())
+ report_fatal_error("Only common variables are supported on AIX.");
+
+ // Create the containing csect and switch to it.
+ MCSectionXCOFF *CSect = dyn_cast<MCSectionXCOFF>(
+ getObjFileLowering().SectionForGlobal(GV, GVKind, TM));
+ OutStreamer->SwitchSection(CSect);
+
+ // Create the symbol and emit it.
+ MCSymbolXCOFF *XSym = dyn_cast<MCSymbolXCOFF>(getSymbol(GV));
+ auto DL = GV->getParent()->getDataLayout();
+ unsigned Align =
+ GV->getAlignment() ? GV->getAlignment() : DL.getPreferredAlignment(GV);
+ uint64_t Size = DL.getTypeAllocSize(GV->getType()->getElementType());
+ OutStreamer->EmitCommonSymbol(XSym, Size, Align);
+}
+
/// createPPCAsmPrinterPass - Returns a pass that prints the PPC assembly code
/// for a MachineFunction to the given output stream, in a format that the
/// Darwin assembler can deal with.
diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
index ce00f848dd7..213e2f55727 100644
--- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
+++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp
@@ -185,11 +185,12 @@ static std::string computeFSAdditions(StringRef FS, CodeGenOpt::Level OL,
}
static std::unique_ptr<TargetLoweringObjectFile> createTLOF(const Triple &TT) {
- // If it isn't a Mach-O file then it's going to be a linux ELF
- // object file.
if (TT.isOSDarwin())
return llvm::make_unique<TargetLoweringObjectFileMachO>();
+ if (TT.isOSAIX())
+ return llvm::make_unique<TargetLoweringObjectFileXCOFF>();
+
return llvm::make_unique<PPC64LinuxTargetObjectFile>();
}
OpenPOWER on IntegriCloud