llvm.org GIT mirror llvm / 686cb3d
add a new MachineModuleInfoMachO class, which is the per-module stuff common across all macho targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82018 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
4 changed file(s) with 124 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
5959 /// to hold private target-specific information for each Module. Objects of
6060 /// type are accessed/created with MMI::getInfo and destroyed when the
6161 /// MachineModuleInfo is destroyed.
62 struct MachineModuleInfoImpl {
62 class MachineModuleInfoImpl {
63 public:
6364 virtual ~MachineModuleInfoImpl();
6465 };
6566
0 //===-- llvm/CodeGen/MachineModuleInfoImpls.h -------------------*- C++ -*-===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines object-file format specific implementations of
10 // MachineModuleInfoImpl.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
15 #define LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
16
17 #include "llvm/CodeGen/MachineModuleInfo.h"
18
19 namespace llvm {
20 class MCSymbol;
21
22 /// MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation
23 /// for MachO targets.
24 class MachineModuleInfoMachO : public MachineModuleInfoImpl {
25 /// FnStubs - Darwin '$stub' stubs. The key is something like "Lfoo$stub",
26 /// the value is something like "_foo".
27 DenseMap FnStubs;
28
29 /// GVStubs - Darwin '$non_lazy_ptr' stubs. The key is something like
30 /// "Lfoo$non_lazy_ptr", the value is something like "_foo".
31 DenseMap GVStubs;
32
33 /// HiddenGVStubs - Darwin '$non_lazy_ptr' stubs. The key is something like
34 /// "Lfoo$non_lazy_ptr", the value is something like "_foo". Unlike GVStubs
35 /// these are for things with hidden visibility.
36 DenseMap HiddenGVStubs;
37
38 virtual void Anchor(); // Out of line virtual method.
39 public:
40
41 const MCSymbol *&getFnStubEntry(const MCSymbol *Sym) {
42 assert(Sym && "Key cannot be null");
43 return FnStubs[Sym];
44 }
45
46 const MCSymbol *&getGVStubsEntry(const MCSymbol *Sym) {
47 assert(Sym && "Key cannot be null");
48 return GVStubs[Sym];
49 }
50
51 const MCSymbol *&getHiddenGVStubsEntry(const MCSymbol *Sym) {
52 assert(Sym && "Key cannot be null");
53 return HiddenGVStubs[Sym];
54 }
55
56 /// Accessor methods to return the set of stubs in sorted order.
57 typedef std::vector >
58 SymbolListTy;
59
60 SymbolListTy GetFnStubList() const {
61 return GetSortedStubs(FnStubs);
62 }
63 SymbolListTy GetGVStubList() const {
64 return GetSortedStubs(GVStubs);
65 }
66 SymbolListTy GetHiddenGVStubList() const {
67 return GetSortedStubs(HiddenGVStubs);
68 }
69
70 private:
71 static SymbolListTy
72 GetSortedStubs(const DenseMap &Map);
73 };
74
75 } // end namespace llvm
76
77 #endif
0 //===-- llvm/CodeGen/MachineModuleInfoImpls.cpp ---------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements object-file format specific implementations of
10 // MachineModuleInfoImpl.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/CodeGen/MachineModuleInfoImpls.h"
15 #include "llvm/MC/MCSymbol.h"
16 using namespace llvm;
17
18 //===----------------------------------------------------------------------===//
19 // MachineModuleInfoMachO
20 //===----------------------------------------------------------------------===//
21
22 // Out of line virtual method.
23 void MachineModuleInfoMachO::Anchor() {}
24
25
26 static int SortSymbolPair(const void *LHS, const void *RHS) {
27 const MCSymbol *LHSS =
28 ((const std::pair*)LHS)->first;
29 const MCSymbol *RHSS =
30 ((const std::pair*)RHS)->first;
31 return LHSS->getName().compare(RHSS->getName());
32 }
33
34 /// GetSortedStubs - Return the entries from a DenseMap in a deterministic
35 /// sorted orer.
36 MachineModuleInfoMachO::SymbolListTy
37 MachineModuleInfoMachO::GetSortedStubs(const DenseMap
38 const MCSymbol*> &Map) {
39 MachineModuleInfoMachO::SymbolListTy List(Map.begin(), Map.end());
40 qsort(&List[0], List.size(), sizeof(List[0]), SortSymbolPair);
41 return List;
42 }
43
151151
152152 void emitFunctionHeader(const MachineFunction &MF);
153153
154 // Necessary for Darwin to print out the appropriate types of linker stubs.
155 DenseMap FnStubs; // Darwin $stub stubs.
156 DenseMap GVStubs; // Darwin $non_lazy_ptr stub.
157 DenseMap HiddenGVStubs; // Darwin $non_lazy_ptr stub.
158
159154 // Necessary for dllexport support
160155 StringSet<> CygMingStubs, DLLExportedFns, DLLExportedGVs;
161156