18#if defined(_WIN32) && !defined(__MINGW32__)
24template<
typename T, std::
size_t N>
26 char *EndPtr = std::end(Buffer);
27 char *CurPtr = EndPtr;
33 return EndPtr - CurPtr;
40 int InitialDigits = ((Buffer.
size() - 1) % 3) + 1;
46 while (!Buffer.
empty()) {
57 static_assert(std::is_unsigned_v<T>,
"Value is not unsigned!");
59 char NumberBuffer[128];
65 if (Len < MinDigits && Style != IntegerStyle::Number) {
66 for (
size_t I = Len;
I < MinDigits; ++
I)
70 if (Style == IntegerStyle::Number) {
73 S.
write(std::end(NumberBuffer) - Len, Len);
91 static_assert(std::is_signed_v<T>,
"Value is not signed!");
93 using UnsignedT = std::make_unsigned_t<T>;
100 UnsignedT UN = -(UnsignedT)
N;
135 std::optional<size_t> Width) {
136 const size_t kMaxWidth = 128u;
138 size_t W = std::min(kMaxWidth, Width.value_or(0u));
141 bool Prefix = (Style == HexPrintStyle::PrefixLower ||
142 Style == HexPrintStyle::PrefixUpper);
144 (Style == HexPrintStyle::Upper || Style == HexPrintStyle::PrefixUpper);
145 unsigned PrefixChars = Prefix ? 2 : 0;
147 std::max(
static_cast<unsigned>(W), std::max(1u, Nibbles) + PrefixChars);
149 char NumberBuffer[kMaxWidth];
150 ::memset(NumberBuffer,
'0', std::size(NumberBuffer));
152 NumberBuffer[1] =
'x';
153 char *EndPtr = NumberBuffer + NumChars;
154 char *CurPtr = EndPtr;
156 unsigned char x =
static_cast<unsigned char>(
N) % 16;
157 *--CurPtr = hexdigit(x, !
Upper);
161 S.
write(NumberBuffer, NumChars);
165 std::optional<size_t> Precision) {
171 }
else if (std::isinf(
N)) {
172 S << (std::signbit(
N) ?
"-INF" :
"INF");
177 if (Style == FloatStyle::Exponent)
179 else if (Style == FloatStyle::ExponentUpper)
186 Out <<
"%." << Prec << Letter;
188 if (Style == FloatStyle::Exponent || Style == FloatStyle::ExponentUpper) {
193#if defined(__MINGW32__)
195 if (
N == 0.0 && std::signbit(
N)) {
197 if (Style == FloatStyle::ExponentUpper)
203 int fpcl = _fpclass(
N);
206 if (fpcl == _FPCLASS_NZ) {
208 if (Style == FloatStyle::ExponentUpper)
217 len =
format(
Spec.c_str(),
N).snprint(buf,
sizeof(buf));
218 if (len <=
sizeof(buf) - 2) {
219 if (len >= 5 && (buf[len - 5] ==
'e' || buf[len - 5] ==
'E') &&
220 buf[len - 3] ==
'0') {
221 int cs = buf[len - 4];
222 if (cs ==
'+' || cs ==
'-') {
223 int c1 = buf[len - 2];
224 int c0 = buf[len - 1];
225 if (isdigit(
static_cast<unsigned char>(c1)) &&
226 isdigit(
static_cast<unsigned char>(c0))) {
240 if (Style == FloatStyle::Percent)
246 if (Style == FloatStyle::Percent)
251 return (S == HexPrintStyle::PrefixLower || S == HexPrintStyle::PrefixUpper);
256 case FloatStyle::Exponent:
257 case FloatStyle::ExponentUpper:
259 case FloatStyle::Fixed:
260 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)