Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions mlir/lib/Bytecode/Writer/BytecodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/DebugLog.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/raw_ostream.h"
#include <optional>
Expand Down Expand Up @@ -150,8 +151,7 @@ class EncodingEmitter {

/// Backpatch a byte in the result buffer at the given offset.
void patchByte(uint64_t offset, uint8_t value, StringLiteral desc) {
LLVM_DEBUG(llvm::dbgs() << "patchByte(" << offset << ',' << uint64_t(value)
<< ")\t" << desc << '\n');
LDBG() << "patchByte(" << offset << ',' << uint64_t(value) << ")\t" << desc;
assert(offset < size() && offset >= prevResultSize &&
"cannot patch previously emitted data");
currentResult[offset - prevResultSize] = value;
Expand All @@ -160,8 +160,7 @@ class EncodingEmitter {
/// Emit the provided blob of data, which is owned by the caller and is
/// guaranteed to not die before the end of the bytecode process.
void emitOwnedBlob(ArrayRef<uint8_t> data, StringLiteral desc) {
LLVM_DEBUG(llvm::dbgs()
<< "emitOwnedBlob(" << data.size() << "b)\t" << desc << '\n');
LDBG() << "emitOwnedBlob(" << data.size() << "b)\t" << desc;
// Push the current buffer before adding the provided data.
appendResult(std::move(currentResult));
appendOwnedResult(data);
Expand Down Expand Up @@ -209,15 +208,13 @@ class EncodingEmitter {
/// Emit a single byte.
template <typename T>
void emitByte(T byte, StringLiteral desc) {
LLVM_DEBUG(llvm::dbgs()
<< "emitByte(" << uint64_t(byte) << ")\t" << desc << '\n');
LDBG() << "emitByte(" << uint64_t(byte) << ")\t" << desc;
currentResult.push_back(static_cast<uint8_t>(byte));
}

/// Emit a range of bytes.
void emitBytes(ArrayRef<uint8_t> bytes, StringLiteral desc) {
LLVM_DEBUG(llvm::dbgs()
<< "emitBytes(" << bytes.size() << "b)\t" << desc << '\n');
LDBG() << "emitBytes(" << bytes.size() << "b)\t" << desc;
llvm::append_range(currentResult, bytes);
}

Expand All @@ -229,7 +226,7 @@ class EncodingEmitter {
/// additional bytes, provide the value of the integer encoded in
/// little-endian order.
void emitVarInt(uint64_t value, StringLiteral desc) {
LLVM_DEBUG(llvm::dbgs() << "emitVarInt(" << value << ")\t" << desc << '\n');
LDBG() << "emitVarInt(" << value << ")\t" << desc;

// In the most common case, the value can be represented in a single byte.
// Given how hot this case is, explicitly handle that here.
Expand Down