brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.4 KiB · 2be79d1 Raw
77 lines · c
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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLD_WASM_WRITERUTILS_H10#define LLD_WASM_WRITERUTILS_H11 12#include "lld/Common/LLVM.h"13#include "llvm/ADT/Twine.h"14#include "llvm/Object/Wasm.h"15 16namespace lld {17namespace wasm {18 19#ifdef LLVM_DEBUG20void debugWrite(uint64_t offset, const Twine &msg);21#else22#define debugWrite(...) (void *)023#endif24 25void writeUleb128(raw_ostream &os, uint64_t number, const Twine &msg);26 27void writeSleb128(raw_ostream &os, int64_t number, const Twine &msg);28 29void writeBytes(raw_ostream &os, const char *bytes, size_t count,30                const Twine &msg);31 32void writeStr(raw_ostream &os, StringRef string, const Twine &msg);33 34void writeU8(raw_ostream &os, uint8_t byte, const Twine &msg);35 36void writeU32(raw_ostream &os, uint32_t number, const Twine &msg);37 38void writeValueType(raw_ostream &os, llvm::wasm::ValType type,39                    const Twine &msg);40 41void writeSig(raw_ostream &os, const llvm::wasm::WasmSignature &sig);42 43void writeI32Const(raw_ostream &os, int32_t number, const Twine &msg);44 45void writeI64Const(raw_ostream &os, int64_t number, const Twine &msg);46 47void writePtrConst(raw_ostream &os, int64_t number, bool is64,48                   const Twine &msg);49 50void writeMemArg(raw_ostream &os, uint32_t alignment, uint64_t offset);51 52void writeInitExpr(raw_ostream &os, const llvm::wasm::WasmInitExpr &initExpr);53 54void writeInitExprMVP(raw_ostream &os,55                      const llvm::wasm::WasmInitExprMVP &initExpr);56 57void writeLimits(raw_ostream &os, const llvm::wasm::WasmLimits &limits);58 59void writeGlobalType(raw_ostream &os, const llvm::wasm::WasmGlobalType &type);60 61void writeTableType(raw_ostream &os, const llvm::wasm::WasmTableType &type);62 63void writeImport(raw_ostream &os, const llvm::wasm::WasmImport &import);64 65void writeExport(raw_ostream &os, const llvm::wasm::WasmExport &export_);66 67} // namespace wasm68 69std::string toString(llvm::wasm::ValType type);70std::string toString(const llvm::wasm::WasmSignature &sig);71std::string toString(const llvm::wasm::WasmGlobalType &type);72std::string toString(const llvm::wasm::WasmTableType &type);73 74} // namespace lld75 76#endif // LLD_WASM_WRITERUTILS_H77