1//===-- llvm/CodeGen/MachineModuleInfoImpls.h -------------------*- 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 defines object-file format specific implementations of
11// MachineModuleInfoImpl.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
16#define LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
17
18#include "llvm/CodeGen/MachineModuleInfo.h"
19
20namespace llvm {
21class MCSymbol;
22
23/// MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation
24/// for MachO targets.
25class MachineModuleInfoMachO : public MachineModuleInfoImpl {
26  /// GVStubs - Darwin '$non_lazy_ptr' stubs.  The key is something like
27  /// "Lfoo$non_lazy_ptr", the value is something like "_foo". The extra bit
28  /// is true if this GV is external.
29  DenseMap<MCSymbol *, StubValueTy> GVStubs;
30
31  /// ThreadLocalGVStubs - Darwin '$non_lazy_ptr' stubs.  The key is something
32  /// like "Lfoo$non_lazy_ptr", the value is something like "_foo". The extra
33  /// bit is true if this GV is external.
34  DenseMap<MCSymbol *, StubValueTy> ThreadLocalGVStubs;
35
36  virtual void anchor(); // Out of line virtual method.
37public:
38  MachineModuleInfoMachO(const MachineModuleInfo &) {}
39
40  StubValueTy &getGVStubEntry(MCSymbol *Sym) {
41    assert(Sym && "Key cannot be null");
42    return GVStubs[Sym];
43  }
44
45  StubValueTy &getThreadLocalGVStubEntry(MCSymbol *Sym) {
46    assert(Sym && "Key cannot be null");
47    return ThreadLocalGVStubs[Sym];
48  }
49
50  /// Accessor methods to return the set of stubs in sorted order.
51  SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); }
52  SymbolListTy GetThreadLocalGVStubList() {
53    return getSortedStubs(ThreadLocalGVStubs);
54  }
55};
56
57/// MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation
58/// for ELF targets.
59class MachineModuleInfoELF : public MachineModuleInfoImpl {
60  /// GVStubs - These stubs are used to materialize global addresses in PIC
61  /// mode.
62  DenseMap<MCSymbol *, StubValueTy> GVStubs;
63
64  virtual void anchor(); // Out of line virtual method.
65public:
66  MachineModuleInfoELF(const MachineModuleInfo &) {}
67
68  StubValueTy &getGVStubEntry(MCSymbol *Sym) {
69    assert(Sym && "Key cannot be null");
70    return GVStubs[Sym];
71  }
72
73  /// Accessor methods to return the set of stubs in sorted order.
74
75  SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); }
76};
77
78} // end namespace llvm
79
80#endif
81