1198090Srdivacky//===-- llvm/CodeGen/MachineModuleInfoImpls.h -------------------*- C++ -*-===//
2198090Srdivacky//
3198090Srdivacky//                     The LLVM Compiler Infrastructure
4198090Srdivacky//
5198090Srdivacky// This file is distributed under the University of Illinois Open Source
6198090Srdivacky// License. See LICENSE.TXT for details.
7198090Srdivacky//
8198090Srdivacky//===----------------------------------------------------------------------===//
9198090Srdivacky//
10198090Srdivacky// This file defines object-file format specific implementations of
11198090Srdivacky// MachineModuleInfoImpl.
12198090Srdivacky//
13198090Srdivacky//===----------------------------------------------------------------------===//
14198090Srdivacky
15198090Srdivacky#ifndef LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
16198090Srdivacky#define LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
17198090Srdivacky
18198090Srdivacky#include "llvm/CodeGen/MachineModuleInfo.h"
19198090Srdivacky
20198090Srdivackynamespace llvm {
21198090Srdivacky  class MCSymbol;
22203954Srdivacky
23198090Srdivacky  /// MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation
24198090Srdivacky  /// for MachO targets.
25198090Srdivacky  class MachineModuleInfoMachO : public MachineModuleInfoImpl {
26198090Srdivacky    /// FnStubs - Darwin '$stub' stubs.  The key is something like "Lfoo$stub",
27198090Srdivacky    /// the value is something like "_foo".
28205218Srdivacky    DenseMap<MCSymbol*, StubValueTy> FnStubs;
29198090Srdivacky
30198090Srdivacky    /// GVStubs - Darwin '$non_lazy_ptr' stubs.  The key is something like
31205218Srdivacky    /// "Lfoo$non_lazy_ptr", the value is something like "_foo". The extra bit
32205218Srdivacky    /// is true if this GV is external.
33205218Srdivacky    DenseMap<MCSymbol*, StubValueTy> GVStubs;
34198090Srdivacky
35198090Srdivacky    /// HiddenGVStubs - Darwin '$non_lazy_ptr' stubs.  The key is something like
36198090Srdivacky    /// "Lfoo$non_lazy_ptr", the value is something like "_foo".  Unlike GVStubs
37205218Srdivacky    /// these are for things with hidden visibility. The extra bit is true if
38205218Srdivacky    /// this GV is external.
39205218Srdivacky    DenseMap<MCSymbol*, StubValueTy> HiddenGVStubs;
40198090Srdivacky
41243830Sdim    virtual void anchor();  // Out of line virtual method.
42198090Srdivacky  public:
43198090Srdivacky    MachineModuleInfoMachO(const MachineModuleInfo &) {}
44198090Srdivacky
45205218Srdivacky    StubValueTy &getFnStubEntry(MCSymbol *Sym) {
46198090Srdivacky      assert(Sym && "Key cannot be null");
47198090Srdivacky      return FnStubs[Sym];
48198090Srdivacky    }
49198090Srdivacky
50205218Srdivacky    StubValueTy &getGVStubEntry(MCSymbol *Sym) {
51198090Srdivacky      assert(Sym && "Key cannot be null");
52198090Srdivacky      return GVStubs[Sym];
53198090Srdivacky    }
54198090Srdivacky
55205218Srdivacky    StubValueTy &getHiddenGVStubEntry(MCSymbol *Sym) {
56198090Srdivacky      assert(Sym && "Key cannot be null");
57198090Srdivacky      return HiddenGVStubs[Sym];
58198090Srdivacky    }
59203954Srdivacky
60198090Srdivacky    /// Accessor methods to return the set of stubs in sorted order.
61198090Srdivacky    SymbolListTy GetFnStubList() const {
62198090Srdivacky      return GetSortedStubs(FnStubs);
63198090Srdivacky    }
64198090Srdivacky    SymbolListTy GetGVStubList() const {
65198090Srdivacky      return GetSortedStubs(GVStubs);
66198090Srdivacky    }
67198090Srdivacky    SymbolListTy GetHiddenGVStubList() const {
68198090Srdivacky      return GetSortedStubs(HiddenGVStubs);
69198090Srdivacky    }
70198090Srdivacky  };
71203954Srdivacky
72203954Srdivacky  /// MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation
73203954Srdivacky  /// for ELF targets.
74203954Srdivacky  class MachineModuleInfoELF : public MachineModuleInfoImpl {
75203954Srdivacky    /// GVStubs - These stubs are used to materialize global addresses in PIC
76203954Srdivacky    /// mode.
77205218Srdivacky    DenseMap<MCSymbol*, StubValueTy> GVStubs;
78203954Srdivacky
79243830Sdim    virtual void anchor();  // Out of line virtual method.
80203954Srdivacky  public:
81203954Srdivacky    MachineModuleInfoELF(const MachineModuleInfo &) {}
82203954Srdivacky
83205218Srdivacky    StubValueTy &getGVStubEntry(MCSymbol *Sym) {
84203954Srdivacky      assert(Sym && "Key cannot be null");
85203954Srdivacky      return GVStubs[Sym];
86203954Srdivacky    }
87203954Srdivacky
88203954Srdivacky    /// Accessor methods to return the set of stubs in sorted order.
89203954Srdivacky
90203954Srdivacky    SymbolListTy GetGVStubList() const {
91203954Srdivacky      return GetSortedStubs(GVStubs);
92203954Srdivacky    }
93203954Srdivacky  };
94203954Srdivacky
95198090Srdivacky} // end namespace llvm
96198090Srdivacky
97198090Srdivacky#endif
98