MachineModuleInfoImpls.h 3.1 KB

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