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.

126 lines
4.1 KiB

  1. //===- MCELFStreamer.h - MCStreamer ELF Object File Interface ---*- 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. #ifndef LLVM_MC_MCELFSTREAMER_H
  10. #define LLVM_MC_MCELFSTREAMER_H
  11. #include "llvm/ADT/SmallPtrSet.h"
  12. #include "llvm/MC/MCDirectives.h"
  13. #include "llvm/MC/MCObjectStreamer.h"
  14. #include "llvm/MC/SectionKind.h"
  15. #include "llvm/Support/DataTypes.h"
  16. #include <vector>
  17. namespace llvm {
  18. class MCAsmBackend;
  19. class MCAssembler;
  20. class MCCodeEmitter;
  21. class MCExpr;
  22. class MCInst;
  23. class MCSymbol;
  24. class MCSymbolData;
  25. class raw_ostream;
  26. class MCELFStreamer : public MCObjectStreamer {
  27. protected:
  28. MCELFStreamer(StreamerKind Kind, MCContext &Context, MCAsmBackend &TAB,
  29. raw_ostream &OS, MCCodeEmitter *Emitter)
  30. : MCObjectStreamer(Kind, Context, TAB, OS, Emitter) {}
  31. public:
  32. MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
  33. MCCodeEmitter *Emitter)
  34. : MCObjectStreamer(SK_ELFStreamer, Context, TAB, OS, Emitter) {}
  35. MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS,
  36. MCCodeEmitter *Emitter, MCAssembler *Assembler)
  37. : MCObjectStreamer(SK_ELFStreamer, Context, TAB, OS, Emitter,
  38. Assembler) {}
  39. virtual ~MCELFStreamer();
  40. /// @name MCStreamer Interface
  41. /// @{
  42. virtual void InitSections();
  43. virtual void InitToTextSection();
  44. virtual void ChangeSection(const MCSection *Section,
  45. const MCExpr *Subsection);
  46. virtual void EmitLabel(MCSymbol *Symbol);
  47. virtual void EmitDebugLabel(MCSymbol *Symbol);
  48. virtual void EmitAssemblerFlag(MCAssemblerFlag Flag);
  49. virtual void EmitThumbFunc(MCSymbol *Func);
  50. virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol);
  51. virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute);
  52. virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue);
  53. virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
  54. unsigned ByteAlignment);
  55. virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol);
  56. virtual void EmitCOFFSymbolStorageClass(int StorageClass);
  57. virtual void EmitCOFFSymbolType(int Type);
  58. virtual void EndCOFFSymbolDef();
  59. virtual MCSymbolData &getOrCreateSymbolData(MCSymbol *Symbol);
  60. virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value);
  61. virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
  62. unsigned ByteAlignment);
  63. virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
  64. uint64_t Size = 0, unsigned ByteAlignment = 0);
  65. virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
  66. uint64_t Size, unsigned ByteAlignment = 0);
  67. virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
  68. unsigned AddrSpace);
  69. virtual void EmitFileDirective(StringRef Filename);
  70. virtual void EmitTCEntry(const MCSymbol &S);
  71. virtual void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned);
  72. virtual void FinishImpl();
  73. /// @}
  74. static bool classof(const MCStreamer *S) {
  75. return S->getKind() == SK_ELFStreamer || S->getKind() == SK_ARMELFStreamer;
  76. }
  77. private:
  78. virtual void EmitInstToFragment(const MCInst &Inst);
  79. virtual void EmitInstToData(const MCInst &Inst);
  80. virtual void EmitBundleAlignMode(unsigned AlignPow2);
  81. virtual void EmitBundleLock(bool AlignToEnd);
  82. virtual void EmitBundleUnlock();
  83. void fixSymbolsInTLSFixups(const MCExpr *expr);
  84. struct LocalCommon {
  85. MCSymbolData *SD;
  86. uint64_t Size;
  87. unsigned ByteAlignment;
  88. };
  89. std::vector<LocalCommon> LocalCommons;
  90. SmallPtrSet<MCSymbol *, 16> BindingExplicitlySet;
  91. void SetSection(StringRef Section, unsigned Type, unsigned Flags,
  92. SectionKind Kind);
  93. void SetSectionData();
  94. void SetSectionText();
  95. void SetSectionBss();
  96. };
  97. } // end namespace llvm
  98. #endif