summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/NVPTX/MCTargetDesc
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/NVPTX/MCTargetDesc')
-rw-r--r--llvm/lib/Target/NVPTX/MCTargetDesc/CMakeLists.txt1
-rw-r--r--llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp26
-rw-r--r--llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.h11
-rw-r--r--llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp12
-rw-r--r--llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp94
-rw-r--r--llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h46
6 files changed, 16 insertions, 174 deletions
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/CMakeLists.txt b/llvm/lib/Target/NVPTX/MCTargetDesc/CMakeLists.txt
index 9b4eadd59a3..dbbf23554aa 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/CMakeLists.txt
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/CMakeLists.txt
@@ -1,5 +1,4 @@
add_llvm_library(LLVMNVPTXDesc
NVPTXMCAsmInfo.cpp
NVPTXMCTargetDesc.cpp
- NVPTXTargetStreamer.cpp
)
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp
index f6cbd23f01c..bdd0f156c8a 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.cpp
@@ -13,9 +13,16 @@
#include "NVPTXMCAsmInfo.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/Support/CommandLine.h"
using namespace llvm;
+// -debug-compile - Command line option to inform opt and llc passes to
+// compile for debugging
+static cl::opt<bool> CompileForDebugging("debug-compile",
+ cl::desc("Compile for debugging"),
+ cl::Hidden, cl::init(false));
+
void NVPTXMCAsmInfo::anchor() {}
NVPTXMCAsmInfo::NVPTXMCAsmInfo(const Triple &TheTriple) {
@@ -30,7 +37,7 @@ NVPTXMCAsmInfo::NVPTXMCAsmInfo(const Triple &TheTriple) {
InlineAsmStart = " begin inline asm";
InlineAsmEnd = " end inline asm";
- SupportsDebugInformation = true;
+ SupportsDebugInformation = CompileForDebugging;
// PTX does not allow .align on functions.
HasFunctionAlignment = false;
HasDotTypeDotSizeDirective = false;
@@ -38,16 +45,13 @@ NVPTXMCAsmInfo::NVPTXMCAsmInfo(const Triple &TheTriple) {
HiddenDeclarationVisibilityAttr = HiddenVisibilityAttr = MCSA_Invalid;
ProtectedVisibilityAttr = MCSA_Invalid;
- // FIXME: remove comment once debug info is properly supported.
- Data8bitsDirective = "// .b8 ";
- Data16bitsDirective = nullptr; // not supported
- Data32bitsDirective = "// .b32 ";
- Data64bitsDirective = "// .b64 ";
- ZeroDirective = "// .b8";
- AsciiDirective = nullptr; // not supported
- AscizDirective = nullptr; // not supported
- SupportsQuotedNames = false;
- SupportsExtendedDwarfLocDirective = false;
+ Data8bitsDirective = " .b8 ";
+ Data16bitsDirective = " .b16 ";
+ Data32bitsDirective = " .b32 ";
+ Data64bitsDirective = " .b64 ";
+ ZeroDirective = " .b8";
+ AsciiDirective = " .b8";
+ AscizDirective = " .b8";
// @TODO: Can we just disable this?
WeakDirective = "\t// .weak\t";
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.h b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.h
index 9fd7600cf67..9ac3c8850f7 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.h
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCAsmInfo.h
@@ -25,17 +25,6 @@ class NVPTXMCAsmInfo : public MCAsmInfo {
public:
explicit NVPTXMCAsmInfo(const Triple &TheTriple);
-
- /// Return true if the .section directive should be omitted when
- /// emitting \p SectionName. For example:
- ///
- /// shouldOmitSectionDirective(".text")
- ///
- /// returns false => .section .text,#alloc,#execinstr
- /// returns true => .text
- bool shouldOmitSectionDirective(StringRef SectionName) const override {
- return true;
- }
};
} // namespace llvm
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp
index b1a77a17ec1..12f99274936 100644
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp
+++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp
@@ -11,10 +11,9 @@
//
//===----------------------------------------------------------------------===//
+#include "NVPTXMCTargetDesc.h"
#include "InstPrinter/NVPTXInstPrinter.h"
#include "NVPTXMCAsmInfo.h"
-#include "NVPTXMCTargetDesc.h"
-#include "NVPTXTargetStreamer.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
@@ -59,12 +58,6 @@ static MCInstPrinter *createNVPTXMCInstPrinter(const Triple &T,
return nullptr;
}
-static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
- formatted_raw_ostream &,
- MCInstPrinter *, bool) {
- return new NVPTXTargetStreamer(S);
-}
-
// Force static initialization.
extern "C" void LLVMInitializeNVPTXTargetMC() {
for (Target *T : {&getTheNVPTXTarget32(), &getTheNVPTXTarget64()}) {
@@ -82,8 +75,5 @@ extern "C" void LLVMInitializeNVPTXTargetMC() {
// Register the MCInstPrinter.
TargetRegistry::RegisterMCInstPrinter(*T, createNVPTXMCInstPrinter);
-
- // Register the MCTargetStreamer.
- TargetRegistry::RegisterAsmTargetStreamer(*T, createTargetAsmStreamer);
}
}
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
deleted file mode 100644
index aeb90eca3a0..00000000000
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-//=====- NVPTXTargetStreamer.cpp - NVPTXTargetStreamer class ------------=====//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements the NVPTXTargetStreamer class.
-//
-//===----------------------------------------------------------------------===//
-
-#include "NVPTXTargetStreamer.h"
-#include "llvm/MC/MCAsmInfo.h"
-#include "llvm/MC/MCContext.h"
-#include "llvm/MC/MCObjectFileInfo.h"
-
-using namespace llvm;
-
-//
-// NVPTXTargetStreamer Implemenation
-//
-NVPTXTargetStreamer::NVPTXTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
-
-NVPTXTargetStreamer::~NVPTXTargetStreamer() = default;
-
-void NVPTXTargetStreamer::emitDwarfFileDirective(StringRef Directive) {
- DwarfFiles.emplace_back(Directive);
-}
-
-static bool isDwarfSection(const MCObjectFileInfo *FI,
- const MCSection *Section) {
- // FIXME: the checks for the DWARF sections are very fragile and should be
- // fixed up in a followup patch.
- if (!Section || Section->getKind().isText() ||
- Section->getKind().isWriteable())
- return false;
- return Section == FI->getDwarfAbbrevSection() ||
- Section == FI->getDwarfInfoSection() ||
- Section == FI->getDwarfMacinfoSection() ||
- Section == FI->getDwarfFrameSection() ||
- Section == FI->getDwarfAddrSection() ||
- Section == FI->getDwarfRangesSection() ||
- Section == FI->getDwarfARangesSection() ||
- Section == FI->getDwarfLocSection() ||
- Section == FI->getDwarfStrSection() ||
- Section == FI->getDwarfLineSection() ||
- Section == FI->getDwarfStrOffSection() ||
- Section == FI->getDwarfLineStrSection() ||
- Section == FI->getDwarfPubNamesSection() ||
- Section == FI->getDwarfPubTypesSection() ||
- Section == FI->getDwarfSwiftASTSection() ||
- Section == FI->getDwarfTypesDWOSection() ||
- Section == FI->getDwarfAbbrevDWOSection() ||
- Section == FI->getDwarfAccelObjCSection() ||
- Section == FI->getDwarfAccelNamesSection() ||
- Section == FI->getDwarfAccelTypesSection() ||
- Section == FI->getDwarfAccelNamespaceSection() ||
- Section == FI->getDwarfLocDWOSection() ||
- Section == FI->getDwarfStrDWOSection() ||
- Section == FI->getDwarfCUIndexSection() ||
- Section == FI->getDwarfInfoDWOSection() ||
- Section == FI->getDwarfLineDWOSection() ||
- Section == FI->getDwarfTUIndexSection() ||
- Section == FI->getDwarfStrOffDWOSection() ||
- Section == FI->getDwarfDebugNamesSection() ||
- Section == FI->getDwarfDebugInlineSection() ||
- Section == FI->getDwarfGnuPubNamesSection() ||
- Section == FI->getDwarfGnuPubTypesSection();
-}
-
-void NVPTXTargetStreamer::changeSection(const MCSection *CurSection,
- MCSection *Section,
- const MCExpr *SubSection,
- raw_ostream &OS) {
- assert(!SubSection && "SubSection is not null!");
- const MCObjectFileInfo *FI = getStreamer().getContext().getObjectFileInfo();
- // FIXME: remove comment once debug info is properly supported.
- // Emit closing brace for DWARF sections only.
- if (isDwarfSection(FI, CurSection))
- OS << "//\t}\n";
- if (isDwarfSection(FI, Section)) {
- // Emit DWARF .file directives in the outermost scope.
- for (const std::string &S : DwarfFiles)
- getStreamer().EmitRawText(S.data());
- DwarfFiles.clear();
- OS << "//\t.section";
- Section->PrintSwitchToSection(*getStreamer().getContext().getAsmInfo(),
- FI->getTargetTriple(), OS, SubSection);
- // DWARF sections are enclosed into braces - emit the open one.
- OS << "//\t{\n";
- }
-}
diff --git a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
deleted file mode 100644
index 30831ab8bbe..00000000000
--- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXTargetStreamer.h
+++ /dev/null
@@ -1,46 +0,0 @@
-//=====-- NVPTXTargetStreamer.h - NVPTX Target Streamer ------*- 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_NVPTX_MCTARGETDESC_NVPTXTARGETSTREAMER_H
-#define LLVM_LIB_TARGET_NVPTX_MCTARGETDESC_NVPTXTARGETSTREAMER_H
-
-#include "llvm/MC/MCStreamer.h"
-
-namespace llvm {
-class MCSection;
-
-/// Implments NVPTX-specific streamer.
-class NVPTXTargetStreamer : public MCTargetStreamer {
-private:
- SmallVector<std::string, 4> DwarfFiles;
-
-public:
- NVPTXTargetStreamer(MCStreamer &S);
- ~NVPTXTargetStreamer() override;
-
- /// Record DWARF file directives for later output.
- /// According to PTX ISA, CUDA Toolkit documentation, 11.5.3. Debugging
- /// Directives: .file
- /// (http://docs.nvidia.com/cuda/parallel-thread-execution/index.html#debugging-directives-file),
- /// The .file directive is allowed only in the outermost scope, i.e., at the
- /// same level as kernel and device function declarations. Also, the order of
- /// the .loc and .file directive does not matter, .file directives may follow
- /// the .loc directives where the file is referenced.
- /// LLVM emits .file directives immediately the location debug info is
- /// emitted, i.e. they may be emitted inside functions. We gather all these
- /// directives and emit them outside of the sections and, thus, outside of the
- /// functions.
- void emitDwarfFileDirective(StringRef Directive) override;
- void changeSection(const MCSection *CurSection, MCSection *Section,
- const MCExpr *SubSection, raw_ostream &OS) override;
-};
-
-} // end namespace llvm
-
-#endif
OpenPOWER on IntegriCloud