blob: 2d4eaf9662e8d4a23e217c8c42b1238d0b763e30 [file] [log] [blame]
Sam Cleggc94d3932017-11-17 18:14:09 +00001//===- WriterUtils.h --------------------------------------------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Sam Cleggc94d3932017-11-17 18:14:09 +00006//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLD_WASM_WRITERUTILS_H
10#define LLD_WASM_WRITERUTILS_H
11
Rui Ueyama11842532018-02-16 20:38:00 +000012#include "lld/Common/LLVM.h"
Sam Cleggc94d3932017-11-17 18:14:09 +000013#include "llvm/ADT/Twine.h"
14#include "llvm/Object/Wasm.h"
Sam Cleggc94d3932017-11-17 18:14:09 +000015
16namespace lld {
17namespace wasm {
18
Rui Ueyama136d27a2019-07-11 05:40:30 +000019void debugWrite(uint64_t offset, const Twine &msg);
Sam Cleggc94d3932017-11-17 18:14:09 +000020
Rui Ueyama136d27a2019-07-11 05:40:30 +000021void writeUleb128(raw_ostream &os, uint32_t number, const Twine &msg);
Sam Cleggc94d3932017-11-17 18:14:09 +000022
Rui Ueyama136d27a2019-07-11 05:40:30 +000023void writeSleb128(raw_ostream &os, int32_t number, const Twine &msg);
Sam Cleggc94d3932017-11-17 18:14:09 +000024
Rui Ueyama136d27a2019-07-11 05:40:30 +000025void writeBytes(raw_ostream &os, const char *bytes, size_t count,
26 const Twine &msg);
Sam Cleggc94d3932017-11-17 18:14:09 +000027
Rui Ueyama136d27a2019-07-11 05:40:30 +000028void writeStr(raw_ostream &os, StringRef string, const Twine &msg);
Sam Cleggc94d3932017-11-17 18:14:09 +000029
Rui Ueyama136d27a2019-07-11 05:40:30 +000030void writeU8(raw_ostream &os, uint8_t byte, const Twine &msg);
Sam Cleggc94d3932017-11-17 18:14:09 +000031
Rui Ueyama136d27a2019-07-11 05:40:30 +000032void writeU32(raw_ostream &os, uint32_t number, const Twine &msg);
Sam Cleggc94d3932017-11-17 18:14:09 +000033
Rui Ueyama136d27a2019-07-11 05:40:30 +000034void writeValueType(raw_ostream &os, llvm::wasm::ValType type,
35 const Twine &msg);
Sam Cleggc94d3932017-11-17 18:14:09 +000036
Rui Ueyama136d27a2019-07-11 05:40:30 +000037void writeSig(raw_ostream &os, const llvm::wasm::WasmSignature &sig);
Sam Cleggc94d3932017-11-17 18:14:09 +000038
Rui Ueyama136d27a2019-07-11 05:40:30 +000039void writeInitExpr(raw_ostream &os, const llvm::wasm::WasmInitExpr &initExpr);
Sam Cleggc94d3932017-11-17 18:14:09 +000040
Rui Ueyama136d27a2019-07-11 05:40:30 +000041void writeLimits(raw_ostream &os, const llvm::wasm::WasmLimits &limits);
Sam Cleggc94d3932017-11-17 18:14:09 +000042
Rui Ueyama136d27a2019-07-11 05:40:30 +000043void writeGlobalType(raw_ostream &os, const llvm::wasm::WasmGlobalType &type);
Sam Clegg1a9b7b92018-01-31 19:54:34 +000044
Rui Ueyama136d27a2019-07-11 05:40:30 +000045void writeGlobal(raw_ostream &os, const llvm::wasm::WasmGlobal &global);
Sam Cleggc94d3932017-11-17 18:14:09 +000046
Rui Ueyama136d27a2019-07-11 05:40:30 +000047void writeEventType(raw_ostream &os, const llvm::wasm::WasmEventType &type);
Heejin Ahne915a712018-12-08 06:17:43 +000048
Rui Ueyama136d27a2019-07-11 05:40:30 +000049void writeEvent(raw_ostream &os, const llvm::wasm::WasmEvent &event);
Heejin Ahne915a712018-12-08 06:17:43 +000050
Rui Ueyama136d27a2019-07-11 05:40:30 +000051void writeTableType(raw_ostream &os, const llvm::wasm::WasmTable &type);
Nicholas Wilson874eedd2018-03-27 17:38:51 +000052
Rui Ueyama136d27a2019-07-11 05:40:30 +000053void writeImport(raw_ostream &os, const llvm::wasm::WasmImport &import);
Sam Cleggc94d3932017-11-17 18:14:09 +000054
Rui Ueyama136d27a2019-07-11 05:40:30 +000055void writeExport(raw_ostream &os, const llvm::wasm::WasmExport &export_);
Sam Cleggc94d3932017-11-17 18:14:09 +000056
Sam Cleggc94d3932017-11-17 18:14:09 +000057} // namespace wasm
Sam Cleggb8621592017-11-30 01:40:08 +000058
Rui Ueyama136d27a2019-07-11 05:40:30 +000059std::string toString(llvm::wasm::ValType type);
60std::string toString(const llvm::wasm::WasmSignature &sig);
61std::string toString(const llvm::wasm::WasmGlobalType &type);
62std::string toString(const llvm::wasm::WasmEventType &type);
Sam Cleggb8621592017-11-30 01:40:08 +000063
Sam Cleggc94d3932017-11-17 18:14:09 +000064} // namespace lld
65
66#endif // LLD_WASM_WRITERUTILS_H