2017-11-17 18:14:09 +00:00
|
|
|
//===- WriterUtils.h --------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 08:50:56 +00: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-17 18:14:09 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLD_WASM_WRITERUTILS_H
|
|
|
|
#define LLD_WASM_WRITERUTILS_H
|
|
|
|
|
2018-02-16 20:38:00 +00:00
|
|
|
#include "lld/Common/LLVM.h"
|
2017-11-17 18:14:09 +00:00
|
|
|
#include "llvm/ADT/Twine.h"
|
|
|
|
#include "llvm/Object/Wasm.h"
|
|
|
|
|
|
|
|
namespace lld {
|
|
|
|
namespace wasm {
|
|
|
|
|
2021-09-10 04:46:03 -04:00
|
|
|
#ifdef LLVM_DEBUG
|
2018-02-16 20:38:00 +00:00
|
|
|
void debugWrite(uint64_t offset, const Twine &msg);
|
2021-09-10 04:46:03 -04:00
|
|
|
#else
|
|
|
|
#define debugWrite(...) (void *)0
|
|
|
|
#endif
|
2017-11-17 18:14:09 +00:00
|
|
|
|
2020-06-05 09:03:12 -07:00
|
|
|
void writeUleb128(raw_ostream &os, uint64_t number, const Twine &msg);
|
2017-11-17 18:14:09 +00:00
|
|
|
|
2020-06-05 09:03:12 -07:00
|
|
|
void writeSleb128(raw_ostream &os, int64_t number, const Twine &msg);
|
2017-11-17 18:14:09 +00:00
|
|
|
|
2018-03-01 00:42:57 +00:00
|
|
|
void writeBytes(raw_ostream &os, const char *bytes, size_t count,
|
|
|
|
const Twine &msg);
|
2017-11-17 18:14:09 +00:00
|
|
|
|
2018-03-01 00:42:57 +00:00
|
|
|
void writeStr(raw_ostream &os, StringRef string, const Twine &msg);
|
2017-11-17 18:14:09 +00:00
|
|
|
|
2018-03-01 00:42:57 +00:00
|
|
|
void writeU8(raw_ostream &os, uint8_t byte, const Twine &msg);
|
2017-11-17 18:14:09 +00:00
|
|
|
|
2018-03-01 00:42:57 +00:00
|
|
|
void writeU32(raw_ostream &os, uint32_t number, const Twine &msg);
|
2017-11-17 18:14:09 +00:00
|
|
|
|
2018-10-03 22:25:32 +00:00
|
|
|
void writeValueType(raw_ostream &os, llvm::wasm::ValType type,
|
|
|
|
const Twine &msg);
|
2017-11-17 18:14:09 +00:00
|
|
|
|
|
|
|
void writeSig(raw_ostream &os, const llvm::wasm::WasmSignature &sig);
|
|
|
|
|
2019-09-04 19:50:39 +00:00
|
|
|
void writeI32Const(raw_ostream &os, int32_t number, const Twine &msg);
|
|
|
|
|
2020-06-05 09:03:12 -07:00
|
|
|
void writeI64Const(raw_ostream &os, int64_t number, const Twine &msg);
|
2019-09-04 19:50:39 +00:00
|
|
|
|
2020-11-30 14:00:34 -08:00
|
|
|
void writePtrConst(raw_ostream &os, int64_t number, bool is64,
|
|
|
|
const Twine &msg);
|
|
|
|
|
2020-06-05 09:03:12 -07:00
|
|
|
void writeMemArg(raw_ostream &os, uint32_t alignment, uint64_t offset);
|
2019-09-04 19:50:39 +00:00
|
|
|
|
2017-11-17 18:14:09 +00:00
|
|
|
void writeInitExpr(raw_ostream &os, const llvm::wasm::WasmInitExpr &initExpr);
|
|
|
|
|
2022-03-09 18:11:44 -08:00
|
|
|
void writeInitExprMVP(raw_ostream &os,
|
|
|
|
const llvm::wasm::WasmInitExprMVP &initExpr);
|
|
|
|
|
2017-11-17 18:14:09 +00:00
|
|
|
void writeLimits(raw_ostream &os, const llvm::wasm::WasmLimits &limits);
|
|
|
|
|
2018-01-31 19:54:34 +00:00
|
|
|
void writeGlobalType(raw_ostream &os, const llvm::wasm::WasmGlobalType &type);
|
|
|
|
|
2020-11-25 07:54:31 -08:00
|
|
|
void writeTableType(raw_ostream &os, const llvm::wasm::WasmTableType &type);
|
2018-03-27 17:38:51 +00:00
|
|
|
|
2017-11-17 18:14:09 +00: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 01:40:08 +00:00
|
|
|
|
2018-03-14 15:58:16 +00:00
|
|
|
std::string toString(llvm::wasm::ValType type);
|
2017-11-30 01:40:08 +00:00
|
|
|
std::string toString(const llvm::wasm::WasmSignature &sig);
|
2018-12-08 06:17:43 +00:00
|
|
|
std::string toString(const llvm::wasm::WasmGlobalType &type);
|
2021-01-05 12:08:58 +01:00
|
|
|
std::string toString(const llvm::wasm::WasmTableType &type);
|
2017-11-30 01:40:08 +00:00
|
|
|
|
2017-11-17 18:14:09 +00:00
|
|
|
} // namespace lld
|
|
|
|
|
|
|
|
#endif // LLD_WASM_WRITERUTILS_H
|