22#ifndef LLVM_SUPPORT_FORMAT_H
23#define LLVM_SUPPORT_FORMAT_H
48 virtual int snprint(
char *Buffer,
unsigned BufferSize)
const = 0;
56 unsigned print(
char *Buffer,
unsigned BufferSize)
const {
57 assert(BufferSize &&
"Invalid buffer size!");
60 int N = snprint(Buffer, BufferSize);
64 return BufferSize * 2;
68 if (
unsigned(
N) >= BufferSize)
83template <
typename Arg,
typename... Args>
85 static_assert(std::is_scalar_v<Arg>,
86 "format can't be used with non fundamental / non pointer type");
91template <
typename... Ts>
93 std::tuple<Ts...> Vals;
95 template <std::size_t... Is>
96 int snprint_tuple(
char *Buffer,
unsigned BufferSize,
97 std::index_sequence<Is...>)
const {
99 return _snprintf(Buffer, BufferSize,
Fmt, std::get<Is>(Vals)...);
101 return snprintf(Buffer, BufferSize,
Fmt, std::get<Is>(Vals)...);
111 int snprint(
char *Buffer,
unsigned BufferSize)
const override {
112 return snprint_tuple(Buffer, BufferSize, std::index_sequence_for<Ts...>());
125template <
typename... Ts>
135 : Str(S), Width(W), Justify(J) {}
178 : HexValue(HV), DecValue(DV), Width(W), Hex(
H),
Upper(U),
189 bool Upper =
false) {
190 assert(Width <= 18 &&
"hex width must be <= 18");
202 bool Upper =
false) {
203 assert(Width <= 16 &&
"hex width must be <= 16");
222 std::optional<uint64_t> FirstByteOffset;
233 : Bytes(
B), FirstByteOffset(O), IndentLevel(IL), NumPerLine(NPL),
234 ByteGroupSize(BGS),
Upper(U), ASCII(
A) {
236 if (ByteGroupSize > NumPerLine)
237 ByteGroupSize = NumPerLine;
243 std::optional<uint64_t> FirstByteOffset = std::nullopt,
246 return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
247 ByteGroupSize,
Upper,
false);
252 std::optional<uint64_t> FirstByteOffset = std::nullopt,
255 return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
256 ByteGroupSize,
Upper,
true);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
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)