22#ifndef LLVM_SUPPORT_FORMAT_H
23#define LLVM_SUPPORT_FORMAT_H
47 virtual int snprint(
char *Buffer,
unsigned BufferSize)
const = 0;
55 unsigned print(
char *Buffer,
unsigned BufferSize)
const {
56 assert(BufferSize &&
"Invalid buffer size!");
63 return BufferSize * 2;
67 if (
unsigned(
N) >= BufferSize)
82template <
typename Arg,
typename... Args>
84 static_assert(std::is_scalar_v<Arg>,
85 "format can't be used with non fundamental / non pointer type");
90template <
typename... Ts>
92 std::tuple<Ts...> Vals;
94 template <std::size_t... Is>
95 int snprint_tuple(
char *Buffer,
unsigned BufferSize,
96 std::index_sequence<Is...>)
const {
98 return _snprintf(Buffer, BufferSize,
Fmt, std::get<Is>(Vals)...);
100 return snprintf(Buffer, BufferSize,
Fmt, std::get<Is>(Vals)...);
110 int snprint(
char *Buffer,
unsigned BufferSize)
const override {
111 return snprint_tuple(Buffer, BufferSize, std::index_sequence_for<Ts...>());
124template <
typename... Ts>
134 : Str(S), Width(W), Justify(J) {}
177 : HexValue(HV), DecValue(DV), Width(W), Hex(
H),
Upper(U),
188 bool Upper =
false) {
189 assert(Width <= 18 &&
"hex width must be <= 18");
201 bool Upper =
false) {
202 assert(Width <= 16 &&
"hex width must be <= 16");
221 std::optional<uint64_t> FirstByteOffset;
224 uint8_t ByteGroupSize;
231 uint32_t NPL, uint8_t BGS,
bool U,
bool A)
232 : Bytes(
B), FirstByteOffset(O), IndentLevel(IL), NumPerLine(NPL),
233 ByteGroupSize(BGS),
Upper(U), ASCII(
A) {
235 if (ByteGroupSize > NumPerLine)
236 ByteGroupSize = NumPerLine;
242 std::optional<uint64_t> FirstByteOffset = std::nullopt,
243 uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4,
245 return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
246 ByteGroupSize,
Upper,
false);
251 std::optional<uint64_t> FirstByteOffset = std::nullopt,
252 uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4,
254 return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
255 ByteGroupSize,
Upper,
true);
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringRef - Represent a constant reference to a string, i.e.
This class implements an extremely fast bulk output stream that can only output to a stream.
This is an optimization pass for GlobalISel generic memory operations.
FormattedNumber format_decimal(int64_t N, unsigned Width)
format_decimal - Output N as a right justified, fixed-width decimal.
FormattedString right_justify(StringRef Str, unsigned Width)
right_justify - add spaces before string so total output is Width characters.
FormattedString center_justify(StringRef Str, unsigned Width)
center_justify - add spaces before and after string so total output is Width characters.
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
FormattedNumber format_hex_no_prefix(uint64_t N, unsigned Width, bool Upper=false)
format_hex_no_prefix - Output N as a fixed width hexadecimal.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
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)
FormattedString left_justify(StringRef Str, unsigned Width)
left_justify - append spaces after string so total output is Width characters.
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)