19#if defined(_WIN32) && !defined(__MINGW32__)
25template<
typename T, std::
size_t N>
27 char *EndPtr = std::end(Buffer);
28 char *CurPtr = EndPtr;
34 return EndPtr - CurPtr;
41 int InitialDigits = ((Buffer.
size() - 1) % 3) + 1;
47 while (!Buffer.
empty()) {
58 static_assert(std::is_unsigned_v<T>,
"Value is not unsigned!");
60 char NumberBuffer[128];
66 if (Len < MinDigits && Style != IntegerStyle::Number) {
67 for (
size_t I = Len;
I < MinDigits; ++
I)
71 if (Style == IntegerStyle::Number) {
74 S.
write(std::end(NumberBuffer) - Len, Len);
92 static_assert(std::is_signed_v<T>,
"Value is not signed!");
94 using UnsignedT = std::make_unsigned_t<T>;
101 UnsignedT UN = -(UnsignedT)
N;
136 std::optional<size_t> Width) {
137 const size_t kMaxWidth = 128u;
139 size_t W = std::min(kMaxWidth, Width.value_or(0u));
142 bool Prefix = (Style == HexPrintStyle::PrefixLower ||
143 Style == HexPrintStyle::PrefixUpper);
145 (Style == HexPrintStyle::Upper || Style == HexPrintStyle::PrefixUpper);
146 unsigned PrefixChars = Prefix ? 2 : 0;
148 std::max(
static_cast<unsigned>(W), std::max(1u, Nibbles) + PrefixChars);
150 char NumberBuffer[kMaxWidth];
151 ::memset(NumberBuffer,
'0', std::size(NumberBuffer));
153 NumberBuffer[1] =
'x';
154 char *EndPtr = NumberBuffer + NumChars;
155 char *CurPtr = EndPtr;
157 unsigned char x =
static_cast<unsigned char>(
N) % 16;
158 *--CurPtr = hexdigit(x, !
Upper);
162 S.
write(NumberBuffer, NumChars);
166 std::optional<size_t> Precision) {
172 }
else if (std::isinf(
N)) {
173 S << (std::signbit(
N) ?
"-INF" :
"INF");
178 if (Style == FloatStyle::Exponent)
180 else if (Style == FloatStyle::ExponentUpper)
187 Out <<
"%." << Prec << Letter;
189 if (Style == FloatStyle::Exponent || Style == FloatStyle::ExponentUpper) {
194#if defined(__MINGW32__)
196 if (
N == 0.0 && std::signbit(
N)) {
198 if (Style == FloatStyle::ExponentUpper)
204 int fpcl = _fpclass(
N);
207 if (fpcl == _FPCLASS_NZ) {
209 if (Style == FloatStyle::ExponentUpper)
218 len =
format(
Spec.c_str(),
N).snprint(buf,
sizeof(buf));
219 if (len <=
sizeof(buf) - 2) {
220 if (len >= 5 && (buf[len - 5] ==
'e' || buf[len - 5] ==
'E') &&
221 buf[len - 3] ==
'0') {
222 int cs = buf[len - 4];
223 if (cs ==
'+' || cs ==
'-') {
224 int c1 = buf[len - 2];
225 int c0 = buf[len - 1];
226 if (isdigit(
static_cast<unsigned char>(c1)) &&
227 isdigit(
static_cast<unsigned char>(c0))) {
241 if (Style == FloatStyle::Percent)
247 if (Style == FloatStyle::Percent)
252 return (S == HexPrintStyle::PrefixLower || S == HexPrintStyle::PrefixUpper);
257 case FloatStyle::Exponent:
258 case FloatStyle::ExponentUpper:
260 case FloatStyle::Fixed:
261 case FloatStyle::Percent:
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
ArrayRef< T > drop_front(size_t N=1) const
Drop the first N elements of the array.
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
LLVM Value Representation.
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write(unsigned char C)
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
int bit_width(T Value)
Returns the number of bits needed to represent Value if Value is nonzero.
void write_integer(raw_ostream &S, unsigned int N, size_t MinDigits, IntegerStyle Style)
size_t getDefaultPrecision(FloatStyle Style)
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, std::optional< size_t > Width=std::nullopt)
void write_double(raw_ostream &S, double D, FloatStyle Style, std::optional< size_t > Precision=std::nullopt)
bool isPrefixedHexStyle(HexPrintStyle S)