Remove useless .debug_macinfo section setup.
[oota-llvm.git] / include / llvm / MC / MCSectionMachO.h
1 //===- MCSectionMachO.h - MachO Machine Code Sections -----------*- 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 // This file declares the MCSectionMachO class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_MC_MCSECTIONMACHO_H
15 #define LLVM_MC_MCSECTIONMACHO_H
16
17 #include "llvm/ADT/StringRef.h"
18 #include "llvm/MC/MCSection.h"
19 #include "llvm/Support/MachO.h"
20
21 namespace llvm {
22
23 /// MCSectionMachO - This represents a section on a Mach-O system (used by
24 /// Mac OS X).  On a Mac system, these are also described in
25 /// /usr/include/mach-o/loader.h.
26 class MCSectionMachO : public MCSection {
27   char SegmentName[16];  // Not necessarily null terminated!
28   char SectionName[16];  // Not necessarily null terminated!
29
30   /// TypeAndAttributes - This is the SECTION_TYPE and SECTION_ATTRIBUTES
31   /// field of a section, drawn from the enums below.
32   unsigned TypeAndAttributes;
33
34   /// Reserved2 - The 'reserved2' field of a section, used to represent the
35   /// size of stubs, for example.
36   unsigned Reserved2;
37
38   MCSectionMachO(StringRef Segment, StringRef Section,
39                  unsigned TAA, unsigned reserved2, SectionKind K);
40   friend class MCContext;
41 public:
42
43   StringRef getSegmentName() const {
44     // SegmentName is not necessarily null terminated!
45     if (SegmentName[15])
46       return StringRef(SegmentName, 16);
47     return StringRef(SegmentName);
48   }
49   StringRef getSectionName() const {
50     // SectionName is not necessarily null terminated!
51     if (SectionName[15])
52       return StringRef(SectionName, 16);
53     return StringRef(SectionName);
54   }
55
56   std::string getLabelBeginName() const override {
57     return StringRef(getSegmentName().str() + getSectionName().str() + "_begin");
58   }
59
60   std::string getLabelEndName() const override {
61     return StringRef(getSegmentName().str() + getSectionName().str() + "_end");
62   }
63
64   unsigned getTypeAndAttributes() const { return TypeAndAttributes; }
65   unsigned getStubSize() const { return Reserved2; }
66
67   MachO::SectionType getType() const {
68     return static_cast<MachO::SectionType>(TypeAndAttributes &
69                                            MachO::SECTION_TYPE);
70   }
71   bool hasAttribute(unsigned Value) const {
72     return (TypeAndAttributes & Value) != 0;
73   }
74
75   /// ParseSectionSpecifier - Parse the section specifier indicated by "Spec".
76   /// This is a string that can appear after a .section directive in a mach-o
77   /// flavored .s file.  If successful, this fills in the specified Out
78   /// parameters and returns an empty string.  When an invalid section
79   /// specifier is present, this returns a string indicating the problem.
80   /// If no TAA was parsed, TAA is not altered, and TAAWasSet becomes false.
81   static std::string ParseSectionSpecifier(StringRef Spec,       // In.
82                                            StringRef &Segment,   // Out.
83                                            StringRef &Section,   // Out.
84                                            unsigned  &TAA,       // Out.
85                                            bool      &TAAParsed, // Out.
86                                            unsigned  &StubSize); // Out.
87
88   void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
89                             const MCExpr *Subsection) const override;
90   bool UseCodeAlign() const override;
91   bool isVirtualSection() const override;
92
93   static bool classof(const MCSection *S) {
94     return S->getVariant() == SV_MachO;
95   }
96 };
97
98 } // end namespace llvm
99
100 #endif