Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===-- llvm/MC/MCWasmObjectWriter.h - Wasm Object Writer -------*- C++ -*-===// |
| 2 | // |
Andrew Walbran | 16937d0 | 2019-10-22 13:54:20 +0100 | [diff] [blame] | 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 |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef LLVM_MC_MCWASMOBJECTWRITER_H |
| 10 | #define LLVM_MC_MCWASMOBJECTWRITER_H |
| 11 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 12 | #include "llvm/MC/MCObjectWriter.h" |
| 13 | #include <memory> |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 14 | |
| 15 | namespace llvm { |
| 16 | |
| 17 | class MCFixup; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 18 | class MCValue; |
| 19 | class raw_pwrite_stream; |
| 20 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 21 | class MCWasmObjectTargetWriter : public MCObjectTargetWriter { |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 22 | const unsigned Is64Bit : 1; |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 23 | const unsigned IsEmscripten : 1; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 24 | |
| 25 | protected: |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 26 | explicit MCWasmObjectTargetWriter(bool Is64Bit_, bool IsEmscripten); |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 27 | |
| 28 | public: |
| 29 | virtual ~MCWasmObjectTargetWriter(); |
| 30 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 31 | Triple::ObjectFormatType getFormat() const override { return Triple::Wasm; } |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 32 | static bool classof(const MCObjectTargetWriter *W) { |
| 33 | return W->getFormat() == Triple::Wasm; |
| 34 | } |
| 35 | |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 36 | virtual unsigned getRelocType(const MCValue &Target, |
| 37 | const MCFixup &Fixup) const = 0; |
| 38 | |
| 39 | /// \name Accessors |
| 40 | /// @{ |
| 41 | bool is64Bit() const { return Is64Bit; } |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 42 | bool isEmscripten() const { return IsEmscripten; } |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 43 | /// @} |
| 44 | }; |
| 45 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame] | 46 | /// Construct a new Wasm writer instance. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 47 | /// |
| 48 | /// \param MOTW - The target specific Wasm writer subclass. |
| 49 | /// \param OS - The stream to write to. |
| 50 | /// \returns The constructed object writer. |
| 51 | std::unique_ptr<MCObjectWriter> |
| 52 | createWasmObjectWriter(std::unique_ptr<MCWasmObjectTargetWriter> MOTW, |
| 53 | raw_pwrite_stream &OS); |
| 54 | |
Olivier Deprez | f4ef2d0 | 2021-04-20 13:36:24 +0200 | [diff] [blame] | 55 | std::unique_ptr<MCObjectWriter> |
| 56 | createWasmDwoObjectWriter(std::unique_ptr<MCWasmObjectTargetWriter> MOTW, |
| 57 | raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS); |
| 58 | |
Andrew Scull | 0372a57 | 2018-11-16 15:47:06 +0000 | [diff] [blame] | 59 | } // namespace llvm |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 60 | |
| 61 | #endif |