LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TargetLoweringObjectFile.h
Go to the documentation of this file.
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/ADT/ArrayRef.h"
19 #include "llvm/IR/Module.h"
21 #include "llvm/MC/SectionKind.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 MCSymbolRefExpr;
31  class MCStreamer;
32  class GlobalValue;
33  class TargetMachine;
34 
36  MCContext *Ctx;
37 
40  void operator=(const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION;
41 
42 public:
43  MCContext &getContext() const { return *Ctx; }
44 
46 
47  virtual ~TargetLoweringObjectFile();
48 
49  /// Initialize - this method must be called before any actual lowering is
50  /// done. This specifies the current context for codegen, and gives the
51  /// lowering implementations a chance to set up their default sections.
52  virtual void Initialize(MCContext &ctx, const TargetMachine &TM);
53 
54  virtual void emitPersonalityValue(MCStreamer &Streamer,
55  const TargetMachine &TM,
56  const MCSymbol *Sym) const;
57 
58  /// emitModuleFlags - Emit the module flags that the platform cares about.
59  virtual void emitModuleFlags(MCStreamer &,
61  Mangler *, const TargetMachine &) const {
62  }
63 
64  /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
65  /// decide not to emit the UsedDirective for some symbols in llvm.used.
66  /// FIXME: REMOVE this (rdar://7071300)
67  virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
68  Mangler *) const {
69  return GV != 0;
70  }
71 
72  /// getSectionForConstant - Given a constant with the SectionKind, return a
73  /// section that it should be placed in.
74  virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
75 
76  /// getKindForGlobal - Classify the specified global variable into a set of
77  /// target independent categories embodied in SectionKind.
78  static SectionKind getKindForGlobal(const GlobalValue *GV,
79  const TargetMachine &TM);
80 
81  /// SectionForGlobal - This method computes the appropriate section to emit
82  /// the specified global variable or function definition. This should not
83  /// be passed external (or available externally) globals.
84  const MCSection *SectionForGlobal(const GlobalValue *GV,
85  SectionKind Kind, Mangler *Mang,
86  const TargetMachine &TM) const;
87 
88  /// SectionForGlobal - This method computes the appropriate section to emit
89  /// the specified global variable or function definition. This should not
90  /// be passed external (or available externally) globals.
92  Mangler *Mang,
93  const TargetMachine &TM) const {
94  return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
95  }
96 
97  /// getExplicitSectionGlobal - Targets should implement this method to assign
98  /// a section to globals with an explicit section specfied. The
99  /// implementation of this method can assume that GV->hasSection() is true.
100  virtual const MCSection *
102  Mangler *Mang, const TargetMachine &TM) const = 0;
103 
104  /// getSpecialCasedSectionGlobals - Allow the target to completely override
105  /// section assignment of a global.
106  virtual const MCSection *
108  SectionKind Kind) const {
109  return 0;
110  }
111 
112  /// getTTypeGlobalReference - Return an MCExpr to use for a reference
113  /// to the specified global variable from exception handling information.
114  ///
115  virtual const MCExpr *
117  MachineModuleInfo *MMI, unsigned Encoding,
118  MCStreamer &Streamer) const;
119 
120  /// Return the MCSymbol for the specified global value. This symbol is the
121  /// main label that is the address of the global
122  MCSymbol *getSymbol(Mangler &M, const GlobalValue *GV) const;
123 
124  // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
125  virtual MCSymbol *
127  MachineModuleInfo *MMI) const;
128 
129  ///
130  const MCExpr *
131  getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
132  MCStreamer &Streamer) const;
133 
134  virtual const MCSection *
135  getStaticCtorSection(unsigned Priority = 65535) const {
136  (void)Priority;
137  return StaticCtorSection;
138  }
139  virtual const MCSection *
140  getStaticDtorSection(unsigned Priority = 65535) const {
141  (void)Priority;
142  return StaticDtorSection;
143  }
144 
145  /// \brief Create a symbol reference to describe the given TLS variable when
146  /// emitting the address in debug info.
147  virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
148 
149 protected:
150  virtual const MCSection *
152  Mangler *Mang, const TargetMachine &TM) const;
153 };
154 
155 } // end namespace llvm
156 
157 #endif
static SectionKind getKindForGlobal(const GlobalValue *GV, const TargetMachine &TM)
virtual void emitModuleFlags(MCStreamer &, ArrayRef< Module::ModuleFlagEntry >, Mangler *, const TargetMachine &) const
emitModuleFlags - Emit the module flags that the platform cares about.
virtual const MCSection * SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const
const MCSection * SectionForGlobal(const GlobalValue *GV, Mangler *Mang, const TargetMachine &TM) const
const MCSection * StaticDtorSection
virtual const MCSection * getSectionForConstant(SectionKind Kind) const
virtual void Initialize(MCContext &ctx, const TargetMachine &TM)
const MCExpr * getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding, MCStreamer &Streamer) const
virtual const MCExpr * getDebugThreadLocalSymbol(const MCSymbol *Sym) const
Create a symbol reference to describe the given TLS variable when emitting the address in debug info...
const MCSection * SectionForGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const
virtual const MCSection * getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind, Mangler *Mang, const TargetMachine &TM) const =0
virtual const MCSection * getStaticDtorSection(unsigned Priority=65535) const
virtual void emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM, const MCSymbol *Sym) const
#define LLVM_DELETED_FUNCTION
Definition: Compiler.h:137
virtual const MCExpr * getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI, unsigned Encoding, MCStreamer &Streamer) const
const MCSection * StaticCtorSection
virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV, Mangler *) const
virtual const MCSection * getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang, SectionKind Kind) const
virtual MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, MachineModuleInfo *MMI) const
virtual const MCSection * getStaticCtorSection(unsigned Priority=65535) const
MCSymbol * getSymbol(Mangler &M, const GlobalValue *GV) const