LLVM API Documentation

TargetLoweringObjectFileImpl.h
Go to the documentation of this file.
00001 //==-- llvm/CodeGen/TargetLoweringObjectFileImpl.h - Object Info -*- C++ -*-==//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements classes used to handle lowerings specific to common
00011 // object file formats.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
00016 #define LLVM_CODEGEN_TARGETLOWERINGOBJECTFILEIMPL_H
00017 
00018 #include "llvm/ADT/StringRef.h"
00019 #include "llvm/MC/SectionKind.h"
00020 #include "llvm/Target/TargetLoweringObjectFile.h"
00021 
00022 namespace llvm {
00023   class MachineModuleInfo;
00024   class Mangler;
00025   class MCAsmInfo;
00026   class MCExpr;
00027   class MCSection;
00028   class MCSectionMachO;
00029   class MCSymbol;
00030   class MCContext;
00031   class GlobalValue;
00032   class TargetMachine;
00033 
00034 
00035 class TargetLoweringObjectFileELF : public TargetLoweringObjectFile {
00036   bool UseInitArray;
00037 
00038 public:
00039   virtual ~TargetLoweringObjectFileELF() {}
00040 
00041   void emitPersonalityValue(MCStreamer &Streamer, const TargetMachine &TM,
00042                             const MCSymbol *Sym) const override;
00043 
00044   /// Given a constant with the SectionKind, return a section that it should be
00045   /// placed in.
00046   const MCSection *getSectionForConstant(SectionKind Kind,
00047                                          const Constant *C) const override;
00048 
00049   const MCSection *getExplicitSectionGlobal(const GlobalValue *GV,
00050                                         SectionKind Kind, Mangler &Mang,
00051                                         const TargetMachine &TM) const override;
00052 
00053   const MCSection *SelectSectionForGlobal(const GlobalValue *GV,
00054                                         SectionKind Kind, Mangler &Mang,
00055                                         const TargetMachine &TM) const override;
00056 
00057   /// Return an MCExpr to use for a reference to the specified type info global
00058   /// variable from exception handling information.
00059   const MCExpr *
00060   getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
00061                           Mangler &Mang, const TargetMachine &TM,
00062                           MachineModuleInfo *MMI,
00063                           MCStreamer &Streamer) const override;
00064 
00065   // The symbol that gets passed to .cfi_personality.
00066   MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
00067                                     const TargetMachine &TM,
00068                                     MachineModuleInfo *MMI) const override;
00069 
00070   void InitializeELF(bool UseInitArray_);
00071   const MCSection *getStaticCtorSection(unsigned Priority,
00072                                         const MCSymbol *KeySym) const override;
00073   const MCSection *getStaticDtorSection(unsigned Priority,
00074                                         const MCSymbol *KeySym) const override;
00075 };
00076 
00077 
00078 
00079 class TargetLoweringObjectFileMachO : public TargetLoweringObjectFile {
00080 public:
00081   virtual ~TargetLoweringObjectFileMachO() {}
00082 
00083   /// Extract the dependent library name from a linker option string. Returns
00084   /// StringRef() if the option does not specify a library.
00085   StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const override;
00086 
00087   /// Emit the module flags that specify the garbage collection information.
00088   void emitModuleFlags(MCStreamer &Streamer,
00089                        ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
00090                        Mangler &Mang, const TargetMachine &TM) const override;
00091 
00092   bool isSectionAtomizableBySymbols(const MCSection &Section) const override;
00093 
00094   const MCSection *
00095     SelectSectionForGlobal(const GlobalValue *GV,
00096                            SectionKind Kind, Mangler &Mang,
00097                            const TargetMachine &TM) const override;
00098 
00099   const MCSection *
00100     getExplicitSectionGlobal(const GlobalValue *GV,
00101                              SectionKind Kind, Mangler &Mang,
00102                              const TargetMachine &TM) const override;
00103 
00104   const MCSection *getSectionForConstant(SectionKind Kind,
00105                                          const Constant *C) const override;
00106 
00107   /// The mach-o version of this method defaults to returning a stub reference.
00108   const MCExpr *
00109   getTTypeGlobalReference(const GlobalValue *GV, unsigned Encoding,
00110                           Mangler &Mang, const TargetMachine &TM,
00111                           MachineModuleInfo *MMI,
00112                           MCStreamer &Streamer) const override;
00113 
00114   // The symbol that gets passed to .cfi_personality.
00115   MCSymbol *getCFIPersonalitySymbol(const GlobalValue *GV, Mangler &Mang,
00116                                     const TargetMachine &TM,
00117                                     MachineModuleInfo *MMI) const override;
00118 };
00119 
00120 
00121 
00122 class TargetLoweringObjectFileCOFF : public TargetLoweringObjectFile {
00123 public:
00124   virtual ~TargetLoweringObjectFileCOFF() {}
00125 
00126   const MCSection *
00127     getExplicitSectionGlobal(const GlobalValue *GV,
00128                              SectionKind Kind, Mangler &Mang,
00129                              const TargetMachine &TM) const override;
00130 
00131   const MCSection *
00132     SelectSectionForGlobal(const GlobalValue *GV,
00133                            SectionKind Kind, Mangler &Mang,
00134                            const TargetMachine &TM) const override;
00135 
00136   /// Extract the dependent library name from a linker option string. Returns
00137   /// StringRef() if the option does not specify a library.
00138   StringRef getDepLibFromLinkerOpt(StringRef LinkerOption) const override;
00139 
00140   /// Emit Obj-C garbage collection and linker options. Only linker option
00141   /// emission is implemented for COFF.
00142   void emitModuleFlags(MCStreamer &Streamer,
00143                        ArrayRef<Module::ModuleFlagEntry> ModuleFlags,
00144                        Mangler &Mang, const TargetMachine &TM) const override;
00145 
00146   const MCSection *getStaticCtorSection(unsigned Priority,
00147                                         const MCSymbol *KeySym) const override;
00148   const MCSection *getStaticDtorSection(unsigned Priority,
00149                                         const MCSymbol *KeySym) const override;
00150 };
00151 
00152 } // end namespace llvm
00153 
00154 #endif