Taints the non-acquire RMW's store address with the load part
[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/ADT/ArrayRef.h"
19 #include "llvm/IR/Module.h"
20 #include "llvm/MC/MCObjectFileInfo.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 MCValue;
33   class ConstantExpr;
34   class GlobalValue;
35   class TargetMachine;
36
37 class TargetLoweringObjectFile : public MCObjectFileInfo {
38   MCContext *Ctx;
39
40   TargetLoweringObjectFile(
41     const TargetLoweringObjectFile&) = delete;
42   void operator=(const TargetLoweringObjectFile&) = delete;
43
44 protected:
45   bool SupportIndirectSymViaGOTPCRel;
46   bool SupportGOTPCRelWithOffset;
47
48 public:
49   MCContext &getContext() const { return *Ctx; }
50
51   TargetLoweringObjectFile()
52       : MCObjectFileInfo(), Ctx(nullptr), SupportIndirectSymViaGOTPCRel(false),
53         SupportGOTPCRelWithOffset(true) {}
54
55   virtual ~TargetLoweringObjectFile();
56
57   /// This method must be called before any actual lowering is done.  This
58   /// specifies the current context for codegen, and gives the lowering
59   /// implementations a chance to set up their default sections.
60   virtual void Initialize(MCContext &ctx, const TargetMachine &TM);
61
62   virtual void emitPersonalityValue(MCStreamer &Streamer, const DataLayout &TM,
63                                     const MCSymbol *Sym) const;
64
65   /// Emit the module flags that the platform cares about.
66   virtual void emitModuleFlags(MCStreamer &Streamer,
67                                ArrayRef<Module::ModuleFlagEntry> Flags,
68                                Mangler &Mang, const TargetMachine &TM) const {}
69
70   /// Given a constant with the SectionKind, return a section that it should be
71   /// placed in.
72   virtual MCSection *getSectionForConstant(const DataLayout &DL,
73                                            SectionKind Kind,
74                                            const Constant *C) const;
75
76   /// Classify the specified global variable into a set of target independent
77   /// categories embodied in SectionKind.
78   static SectionKind getKindForGlobal(const GlobalValue *GV,
79                                       const TargetMachine &TM);
80
81   /// This method computes the appropriate section to emit the specified global
82   /// variable or function definition. This should not be passed external (or
83   /// available externally) globals.
84   MCSection *SectionForGlobal(const GlobalValue *GV, SectionKind Kind,
85                               Mangler &Mang, const TargetMachine &TM) const;
86
87   /// This method computes the appropriate section to emit the specified global
88   /// variable or function definition. This should not be passed external (or
89   /// available externally) globals.
90   MCSection *SectionForGlobal(const GlobalValue *GV, Mangler &Mang,
91                               const TargetMachine &TM) const {
92     return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
93   }
94
95   virtual void getNameWithPrefix(SmallVectorImpl<char> &OutName,
96                                  const GlobalValue *GV, Mangler &Mang,
97                                  const TargetMachine &TM) const;
98
99   virtual MCSection *getSectionForJumpTable(const Function &F, Mangler &Mang,
100                                             const TargetMachine &TM) const;
101
102   virtual bool shouldPutJumpTableInFunctionSection(bool UsesLabelDifference,
103                                                    const Function &F) const;
104
105   /// Targets should implement this method to assign a section to globals with
106   /// an explicit section specfied. The implementation of this method can
107   /// assume that GV->hasSection() is true.
108   virtual MCSection *
109   getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
110                            Mangler &Mang, const TargetMachine &TM) const = 0;
111
112   /// Allow the target to completely override section assignment of a global.
113   virtual const MCSection *getSpecialCasedSectionGlobals(const GlobalValue *GV,
114                                                          SectionKind Kind,
115                                                          Mangler &Mang) const {
116     return nullptr;
117   }
118
119   /// Return an MCExpr to use for a reference to the specified global variable
120   /// from exception handling information.
121   virtual const MCExpr *
122   getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
123                           Mangler &Mang, const TargetMachine &TM,
124                           MachineModuleInfo *MMI, MCStreamer &Streamer) const;
125
126   /// Return the MCSymbol for a private symbol with global value name as its
127   /// base, with the specified suffix.
128   MCSymbol *getSymbolWithGlobalValueBase(const GlobalValue *GV,
129                                          StringRef Suffix, Mangler &Mang,
130                                          const TargetMachine &TM) const;
131
132   // The symbol that gets passed to .cfi_personality.
133   virtual MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV,
134                                             Mangler &Mang,
135                                             const TargetMachine &TM,
136                                             MachineModuleInfo *MMI) const;
137
138   const MCExpr *
139   getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
140                     MCStreamer &Streamer) const;
141
142   virtual MCSection *getStaticCtorSection(unsigned Priority,
143                                           const MCSymbol *KeySym) const {
144     return StaticCtorSection;
145   }
146
147   virtual MCSection *getStaticDtorSection(unsigned Priority,
148                                           const MCSymbol *KeySym) const {
149     return StaticDtorSection;
150   }
151
152   /// \brief Create a symbol reference to describe the given TLS variable when
153   /// emitting the address in debug info.
154   virtual const MCExpr *getDebugThreadLocalSymbol(const MCSymbol *Sym) const;
155
156   virtual const MCExpr *
157   getExecutableRelativeSymbol(const ConstantExpr *CE, Mangler &Mang,
158                               const TargetMachine &TM) const {
159     return nullptr;
160   }
161
162   /// \brief Target supports replacing a data "PC"-relative access to a symbol
163   /// through another symbol, by accessing the later via a GOT entry instead?
164   bool supportIndirectSymViaGOTPCRel() const {
165     return SupportIndirectSymViaGOTPCRel;
166   }
167
168   /// \brief Target GOT "PC"-relative relocation supports encoding an additional
169   /// binary expression with an offset?
170   bool supportGOTPCRelWithOffset() const {
171     return SupportGOTPCRelWithOffset;
172   }
173
174   /// \brief Get the target specific PC relative GOT entry relocation
175   virtual const MCExpr *getIndirectSymViaGOTPCRel(const MCSymbol *Sym,
176                                                   const MCValue &MV,
177                                                   int64_t Offset,
178                                                   MachineModuleInfo *MMI,
179                                                   MCStreamer &Streamer) const {
180     return nullptr;
181   }
182
183   virtual void emitLinkerFlagsForGlobal(raw_ostream &OS, const GlobalValue *GV,
184                                         const Mangler &Mang) const {}
185
186 protected:
187   virtual MCSection *SelectSectionForGlobal(const GlobalValue *GV,
188                                             SectionKind Kind, Mangler &Mang,
189                                             const TargetMachine &TM) const = 0;
190 };
191
192 } // end namespace llvm
193
194 #endif