2017-11-18 02:14:09 +08:00
|
|
|
//===- WriterUtils.h --------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-11-18 02:14:09 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_WASM_WRITERUTILS_H
|
|
|
|
#define LLD_WASM_WRITERUTILS_H
|
|
|
|
|
2018-02-17 04:38:00 +08:00
|
|
|
#include "lld/Common/LLVM.h"
|
2017-11-18 02:14:09 +08:00
|
|
|
#include "llvm/ADT/Twine.h"
|
|
|
|
#include "llvm/Object/Wasm.h"
|
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace wasm {
|
|
|
|
|
2021-09-10 16:46:03 +08:00
|
|
|
#ifdef LLVM_DEBUG
|
2018-02-17 04:38:00 +08:00
|
|
|
void debugWrite(uint64_t offset, const Twine &msg);
|
2021-09-10 16:46:03 +08:00
|
|
|
#else
|
|
|
|
#define debugWrite(...) (void *)0
|
|
|
|
#endif
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2020-06-06 00:03:12 +08:00
|
|
|
void writeUleb128(raw_ostream &os, uint64_t number, const Twine &msg);
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2020-06-06 00:03:12 +08:00
|
|
|
void writeSleb128(raw_ostream &os, int64_t number, const Twine &msg);
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-03-01 08:42:57 +08:00
|
|
|
void writeBytes(raw_ostream &os, const char *bytes, size_t count,
|
|
|
|
const Twine &msg);
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-03-01 08:42:57 +08:00
|
|
|
void writeStr(raw_ostream &os, StringRef string, const Twine &msg);
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-03-01 08:42:57 +08:00
|
|
|
void writeU8(raw_ostream &os, uint8_t byte, const Twine &msg);
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-03-01 08:42:57 +08:00
|
|
|
void writeU32(raw_ostream &os, uint32_t number, const Twine &msg);
|
2017-11-18 02:14:09 +08:00
|
|
|
|
2018-10-04 06:25:32 +08:00
|
|
|
void writeValueType(raw_ostream &os, llvm::wasm::ValType type,
|
|
|
|
const Twine &msg);
|
2017-11-18 02:14:09 +08:00
|
|
|
|
|
|
|
void writeSig(raw_ostream &os, const llvm::wasm::WasmSignature &sig);
|
|
|
|
|
2019-09-05 03:50:39 +08:00
|
|
|
void writeI32Const(raw_ostream &os, int32_t number, const Twine &msg);
|
|
|
|
|
2020-06-06 00:03:12 +08:00
|
|
|
void writeI64Const(raw_ostream &os, int64_t number, const Twine &msg);
|
2019-09-05 03:50:39 +08:00
|
|
|
|
2020-12-01 06:00:34 +08:00
|
|
|
void writePtrConst(raw_ostream &os, int64_t number, bool is64,
|
|
|
|
const Twine &msg);
|
|
|
|
|
2020-06-06 00:03:12 +08:00
|
|
|
void writeMemArg(raw_ostream &os, uint32_t alignment, uint64_t offset);
|
2019-09-05 03:50:39 +08:00
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
void writeInitExpr(raw_ostream &os, const llvm::wasm::WasmInitExpr &initExpr);
|
|
|
|
|
2022-03-10 10:11:44 +08:00
|
|
|
void writeInitExprMVP(raw_ostream &os,
|
|
|
|
const llvm::wasm::WasmInitExprMVP &initExpr);
|
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
void writeLimits(raw_ostream &os, const llvm::wasm::WasmLimits &limits);
|
|
|
|
|
2018-02-01 03:54:34 +08:00
|
|
|
void writeGlobalType(raw_ostream &os, const llvm::wasm::WasmGlobalType &type);
|
|
|
|
|
2020-11-25 23:54:31 +08:00
|
|
|
void writeTableType(raw_ostream &os, const llvm::wasm::WasmTableType &type);
|
2018-03-28 01:38:51 +08:00
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
void writeImport(raw_ostream &os, const llvm::wasm::WasmImport &import);
|
|
|
|
|
|
|
|
void writeExport(raw_ostream &os, const llvm::wasm::WasmExport &export_);
|
|
|
|
|
|
|
|
} // namespace wasm
|
2017-11-30 09:40:08 +08:00
|
|
|
|
2018-03-14 23:58:16 +08:00
|
|
|
std::string toString(llvm::wasm::ValType type);
|
2017-11-30 09:40:08 +08:00
|
|
|
std::string toString(const llvm::wasm::WasmSignature &sig);
|
2018-12-08 14:17:43 +08:00
|
|
|
std::string toString(const llvm::wasm::WasmGlobalType &type);
|
2021-01-05 19:08:58 +08:00
|
|
|
std::string toString(const llvm::wasm::WasmTableType &type);
|
2017-11-30 09:40:08 +08:00
|
|
|
|
2017-11-18 02:14:09 +08:00
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif // LLD_WASM_WRITERUTILS_H
|