[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / llvm / lib / Support / ScopedPrinter.cpp
bloba17e397c0aa581f984b6022620390fbfca15adfe
1 #include "llvm/Support/ScopedPrinter.h"
3 #include "llvm/Support/Format.h"
5 using namespace llvm::support;
7 namespace llvm {
9 raw_ostream &operator<<(raw_ostream &OS, const HexNumber &Value) {
10 OS << "0x" << utohexstr(Value.Value);
11 return OS;
14 void ScopedPrinter::printBinaryImpl(StringRef Label, StringRef Str,
15 ArrayRef<uint8_t> Data, bool Block,
16 uint32_t StartOffset) {
17 if (Data.size() > 16)
18 Block = true;
20 if (Block) {
21 startLine() << Label;
22 if (!Str.empty())
23 OS << ": " << Str;
24 OS << " (\n";
25 if (!Data.empty())
26 OS << format_bytes_with_ascii(Data, StartOffset, 16, 4,
27 (IndentLevel + 1) * 2, true)
28 << "\n";
29 startLine() << ")\n";
30 } else {
31 startLine() << Label << ":";
32 if (!Str.empty())
33 OS << " " << Str;
34 OS << " (" << format_bytes(Data, std::nullopt, Data.size(), 1, 0, true)
35 << ")\n";
39 JSONScopedPrinter::JSONScopedPrinter(
40 raw_ostream &OS, bool PrettyPrint,
41 std::unique_ptr<DelimitedScope> &&OuterScope)
42 : ScopedPrinter(OS, ScopedPrinter::ScopedPrinterKind::JSON),
43 JOS(OS, /*Indent=*/PrettyPrint ? 2 : 0),
44 OuterScope(std::move(OuterScope)) {
45 if (this->OuterScope)
46 this->OuterScope->setPrinter(*this);
49 } // namespace llvm