LLVM 22.0.0git
ScopedPrinter.cpp
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
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-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "llvm/Support/Format.h"
11
12using namespace llvm;
13
15 OS << "0x" << utohexstr(Value.Value);
16 return OS;
17}
18
19void ScopedPrinter::printBinaryImpl(StringRef Label, StringRef Str,
21 uint32_t StartOffset) {
22 if (Data.size() > 16)
23 Block = true;
24
25 if (Block) {
26 startLine() << Label;
27 if (!Str.empty())
28 OS << ": " << Str;
29 OS << " (\n";
30 if (!Data.empty())
31 OS << format_bytes_with_ascii(Data, StartOffset, 16, 4,
32 (IndentLevel + 1) * 2, true)
33 << "\n";
34 startLine() << ")\n";
35 } else {
36 startLine() << Label << ":";
37 if (!Str.empty())
38 OS << " " << Str;
39 OS << " (" << format_bytes(Data, std::nullopt, Data.size(), 1, 0, true)
40 << ")\n";
41 }
42}
43
45 raw_ostream &OS, bool PrettyPrint,
46 std::unique_ptr<DelimitedScope> &&OuterScope)
48 JOS(OS, /*Indent=*/PrettyPrint ? 2 : 0),
49 OuterScope(std::move(OuterScope)) {
50 if (this->OuterScope)
51 this->OuterScope->setPrinter(*this);
52}
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:41
LLVM_ABI JSONScopedPrinter(raw_ostream &OS, bool PrettyPrint=false, std::unique_ptr< DelimitedScope > &&OuterScope=std::unique_ptr< DelimitedScope >{})
ScopedPrinter(raw_ostream &OS, ScopedPrinterKind Kind=ScopedPrinterKind::Base)
virtual raw_ostream & startLine()
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
LLVM Value Representation.
Definition Value.h:75
LLVM_ABI Value(Type *Ty, unsigned scid)
Definition Value.cpp:53
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
std::string utohexstr(uint64_t X, bool LowerCase=false, unsigned Width=0)
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition InstrProf.h:189
FormattedBytes format_bytes_with_ascii(ArrayRef< uint8_t > Bytes, std::optional< uint64_t > FirstByteOffset=std::nullopt, uint32_t NumPerLine=16, uint8_t ByteGroupSize=4, uint32_t IndentLevel=0, bool Upper=false)
Definition Format.h:243
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1847
FormattedBytes format_bytes(ArrayRef< uint8_t > Bytes, std::optional< uint64_t > FirstByteOffset=std::nullopt, uint32_t NumPerLine=16, uint8_t ByteGroupSize=4, uint32_t IndentLevel=0, bool Upper=false)
Definition Format.h:234
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:870