1 //===- llvm/CodeGen/MachineModuleInfoImpls.h --------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines object-file format specific implementations of
10 // MachineModuleInfoImpl.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
15 #define LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/CodeGen/MachineModuleInfo.h"
25 /// MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation
26 /// for MachO targets.
27 class MachineModuleInfoMachO
: public MachineModuleInfoImpl
{
28 /// GVStubs - Darwin '$non_lazy_ptr' stubs. The key is something like
29 /// "Lfoo$non_lazy_ptr", the value is something like "_foo". The extra bit
30 /// is true if this GV is external.
31 DenseMap
<MCSymbol
*, StubValueTy
> GVStubs
;
33 /// ThreadLocalGVStubs - Darwin '$non_lazy_ptr' stubs. The key is something
34 /// like "Lfoo$non_lazy_ptr", the value is something like "_foo". The extra
35 /// bit is true if this GV is external.
36 DenseMap
<MCSymbol
*, StubValueTy
> ThreadLocalGVStubs
;
38 virtual void anchor(); // Out of line virtual method.
41 MachineModuleInfoMachO(const MachineModuleInfo
&) {}
43 StubValueTy
&getGVStubEntry(MCSymbol
*Sym
) {
44 assert(Sym
&& "Key cannot be null");
48 StubValueTy
&getThreadLocalGVStubEntry(MCSymbol
*Sym
) {
49 assert(Sym
&& "Key cannot be null");
50 return ThreadLocalGVStubs
[Sym
];
53 /// Accessor methods to return the set of stubs in sorted order.
54 SymbolListTy
GetGVStubList() { return getSortedStubs(GVStubs
); }
55 SymbolListTy
GetThreadLocalGVStubList() {
56 return getSortedStubs(ThreadLocalGVStubs
);
60 /// MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation
62 class MachineModuleInfoELF
: public MachineModuleInfoImpl
{
63 /// GVStubs - These stubs are used to materialize global addresses in PIC
65 DenseMap
<MCSymbol
*, StubValueTy
> GVStubs
;
67 virtual void anchor(); // Out of line virtual method.
70 MachineModuleInfoELF(const MachineModuleInfo
&) {}
72 StubValueTy
&getGVStubEntry(MCSymbol
*Sym
) {
73 assert(Sym
&& "Key cannot be null");
77 /// Accessor methods to return the set of stubs in sorted order.
79 SymbolListTy
GetGVStubList() { return getSortedStubs(GVStubs
); }
82 /// MachineModuleInfoCOFF - This is a MachineModuleInfoImpl implementation
84 class MachineModuleInfoCOFF
: public MachineModuleInfoImpl
{
85 /// GVStubs - These stubs are used to materialize global addresses in PIC
87 DenseMap
<MCSymbol
*, StubValueTy
> GVStubs
;
89 virtual void anchor(); // Out of line virtual method.
92 MachineModuleInfoCOFF(const MachineModuleInfo
&) {}
94 StubValueTy
&getGVStubEntry(MCSymbol
*Sym
) {
95 assert(Sym
&& "Key cannot be null");
99 /// Accessor methods to return the set of stubs in sorted order.
101 SymbolListTy
GetGVStubList() { return getSortedStubs(GVStubs
); }
104 } // end namespace llvm
106 #endif // LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H