23 #ifndef LLVM_SUPPORT_FORMAT_H 24 #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)
81 template <
typename Arg,
typename...
Args>
83 static_assert(std::is_scalar<Arg>::value,
84 "format can't be used with non fundamental / non pointer type");
89 template <
typename... Ts>
91 std::tuple<Ts...> Vals;
93 template <std::size_t... Is>
94 int snprint_tuple(
char *Buffer,
unsigned BufferSize,
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 {
123 template <
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");
222 uint8_t ByteGroupSize;
229 uint32_t NPL, uint8_t BGS,
bool U,
bool A)
230 : Bytes(B), FirstByteOffset(O), IndentLevel(IL), NumPerLine(NPL),
231 ByteGroupSize(BGS), Upper(U), ASCII(A) {
233 if (ByteGroupSize > NumPerLine)
234 ByteGroupSize = NumPerLine;
240 uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4,
242 return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
243 ByteGroupSize,
Upper,
false);
249 uint32_t NumPerLine = 16, uint8_t ByteGroupSize = 4,
251 return FormattedBytes(Bytes, IndentLevel, FirstByteOffset, NumPerLine,
252 ByteGroupSize,
Upper,
true);
FormattedString left_justify(StringRef Str, unsigned Width)
left_justify - append spaces after string so total output is Width characters.
This class represents lattice values for constants.
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - 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, Optional< uint64_t > FirstByteOffset=None, uint32_t NumPerLine=16, uint8_t ByteGroupSize=4, uint32_t IndentLevel=0, bool Upper=false)
FormattedBytes format_bytes(ArrayRef< uint8_t > Bytes, Optional< uint64_t > FirstByteOffset=None, uint32_t NumPerLine=16, uint8_t ByteGroupSize=4, uint32_t IndentLevel=0, bool Upper=false)
FormattedString center_justify(StringRef Str, unsigned Width)
center_justify - add spaces before and after string so total output is Width characters.
Alias for the common case of a sequence of size_ts.
FormattedString right_justify(StringRef Str, unsigned Width)
right_justify - add spaces before string so total output is Width characters.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Creates a compile-time integer sequence for a parameter pack.
FormattedNumber format_decimal(int64_t N, unsigned Width)
format_decimal - Output N as a right justified, fixed-width decimal.
amdgpu Simplify well known AMD library false Value Value * Arg
FormattedNumber format_hex_no_prefix(uint64_t N, unsigned Width, bool Upper=false)
format_hex_no_prefix - Output N as a fixed width hexadecimal.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.