1 //=====- NVPTXTargetStreamer.cpp - NVPTXTargetStreamer class ------------=====//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the NVPTXTargetStreamer class.
12 //===----------------------------------------------------------------------===//
14 #include "NVPTXTargetStreamer.h"
15 #include "llvm/MC/MCAsmInfo.h"
16 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCObjectFileInfo.h"
22 // NVPTXTargetStreamer Implemenation
24 NVPTXTargetStreamer::NVPTXTargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {}
26 NVPTXTargetStreamer::~NVPTXTargetStreamer() = default;
28 void NVPTXTargetStreamer::emitDwarfFileDirective(StringRef Directive) {
29 DwarfFiles.emplace_back(Directive);
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())
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();
73 void NVPTXTargetStreamer::changeSection(const MCSection *CurSection,
75 const MCExpr *SubSection,
77 assert(!SubSection && "SubSection is not null!");
78 const MCObjectFileInfo *FI = getStreamer().getContext().getObjectFileInfo();
79 // FIXME: remove comment once debug info is properly supported.
80 // Emit closing brace for DWARF sections only.
81 if (isDwarfSection(FI, CurSection))
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());
89 Section->PrintSwitchToSection(*getStreamer().getContext().getAsmInfo(),
90 FI->getTargetTriple(), OS, SubSection);
91 // DWARF sections are enclosed into braces - emit the open one.