MCWasmStreamer.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- MCWasmStreamer.h - MCStreamer Wasm Object File Interface -*- 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. #ifndef LLVM_MC_MCWASMSTREAMER_H
  14. #define LLVM_MC_MCWASMSTREAMER_H
  15. #include "MCAsmBackend.h"
  16. #include "MCCodeEmitter.h"
  17. #include "llvm/MC/MCDirectives.h"
  18. #include "llvm/MC/MCObjectStreamer.h"
  19. #include "llvm/MC/MCObjectWriter.h"
  20. #include "llvm/Support/DataTypes.h"
  21. namespace llvm {
  22. class MCExpr;
  23. class MCInst;
  24. class MCWasmStreamer : public MCObjectStreamer {
  25. public:
  26. MCWasmStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
  27. std::unique_ptr<MCObjectWriter> OW,
  28. std::unique_ptr<MCCodeEmitter> Emitter)
  29. : MCObjectStreamer(Context, std::move(TAB), std::move(OW),
  30. std::move(Emitter)),
  31. SeenIdent(false) {}
  32. ~MCWasmStreamer() override;
  33. /// state management
  34. void reset() override {
  35. SeenIdent = false;
  36. MCObjectStreamer::reset();
  37. }
  38. /// \name MCStreamer Interface
  39. /// @{
  40. void changeSection(MCSection *Section, const MCExpr *Subsection) override;
  41. void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
  42. void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F,
  43. uint64_t Offset) override;
  44. void emitAssemblerFlag(MCAssemblerFlag Flag) override;
  45. void emitThumbFunc(MCSymbol *Func) override;
  46. void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
  47. bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
  48. void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
  49. void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
  50. unsigned ByteAlignment) override;
  51. void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
  52. void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
  53. unsigned ByteAlignment) override;
  54. void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
  55. uint64_t Size = 0, unsigned ByteAlignment = 0,
  56. SMLoc Loc = SMLoc()) override;
  57. void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
  58. unsigned ByteAlignment = 0) override;
  59. void emitIdent(StringRef IdentString) override;
  60. void finishImpl() override;
  61. private:
  62. void emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;
  63. void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
  64. void fixSymbolsInTLSFixups(const MCExpr *expr);
  65. /// Merge the content of the fragment \p EF into the fragment \p DF.
  66. void mergeFragment(MCDataFragment *, MCDataFragment *);
  67. bool SeenIdent;
  68. };
  69. } // end namespace llvm
  70. #endif
  71. #ifdef __GNUC__
  72. #pragma GCC diagnostic pop
  73. #endif