LLVM  15.0.0git
ScopedPrinter.cpp
Go to the documentation of this file.
2 
3 #include "llvm/Support/Format.h"
4 
5 using namespace llvm::support;
6 
7 namespace llvm {
8 
10  OS << "0x" << to_hexString(Value.Value);
11  return OS;
12 }
13 
14 std::string to_hexString(uint64_t Value, bool UpperCase) {
15  std::string number;
16  llvm::raw_string_ostream stream(number);
17  stream << format_hex_no_prefix(Value, 1, UpperCase);
18  return stream.str();
19 }
20 
21 void ScopedPrinter::printBinaryImpl(StringRef Label, StringRef Str,
22  ArrayRef<uint8_t> Data, bool Block,
23  uint32_t StartOffset) {
24  if (Data.size() > 16)
25  Block = true;
26 
27  if (Block) {
28  startLine() << Label;
29  if (!Str.empty())
30  OS << ": " << Str;
31  OS << " (\n";
32  if (!Data.empty())
33  OS << format_bytes_with_ascii(Data, StartOffset, 16, 4,
34  (IndentLevel + 1) * 2, true)
35  << "\n";
36  startLine() << ")\n";
37  } else {
38  startLine() << Label << ":";
39  if (!Str.empty())
40  OS << " " << Str;
41  OS << " (" << format_bytes(Data, None, Data.size(), 1, 0, true) << ")\n";
42  }
43 }
44 
46  raw_ostream &OS, bool PrettyPrint,
47  std::unique_ptr<DelimitedScope> &&OuterScope)
49  JOS(OS, /*Indent=*/PrettyPrint ? 2 : 0),
50  OuterScope(std::move(OuterScope)) {
51  if (this->OuterScope)
52  this->OuterScope->setPrinter(*this);
53 }
54 
55 } // namespace llvm
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::format_bytes
FormattedBytes format_bytes(ArrayRef< uint8_t > Bytes, Optional< uint64_t > FirstByteOffset=None, uint32_t NumPerLine=16, uint8_t ByteGroupSize=4, uint32_t IndentLevel=0, bool Upper=false)
Definition: Format.h:239
llvm::raw_string_ostream
A raw_ostream that writes to an std::string.
Definition: raw_ostream.h:632
llvm::to_hexString
std::string to_hexString(uint64_t Value, bool UpperCase=true)
Definition: ScopedPrinter.cpp:14
Format.h
llvm::format_hex_no_prefix
FormattedNumber format_hex_no_prefix(uint64_t N, unsigned Width, bool Upper=false)
format_hex_no_prefix - Output N as a fixed width hexadecimal.
Definition: Format.h:199
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::ScopedPrinter::ScopedPrinterKind
ScopedPrinterKind
Definition: ScopedPrinter.h:103
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:54
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::Value::Value
Value(Type *Ty, unsigned scid)
Definition: Value.cpp:49
uint64_t
llvm::HexNumber
Definition: ScopedPrinter.h:40
llvm::move
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:1665
uint32_t
llvm::JSONScopedPrinter::JSONScopedPrinter
JSONScopedPrinter(raw_ostream &OS, bool PrettyPrint=false, std::unique_ptr< DelimitedScope > &&OuterScope=std::unique_ptr< DelimitedScope >{})
Definition: ScopedPrinter.cpp:45
llvm::pdb::PDB_SymType::Label
@ Label
std
Definition: BitVector.h:851
llvm::support
Definition: Endian.h:25
llvm::ScopedPrinter
Definition: ScopedPrinter.h:101
llvm::format_bytes_with_ascii
FormattedBytes format_bytes_with_ascii(ArrayRef< uint8_t > Bytes, Optional< uint64_t > FirstByteOffset=None, uint32_t NumPerLine=16, uint8_t ByteGroupSize=4, uint32_t IndentLevel=0, bool Upper=false)
Definition: Format.h:247
llvm::raw_string_ostream::str
std::string & str()
Returns the string's reference.
Definition: raw_ostream.h:650
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
ScopedPrinter.h