forked from OSchip/llvm-project
[WebAssembly] Use Twine rather than StringRef for logging messages
Also add missing tracing to writeU8. Differential Revision: https://reviews.llvm.org/D43919 llvm-svn: 326398
This commit is contained in:
parent
b735004615
commit
ea397f67e3
|
@ -40,37 +40,40 @@ void wasm::debugWrite(uint64_t Offset, const Twine &Msg) {
|
||||||
DEBUG(dbgs() << format(" | %08lld: ", Offset) << Msg << "\n");
|
DEBUG(dbgs() << format(" | %08lld: ", Offset) << Msg << "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void wasm::writeUleb128(raw_ostream &OS, uint32_t Number, StringRef Msg) {
|
void wasm::writeUleb128(raw_ostream &OS, uint32_t Number, const Twine &Msg) {
|
||||||
debugWrite(OS.tell(), Msg + "[" + utohexstr(Number) + "]");
|
debugWrite(OS.tell(), Msg + "[" + utohexstr(Number) + "]");
|
||||||
encodeULEB128(Number, OS);
|
encodeULEB128(Number, OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wasm::writeSleb128(raw_ostream &OS, int32_t Number, StringRef Msg) {
|
void wasm::writeSleb128(raw_ostream &OS, int32_t Number, const Twine &Msg) {
|
||||||
debugWrite(OS.tell(), Msg + "[" + utohexstr(Number) + "]");
|
debugWrite(OS.tell(), Msg + "[" + utohexstr(Number) + "]");
|
||||||
encodeSLEB128(Number, OS);
|
encodeSLEB128(Number, OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wasm::writeBytes(raw_ostream &OS, const char *Bytes, size_t Count,
|
void wasm::writeBytes(raw_ostream &OS, const char *Bytes, size_t Count,
|
||||||
StringRef Msg) {
|
const Twine &Msg) {
|
||||||
debugWrite(OS.tell(), Msg + " [data[" + Twine(Count) + "]]");
|
debugWrite(OS.tell(), Msg + " [data[" + Twine(Count) + "]]");
|
||||||
OS.write(Bytes, Count);
|
OS.write(Bytes, Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wasm::writeStr(raw_ostream &OS, StringRef String, StringRef Msg) {
|
void wasm::writeStr(raw_ostream &OS, StringRef String, const Twine &Msg) {
|
||||||
debugWrite(OS.tell(),
|
debugWrite(OS.tell(),
|
||||||
Msg + " [str[" + Twine(String.size()) + "]: " + String + "]");
|
Msg + " [str[" + Twine(String.size()) + "]: " + String + "]");
|
||||||
encodeULEB128(String.size(), OS);
|
encodeULEB128(String.size(), OS);
|
||||||
OS.write(String.data(), String.size());
|
OS.write(String.data(), String.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void wasm::writeU8(raw_ostream &OS, uint8_t Byte, StringRef Msg) { OS << Byte; }
|
void wasm::writeU8(raw_ostream &OS, uint8_t Byte, const Twine &Msg) {
|
||||||
|
debugWrite(OS.tell(), Msg + " [0x" + utohexstr(Byte) + "]");
|
||||||
|
OS << Byte;
|
||||||
|
}
|
||||||
|
|
||||||
void wasm::writeU32(raw_ostream &OS, uint32_t Number, StringRef Msg) {
|
void wasm::writeU32(raw_ostream &OS, uint32_t Number, const Twine &Msg) {
|
||||||
debugWrite(OS.tell(), Msg + "[" + utohexstr(Number) + "]");
|
debugWrite(OS.tell(), Msg + "[0x" + utohexstr(Number) + "]");
|
||||||
support::endian::Writer<support::little>(OS).write(Number);
|
support::endian::Writer<support::little>(OS).write(Number);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wasm::writeValueType(raw_ostream &OS, int32_t Type, StringRef Msg) {
|
void wasm::writeValueType(raw_ostream &OS, int32_t Type, const Twine &Msg) {
|
||||||
debugWrite(OS.tell(), Msg + "[type: " + valueTypeToString(Type) + "]");
|
debugWrite(OS.tell(), Msg + "[type: " + valueTypeToString(Type) + "]");
|
||||||
encodeSLEB128(Type, OS);
|
encodeSLEB128(Type, OS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,19 +44,20 @@ namespace wasm {
|
||||||
|
|
||||||
void debugWrite(uint64_t Offset, const Twine &Msg);
|
void debugWrite(uint64_t Offset, const Twine &Msg);
|
||||||
|
|
||||||
void writeUleb128(raw_ostream &OS, uint32_t Number, StringRef Msg);
|
void writeUleb128(raw_ostream &OS, uint32_t Number, const Twine &Msg);
|
||||||
|
|
||||||
void writeSleb128(raw_ostream &OS, int32_t Number, StringRef Msg);
|
void writeSleb128(raw_ostream &OS, int32_t Number, const Twine &Msg);
|
||||||
|
|
||||||
void writeBytes(raw_ostream &OS, const char *Bytes, size_t count, StringRef Msg);
|
void writeBytes(raw_ostream &OS, const char *Bytes, size_t count,
|
||||||
|
const Twine &Msg);
|
||||||
|
|
||||||
void writeStr(raw_ostream &OS, StringRef String, StringRef Msg);
|
void writeStr(raw_ostream &OS, StringRef String, const Twine &Msg);
|
||||||
|
|
||||||
void writeU8(raw_ostream &OS, uint8_t byte, StringRef Msg);
|
void writeU8(raw_ostream &OS, uint8_t byte, const Twine &Msg);
|
||||||
|
|
||||||
void writeU32(raw_ostream &OS, uint32_t Number, StringRef Msg);
|
void writeU32(raw_ostream &OS, uint32_t Number, const Twine &Msg);
|
||||||
|
|
||||||
void writeValueType(raw_ostream &OS, int32_t Type, StringRef Msg);
|
void writeValueType(raw_ostream &OS, int32_t Type, const Twine &Msg);
|
||||||
|
|
||||||
void writeSig(raw_ostream &OS, const llvm::wasm::WasmSignature &Sig);
|
void writeSig(raw_ostream &OS, const llvm::wasm::WasmSignature &Sig);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue