• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLD_WASM_WRITERUTILS_H
10 #define LLD_WASM_WRITERUTILS_H
11 
12 #include "lld/Common/LLVM.h"
13 #include "llvm/ADT/Twine.h"
14 #include "llvm/Object/Wasm.h"
15 
16 namespace lld {
17 namespace wasm {
18 
19 void debugWrite(uint64_t offset, const Twine &msg);
20 
21 void writeUleb128(raw_ostream &os, uint64_t number, const Twine &msg);
22 
23 void writeSleb128(raw_ostream &os, int64_t number, const Twine &msg);
24 
25 void writeBytes(raw_ostream &os, const char *bytes, size_t count,
26                 const Twine &msg);
27 
28 void writeStr(raw_ostream &os, StringRef string, const Twine &msg);
29 
30 void writeU8(raw_ostream &os, uint8_t byte, const Twine &msg);
31 
32 void writeU32(raw_ostream &os, uint32_t number, const Twine &msg);
33 
34 void writeValueType(raw_ostream &os, llvm::wasm::ValType type,
35                     const Twine &msg);
36 
37 void writeSig(raw_ostream &os, const llvm::wasm::WasmSignature &sig);
38 
39 void writeI32Const(raw_ostream &os, int32_t number, const Twine &msg);
40 
41 void writeI64Const(raw_ostream &os, int64_t number, const Twine &msg);
42 
43 void writePtrConst(raw_ostream &os, int64_t number, bool is64,
44                    const Twine &msg);
45 
46 void writeMemArg(raw_ostream &os, uint32_t alignment, uint64_t offset);
47 
48 void writeInitExpr(raw_ostream &os, const llvm::wasm::WasmInitExpr &initExpr);
49 
50 void writeLimits(raw_ostream &os, const llvm::wasm::WasmLimits &limits);
51 
52 void writeGlobalType(raw_ostream &os, const llvm::wasm::WasmGlobalType &type);
53 
54 void writeGlobal(raw_ostream &os, const llvm::wasm::WasmGlobal &global);
55 
56 void writeEventType(raw_ostream &os, const llvm::wasm::WasmEventType &type);
57 
58 void writeEvent(raw_ostream &os, const llvm::wasm::WasmEvent &event);
59 
60 void writeTableType(raw_ostream &os, const llvm::wasm::WasmTableType &type);
61 
62 void writeImport(raw_ostream &os, const llvm::wasm::WasmImport &import);
63 
64 void writeExport(raw_ostream &os, const llvm::wasm::WasmExport &export_);
65 
66 } // namespace wasm
67 
68 std::string toString(llvm::wasm::ValType type);
69 std::string toString(const llvm::wasm::WasmSignature &sig);
70 std::string toString(const llvm::wasm::WasmGlobalType &type);
71 std::string toString(const llvm::wasm::WasmEventType &type);
72 
73 } // namespace lld
74 
75 #endif // LLD_WASM_WRITERUTILS_H
76