New PBQP solver, and updates to the PBQP graph.
[oota-llvm.git] / include / llvm / CodeGen / TargetLoweringObjectFileImpl.h
1 //==-- llvm/CodeGen/TargetLoweringObjectFileImpl.h - 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 // This file implements classes used to handle lowerings specific to common
11 // object file formats.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
16 #define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
17
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/MC/SectionKind.h"
20 #include "llvm/Target/TargetLoweringObjectFile.h"
21
22 namespace llvm {
23   class MachineModuleInfo;
24   class Mangler;
25   class MCAsmInfo;
26   class MCExpr;
27   class MCSection;
28   class MCSectionMachO;
29   class MCSymbol;
30   class MCContext;
31   class GlobalValue;
32   class TargetMachine;
33
34
35 class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
36   bool UseInitArray;
37
38 public:
39   virtual ~TargetLoweringObjectFileELF() {}
40
41   void emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM,
42                             const MCSymbol *Sym) const LLVM_OVERRIDE;
43
44   /// Given a constant with the SectionKind, return a section that it should be
45   /// placed in.
46   const MCSection *getSectionForConstant(SectionKind Kind) const LLVM_OVERRIDE;
47
48   const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
49                                             SectionKind Kind, Mangler &Mang,
50                                             const TargetMachine &TM) const
51       LLVM_OVERRIDE;
52
53   const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
54                                           SectionKind Kind, Mangler &Mang,
55                                           const TargetMachine &TM) const
56       LLVM_OVERRIDE;
57
58   /// Return an MCExpr to use for a reference to the specified type info global
59   /// variable from exception handling information.
60   const MCExpr *
61   getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
62                           Mangler &Mang, const TargetMachine &TM,
63                           MachineModuleInfo *MMI, MCStreamer &Streamer) const
64       LLVM_OVERRIDE;
65
66   // The symbol that gets passed to .cfi_personality.
67   MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
68                                     const TargetMachine &TM,
69                                     MachineModuleInfo *MMI) const LLVM_OVERRIDE;
70
71   void InitializeELF(bool UseInitArray_);
72   const MCSection *getStaticCtorSection(unsigned Priority = 65535) const
73       LLVM_OVERRIDE;
74   const MCSection *getStaticDtorSection(unsigned Priority = 65535) const
75       LLVM_OVERRIDE;
76 };
77
78
79
80 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
81 public:
82   virtual ~TargetLoweringObjectFileMachO() {}
83
84   /// Extract the dependent library name from a linker option string. Returns
85   /// StringRef() if the option does not specify a library.
86   StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const LLVM_OVERRIDE;
87
88   /// Emit the module flags that specify the garbage collection information.
89   void emitModuleFlags(MCStreamer &Streamer,
90                        ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
91                        Mangler &Mang, const TargetMachine &TM) const
92       LLVM_OVERRIDE;
93
94   bool isSectionAtomizableBySymbols(const MCSection &Section) const
95       LLVM_OVERRIDE;
96
97   const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
98                                           SectionKind Kind, Mangler &Mang,
99                                           const TargetMachine &TM) const
100       LLVM_OVERRIDE;
101
102   const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
103                                             SectionKind Kind, Mangler &Mang,
104                                             const TargetMachine &TM) const
105       LLVM_OVERRIDE;
106
107   const MCSection *getSectionForConstant(SectionKind Kind) const LLVM_OVERRIDE;
108
109   /// This hook allows targets to selectively decide not to emit the
110   /// UsedDirective for some symbols in llvm.used.
111   /// FIXME: REMOVE this (rdar://7071300)
112   bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler &Mang,
113                                   TargetMachine &TM) const LLVM_OVERRIDE;
114
115   /// The mach-o version of this method defaults to returning a stub reference.
116   const MCExpr *
117   getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
118                           Mangler &Mang, const TargetMachine &TM,
119                           MachineModuleInfo *MMI, MCStreamer &Streamer) const
120       LLVM_OVERRIDE;
121
122   // The symbol that gets passed to .cfi_personality.
123   MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
124                                     const TargetMachine &TM,
125                                     MachineModuleInfo *MMI) const LLVM_OVERRIDE;
126 };
127
128
129
130 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
131 public:
132   virtual ~TargetLoweringObjectFileCOFF() {}
133
134   const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
135                                             SectionKind Kind, Mangler &Mang,
136                                             const TargetMachine &TM) const
137       LLVM_OVERRIDE;
138
139   const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
140                                           SectionKind Kind, Mangler &Mang,
141                                           const TargetMachine &TM) const
142       LLVM_OVERRIDE;
143
144   /// Extract the dependent library name from a linker option string. Returns
145   /// StringRef() if the option does not specify a library.
146   StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const LLVM_OVERRIDE;
147
148   /// Emit Obj-C garbage collection and linker options. Only linker option
149   /// emission is implemented for COFF.
150   void emitModuleFlags(MCStreamer &Streamer,
151                        ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
152                        Mangler &Mang, const TargetMachine &TM) const
153       LLVM_OVERRIDE;
154 };
155
156 } // end namespace llvm
157
158 #endif