blob: 746e9223961300c76d0410391b597bdd548aead0 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- llvm/CodeGen/MachineModuleInfoImpls.h --------------------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
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/ADT/DenseMap.h"
18#include "llvm/CodeGen/MachineModuleInfo.h"
19#include <cassert>
20
21namespace llvm {
22
23class MCSymbol;
24
25/// MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation
26/// for MachO targets.
27class 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;
32
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;
37
38 virtual void anchor(); // Out of line virtual method.
39
40public:
41 MachineModuleInfoMachO(const MachineModuleInfo &) {}
42
43 StubValueTy &getGVStubEntry(MCSymbol *Sym) {
44 assert(Sym && "Key cannot be null");
45 return GVStubs[Sym];
46 }
47
48 StubValueTy &getThreadLocalGVStubEntry(MCSymbol *Sym) {
49 assert(Sym && "Key cannot be null");
50 return ThreadLocalGVStubs[Sym];
51 }
52
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);
57 }
58};
59
60/// MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation
61/// for ELF targets.
62class MachineModuleInfoELF : public MachineModuleInfoImpl {
63 /// GVStubs - These stubs are used to materialize global addresses in PIC
64 /// mode.
65 DenseMap<MCSymbol *, StubValueTy> GVStubs;
66
67 virtual void anchor(); // Out of line virtual method.
68
69public:
70 MachineModuleInfoELF(const MachineModuleInfo &) {}
71
72 StubValueTy &getGVStubEntry(MCSymbol *Sym) {
73 assert(Sym && "Key cannot be null");
74 return GVStubs[Sym];
75 }
76
77 /// Accessor methods to return the set of stubs in sorted order.
78
79 SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); }
80};
81
Andrew Scull0372a572018-11-16 15:47:06 +000082/// MachineModuleInfoCOFF - This is a MachineModuleInfoImpl implementation
83/// for COFF targets.
84class MachineModuleInfoCOFF : public MachineModuleInfoImpl {
85 /// GVStubs - These stubs are used to materialize global addresses in PIC
86 /// mode.
87 DenseMap<MCSymbol *, StubValueTy> GVStubs;
88
89 virtual void anchor(); // Out of line virtual method.
90
91public:
92 MachineModuleInfoCOFF(const MachineModuleInfo &) {}
93
94 StubValueTy &getGVStubEntry(MCSymbol *Sym) {
95 assert(Sym && "Key cannot be null");
96 return GVStubs[Sym];
97 }
98
99 /// Accessor methods to return the set of stubs in sorted order.
100
101 SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); }
102};
103
Andrew Scull5e1ddfa2018-08-14 10:06:54 +0100104} // end namespace llvm
105
106#endif // LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H