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