LLVM  7.0.0
NVPTXTargetStreamer.cpp
Go to the documentation of this file.
1 //=====- NVPTXTargetStreamer.cpp - NVPTXTargetStreamer class ------------=====//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the NVPTXTargetStreamer class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "NVPTXTargetStreamer.h"
15 #include "llvm/MC/MCAsmInfo.h"
16 #include "llvm/MC/MCContext.h"
18 
19 using namespace llvm;
20 
21 //
22 // NVPTXTargetStreamer Implemenation
23 //
25 
27 
29  DwarfFiles.emplace_back(Directive);
30 }
31 
32 static bool isDwarfSection(const MCObjectFileInfo *FI,
33  const MCSection *Section) {
34  // FIXME: the checks for the DWARF sections are very fragile and should be
35  // fixed up in a followup patch.
36  if (!Section || Section->getKind().isText() ||
37  Section->getKind().isWriteable())
38  return false;
39  return Section == FI->getDwarfAbbrevSection() ||
40  Section == FI->getDwarfInfoSection() ||
41  Section == FI->getDwarfMacinfoSection() ||
42  Section == FI->getDwarfFrameSection() ||
43  Section == FI->getDwarfAddrSection() ||
44  Section == FI->getDwarfRangesSection() ||
45  Section == FI->getDwarfARangesSection() ||
46  Section == FI->getDwarfLocSection() ||
47  Section == FI->getDwarfStrSection() ||
48  Section == FI->getDwarfLineSection() ||
49  Section == FI->getDwarfStrOffSection() ||
50  Section == FI->getDwarfLineStrSection() ||
51  Section == FI->getDwarfPubNamesSection() ||
52  Section == FI->getDwarfPubTypesSection() ||
53  Section == FI->getDwarfSwiftASTSection() ||
54  Section == FI->getDwarfTypesDWOSection() ||
55  Section == FI->getDwarfAbbrevDWOSection() ||
56  Section == FI->getDwarfAccelObjCSection() ||
57  Section == FI->getDwarfAccelNamesSection() ||
58  Section == FI->getDwarfAccelTypesSection() ||
59  Section == FI->getDwarfAccelNamespaceSection() ||
60  Section == FI->getDwarfLocDWOSection() ||
61  Section == FI->getDwarfStrDWOSection() ||
62  Section == FI->getDwarfCUIndexSection() ||
63  Section == FI->getDwarfInfoDWOSection() ||
64  Section == FI->getDwarfLineDWOSection() ||
65  Section == FI->getDwarfTUIndexSection() ||
66  Section == FI->getDwarfStrOffDWOSection() ||
67  Section == FI->getDwarfDebugNamesSection() ||
68  Section == FI->getDwarfDebugInlineSection() ||
69  Section == FI->getDwarfGnuPubNamesSection() ||
70  Section == FI->getDwarfGnuPubTypesSection();
71 }
72 
75  const MCExpr *SubSection,
76  raw_ostream &OS) {
77  assert(!SubSection && "SubSection is not null!");
79  // FIXME: remove comment once debug info is properly supported.
80  // Emit closing brace for DWARF sections only.
81  if (isDwarfSection(FI, CurSection))
82  OS << "//\t}\n";
83  if (isDwarfSection(FI, Section)) {
84  // Emit DWARF .file directives in the outermost scope.
85  for (const std::string &S : DwarfFiles)
86  getStreamer().EmitRawText(S.data());
87  DwarfFiles.clear();
88  OS << "//\t.section";
89  Section->PrintSwitchToSection(*getStreamer().getContext().getAsmInfo(),
90  FI->getTargetTriple(), OS, SubSection);
91  // DWARF sections are enclosed into braces - emit the open one.
92  OS << "//\t{\n";
93  }
94 }
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:39
MCSection * getDwarfStrOffSection() const
SectionKind getKind() const
Definition: MCSection.h:102
MCSection * getDwarfTUIndexSection() const
MCSection * getDwarfAccelObjCSection() const
MCSection * getDwarfCUIndexSection() const
void EmitRawText(const Twine &String)
If this file is backed by a assembly streamer, this dumps the specified string in the output ...
Definition: MCStreamer.cpp:844
MCSection * getDwarfStrSection() const
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
MCSection * getDwarfLineSection() const
bool isWriteable() const
Definition: SectionKind.h:145
MCSection * getDwarfLocSection() const
Target specific streamer interface.
Definition: MCStreamer.h:83
MCSection * getDwarfAccelNamesSection() const
MCSection * getDwarfLineStrSection() const
MCSection * getDwarfARangesSection() const
MCSection * getDwarfPubNamesSection() const
MCContext & getContext() const
Definition: MCStreamer.h:250
MCSection * getDwarfMacinfoSection() const
MCSection * getDwarfLocDWOSection() const
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:36
MCSection * getDwarfFrameSection() const
bool isText() const
Definition: SectionKind.h:119
const MCSection * getDwarfDebugInlineSection() const
MCSection * getDwarfAccelTypesSection() const
MCSection * getDwarfAbbrevSection() const
MCSection * getDwarfAbbrevDWOSection() const
MCSection * getDwarfGnuPubTypesSection() const
MCSection * getDwarfTypesDWOSection() const
Streaming machine code generation interface.
Definition: MCStreamer.h:183
MCSection * getDwarfAddrSection() const
MCSection * getDwarfLineDWOSection() const
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:297
MCSection * getDwarfSwiftASTSection() const
virtual void PrintSwitchToSection(const MCAsmInfo &MAI, const Triple &T, raw_ostream &OS, const MCExpr *Subsection) const =0
void changeSection(const MCSection *CurSection, MCSection *Section, const MCExpr *SubSection, raw_ostream &OS) override
Update streamer for a new active section.
MCStreamer & getStreamer()
Definition: MCStreamer.h:91
const Triple & getTargetTriple() const
static bool isDwarfSection(const MCObjectFileInfo *FI, const MCSection *Section)
MCSection * getDwarfInfoSection() const
MCSection * getDwarfDebugNamesSection() const
MCSection * getDwarfStrOffDWOSection() const
void emitDwarfFileDirective(StringRef Directive) override
Record DWARF file directives for later output.
MCSection * getDwarfPubTypesSection() const
MCSection * getDwarfStrDWOSection() const
void emplace_back(ArgTypes &&... Args)
Definition: SmallVector.h:652
MCSection * getDwarfGnuPubNamesSection() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MCSection * getDwarfAccelNamespaceSection() const
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:46
MCSection * getDwarfInfoDWOSection() const
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
MCSection * getDwarfRangesSection() const