1//===-- NVPTXTargetObjectFile.h - NVPTX Object Info -------------*- C++ -*-===//
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#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXTARGETOBJECTFILE_H
11#define LLVM_LIB_TARGET_NVPTX_NVPTXTARGETOBJECTFILE_H
12
13#include "NVPTXSection.h"
14#include "llvm/Target/TargetLoweringObjectFile.h"
15#include <string>
16
17namespace llvm {
18class GlobalVariable;
19class Module;
20
21class NVPTXTargetObjectFile : public TargetLoweringObjectFile {
22
23public:
24  NVPTXTargetObjectFile() {
25    TextSection = nullptr;
26    DataSection = nullptr;
27    BSSSection = nullptr;
28    ReadOnlySection = nullptr;
29
30    StaticCtorSection = nullptr;
31    StaticDtorSection = nullptr;
32    LSDASection = nullptr;
33    EHFrameSection = nullptr;
34    DwarfAbbrevSection = nullptr;
35    DwarfInfoSection = nullptr;
36    DwarfLineSection = nullptr;
37    DwarfFrameSection = nullptr;
38    DwarfPubTypesSection = nullptr;
39    DwarfDebugInlineSection = nullptr;
40    DwarfStrSection = nullptr;
41    DwarfLocSection = nullptr;
42    DwarfARangesSection = nullptr;
43    DwarfRangesSection = nullptr;
44  }
45
46  virtual ~NVPTXTargetObjectFile();
47
48  void Initialize(MCContext &ctx, const TargetMachine &TM) override {
49    TargetLoweringObjectFile::Initialize(ctx, TM);
50    TextSection = new NVPTXSection(MCSection::SV_ELF, SectionKind::getText());
51    DataSection = new NVPTXSection(MCSection::SV_ELF, SectionKind::getData());
52    BSSSection = new NVPTXSection(MCSection::SV_ELF, SectionKind::getBSS());
53    ReadOnlySection =
54        new NVPTXSection(MCSection::SV_ELF, SectionKind::getReadOnly());
55
56    StaticCtorSection =
57        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
58    StaticDtorSection =
59        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
60    LSDASection =
61        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
62    EHFrameSection =
63        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
64    DwarfAbbrevSection =
65        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
66    DwarfInfoSection =
67        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
68    DwarfLineSection =
69        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
70    DwarfFrameSection =
71        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
72    DwarfPubTypesSection =
73        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
74    DwarfDebugInlineSection =
75        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
76    DwarfStrSection =
77        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
78    DwarfLocSection =
79        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
80    DwarfARangesSection =
81        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
82    DwarfRangesSection =
83        new NVPTXSection(MCSection::SV_ELF, SectionKind::getMetadata());
84  }
85
86  MCSection *getSectionForConstant(const DataLayout &DL, SectionKind Kind,
87                                   const Constant *C) const override {
88    return ReadOnlySection;
89  }
90
91  MCSection *getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
92                                      Mangler &Mang,
93                                      const TargetMachine &TM) const override {
94    return DataSection;
95  }
96
97  MCSection *SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
98                                    Mangler &Mang,
99                                    const TargetMachine &TM) const override;
100};
101
102} // end namespace llvm
103
104#endif
105