[libc-commits] [libc] 4b8543f - [libc][NFC] fix constants not marked constexpr
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Thu Jun 8 16:43:08 PDT 2023
Author: Michael Jones
Date: 2023-06-08T16:43:01-07:00
New Revision: 4b8543f33fa20c1dd9933cbbfea76a6a41294adb
URL: https://github.com/llvm/llvm-project/commit/4b8543f33fa20c1dd9933cbbfea76a6a41294adb
DIFF: https://github.com/llvm/llvm-project/commit/4b8543f33fa20c1dd9933cbbfea76a6a41294adb.diff
LOG: [libc][NFC] fix constants not marked constexpr
The constants in the ryu constant tables were not marked constexpr,
only static const. This caused problems when compiling with GCC.
Differential Revision: https://reviews.llvm.org/D152487
Added:
Modified:
libc/src/__support/ryu_constants.h
libc/src/__support/ryu_long_double_constants.h
Removed:
################################################################################
diff --git a/libc/src/__support/ryu_constants.h b/libc/src/__support/ryu_constants.h
index beac9efdbc949..9858aacba6cba 100644
--- a/libc/src/__support/ryu_constants.h
+++ b/libc/src/__support/ryu_constants.h
@@ -17,14 +17,14 @@ constexpr size_t IDX_SIZE = 16;
constexpr size_t MID_INT_SIZE = 192;
-static const uint16_t POW10_OFFSET[64] = {
+constexpr uint16_t POW10_OFFSET[64] = {
0, 2, 5, 8, 12, 16, 21, 26, 32, 39, 46, 54, 62,
71, 80, 90, 100, 111, 122, 134, 146, 159, 173, 187, 202, 217,
233, 249, 266, 283, 301, 319, 338, 357, 377, 397, 418, 440, 462,
485, 508, 532, 556, 581, 606, 632, 658, 685, 712, 740, 769, 798,
828, 858, 889, 920, 952, 984, 1017, 1050, 1084, 1118, 1153, 1188};
-static const uint64_t POW10_SPLIT[1224][3] = {
+constexpr uint64_t POW10_SPLIT[1224][3] = {
{1u, 72057594037927936u, 0u},
{699646928636035157u, 72057594u, 0u},
{1u, 0u, 256u},
@@ -1251,7 +1251,7 @@ static const uint64_t POW10_SPLIT[1224][3] = {
{8310173728816391804u, 197658u, 0u},
};
-static const uint16_t POW10_OFFSET_2[69] = {
+constexpr uint16_t POW10_OFFSET_2[69] = {
0, 2, 6, 12, 20, 29, 40, 52, 66, 80, 95, 112,
130, 150, 170, 192, 215, 240, 265, 292, 320, 350, 381, 413,
446, 480, 516, 552, 590, 629, 670, 712, 755, 799, 845, 892,
@@ -1259,13 +1259,13 @@ static const uint16_t POW10_OFFSET_2[69] = {
1613, 1678, 1743, 1810, 1878, 1947, 2017, 2088, 2161, 2235, 2311, 2387,
2465, 2544, 2625, 2706, 2789, 2873, 2959, 3046, 3133};
-static const uint8_t MIN_BLOCK_2[69] = {
+constexpr uint8_t MIN_BLOCK_2[69] = {
0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7,
7, 8, 8, 9, 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16,
17, 17, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 26, 26,
27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 32, 33, 34, 0};
-static const uint64_t POW10_SPLIT_2[3133][3] = {
+constexpr uint64_t POW10_SPLIT_2[3133][3] = {
{0u, 0u, 3906250u},
{0u, 0u, 202000000000u},
{0u, 11153727427136454656u, 59u},
diff --git a/libc/src/__support/ryu_long_double_constants.h b/libc/src/__support/ryu_long_double_constants.h
index 3863ba5157999..8415423e9eddd 100644
--- a/libc/src/__support/ryu_long_double_constants.h
+++ b/libc/src/__support/ryu_long_double_constants.h
@@ -17,7 +17,7 @@ constexpr size_t IDX_SIZE = 128;
constexpr size_t MID_INT_SIZE = (256 + 64);
-static const uint32_t POW10_OFFSET[] = {
+constexpr uint32_t POW10_OFFSET[] = {
0, 4, 13, 26, 43, 64, 90, 120, 154, 193, 236,
283, 334, 390, 450, 514, 582, 655, 732, 813, 899, 989,
1083, 1181, 1284, 1391, 1502, 1618, 1738, 1862, 1990, 2123, 2260,
@@ -31,7 +31,7 @@ static const uint32_t POW10_OFFSET[] = {
26137, 26612, 27092, 27576, 28064, 28556, 29053, 29554, 30059, 30568, 31082,
31600, 32122, 32649, 33180, 33715, 34254, 34798, 35346};
-static const uint32_t POW10_OFFSET_2[130] = {
+constexpr uint32_t POW10_OFFSET_2[130] = {
0, 15, 44, 83, 131, 190, 259, 338, 426, 524, 633,
751, 879, 1017, 1166, 1324, 1492, 1670, 1858, 2056, 2264, 2482,
2709, 2947, 3195, 3453, 3720, 3997, 4285, 4582, 4889, 5206, 5534,
@@ -45,7 +45,7 @@ static const uint32_t POW10_OFFSET_2[130] = {
61678, 62790, 63912, 65045, 66188, 67340, 68502, 69674, 70856, 72048, 73250,
74462, 75684, 76916, 78158, 79409, 80670, 81942, 83224, 84515};
-static const uint16_t MIN_BLOCK_2[130] = {
+constexpr uint16_t MIN_BLOCK_2[130] = {
0, 0, 4, 9, 13, 17, 21, 26, 30, 34, 39, 43, 47, 51, 56,
60, 64, 68, 73, 77, 81, 86, 90, 94, 98, 103, 107, 111, 116, 120,
124, 128, 133, 137, 141, 146, 150, 154, 158, 163, 167, 171, 176, 180, 184,
@@ -56,7 +56,7 @@ static const uint16_t MIN_BLOCK_2[130] = {
445, 450, 454, 458, 462, 467, 471, 475, 479, 484, 488, 492, 497, 501, 505,
509, 514, 518, 522, 527, 531, 535, 539, 544, 0};
-static const uint64_t POW10_SPLIT[][5] = {
+constexpr uint64_t POW10_SPLIT[][5] = {
{1u, 72057594037927936u, 0u, 0u, 0u},
{699646928636035157u, 72057594u, 0u, 0u, 0u},
{1329227995784915873u, 0u, 0u, 0u, 0u},
@@ -35405,7 +35405,7 @@ static const uint64_t POW10_SPLIT[][5] = {
{4647389u, 0u, 0u, 0u, 0u},
};
-static const uint64_t POW10_SPLIT_2[][5] = {
+constexpr uint64_t POW10_SPLIT_2[][5] = {
{0u, 0u, 3906250u, 0u, 0u},
{0u, 0u, 3906250000000000u, 0u, 0u},
{0u, 0u, 4368439412768899072u, 211758u, 0u},
More information about the libc-commits
mailing list