Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 1 | //===-- llvm/MC/MCWasmObjectWriter.h - Wasm Object Writer -------*- 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 | |
| 10 | #ifndef LLVM_MC_MCWASMOBJECTWRITER_H |
| 11 | #define LLVM_MC_MCWASMOBJECTWRITER_H |
| 12 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 13 | #include "llvm/MC/MCObjectWriter.h" |
| 14 | #include <memory> |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 15 | |
| 16 | namespace llvm { |
| 17 | |
| 18 | class MCFixup; |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 19 | class MCValue; |
| 20 | class raw_pwrite_stream; |
| 21 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 22 | class MCWasmObjectTargetWriter : public MCObjectTargetWriter { |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 23 | const unsigned Is64Bit : 1; |
| 24 | |
| 25 | protected: |
| 26 | explicit MCWasmObjectTargetWriter(bool Is64Bit_); |
| 27 | |
| 28 | public: |
| 29 | virtual ~MCWasmObjectTargetWriter(); |
| 30 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 31 | virtual Triple::ObjectFormatType getFormat() const { return Triple::Wasm; } |
| 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; } |
| 42 | /// @} |
| 43 | }; |
| 44 | |
Andrew Scull | cdfcccc | 2018-10-05 20:58:37 +0100 | [diff] [blame^] | 45 | /// Construct a new Wasm writer instance. |
Andrew Scull | 5e1ddfa | 2018-08-14 10:06:54 +0100 | [diff] [blame] | 46 | /// |
| 47 | /// \param MOTW - The target specific Wasm writer subclass. |
| 48 | /// \param OS - The stream to write to. |
| 49 | /// \returns The constructed object writer. |
| 50 | std::unique_ptr<MCObjectWriter> |
| 51 | createWasmObjectWriter(std::unique_ptr<MCWasmObjectTargetWriter> MOTW, |
| 52 | raw_pwrite_stream &OS); |
| 53 | |
| 54 | } // End llvm namespace |
| 55 | |
| 56 | #endif |