MCWasmStreamer.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //===- MCWasmStreamer.h - MCStreamer Wasm Object File Interface -*- C++ -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #ifndef LLVM_MC_MCWASMSTREAMER_H
  9. #define LLVM_MC_MCWASMSTREAMER_H
  10. #include "MCAsmBackend.h"
  11. #include "MCCodeEmitter.h"
  12. #include "llvm/MC/MCDirectives.h"
  13. #include "llvm/MC/MCObjectStreamer.h"
  14. #include "llvm/MC/MCObjectWriter.h"
  15. #include "llvm/Support/DataTypes.h"
  16. namespace llvm {
  17. class MCExpr;
  18. class MCInst;
  19. class MCWasmStreamer : public MCObjectStreamer {
  20. public:
  21. MCWasmStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
  22. std::unique_ptr<MCObjectWriter> OW,
  23. std::unique_ptr<MCCodeEmitter> Emitter)
  24. : MCObjectStreamer(Context, std::move(TAB), std::move(OW),
  25. std::move(Emitter)),
  26. SeenIdent(false) {}
  27. ~MCWasmStreamer() override;
  28. /// state management
  29. void reset() override {
  30. SeenIdent = false;
  31. MCObjectStreamer::reset();
  32. }
  33. /// \name MCStreamer Interface
  34. /// @{
  35. void changeSection(MCSection *Section, const MCExpr *Subsection) override;
  36. void emitAssemblerFlag(MCAssemblerFlag Flag) override;
  37. void emitThumbFunc(MCSymbol *Func) override;
  38. void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
  39. bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
  40. void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
  41. void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
  42. unsigned ByteAlignment) override;
  43. void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
  44. void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
  45. unsigned ByteAlignment) override;
  46. void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
  47. uint64_t Size = 0, unsigned ByteAlignment = 0,
  48. SMLoc Loc = SMLoc()) override;
  49. void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
  50. unsigned ByteAlignment = 0) override;
  51. void emitIdent(StringRef IdentString) override;
  52. void finishImpl() override;
  53. private:
  54. void emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &) override;
  55. void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &) override;
  56. /// Merge the content of the fragment \p EF into the fragment \p DF.
  57. void mergeFragment(MCDataFragment *, MCDataFragment *);
  58. bool SeenIdent;
  59. };
  60. } // end namespace llvm
  61. #endif