22#ifndef LLVM_SUPPORT_FORMAT_H
23#define LLVM_SUPPORT_FORMAT_H
46 virtual int snprint(
char *Buffer,
unsigned BufferSize)
const = 0;
54 unsigned print(
char *Buffer,
unsigned BufferSize)
const {
55 assert(BufferSize &&
"Invalid buffer size!");
62 return BufferSize * 2;
66 if (
unsigned(
N) >= BufferSize)
81template <
typename Arg,
typename... Args>
83 static_assert(std::is_scalar_v<Arg>,
84 "format can't be used with non fundamental / non pointer type");
89template <
typename... Ts>
91 std::tuple<Ts...> Vals;
93 template <std::size_t... Is>
94 int snprint_tuple(
char *Buffer,
unsigned BufferSize,
95 std::index_sequence<Is...>)
const {
97 return _snprintf(Buffer, BufferSize,
Fmt, std::get<Is>(Vals)...);
99 return snprintf(Buffer, BufferSize,
Fmt, std::get<Is>(Vals)...);
109 int snprint(
char *Buffer,
unsigned BufferSize)
const override {
110 return snprint_tuple(Buffer, BufferSize, std::index_sequence_for<Ts...>());
123template <
typename... Ts>
133 : Str(S), Width(W), Justify(J) {}
176 : HexValue(HV), DecValue(DV), Width(W), Hex(
H),
Upper(U),
187 bool Upper =
false) {
188 assert(Width <= 18 &&
"hex width must be <= 18");
200 bool Upper =
false) {
201 assert(Width <= 16 &&
"hex width must be <= 16");
220 std::optional<uint64_t> FirstByteOffset;
223 uint8_t ByteGroupSize;
230 uint32_t NPL, uint8_t BGS,
bool U,
bool A)
231 : Bytes(
B), FirstByteOffset(O), IndentLevel(IL), NumPerLine(NPL),
232 ByteGroupSize(BGS),
Upper(U), ASCII(
A) {
234 if (ByteGroupSize > NumPerLine)
235 ByteGroupSize = NumPerLine;
241 std::optional<uint64_t> FirstByteOffset = std::nullopt,
242 uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4,
244 return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
245 ByteGroupSize,
Upper,
false);
250 std::optional<uint64_t> FirstByteOffset = std::nullopt,
251 uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4,
253 return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
254 ByteGroupSize,
Upper,
true);
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
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)