Prune some includes and forward declarations.
[oota-llvm.git] / include / llvm / Target / TargetLoweringObjectFile.h
1 //===-- llvm/Target/TargetLoweringObjectFile.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_TARGET_TARGETLOWERINGOBJECTFILE_H
16 #define LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H
17
18 #include "llvm/Module.h"
19 #include "llvm/MC/MCObjectFileInfo.h"
20 #include "llvm/MC/SectionKind.h"
21 #include "llvm/ADT/ArrayRef.h"
22
23 namespace llvm {
24   class MachineModuleInfo;
25   class Mangler;
26   class MCContext;
27   class MCExpr;
28   class MCSection;
29   class MCSymbol;
30   class MCStreamer;
31   class GlobalValue;
32   class TargetMachine;
33   
34 class TargetLoweringObjectFile : public MCObjectFileInfo {
35   MCContext *Ctx;
36   
37   TargetLoweringObjectFile(const TargetLoweringObjectFile&); // DO NOT IMPLEMENT
38   void operator=(const TargetLoweringObjectFile&);           // DO NOT IMPLEMENT
39   
40 public:
41   MCContext &getContext() const { return *Ctx; }
42
43   TargetLoweringObjectFile() : MCObjectFileInfo(), Ctx(0) {}
44   
45   virtual ~TargetLoweringObjectFile();
46   
47   /// Initialize - this method must be called before any actual lowering is
48   /// done.  This specifies the current context for codegen, and gives the
49   /// lowering implementations a chance to set up their default sections.
50   virtual void Initialize(MCContext &ctx, const TargetMachine &TM);
51   
52   virtual void emitPersonalityValue(MCStreamer &Streamer,
53                                     const TargetMachine &TM,
54                                     const MCSymbol *Sym) const;
55
56   /// emitModuleFlags - Emit the module flags that the platform cares about.
57   virtual void emitModuleFlags(MCStreamer &,
58                                ArrayRef<Module::ModuleFlagEntry>,
59                                Mangler *, const TargetMachine &) const {
60   }
61
62   /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
63   /// decide not to emit the UsedDirective for some symbols in llvm.used.
64   /// FIXME: REMOVE this (rdar://7071300)
65   virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
66                                           Mangler *) const {
67     return GV != 0;
68   }
69   
70   /// getSectionForConstant - Given a constant with the SectionKind, return a
71   /// section that it should be placed in.
72   virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
73   
74   /// getKindForGlobal - Classify the specified global variable into a set of
75   /// target independent categories embodied in SectionKind.
76   static SectionKind getKindForGlobal(const GlobalValue *GV,
77                                       const TargetMachine &TM);
78   
79   /// SectionForGlobal - This method computes the appropriate section to emit
80   /// the specified global variable or function definition.  This should not
81   /// be passed external (or available externally) globals.
82   const MCSection *SectionForGlobal(const GlobalValue *GV,
83                                     SectionKind Kind, Mangler *Mang,
84                                     const TargetMachine &TM) const;
85   
86   /// SectionForGlobal - This method computes the appropriate section to emit
87   /// the specified global variable or function definition.  This should not
88   /// be passed external (or available externally) globals.
89   const MCSection *SectionForGlobal(const GlobalValue *GV,
90                                     Mangler *Mang,
91                                     const TargetMachine &TM) const {
92     return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
93   }
94
95   /// getExplicitSectionGlobal - Targets should implement this method to assign
96   /// a section to globals with an explicit section specfied.  The
97   /// implementation of this method can assume that GV->hasSection() is true.
98   virtual const MCSection *
99   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, 
100                            Mangler *Mang, const TargetMachine &TM) const = 0;
101   
102   /// getSpecialCasedSectionGlobals - Allow the target to completely override
103   /// section assignment of a global.
104   virtual const MCSection *
105   getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
106                                 SectionKind Kind) const {
107     return 0;
108   }
109   
110   /// getExprForDwarfGlobalReference - Return an MCExpr to use for a reference
111   /// to the specified global variable from exception handling information.
112   ///
113   virtual const MCExpr *
114   getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
115                                  MachineModuleInfo *MMI, unsigned Encoding,
116                                  MCStreamer &Streamer) const;
117
118   // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
119   virtual MCSymbol *
120   getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
121                           MachineModuleInfo *MMI) const;
122
123   /// 
124   const MCExpr *
125   getExprForDwarfReference(const MCSymbol *Sym, unsigned Encoding,
126                            MCStreamer &Streamer) const;
127
128   virtual const MCSection *
129   getStaticCtorSection(unsigned Priority = 65535) const {
130     (void)Priority;
131     return StaticCtorSection;
132   }
133   virtual const MCSection *
134   getStaticDtorSection(unsigned Priority = 65535) const {
135     (void)Priority;
136     return StaticDtorSection;
137   }
138
139 protected:
140   virtual const MCSection *
141   SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
142                          Mangler *Mang, const TargetMachine &TM) const;
143 };
144
145 } // end namespace llvm
146
147 #endif