LLVM API Documentation

MachineModuleInfoImpls.h
Go to the documentation of this file.
00001 //===-- llvm/CodeGen/MachineModuleInfoImpls.h -------------------*- 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 defines object-file format specific implementations of
00011 // MachineModuleInfoImpl.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
00016 #define LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
00017 
00018 #include "llvm/CodeGen/MachineModuleInfo.h"
00019 
00020 namespace llvm {
00021   class MCSymbol;
00022 
00023   /// MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation
00024   /// for MachO targets.
00025   class MachineModuleInfoMachO : public MachineModuleInfoImpl {
00026     /// FnStubs - Darwin '$stub' stubs.  The key is something like "Lfoo$stub",
00027     /// the value is something like "_foo".
00028     DenseMap<MCSymbol*, StubValueTy> FnStubs;
00029     
00030     /// GVStubs - Darwin '$non_lazy_ptr' stubs.  The key is something like
00031     /// "Lfoo$non_lazy_ptr", the value is something like "_foo". The extra bit
00032     /// is true if this GV is external.
00033     DenseMap<MCSymbol*, StubValueTy> GVStubs;
00034     
00035     /// HiddenGVStubs - Darwin '$non_lazy_ptr' stubs.  The key is something like
00036     /// "Lfoo$non_lazy_ptr", the value is something like "_foo".  Unlike GVStubs
00037     /// these are for things with hidden visibility. The extra bit is true if
00038     /// this GV is external.
00039     DenseMap<MCSymbol*, StubValueTy> HiddenGVStubs;
00040     
00041     virtual void anchor();  // Out of line virtual method.
00042   public:
00043     MachineModuleInfoMachO(const MachineModuleInfo &) {}
00044     
00045     StubValueTy &getFnStubEntry(MCSymbol *Sym) {
00046       assert(Sym && "Key cannot be null");
00047       return FnStubs[Sym];
00048     }
00049 
00050     StubValueTy &getGVStubEntry(MCSymbol *Sym) {
00051       assert(Sym && "Key cannot be null");
00052       return GVStubs[Sym];
00053     }
00054 
00055     StubValueTy &getHiddenGVStubEntry(MCSymbol *Sym) {
00056       assert(Sym && "Key cannot be null");
00057       return HiddenGVStubs[Sym];
00058     }
00059 
00060     /// Accessor methods to return the set of stubs in sorted order.
00061     SymbolListTy GetFnStubList() const {
00062       return GetSortedStubs(FnStubs);
00063     }
00064     SymbolListTy GetGVStubList() const {
00065       return GetSortedStubs(GVStubs);
00066     }
00067     SymbolListTy GetHiddenGVStubList() const {
00068       return GetSortedStubs(HiddenGVStubs);
00069     }
00070   };
00071 
00072   /// MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation
00073   /// for ELF targets.
00074   class MachineModuleInfoELF : public MachineModuleInfoImpl {
00075     /// GVStubs - These stubs are used to materialize global addresses in PIC
00076     /// mode.
00077     DenseMap<MCSymbol*, StubValueTy> GVStubs;
00078 
00079     virtual void anchor();  // Out of line virtual method.
00080   public:
00081     MachineModuleInfoELF(const MachineModuleInfo &) {}
00082 
00083     StubValueTy &getGVStubEntry(MCSymbol *Sym) {
00084       assert(Sym && "Key cannot be null");
00085       return GVStubs[Sym];
00086     }
00087 
00088     /// Accessor methods to return the set of stubs in sorted order.
00089 
00090     SymbolListTy GetGVStubList() const {
00091       return GetSortedStubs(GVStubs);
00092     }
00093   };
00094 
00095 } // end namespace llvm
00096 
00097 #endif