Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

149 lines
5.6 KiB

  1. //===-- llvm/Target/TargetLoweringObjectFile.h - Object Info ----*- 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 implements classes used to handle lowerings specific to common
  11. // object file formats.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. #ifndef LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H
  15. #define LLVM_TARGET_TARGETLOWERINGOBJECTFILE_H
  16. #include "llvm/ADT/ArrayRef.h"
  17. #include "llvm/IR/Module.h"
  18. #include "llvm/MC/MCObjectFileInfo.h"
  19. #include "llvm/MC/SectionKind.h"
  20. namespace llvm {
  21. class MachineModuleInfo;
  22. class Mangler;
  23. class MCContext;
  24. class MCExpr;
  25. class MCSection;
  26. class MCSymbol;
  27. class MCSymbolRefExpr;
  28. class MCStreamer;
  29. class GlobalValue;
  30. class TargetMachine;
  31. class TargetLoweringObjectFile : public MCObjectFileInfo {
  32. MCContext *Ctx;
  33. TargetLoweringObjectFile(
  34. const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION;
  35. void operator=(const TargetLoweringObjectFile&) LLVM_DELETED_FUNCTION;
  36. public:
  37. MCContext &getContext() const { return *Ctx; }
  38. TargetLoweringObjectFile() : MCObjectFileInfo(), Ctx(0) {}
  39. virtual ~TargetLoweringObjectFile();
  40. /// Initialize - this method must be called before any actual lowering is
  41. /// done. This specifies the current context for codegen, and gives the
  42. /// lowering implementations a chance to set up their default sections.
  43. virtual void Initialize(MCContext &ctx, const TargetMachine &TM);
  44. virtual void emitPersonalityValue(MCStreamer &Streamer,
  45. const TargetMachine &TM,
  46. const MCSymbol *Sym) const;
  47. /// emitModuleFlags - Emit the module flags that the platform cares about.
  48. virtual void emitModuleFlags(MCStreamer &,
  49. ArrayRef<Module::ModuleFlagEntry>,
  50. Mangler *, const TargetMachine &) const {
  51. }
  52. /// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
  53. /// decide not to emit the UsedDirective for some symbols in llvm.used.
  54. /// FIXME: REMOVE this (rdar://7071300)
  55. virtual bool shouldEmitUsedDirectiveFor(const GlobalValue *GV,
  56. Mangler *) const {
  57. return GV != 0;
  58. }
  59. /// getSectionForConstant - Given a constant with the SectionKind, return a
  60. /// section that it should be placed in.
  61. virtual const MCSection *getSectionForConstant(SectionKind Kind) const;
  62. /// getKindForGlobal - Classify the specified global variable into a set of
  63. /// target independent categories embodied in SectionKind.
  64. static SectionKind getKindForGlobal(const GlobalValue *GV,
  65. const TargetMachine &TM);
  66. /// SectionForGlobal - This method computes the appropriate section to emit
  67. /// the specified global variable or function definition. This should not
  68. /// be passed external (or available externally) globals.
  69. const MCSection *SectionForGlobal(const GlobalValue *GV,
  70. SectionKind Kind, Mangler *Mang,
  71. const TargetMachine &TM) const;
  72. /// SectionForGlobal - This method computes the appropriate section to emit
  73. /// the specified global variable or function definition. This should not
  74. /// be passed external (or available externally) globals.
  75. const MCSection *SectionForGlobal(const GlobalValue *GV,
  76. Mangler *Mang,
  77. const TargetMachine &TM) const {
  78. return SectionForGlobal(GV, getKindForGlobal(GV, TM), Mang, TM);
  79. }
  80. /// getExplicitSectionGlobal - Targets should implement this method to assign
  81. /// a section to globals with an explicit section specfied. The
  82. /// implementation of this method can assume that GV->hasSection() is true.
  83. virtual const MCSection *
  84. getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
  85. Mangler *Mang, const TargetMachine &TM) const = 0;
  86. /// getSpecialCasedSectionGlobals - Allow the target to completely override
  87. /// section assignment of a global.
  88. virtual const MCSection *
  89. getSpecialCasedSectionGlobals(const GlobalValue *GV, Mangler *Mang,
  90. SectionKind Kind) const {
  91. return 0;
  92. }
  93. /// getTTypeGlobalReference - Return an MCExpr to use for a reference
  94. /// to the specified global variable from exception handling information.
  95. ///
  96. virtual const MCExpr *
  97. getTTypeGlobalReference(const GlobalValue *GV, Mangler *Mang,
  98. MachineModuleInfo *MMI, unsigned Encoding,
  99. MCStreamer &Streamer) const;
  100. // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality.
  101. virtual MCSymbol *
  102. getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang,
  103. MachineModuleInfo *MMI) const;
  104. ///
  105. const MCExpr *
  106. getTTypeReference(const MCSymbolRefExpr *Sym, unsigned Encoding,
  107. MCStreamer &Streamer) const;
  108. virtual const MCSection *
  109. getStaticCtorSection(unsigned Priority = 65535) const {
  110. (void)Priority;
  111. return StaticCtorSection;
  112. }
  113. virtual const MCSection *
  114. getStaticDtorSection(unsigned Priority = 65535) const {
  115. (void)Priority;
  116. return StaticDtorSection;
  117. }
  118. protected:
  119. virtual const MCSection *
  120. SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
  121. Mangler *Mang, const TargetMachine &TM) const;
  122. };
  123. } // end namespace llvm
  124. #endif