[JITLink][arm64] Support arm64e JIT'd code (initially enabled for MachO only).
[llvm-project.git] / lld / wasm / WriterUtils.h
blob2be79d1d86e977b11fa3d42053881cb92370938e
1 //===- WriterUtils.h --------------------------------------------*- 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 //===----------------------------------------------------------------------===//
9 #ifndef LLD_WASM_WRITERUTILS_H
10 #define LLD_WASM_WRITERUTILS_H
12 #include "lld/Common/LLVM.h"
13 #include "llvm/ADT/Twine.h"
14 #include "llvm/Object/Wasm.h"
16 namespace lld {
17 namespace wasm {
19 #ifdef LLVM_DEBUG
20 void debugWrite(uint64_t offset, const Twine &msg);
21 #else
22 #define debugWrite(...) (void *)0
23 #endif
25 void writeUleb128(raw_ostream &os, uint64_t number, const Twine &msg);
27 void writeSleb128(raw_ostream &os, int64_t number, const Twine &msg);
29 void writeBytes(raw_ostream &os, const char *bytes, size_t count,
30 const Twine &msg);
32 void writeStr(raw_ostream &os, StringRef string, const Twine &msg);
34 void writeU8(raw_ostream &os, uint8_t byte, const Twine &msg);
36 void writeU32(raw_ostream &os, uint32_t number, const Twine &msg);
38 void writeValueType(raw_ostream &os, llvm::wasm::ValType type,
39 const Twine &msg);
41 void writeSig(raw_ostream &os, const llvm::wasm::WasmSignature &sig);
43 void writeI32Const(raw_ostream &os, int32_t number, const Twine &msg);
45 void writeI64Const(raw_ostream &os, int64_t number, const Twine &msg);
47 void writePtrConst(raw_ostream &os, int64_t number, bool is64,
48 const Twine &msg);
50 void writeMemArg(raw_ostream &os, uint32_t alignment, uint64_t offset);
52 void writeInitExpr(raw_ostream &os, const llvm::wasm::WasmInitExpr &initExpr);
54 void writeInitExprMVP(raw_ostream &os,
55 const llvm::wasm::WasmInitExprMVP &initExpr);
57 void writeLimits(raw_ostream &os, const llvm::wasm::WasmLimits &limits);
59 void writeGlobalType(raw_ostream &os, const llvm::wasm::WasmGlobalType &type);
61 void writeTableType(raw_ostream &os, const llvm::wasm::WasmTableType &type);
63 void writeImport(raw_ostream &os, const llvm::wasm::WasmImport &import);
65 void writeExport(raw_ostream &os, const llvm::wasm::WasmExport &export_);
67 } // namespace wasm
69 std::string toString(llvm::wasm::ValType type);
70 std::string toString(const llvm::wasm::WasmSignature &sig);
71 std::string toString(const llvm::wasm::WasmGlobalType &type);
72 std::string toString(const llvm::wasm::WasmTableType &type);
74 } // namespace lld
76 #endif // LLD_WASM_WRITERUTILS_H