================
@@ -53,46 +55,102 @@ static_assert(APFloatBase::integerPartWidth % 4 == 0, 
"Part width must be divisi
 
 namespace llvm {
 
-constexpr fltSemantics APFloatBase::semIEEEhalf = {15, -14, 11, 16};
-constexpr fltSemantics APFloatBase::semBFloat = {127, -126, 8, 16};
-constexpr fltSemantics APFloatBase::semIEEEsingle = {127, -126, 24, 32};
-constexpr fltSemantics APFloatBase::semIEEEdouble = {1023, -1022, 53, 64};
-constexpr fltSemantics APFloatBase::semIEEEquad = {16383, -16382, 113, 128};
-constexpr fltSemantics APFloatBase::semFloat8E5M2 = {15, -14, 3, 8};
+constexpr fltSemantics APFloatBase::semIEEEhalf = {"IEEEhalf", 15, -14, 11, 
16};
+constexpr fltSemantics APFloatBase::semBFloat = {"BFloat", 127, -126, 8, 16};
+constexpr fltSemantics APFloatBase::semIEEEsingle = {"IEEESingle", 127, -126,
+                                                     24, 32};
+constexpr fltSemantics APFloatBase::semIEEEdouble = {"IEEEdouble", 1023, -1022,
+                                                     53, 64};
+constexpr fltSemantics APFloatBase::semIEEEquad = {"IEEEquad", 16383, -16382,
+                                                   113, 128};
+constexpr fltSemantics APFloatBase::semFloat8E5M2 = {"Float8E5M2", 15, -14, 3,
+                                                     8};
 constexpr fltSemantics APFloatBase::semFloat8E5M2FNUZ = {
-    15, -15, 3, 8, fltNonfiniteBehavior::NanOnly, 
fltNanEncoding::NegativeZero};
-constexpr fltSemantics APFloatBase::semFloat8E4M3 = {7, -6, 4, 8};
+    "Float8E5M2FNUZ",
+    15,
+    -15,
+    3,
+    8,
+    2,
+    fltNonfiniteBehavior::NanOnly,
+    fltNanEncoding::NegativeZero};
+constexpr fltSemantics APFloatBase::semFloat8E4M3 = {"Float8E4M3", 7, -6, 4, 
8};
 constexpr fltSemantics APFloatBase::semFloat8E4M3FN = {
-    8, -6, 4, 8, fltNonfiniteBehavior::NanOnly, fltNanEncoding::AllOnes};
+    "Float8E4M3FN",         8, -6, 4, 8, 2, fltNonfiniteBehavior::NanOnly,
+    fltNanEncoding::AllOnes};
 constexpr fltSemantics APFloatBase::semFloat8E4M3FNUZ = {
-    7, -7, 4, 8, fltNonfiniteBehavior::NanOnly, fltNanEncoding::NegativeZero};
+    "Float8E4M3FNUZ",
+    7,
+    -7,
+    4,
+    8,
+    2,
+    fltNonfiniteBehavior::NanOnly,
+    fltNanEncoding::NegativeZero};
 constexpr fltSemantics APFloatBase::semFloat8E4M3B11FNUZ = {
-    4, -10, 4, 8, fltNonfiniteBehavior::NanOnly, fltNanEncoding::NegativeZero};
-constexpr fltSemantics APFloatBase::semFloat8E3M4 = {3, -2, 5, 8};
-constexpr fltSemantics APFloatBase::semFloatTF32 = {127, -126, 11, 19};
+    "Float8E4M3B11FNUZ",         4, -10, 4, 8, 2, 
fltNonfiniteBehavior::NanOnly,
+    fltNanEncoding::NegativeZero};
+constexpr fltSemantics APFloatBase::semFloat8E3M4 = {"Float8E3M4", 3, -2, 5, 
8};
+constexpr fltSemantics APFloatBase::semFloatTF32 = {"FloatTF32", 127, -126, 11,
+                                                    19};
 constexpr fltSemantics APFloatBase::semFloat8E8M0FNU = {
+    "Float8E8M0FNU",
     127,
     -127,
     1,
     8,
+    2,
     fltNonfiniteBehavior::NanOnly,
     fltNanEncoding::AllOnes,
     false,
     false,
     false};
 
 constexpr fltSemantics APFloatBase::semFloat6E3M2FN = {
-    4, -2, 3, 6, fltNonfiniteBehavior::FiniteOnly};
+    "Float6E3M2FN", 4, -2, 3, 6, 2, fltNonfiniteBehavior::FiniteOnly};
 constexpr fltSemantics APFloatBase::semFloat6E2M3FN = {
-    2, 0, 4, 6, fltNonfiniteBehavior::FiniteOnly};
+    "Float6E2M3FN", 2, 0, 4, 6, 2, fltNonfiniteBehavior::FiniteOnly};
 constexpr fltSemantics APFloatBase::semFloat4E2M1FN = {
-    2, 0, 2, 4, fltNonfiniteBehavior::FiniteOnly};
-constexpr fltSemantics APFloatBase::semX87DoubleExtended = {16383, -16382, 64,
-                                                            80};
-constexpr fltSemantics APFloatBase::semBogus = {0, 0, 0, 0};
-constexpr fltSemantics APFloatBase::semPPCDoubleDouble = {-1, 0, 0, 128};
+    "Float4E2M1FN", 2, 0, 2, 4, 2, fltNonfiniteBehavior::FiniteOnly};
+constexpr fltSemantics APFloatBase::semX87DoubleExtended = {
+    "X87DoubleExtended", 16383, -16382, 64, 80};
+constexpr fltSemantics APFloatBase::semBogus = {"Bogus", 0, 0, 0, 0};
+constexpr fltSemantics APFloatBase::semPPCDoubleDouble = {"PPCDoubleDouble", 
-1,
+                                                          0, 0, 128};
 constexpr fltSemantics APFloatBase::semPPCDoubleDoubleLegacy = {
-    1023, -1022 + 53, 53 + 53, 128};
+    "PPCDoubleDoubleLegacy", 1023, -1022 + 53, 53 + 53, 128};
+
+/* Hex float
+   All three sizes share the same sign and exponent fields
+   1 bit for sign
+   7 bits for unsigned CHARACTERISTIC, which is the exponent + a bias of 64.
+     Therefore the range of exponent is -64 .. +63.
+     The exponent is for base 16.
+     (Therefore, the minimum exponent for base 2 is 16^-64 == 2^-256
+     The maximum exponent for base 2 is 16^63 == 2^252)
+   For Hex_FP32, the next 24 bits are the SIGNIFICAND.
+   For Hex_FP64, the next 56 bits are the SIGNIFICAND.
+   For Hex_FP128, two 64-bit values are used.  The first is as Hex_FP64,
+   In the second, the lower 56 bits form the lower significant part
+   of the SIGNIFICAND.
+   Precision is given in terms of the radix, e.g., Hex_FP32 has
+   6 hexits of precision.
+
+   HesFloat is described in
+   http://eece.cu.edu.eg/~hfahmy/arith_class/hex_bin_FP.pdf and in chapters 9
+   and 18 of the z/Architecture Principles of Operation.
+
+   Note that in the fltSemantics below the size of the significand is
+   given in terms of radix places.  As the radix is 16, the number of
+   places is the width of the significand in bits divided by 4 as each
+   radix place is represented by 4 bits.
+*/
+constexpr fltSemantics APFloatBase::semHex_FP32 = {
+    "Hex_FP32", 63, -64, 6, 32, 16, fltNonfiniteBehavior::FiniteOnly};
+constexpr fltSemantics APFloatBase::semHex_FP64 = {
+    "Hex_FP64", 63, -64, 14, 64, 16, fltNonfiniteBehavior::FiniteOnly};
+constexpr fltSemantics APFloatBase::semHex_FP128 = {
+    "Hex_FP128", 63, -64, 28, 128, 16, fltNonfiniteBehavior::FiniteOnly};
----------------
jcranmer-intel wrote:

Okay, I wasn't following the documentation correctly then.

https://github.com/llvm/llvm-project/pull/179771
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to