blob: 492c016fd6c03d030610bdfc75f36a736b36c583 [file] [log] [blame]
Chris Lattner686cb3d2009-09-16 06:03:48 +00001//===-- 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 {
21 class MCSymbol;
22
23 /// MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation
24 /// for MachO targets.
25 class MachineModuleInfoMachO : public MachineModuleInfoImpl {
26 /// FnStubs - Darwin '$stub' stubs. The key is something like "Lfoo$stub",
27 /// the value is something like "_foo".
28 DenseMap<const MCSymbol*, const MCSymbol*> FnStubs;
29
30 /// GVStubs - Darwin '$non_lazy_ptr' stubs. The key is something like
31 /// "Lfoo$non_lazy_ptr", the value is something like "_foo".
32 DenseMap<const MCSymbol*, const MCSymbol*> GVStubs;
33
34 /// HiddenGVStubs - Darwin '$non_lazy_ptr' stubs. The key is something like
35 /// "Lfoo$non_lazy_ptr", the value is something like "_foo". Unlike GVStubs
36 /// these are for things with hidden visibility.
37 DenseMap<const MCSymbol*, const MCSymbol*> HiddenGVStubs;
38
39 virtual void Anchor(); // Out of line virtual method.
40 public:
41
42 const MCSymbol *&getFnStubEntry(const MCSymbol *Sym) {
43 assert(Sym && "Key cannot be null");
44 return FnStubs[Sym];
45 }
46
47 const MCSymbol *&getGVStubsEntry(const MCSymbol *Sym) {
48 assert(Sym && "Key cannot be null");
49 return GVStubs[Sym];
50 }
51
52 const MCSymbol *&getHiddenGVStubsEntry(const MCSymbol *Sym) {
53 assert(Sym && "Key cannot be null");
54 return HiddenGVStubs[Sym];
55 }
56
57 /// Accessor methods to return the set of stubs in sorted order.
58 typedef std::vector<std::pair<const MCSymbol*, const MCSymbol*> >
59 SymbolListTy;
60
61 SymbolListTy GetFnStubList() const {
62 return GetSortedStubs(FnStubs);
63 }
64 SymbolListTy GetGVStubList() const {
65 return GetSortedStubs(GVStubs);
66 }
67 SymbolListTy GetHiddenGVStubList() const {
68 return GetSortedStubs(HiddenGVStubs);
69 }
70
71 private:
72 static SymbolListTy
73 GetSortedStubs(const DenseMap<const MCSymbol*, const MCSymbol*> &Map);
74 };
75
76} // end namespace llvm
77
78#endif