diff options
author | Hans de Goede <hdegoede@redhat.com> | 2016-01-20 21:36:37 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2016-06-28 11:53:21 +0200 |
commit | 0f498eab65a9e3cfb4c0f26bd3b5f20bb243eacf (patch) | |
tree | bb2f6021b204ac1190df8009f3e5b49c36bef9c1 | |
parent | 37b881a98db45bb436bd1452e7ce7b07b30d31de (diff) |
Cleanup header of the output
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | lib/Target/TGSI/MCTargetDesc/TGSIMCTargetDesc.cpp | 1 | ||||
-rw-r--r-- | lib/Target/TGSI/TGSIAsmPrinter.cpp | 6 | ||||
-rw-r--r-- | lib/Target/TGSI/TGSIISelLowering.cpp | 34 | ||||
-rw-r--r-- | lib/Target/TGSI/TGSISection.h | 44 | ||||
-rw-r--r-- | lib/Target/TGSI/TGSITargetMachine.cpp | 3 | ||||
-rw-r--r-- | lib/Target/TGSI/TGSITargetObjectFile.h | 105 |
6 files changed, 192 insertions, 1 deletions
diff --git a/lib/Target/TGSI/MCTargetDesc/TGSIMCTargetDesc.cpp b/lib/Target/TGSI/MCTargetDesc/TGSIMCTargetDesc.cpp index ecb184cc86c..65a9bd0f62f 100644 --- a/lib/Target/TGSI/MCTargetDesc/TGSIMCTargetDesc.cpp +++ b/lib/Target/TGSI/MCTargetDesc/TGSIMCTargetDesc.cpp @@ -37,6 +37,7 @@ namespace { explicit TGSIMCAsmInfo(const Triple &TT) { IsLittleEndian = true; HasDotTypeDotSizeDirective = false; + HasSingleParameterDotFile = false; } }; } diff --git a/lib/Target/TGSI/TGSIAsmPrinter.cpp b/lib/Target/TGSI/TGSIAsmPrinter.cpp index ccf0b4b30c0..2d41b6a97e3 100644 --- a/lib/Target/TGSI/TGSIAsmPrinter.cpp +++ b/lib/Target/TGSI/TGSIAsmPrinter.cpp @@ -48,6 +48,7 @@ namespace { } virtual void EmitInstruction(const MachineInstr *mi); + virtual void EmitFunctionHeader() override; virtual void EmitFunctionBodyStart(); virtual void EmitFunctionBodyEnd(); virtual void EmitConstantPool() override; @@ -143,6 +144,11 @@ void TGSIAsmPrinter::EmitInstruction(const MachineInstr *mi) { OutStreamer->EmitInstruction(mci, getSubtargetInfo()); } +void TGSIAsmPrinter::EmitFunctionHeader() { + EmitConstantPool(); + OutStreamer->AddBlankLine(); +} + void TGSIAsmPrinter::EmitFunctionBodyStart() { MCInst mci; diff --git a/lib/Target/TGSI/TGSIISelLowering.cpp b/lib/Target/TGSI/TGSIISelLowering.cpp index 0311581c3a5..4f56a682188 100644 --- a/lib/Target/TGSI/TGSIISelLowering.cpp +++ b/lib/Target/TGSI/TGSIISelLowering.cpp @@ -14,6 +14,7 @@ #include "TGSIISelLowering.h" #include "TGSITargetMachine.h" +#include "TGSITargetObjectFile.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Function.h" #include "llvm/IR/Module.h" @@ -252,3 +253,36 @@ LowerOperation(SDValue op, SelectionDAG &dag) const { llvm_unreachable("Should not custom lower this!"); }; } + + +// Pin TGSISection's and TGSITargetObjectFile's vtables to this file. +void TGSISection::anchor() {} + +TGSITargetObjectFile::~TGSITargetObjectFile() { + delete static_cast<TGSISection *>(TextSection); + delete static_cast<TGSISection *>(DataSection); + delete static_cast<TGSISection *>(BSSSection); + delete static_cast<TGSISection *>(ReadOnlySection); + + delete static_cast<TGSISection *>(StaticCtorSection); + delete static_cast<TGSISection *>(StaticDtorSection); + delete static_cast<TGSISection *>(LSDASection); + delete static_cast<TGSISection *>(EHFrameSection); + delete static_cast<TGSISection *>(DwarfAbbrevSection); + delete static_cast<TGSISection *>(DwarfInfoSection); + delete static_cast<TGSISection *>(DwarfLineSection); + delete static_cast<TGSISection *>(DwarfFrameSection); + delete static_cast<TGSISection *>(DwarfPubTypesSection); + delete static_cast<const TGSISection *>(DwarfDebugInlineSection); + delete static_cast<TGSISection *>(DwarfStrSection); + delete static_cast<TGSISection *>(DwarfLocSection); + delete static_cast<TGSISection *>(DwarfARangesSection); + delete static_cast<TGSISection *>(DwarfRangesSection); +} + +MCSection * +TGSITargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV, + SectionKind Kind, Mangler &Mang, + const TargetMachine &TM) const { + return getDataSection(); +} diff --git a/lib/Target/TGSI/TGSISection.h b/lib/Target/TGSI/TGSISection.h new file mode 100644 index 00000000000..6531b9cad4f --- /dev/null +++ b/lib/Target/TGSI/TGSISection.h @@ -0,0 +1,44 @@ +//===- TGSISection.h - TGSI-specific section representation -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the TGSISection class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_TARGET_TGSI_TGSISECTION_H +#define LLVM_LIB_TARGET_TGSI_TGSISECTION_H + +#include "llvm/IR/GlobalVariable.h" +#include "llvm/MC/MCSection.h" +#include <vector> + +namespace llvm { +/// Represents a section in PTX PTX does not have sections. We create this class +/// in order to use the ASMPrint interface. +/// +class TGSISection final : public MCSection { + virtual void anchor(); +public: + TGSISection(SectionVariant V, SectionKind K) : MCSection(V, K, nullptr) {} + ~TGSISection() {} + + /// Override this as TGSI has its own way of printing switching + /// to a section. + void PrintSwitchToSection(const MCAsmInfo &MAI, + raw_ostream &OS, + const MCExpr *Subsection) const override {} + + /// Base address of PTX sections is zero. + bool UseCodeAlign() const override { return false; } + bool isVirtualSection() const override { return false; } +}; + +} // end namespace llvm + +#endif diff --git a/lib/Target/TGSI/TGSITargetMachine.cpp b/lib/Target/TGSI/TGSITargetMachine.cpp index 80fde34d1ed..e25ad14412f 100644 --- a/lib/Target/TGSI/TGSITargetMachine.cpp +++ b/lib/Target/TGSI/TGSITargetMachine.cpp @@ -13,6 +13,7 @@ #include "TGSI.h" #include "TGSITargetMachine.h" +#include "TGSITargetObjectFile.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" #include "llvm/CodeGen/TargetPassConfig.h" @@ -60,7 +61,7 @@ TGSITargetMachine::TGSITargetMachine(const Target &T, const Triple &TT, // So we always use Reloc::Static : LLVMTargetMachine(T, computeDataLayout(TT, CPU, Options), TT, CPU, FS, Options, Reloc::Static, CM, OL), - TLOF(make_unique<TargetLoweringObjectFileELF>()), + TLOF(make_unique<TGSITargetObjectFile>()), Subtarget(TT, CPU, FS, *this) { initAsmInfo(); } diff --git a/lib/Target/TGSI/TGSITargetObjectFile.h b/lib/Target/TGSI/TGSITargetObjectFile.h new file mode 100644 index 00000000000..8b2904292d0 --- /dev/null +++ b/lib/Target/TGSI/TGSITargetObjectFile.h @@ -0,0 +1,105 @@ +//===-- TGSITargetObjectFile.h - TGSI Object Info -------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_TARGET_TGSI_TGSITARGETOBJECTFILE_H +#define LLVM_LIB_TARGET_TGSI_TGSITARGETOBJECTFILE_H + +#include "TGSISection.h" +#include "llvm/Target/TargetLoweringObjectFile.h" +#include <string> + +namespace llvm { +class GlobalVariable; +class Module; + +class TGSITargetObjectFile : public TargetLoweringObjectFile { + +public: + TGSITargetObjectFile() { + TextSection = nullptr; + DataSection = nullptr; + BSSSection = nullptr; + ReadOnlySection = nullptr; + + StaticCtorSection = nullptr; + StaticDtorSection = nullptr; + LSDASection = nullptr; + EHFrameSection = nullptr; + DwarfAbbrevSection = nullptr; + DwarfInfoSection = nullptr; + DwarfLineSection = nullptr; + DwarfFrameSection = nullptr; + DwarfPubTypesSection = nullptr; + DwarfDebugInlineSection = nullptr; + DwarfStrSection = nullptr; + DwarfLocSection = nullptr; + DwarfARangesSection = nullptr; + DwarfRangesSection = nullptr; + } + + virtual ~TGSITargetObjectFile(); + + void Initialize(MCContext &ctx, const TargetMachine &TM) override { + TargetLoweringObjectFile::Initialize(ctx, TM); + TextSection = new TGSISection(MCSection::SV_ELF, SectionKind::getText()); + DataSection = new TGSISection(MCSection::SV_ELF, SectionKind::getData()); + BSSSection = new TGSISection(MCSection::SV_ELF, SectionKind::getBSS()); + ReadOnlySection = + new TGSISection(MCSection::SV_ELF, SectionKind::getReadOnly()); + + StaticCtorSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + StaticDtorSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + LSDASection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + EHFrameSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + DwarfAbbrevSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + DwarfInfoSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + DwarfLineSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + DwarfFrameSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + DwarfPubTypesSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + DwarfDebugInlineSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + DwarfStrSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + DwarfLocSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + DwarfARangesSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + DwarfRangesSection = + new TGSISection(MCSection::SV_ELF, SectionKind::getMetadata()); + } + + MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind, + const Constant *C, + unsigned &Align) const override { + return ReadOnlySection; + } + + MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler &Mang, + const TargetMachine &TM) const override { + return DataSection; + } + + MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, + Mangler &Mang, + const TargetMachine &TM) const override; +}; + +} // end namespace llvm + +#endif |