blob: 4adbca28f116ea3a1e25178f4af6eb1a0cb5d729 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===-- llvm/MC/MCWasmObjectWriter.h - Wasm Object Writer -------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// 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 Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_MC_MCWASMOBJECTWRITER_H
10#define LLVM_MC_MCWASMOBJECTWRITER_H
11
Andrew Scullcdfcccc2018-10-05 20:58:37 +010012#include "llvm/MC/MCObjectWriter.h"
13#include <memory>
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010014
15namespace llvm {
16
17class MCFixup;
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010018class MCValue;
19class raw_pwrite_stream;
20
Andrew Scullcdfcccc2018-10-05 20:58:37 +010021class MCWasmObjectTargetWriter : public MCObjectTargetWriter {
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010022 const unsigned Is64Bit : 1;
23
24protected:
25 explicit MCWasmObjectTargetWriter(bool Is64Bit_);
26
27public:
28 virtual ~MCWasmObjectTargetWriter();
29
Andrew Scullcdfcccc2018-10-05 20:58:37 +010030 virtual Triple::ObjectFormatType getFormat() const { return Triple::Wasm; }
31 static bool classof(const MCObjectTargetWriter *W) {
32 return W->getFormat() == Triple::Wasm;
33 }
34
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010035 virtual unsigned getRelocType(const MCValue &Target,
36 const MCFixup &Fixup) const = 0;
37
38 /// \name Accessors
39 /// @{
40 bool is64Bit() const { return Is64Bit; }
41 /// @}
42};
43
Andrew Scullcdfcccc2018-10-05 20:58:37 +010044/// Construct a new Wasm writer instance.
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010045///
46/// \param MOTW - The target specific Wasm writer subclass.
47/// \param OS - The stream to write to.
48/// \returns The constructed object writer.
49std::unique_ptr<MCObjectWriter>
50createWasmObjectWriter(std::unique_ptr<MCWasmObjectTargetWriter> MOTW,
51 raw_pwrite_stream &OS);
52
Andrew Scull0372a572018-11-16 15:47:06 +000053} // namespace llvm
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010054
55#endif