MCWasmObjectWriter.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- llvm/MC/MCWasmObjectWriter.h - Wasm Object Writer -------*- 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_MCWASMOBJECTWRITER_H
  14. #define LLVM_MC_MCWASMOBJECTWRITER_H
  15. #include "llvm/MC/MCObjectWriter.h"
  16. #include <memory>
  17. namespace llvm {
  18. class MCFixup;
  19. class MCSectionWasm;
  20. class MCValue;
  21. class raw_pwrite_stream;
  22. class MCWasmObjectTargetWriter : public MCObjectTargetWriter {
  23. const unsigned Is64Bit : 1;
  24. const unsigned IsEmscripten : 1;
  25. protected:
  26. explicit MCWasmObjectTargetWriter(bool Is64Bit_, bool IsEmscripten);
  27. public:
  28. virtual ~MCWasmObjectTargetWriter();
  29. Triple::ObjectFormatType getFormat() const override { return Triple::Wasm; }
  30. static bool classof(const MCObjectTargetWriter *W) {
  31. return W->getFormat() == Triple::Wasm;
  32. }
  33. virtual unsigned getRelocType(const MCValue &Target, const MCFixup &Fixup,
  34. const MCSectionWasm &FixupSection,
  35. bool IsLocRel) const = 0;
  36. /// \name Accessors
  37. /// @{
  38. bool is64Bit() const { return Is64Bit; }
  39. bool isEmscripten() const { return IsEmscripten; }
  40. /// @}
  41. };
  42. /// Construct a new Wasm writer instance.
  43. ///
  44. /// \param MOTW - The target specific Wasm writer subclass.
  45. /// \param OS - The stream to write to.
  46. /// \returns The constructed object writer.
  47. std::unique_ptr<MCObjectWriter>
  48. createWasmObjectWriter(std::unique_ptr<MCWasmObjectTargetWriter> MOTW,
  49. raw_pwrite_stream &OS);
  50. std::unique_ptr<MCObjectWriter>
  51. createWasmDwoObjectWriter(std::unique_ptr<MCWasmObjectTargetWriter> MOTW,
  52. raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS);
  53. } // namespace llvm
  54. #endif
  55. #ifdef __GNUC__
  56. #pragma GCC diagnostic pop
  57. #endif