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!");
64 return BufferSize * 2;
68 if (
unsigned(
N) >= BufferSize)
92template <
typename... Ts>
94 std::tuple<detail::decay_if_c_char_array_t<Ts>...> Vals;
96 template <std::size_t... Is>
97 int snprint_tuple(
char *Buffer,
unsigned BufferSize,
98 std::index_sequence<Is...>)
const {
100 return _snprintf(Buffer, BufferSize,
Fmt, std::get<Is>(Vals)...);
102 return snprintf(Buffer, BufferSize,
Fmt, std::get<Is>(Vals)...);
110 (std::is_scalar_v<detail::decay_if_c_char_array_t<Ts>> && ...),
111 "format can't be used with non fundamental / non pointer type");
114 int snprint(
char *Buffer,
unsigned BufferSize)
const override {
115 return snprint_tuple(Buffer, BufferSize, std::index_sequence_for<Ts...>());
128template <
typename... Ts>
138 : Str(S), Width(W), Justify(J) {}
143 Justification Justify;
181 : HexValue(HV), DecValue(DV), Width(W), Hex(
H), Upper(U),
192 bool Upper =
false) {
193 assert(Width <= 18 &&
"hex width must be <= 18");
205 bool Upper =
false) {
206 assert(Width <= 16 &&
"hex width must be <= 16");
225 std::optional<uint64_t> FirstByteOffset;
236 : Bytes(
B), FirstByteOffset(O), IndentLevel(IL), NumPerLine(NPL),
237 ByteGroupSize(BGS), Upper(U), ASCII(
A) {
239 if (ByteGroupSize > NumPerLine)
240 ByteGroupSize = NumPerLine;
246 std::optional<uint64_t> FirstByteOffset = std::nullopt,
249 return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
250 ByteGroupSize,
Upper,
false);
255 std::optional<uint64_t> FirstByteOffset = std::nullopt,
258 return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
259 ByteGroupSize,
Upper,
true);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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.
typename decay_if_c_char_array< T >::type decay_if_c_char_array_t
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)