1 //===- NativeFormatting.h - Low level formatting helpers ---------*- C++-*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_SUPPORT_NATIVEFORMATTING_H 10 #define LLVM_SUPPORT_NATIVEFORMATTING_H 11 12 #include "llvm/Support/Compiler.h" 13 #include <cstdint> 14 #include <optional> 15 16 namespace llvm { 17 class raw_ostream; 18 enum class FloatStyle { Exponent, ExponentUpper, Fixed, Percent }; 19 enum class IntegerStyle { 20 Integer, 21 Number, 22 }; 23 enum class HexPrintStyle { Upper, Lower, PrefixUpper, PrefixLower }; 24 25 LLVM_ABI size_t getDefaultPrecision(FloatStyle Style); 26 27 LLVM_ABI bool isPrefixedHexStyle(HexPrintStyle S); 28 29 LLVM_ABI void write_integer(raw_ostream &S, unsigned int N, size_t MinDigits, 30 IntegerStyle Style); 31 LLVM_ABI void write_integer(raw_ostream &S, int N, size_t MinDigits, 32 IntegerStyle Style); 33 LLVM_ABI void write_integer(raw_ostream &S, unsigned long N, size_t MinDigits, 34 IntegerStyle Style); 35 LLVM_ABI void write_integer(raw_ostream &S, long N, size_t MinDigits, 36 IntegerStyle Style); 37 LLVM_ABI void write_integer(raw_ostream &S, unsigned long long N, 38 size_t MinDigits, IntegerStyle Style); 39 LLVM_ABI void write_integer(raw_ostream &S, long long N, size_t MinDigits, 40 IntegerStyle Style); 41 42 LLVM_ABI void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, 43 std::optional<size_t> Width = std::nullopt); 44 LLVM_ABI void write_double(raw_ostream &S, double D, FloatStyle Style, 45 std::optional<size_t> Precision = std::nullopt); 46 } 47 48 #endif 49 50