path: root/doc
diff options
authorH. Peter Anvin <hpa@zytor.com>2020-07-16 23:11:03 -0700
committerH. Peter Anvin <hpa@zytor.com>2020-07-16 23:11:03 -0700
commitd081f0db5d491ee473fdb97b109dd9810b68d9b7 (patch)
tree006a9b776ba4d14dc0ce20c6598a2c927f16e880 /doc
parente830e92b7792a3a8c0e81774c0fb6b3414398753 (diff)
fp: support bfloat16 constants
Support generating bfloat16 constants. This is a bit awkward, as "DW" already generates IEEE half precision constants; therefore there is no longer a single floating-point format for each size. This requires some replumbing. Fortunately bfloat16 fits in 64 bits, so support generating them with a macro that uses __?bfloat16?__() to convert to integers first before passing them to DW. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'doc')
2 files changed, 20 insertions, 3 deletions
diff --git a/doc/changes.src b/doc/changes.src
index cf95224a..c1459231 100644
--- a/doc/changes.src
+++ b/doc/changes.src
@@ -12,6 +12,9 @@ since 2007.
\b Add instructions from the Intel Instruction Set Extensions and
Future Features Programming Reference, June 2020.
+\b Support for \c{bfloat16} floating-point constants. See \k{fltconst}
+and \k{pkg_fp}.
\b Properly display warnings in preprocess-only mode.
\b Fix copy-and-paste of examples from the PDF documentation.
diff --git a/doc/nasmdoc.src b/doc/nasmdoc.src
index cfa92fd1..e3d503c5 100644
--- a/doc/nasmdoc.src
+++ b/doc/nasmdoc.src
@@ -1692,9 +1692,9 @@ context.
\i{Floating-point} constants are acceptable only as arguments to
\i\c{DB}, \i\c{DW}, \i\c{DD}, \i\c{DQ}, \i\c{DT}, and \i\c{DO}, or as
arguments to the special operators \i\c{__?float8?__},
-\i\c{__?float16?__}, \i\c{__?float32?__}, \i\c{__?float64?__},
-\i\c{__?float80m?__}, \i\c{__?float80e?__}, \i\c{__?float128l?__}, and
+\i\c{__?float16?__}, \i\c{__?bfloat16?__}, \i\c{__?float32?__},
+\i\c{__?float64?__}, \i\c{__?float80m?__}, \i\c{__?float80e?__},
+\i\c{__?float128l?__}, and \i\c{__?float128h?__}. See also \k{pkg_fp}.
Floating-point constants are expressed in the traditional form:
digits, then a period, then optionally more digits, then optionally an
@@ -1733,6 +1733,13 @@ appears to be the most frequently used 8-bit floating-point format,
although it is not covered by any formal standard. This is sometimes
called a "\i{minifloat}."
+The \i\c{bfloat16} format is effectively a compressed version of the
+32-bit single precision format, with a reduced mantissa. It is
+effectively the same as truncating the 32-bit format to the upper 16
+bits, except for rounding. There is no \c{D}\e{x} directive that
+corresponds to \c{bfloat16} as it obviously has the same size as the
+IEEE standard 16-bit half precision format, see however \k{pkg_fp}.
The special operators are used to produce floating-point numbers in
other contexts. They produce the binary representation of a specific
floating-point number as an integer, and can use anywhere integer
@@ -4633,6 +4640,7 @@ This packages contains the following floating-point convenience macros:
\c %define float8(x) __?float8?__(x)
\c %define float16(x) __?float16?__(x)
+\c %define bfloat16(x) __?bfloat16?__(x)
\c %define float32(x) __?float32?__(x)
\c %define float64(x) __?float64?__(x)
\c %define float80m(x) __?float80m?__(x)
@@ -4640,6 +4648,12 @@ This packages contains the following floating-point convenience macros:
\c %define float128l(x) __?float128l?__(x)
\c %define float128h(x) __?float128h?__(x)
+It also defines the a multi-line macro \i\c{bf16} that can be used
+in a similar way to the \c{D}\e{x} directives for the other
+floating-point numbers:
+\c bf16 -3.1415, NaN, 2000.0, +Inf
\H{pkg_ifunc} \i\c{ifunc}: \i{Integer functions}