LLVM  14.0.0git
MCWasmObjectWriter.h
Go to the documentation of this file.
1 //===-- llvm/MC/MCWasmObjectWriter.h - Wasm Object Writer -------*- 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 
9 #ifndef LLVM_MC_MCWASMOBJECTWRITER_H
10 #define LLVM_MC_MCWASMOBJECTWRITER_H
11 
12 #include "llvm/MC/MCObjectWriter.h"
13 #include <memory>
14 
15 namespace llvm {
16 
17 class MCFixup;
18 class MCSectionWasm;
19 class MCValue;
20 class raw_pwrite_stream;
21 
23  const unsigned Is64Bit : 1;
24  const unsigned IsEmscripten : 1;
25 
26 protected:
27  explicit MCWasmObjectTargetWriter(bool Is64Bit_, bool IsEmscripten);
28 
29 public:
30  virtual ~MCWasmObjectTargetWriter();
31 
32  Triple::ObjectFormatType getFormat() const override { return Triple::Wasm; }
33  static bool classof(const MCObjectTargetWriter *W) {
34  return W->getFormat() == Triple::Wasm;
35  }
36 
37  virtual unsigned getRelocType(const MCValue &Target, const MCFixup &Fixup,
38  const MCSectionWasm &FixupSection,
39  bool IsLocRel) const = 0;
40 
41  /// \name Accessors
42  /// @{
43  bool is64Bit() const { return Is64Bit; }
44  bool isEmscripten() const { return IsEmscripten; }
45  /// @}
46 };
47 
48 /// Construct a new Wasm writer instance.
49 ///
50 /// \param MOTW - The target specific Wasm writer subclass.
51 /// \param OS - The stream to write to.
52 /// \returns The constructed object writer.
53 std::unique_ptr<MCObjectWriter>
54 createWasmObjectWriter(std::unique_ptr<MCWasmObjectTargetWriter> MOTW,
55  raw_pwrite_stream &OS);
56 
57 std::unique_ptr<MCObjectWriter>
58 createWasmDwoObjectWriter(std::unique_ptr<MCWasmObjectTargetWriter> MOTW,
59  raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS);
60 
61 } // namespace llvm
62 
63 #endif
llvm::Triple::Wasm
@ Wasm
Definition: Triple.h:241
llvm::MCWasmObjectTargetWriter::isEmscripten
bool isEmscripten() const
Definition: MCWasmObjectWriter.h:44
llvm::MCWasmObjectTargetWriter::getRelocType
virtual unsigned getRelocType(const MCValue &Target, const MCFixup &Fixup, const MCSectionWasm &FixupSection, bool IsLocRel) const =0
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::createWasmObjectWriter
std::unique_ptr< MCObjectWriter > createWasmObjectWriter(std::unique_ptr< MCWasmObjectTargetWriter > MOTW, raw_pwrite_stream &OS)
Construct a new Wasm writer instance.
Definition: WasmObjectWriter.cpp:1949
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:137
llvm::RISCVFenceField::W
@ W
Definition: RISCVBaseInfo.h:199
llvm::MCWasmObjectTargetWriter::~MCWasmObjectTargetWriter
virtual ~MCWasmObjectTargetWriter()
llvm::MCWasmObjectTargetWriter
Definition: MCWasmObjectWriter.h:22
llvm::MCObjectTargetWriter
Base class for classes that define behaviour that is specific to both the target and the object forma...
Definition: MCObjectWriter.h:112
llvm::MCSectionWasm
This represents a section on wasm.
Definition: MCSectionWasm.h:26
llvm::MCWasmObjectTargetWriter::MCWasmObjectTargetWriter
MCWasmObjectTargetWriter(bool Is64Bit_, bool IsEmscripten)
Definition: MCWasmObjectTargetWriter.cpp:13
llvm::MCWasmObjectTargetWriter::getFormat
Triple::ObjectFormatType getFormat() const override
Definition: MCWasmObjectWriter.h:32
llvm::Triple::ObjectFormatType
ObjectFormatType
Definition: Triple.h:234
llvm::MCWasmObjectTargetWriter::is64Bit
bool is64Bit() const
Definition: MCWasmObjectWriter.h:43
MCObjectWriter.h
llvm::MCWasmObjectTargetWriter::classof
static bool classof(const MCObjectTargetWriter *W)
Definition: MCWasmObjectWriter.h:33
llvm::createWasmDwoObjectWriter
std::unique_ptr< MCObjectWriter > createWasmDwoObjectWriter(std::unique_ptr< MCWasmObjectTargetWriter > MOTW, raw_pwrite_stream &OS, raw_pwrite_stream &DwoOS)
Definition: WasmObjectWriter.cpp:1955
llvm::MCValue
This represents an "assembler immediate".
Definition: MCValue.h:37
llvm::MCFixup
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:71