NativeFormatting.h 1.8 KB

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