22#ifndef LLVM_SUPPORT_FORMAT_H
23#define LLVM_SUPPORT_FORMAT_H
57 std::tuple<detail::decay_if_c_char_array_t<Ts>...> Vals;
59 template <std::size_t... Is>
60 int snprint_tuple(
char *Buffer,
unsigned BufferSize,
61 std::index_sequence<Is...>)
const {
62 return snprintf(Buffer, BufferSize, Fmt, std::get<Is>(Vals)...);
66 format_object(
const char *fmt,
const Ts &...vals) : Fmt(fmt), Vals(vals...) {
68 (std::is_scalar_v<detail::decay_if_c_char_array_t<Ts>> && ...),
69 "format can't be used with non fundamental / non pointer type");
72 int snprint(
char *Buffer,
unsigned BufferSize)
const {
73 return snprint_tuple(Buffer, BufferSize, std::index_sequence_for<Ts...>());
77template <
typename... Ts>
80 [&Fmt](
char *Buf,
size_t Size) ->
int {
return Fmt.
snprint(Buf,
Size); };
93template <
typename... Ts>
103 : Str(S), Width(W), Justify(J) {}
108 Justification Justify;
146 : HexValue(HV), DecValue(DV), Width(W), Hex(
H), Upper(U),
157 bool Upper =
false) {
158 assert(Width <= 18 &&
"hex width must be <= 18");
170 bool Upper =
false) {
171 assert(Width <= 16 &&
"hex width must be <= 16");
190 std::optional<uint64_t> FirstByteOffset;
201 : Bytes(
B), FirstByteOffset(O), IndentLevel(IL), NumPerLine(NPL),
202 ByteGroupSize(BGS), Upper(U), ASCII(
A) {
204 if (ByteGroupSize > NumPerLine)
205 ByteGroupSize = NumPerLine;
211 std::optional<uint64_t> FirstByteOffset = std::nullopt,
214 return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
215 ByteGroupSize,
Upper,
false);
220 std::optional<uint64_t> FirstByteOffset = std::nullopt,
223 return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
224 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")
Represent a constant reference to an array (0 or more elements consecutively in memory),...
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.
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
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.
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
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)