MachineModuleInfoImpls.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/CodeGen/MachineModuleInfoImpls.h --------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines object-file format specific implementations of
  15. // MachineModuleInfoImpl.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
  19. #define LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
  20. #include "llvm/ADT/DenseMap.h"
  21. #include "llvm/ADT/StringSet.h"
  22. #include "llvm/CodeGen/MachineModuleInfo.h"
  23. #include <cassert>
  24. namespace llvm {
  25. class MCSymbol;
  26. /// MachineModuleInfoMachO - This is a MachineModuleInfoImpl implementation
  27. /// for MachO targets.
  28. class MachineModuleInfoMachO : public MachineModuleInfoImpl {
  29. /// GVStubs - Darwin '$non_lazy_ptr' stubs. The key is something like
  30. /// "Lfoo$non_lazy_ptr", the value is something like "_foo". The extra bit
  31. /// is true if this GV is external.
  32. 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;
  37. virtual void anchor(); // Out of line virtual method.
  38. public:
  39. MachineModuleInfoMachO(const MachineModuleInfo &) {}
  40. StubValueTy &getGVStubEntry(MCSymbol *Sym) {
  41. assert(Sym && "Key cannot be null");
  42. return GVStubs[Sym];
  43. }
  44. StubValueTy &getThreadLocalGVStubEntry(MCSymbol *Sym) {
  45. assert(Sym && "Key cannot be null");
  46. return ThreadLocalGVStubs[Sym];
  47. }
  48. /// Accessor methods to return the set of stubs in sorted order.
  49. SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); }
  50. SymbolListTy GetThreadLocalGVStubList() {
  51. return getSortedStubs(ThreadLocalGVStubs);
  52. }
  53. };
  54. /// MachineModuleInfoELF - This is a MachineModuleInfoImpl implementation
  55. /// for ELF targets.
  56. class MachineModuleInfoELF : public MachineModuleInfoImpl {
  57. /// GVStubs - These stubs are used to materialize global addresses in PIC
  58. /// mode.
  59. DenseMap<MCSymbol *, StubValueTy> GVStubs;
  60. virtual void anchor(); // Out of line virtual method.
  61. public:
  62. MachineModuleInfoELF(const MachineModuleInfo &) {}
  63. StubValueTy &getGVStubEntry(MCSymbol *Sym) {
  64. assert(Sym && "Key cannot be null");
  65. return GVStubs[Sym];
  66. }
  67. /// Accessor methods to return the set of stubs in sorted order.
  68. SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); }
  69. };
  70. /// MachineModuleInfoCOFF - This is a MachineModuleInfoImpl implementation
  71. /// for COFF targets.
  72. class MachineModuleInfoCOFF : public MachineModuleInfoImpl {
  73. /// GVStubs - These stubs are used to materialize global addresses in PIC
  74. /// mode.
  75. DenseMap<MCSymbol *, StubValueTy> GVStubs;
  76. virtual void anchor(); // Out of line virtual method.
  77. public:
  78. MachineModuleInfoCOFF(const MachineModuleInfo &) {}
  79. StubValueTy &getGVStubEntry(MCSymbol *Sym) {
  80. assert(Sym && "Key cannot be null");
  81. return GVStubs[Sym];
  82. }
  83. /// Accessor methods to return the set of stubs in sorted order.
  84. SymbolListTy GetGVStubList() { return getSortedStubs(GVStubs); }
  85. };
  86. /// MachineModuleInfoWasm - This is a MachineModuleInfoImpl implementation
  87. /// for Wasm targets.
  88. class MachineModuleInfoWasm : public MachineModuleInfoImpl {
  89. virtual void anchor(); // Out of line virtual method.
  90. public:
  91. MachineModuleInfoWasm(const MachineModuleInfo &) {}
  92. StringSet<> MachineSymbolsUsed;
  93. };
  94. } // end namespace llvm
  95. #endif // LLVM_CODEGEN_MACHINEMODULEINFOIMPLS_H
  96. #ifdef __GNUC__
  97. #pragma GCC diagnostic pop
  98. #endif