public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] avx512 bfloat16 support
@ 2020-07-21 15:52 Felix Willgerodt
  2020-07-21 15:52 ` [PATCH 1/2] i386-tdep: Fix naming in zmm and ymm type descriptions Felix Willgerodt
  2020-07-21 15:52 ` [PATCH 2/2] Add bfloat16 support for AVX512 register view Felix Willgerodt
  0 siblings, 2 replies; 8+ messages in thread
From: Felix Willgerodt @ 2020-07-21 15:52 UTC (permalink / raw)
  To: gdb-patches

This series introduces support for the bfloat16 datatype available in a set of
new avx512 instructions and fixes some existing avx512 register type
descriptions.

For more information on the new instructions, please see the
Intel Architecture Instruction Set Extensions Programming Reference:
https://software.intel.com/content/www/us/en/develop/articles/intel-sdm.html#architecture

Regards,
Felix

Felix Willgerodt (2):
  i386-tdep: Fix naming in zmm and ymm type descriptions.
  Add bfloat16 support for AVX512 register view.

 gdb/features/i386/64bit-avx512.c          |   5 +
 gdb/features/i386/64bit-avx512.xml        |   4 +-
 gdb/features/i386/64bit-sse.c             |   5 +
 gdb/features/i386/64bit-sse.xml           |   2 +
 gdb/gdbarch.c                             |  45 ++++++
 gdb/gdbarch.h                             |   8 +-
 gdb/gdbarch.sh                            |   4 +-
 gdb/gdbtypes.c                            |   7 +
 gdb/gdbtypes.h                            |   3 +-
 gdb/i386-tdep.c                           |  37 +++--
 gdb/target-descriptions.c                 |   5 +
 gdb/testsuite/gdb.arch/x86-avx512bf16.c   | 166 ++++++++++++++++++++++
 gdb/testsuite/gdb.arch/x86-avx512bf16.exp |  74 ++++++++++
 gdb/testsuite/lib/gdb.exp                 |  51 +++++++
 gdbsupport/tdesc.cc                       |   3 +-
 gdbsupport/tdesc.h                        |   1 +
 include/floatformat.h                     |   3 +
 libiberty/floatformat.c                   |  19 ++-
 18 files changed, 422 insertions(+), 20 deletions(-)
 create mode 100644 gdb/testsuite/gdb.arch/x86-avx512bf16.c
 create mode 100644 gdb/testsuite/gdb.arch/x86-avx512bf16.exp

-- 
2.25.4

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] i386-tdep: Fix naming in zmm and ymm type descriptions.
  2020-07-21 15:52 [PATCH 0/2] avx512 bfloat16 support Felix Willgerodt
@ 2020-07-21 15:52 ` Felix Willgerodt
  2020-07-22 18:45   ` Kevin Buettner
  2020-07-21 15:52 ` [PATCH 2/2] Add bfloat16 support for AVX512 register view Felix Willgerodt
  1 sibling, 1 reply; 8+ messages in thread
From: Felix Willgerodt @ 2020-07-21 15:52 UTC (permalink / raw)
  To: gdb-patches

gdb/Changelog:
2020-07-02  Felix Willgerodt  <felix.willgerodt@intel.com>

	* i386-tdep.c (i386_zmm_type): Fix field names.
	(i386_ymm_type): Fix field names.

2020-07-21  Felix Willgerodt  <felix.willgerodt@intel.com>
---
 gdb/i386-tdep.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 9b905c1996a..648974455f6 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3103,13 +3103,13 @@ i386_zmm_type (struct gdbarch *gdbarch)
 #if 0
       union __gdb_builtin_type_vec512i
       {
-	int128_t uint128[4];
-	int64_t v4_int64[8];
-	int32_t v8_int32[16];
-	int16_t v16_int16[32];
-	int8_t v32_int8[64];
-	double v4_double[8];
-	float v8_float[16];
+	int128_t v4_int128[4];
+	int64_t v8_int64[8];
+	int32_t v16_int32[16];
+	int16_t v32_int16[32];
+	int8_t v64_int8[64];
+	double v8_double[8];
+	float v16_float[16];
       };
 #endif
 
@@ -3156,13 +3156,13 @@ i386_ymm_type (struct gdbarch *gdbarch)
 #if 0
       union __gdb_builtin_type_vec256i
       {
-        int128_t uint128[2];
-        int64_t v2_int64[4];
-        int32_t v4_int32[8];
-        int16_t v8_int16[16];
-        int8_t v16_int8[32];
-        double v2_double[4];
-        float v4_float[8];
+        int128_t v2_int128[2];
+        int64_t v4_int64[4];
+        int32_t v8_int32[8];
+        int16_t v16_int16[16];
+        int8_t v32_int8[32];
+        double v4_double[4];
+        float v8_float[8];
       };
 #endif
 
-- 
2.25.4

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/2] Add bfloat16 support for AVX512 register view.
  2020-07-21 15:52 [PATCH 0/2] avx512 bfloat16 support Felix Willgerodt
  2020-07-21 15:52 ` [PATCH 1/2] i386-tdep: Fix naming in zmm and ymm type descriptions Felix Willgerodt
@ 2020-07-21 15:52 ` Felix Willgerodt
  2020-07-22 22:19   ` Kevin Buettner
  2020-07-22 22:27   ` Luis Machado
  1 sibling, 2 replies; 8+ messages in thread
From: Felix Willgerodt @ 2020-07-21 15:52 UTC (permalink / raw)
  To: gdb-patches

This adds support for the bfloat16 datatype, which can be seen as a short
version of FP32, skipping the least significant 16 bits of the mantissa.
Since the datatype is currently only supported by the AVX512 registers,
the printing of bfloat16 values is only supported for xmm, ymm and zmm
registers.

gdb/ChangeLog:
2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
	    Felix Willgerodt  <Felix.Willgerodt@intel.com>

	* gdbarch.sh: Added bfloat16 type.
	* gdbarch.c: Regenerated.
	* gdbarch.h: Regenerated.
	* gdbtypes.c (floatformats_bfloat16): New struct.
	(gdbtypes_post_init): Add builtin_bfloat16.
	* gdbtypes.h (struct builtin_type) <builtin_bfloat16>: New member.
	(floatformats_bfloat16): New struct.
	* i386-tdep.c (i386_zmm_type): Add field "v32_bfloat16"
	(i386_ymm_type): Add field "v16_bfloat16"
	(i386_gdbarch_init): Add set_gdbarch_bfloat16_format.
	* target-descriptions.c (make_gdb_type): Add case TDESC_TYPE_BFLOAT16.
	* gdbsupport/tdesc.cc (tdesc_predefined_types): New member bfloat16.
	* gdbsupport/tdesc.h (tdesc_type_kind): New member TDESC_TYPE_BFLOAT16.

gdb/features/ChangeLog:
2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
	    Felix Willgerodt  <Felix.Willgerodt@intel.com>

	* features/64bit-avx512.c
	(create_feature_i386_64bit_avx512): Add vector v8bf.
	(create_feature_i386_64bit_avx512): Add field v8_bfloat16.
	* features/64bit-avx512.xml: Likewise.
	* features/64bit-sse.c
	(create_feature_i386_64bit_sse): Add vector v8bf.
	(create_feature_i386_64bit_sse): Add field v8_bfloat16.
	* features/64bit-sse.xml: Likewise.

gdb/testsuite/ChangeLog:
2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
	    Felix Willgerodt  <Felix.Willgerodt@intel.com>

	* x86-avx512bf16.c: New file.
	* x86-avx512bf16.exp: Likewise.
	* lib/gdb.exp (skip_avx512bf16_tests): New function.

include/ChangeLog:
2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>

	* floatformat.h: Add struct floatformat_intel_bfloat16_big.
	Add struct floatformat_intel_bfloat16_little.

libiberty/ChangeLog:
2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>

	* floatformat.c: Add struct floatformat_intel_bfloat16_big.
	Add struct floatformat_intel_bfloat16_little.

2020-07-21  Felix Willgerodt  <felix.willgerodt@intel.com>
---
 gdb/features/i386/64bit-avx512.c          |   5 +
 gdb/features/i386/64bit-avx512.xml        |   4 +-
 gdb/features/i386/64bit-sse.c             |   5 +
 gdb/features/i386/64bit-sse.xml           |   2 +
 gdb/gdbarch.c                             |  45 ++++++
 gdb/gdbarch.h                             |   8 +-
 gdb/gdbarch.sh                            |   4 +-
 gdb/gdbtypes.c                            |   7 +
 gdb/gdbtypes.h                            |   3 +-
 gdb/i386-tdep.c                           |   9 ++
 gdb/target-descriptions.c                 |   5 +
 gdb/testsuite/gdb.arch/x86-avx512bf16.c   | 166 ++++++++++++++++++++++
 gdb/testsuite/gdb.arch/x86-avx512bf16.exp |  74 ++++++++++
 gdb/testsuite/lib/gdb.exp                 |  51 +++++++
 gdbsupport/tdesc.cc                       |   3 +-
 gdbsupport/tdesc.h                        |   1 +
 include/floatformat.h                     |   3 +
 libiberty/floatformat.c                   |  19 ++-
 18 files changed, 408 insertions(+), 6 deletions(-)
 create mode 100644 gdb/testsuite/gdb.arch/x86-avx512bf16.c
 create mode 100644 gdb/testsuite/gdb.arch/x86-avx512bf16.exp

diff --git a/gdb/features/i386/64bit-avx512.c b/gdb/features/i386/64bit-avx512.c
index d12234c41ce..1bd49dcd9d5 100644
--- a/gdb/features/i386/64bit-avx512.c
+++ b/gdb/features/i386/64bit-avx512.c
@@ -10,6 +10,9 @@ create_feature_i386_64bit_avx512 (struct target_desc *result, long regnum)
 
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512");
   tdesc_type *element_type;
+  element_type = tdesc_named_type (feature, "bfloat16");
+  tdesc_create_vector (feature, "v8bf16", element_type, 8);
+
   element_type = tdesc_named_type (feature, "ieee_single");
   tdesc_create_vector (feature, "v4f", element_type, 4);
 
@@ -31,6 +34,8 @@ create_feature_i386_64bit_avx512 (struct target_desc *result, long regnum)
   tdesc_type_with_fields *type_with_fields;
   type_with_fields = tdesc_create_union (feature, "vec128");
   tdesc_type *field_type;
+  field_type = tdesc_named_type (feature, "v8bf16");
+  tdesc_add_field (type_with_fields, "v8_bfloat16", field_type);
   field_type = tdesc_named_type (feature, "v4f");
   tdesc_add_field (type_with_fields, "v4_float", field_type);
   field_type = tdesc_named_type (feature, "v2d");
diff --git a/gdb/features/i386/64bit-avx512.xml b/gdb/features/i386/64bit-avx512.xml
index 4f02136533d..3636121e847 100644
--- a/gdb/features/i386/64bit-avx512.xml
+++ b/gdb/features/i386/64bit-avx512.xml
@@ -7,13 +7,15 @@
 
 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
 <feature name="org.gnu.gdb.i386.avx512">
-<vector id="v4f" type="ieee_single" count="4"/>
+  <vector id="v8bf16" type="bfloat16" count="8"/>
+  <vector id="v4f" type="ieee_single" count="4"/>
   <vector id="v2d" type="ieee_double" count="2"/>
   <vector id="v16i8" type="int8" count="16"/>
   <vector id="v8i16" type="int16" count="8"/>
   <vector id="v4i32" type="int32" count="4"/>
   <vector id="v2i64" type="int64" count="2"/>
   <union id="vec128">
+    <field name="v8_bfloat16" type="v8bf16"/>
     <field name="v4_float" type="v4f"/>
     <field name="v2_double" type="v2d"/>
     <field name="v16_int8" type="v16i8"/>
diff --git a/gdb/features/i386/64bit-sse.c b/gdb/features/i386/64bit-sse.c
index 48b5aa09793..645e3141337 100644
--- a/gdb/features/i386/64bit-sse.c
+++ b/gdb/features/i386/64bit-sse.c
@@ -10,6 +10,9 @@ create_feature_i386_64bit_sse (struct target_desc *result, long regnum)
 
   feature = tdesc_create_feature (result, "org.gnu.gdb.i386.sse");
   tdesc_type *element_type;
+  element_type = tdesc_named_type (feature, "bfloat16");
+  tdesc_create_vector (feature, "v8bf16", element_type, 8);
+
   element_type = tdesc_named_type (feature, "ieee_single");
   tdesc_create_vector (feature, "v4f", element_type, 4);
 
@@ -31,6 +34,8 @@ create_feature_i386_64bit_sse (struct target_desc *result, long regnum)
   tdesc_type_with_fields *type_with_fields;
   type_with_fields = tdesc_create_union (feature, "vec128");
   tdesc_type *field_type;
+  field_type = tdesc_named_type (feature, "v8bf16");
+  tdesc_add_field (type_with_fields, "v8_bfloat16", field_type);
   field_type = tdesc_named_type (feature, "v4f");
   tdesc_add_field (type_with_fields, "v4_float", field_type);
   field_type = tdesc_named_type (feature, "v2d");
diff --git a/gdb/features/i386/64bit-sse.xml b/gdb/features/i386/64bit-sse.xml
index 4ec1e7c1e36..e3dec544cf4 100644
--- a/gdb/features/i386/64bit-sse.xml
+++ b/gdb/features/i386/64bit-sse.xml
@@ -7,6 +7,7 @@
 
 <!DOCTYPE feature SYSTEM "gdb-target.dtd">
 <feature name="org.gnu.gdb.i386.sse">
+  <vector id="v8bf16" type="bfloat16" count="8"/>
   <vector id="v4f" type="ieee_single" count="4"/>
   <vector id="v2d" type="ieee_double" count="2"/>
   <vector id="v16i8" type="int8" count="16"/>
@@ -14,6 +15,7 @@
   <vector id="v4i32" type="int32" count="4"/>
   <vector id="v2i64" type="int64" count="2"/>
   <union id="vec128">
+    <field name="v8_bfloat16" type="v8bf16"/>
     <field name="v4_float" type="v4f"/>
     <field name="v2_double" type="v2d"/>
     <field name="v16_int8" type="v16i8"/>
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index 21ee840e88f..d9e5dcfbaf5 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -166,6 +166,8 @@ struct gdbarch
   int int_bit;
   int long_bit;
   int long_long_bit;
+  int bfloat16_bit;
+  const struct floatformat ** bfloat16_format;
   int half_bit;
   const struct floatformat ** half_format;
   int float_bit;
@@ -382,6 +384,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
   gdbarch->int_bit = 4*TARGET_CHAR_BIT;
   gdbarch->long_bit = 4*TARGET_CHAR_BIT;
   gdbarch->long_long_bit = 2*gdbarch->long_bit;
+  gdbarch->bfloat16_bit = 2*TARGET_CHAR_BIT;
   gdbarch->half_bit = 2*TARGET_CHAR_BIT;
   gdbarch->float_bit = 4*TARGET_CHAR_BIT;
   gdbarch->double_bit = 8*TARGET_CHAR_BIT;
@@ -521,6 +524,9 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of int_bit, invalid_p == 0 */
   /* Skip verify of long_bit, invalid_p == 0 */
   /* Skip verify of long_long_bit, invalid_p == 0 */
+  /* Skip verify of bfloat16_bit, invalid_p == 0 */
+  if (gdbarch->bfloat16_format == 0)
+    gdbarch->bfloat16_format = floatformats_bfloat16;
   /* Skip verify of half_bit, invalid_p == 0 */
   if (gdbarch->half_format == 0)
     gdbarch->half_format = floatformats_ieee_half;
@@ -804,6 +810,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
   fprintf_unfiltered (file,
                       "gdbarch_dump: bfd_arch_info = %s\n",
                       gdbarch_bfd_arch_info (gdbarch)->printable_name);
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: bfloat16_bit = %s\n",
+                      plongest (gdbarch->bfloat16_bit));
+  fprintf_unfiltered (file,
+                      "gdbarch_dump: bfloat16_format = %s\n",
+                      pformat (gdbarch->bfloat16_format));
   fprintf_unfiltered (file,
                       "gdbarch_dump: breakpoint_from_pc = <%s>\n",
                       host_address_to_string (gdbarch->breakpoint_from_pc));
@@ -1614,6 +1626,39 @@ set_gdbarch_long_long_bit (struct gdbarch *gdbarch,
   gdbarch->long_long_bit = long_long_bit;
 }
 
+int
+gdbarch_bfloat16_bit (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  /* Skip verify of bfloat16_bit, invalid_p == 0 */
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_bfloat16_bit called\n");
+  return gdbarch->bfloat16_bit;
+}
+
+void
+set_gdbarch_bfloat16_bit (struct gdbarch *gdbarch,
+                          int bfloat16_bit)
+{
+  gdbarch->bfloat16_bit = bfloat16_bit;
+}
+
+const struct floatformat **
+gdbarch_bfloat16_format (struct gdbarch *gdbarch)
+{
+  gdb_assert (gdbarch != NULL);
+  if (gdbarch_debug >= 2)
+    fprintf_unfiltered (gdb_stdlog, "gdbarch_bfloat16_format called\n");
+  return gdbarch->bfloat16_format;
+}
+
+void
+set_gdbarch_bfloat16_format (struct gdbarch *gdbarch,
+                             const struct floatformat ** bfloat16_format)
+{
+  gdbarch->bfloat16_format = bfloat16_format;
+}
+
 int
 gdbarch_half_bit (struct gdbarch *gdbarch)
 {
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index 0940156aeb8..c555fc2bc42 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -158,12 +158,18 @@ extern void set_gdbarch_long_bit (struct gdbarch *gdbarch, int long_bit);
 extern int gdbarch_long_long_bit (struct gdbarch *gdbarch);
 extern void set_gdbarch_long_long_bit (struct gdbarch *gdbarch, int long_long_bit);
 
-/* The ABI default bit-size and format for "half", "float", "double", and
+/* The ABI default bit-size and format for "bfloat16", "half", "float", "double", and
    "long double".  These bit/format pairs should eventually be combined
    into a single object.  For the moment, just initialize them as a pair.
    Each format describes both the big and little endian layouts (if
    useful). */
 
+extern int gdbarch_bfloat16_bit (struct gdbarch *gdbarch);
+extern void set_gdbarch_bfloat16_bit (struct gdbarch *gdbarch, int bfloat16_bit);
+
+extern const struct floatformat ** gdbarch_bfloat16_format (struct gdbarch *gdbarch);
+extern void set_gdbarch_bfloat16_format (struct gdbarch *gdbarch, const struct floatformat ** bfloat16_format);
+
 extern int gdbarch_half_bit (struct gdbarch *gdbarch);
 extern void set_gdbarch_half_bit (struct gdbarch *gdbarch, int half_bit);
 
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 41e7b8d5cc3..f2f2b76d954 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -325,12 +325,14 @@ v;int;long_bit;;;8 * sizeof (long);4*TARGET_CHAR_BIT;;0
 # machine.
 v;int;long_long_bit;;;8 * sizeof (LONGEST);2*gdbarch->long_bit;;0
 
-# The ABI default bit-size and format for "half", "float", "double", and
+# The ABI default bit-size and format for "bfloat16", "half", "float", "double", and
 # "long double".  These bit/format pairs should eventually be combined
 # into a single object.  For the moment, just initialize them as a pair.
 # Each format describes both the big and little endian layouts (if
 # useful).
 
+v;int;bfloat16_bit;;;16;2*TARGET_CHAR_BIT;;0
+v;const struct floatformat **;bfloat16_format;;;;;floatformats_bfloat16;;pformat (gdbarch->bfloat16_format)
 v;int;half_bit;;;16;2*TARGET_CHAR_BIT;;0
 v;const struct floatformat **;half_format;;;;;floatformats_ieee_half;;pformat (gdbarch->half_format)
 v;int;float_bit;;;8 * sizeof (float);4*TARGET_CHAR_BIT;;0
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index e87648813ec..a9ce0e6c34c 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -115,6 +115,10 @@ const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN] = {
   &floatformat_ibm_long_double_big,
   &floatformat_ibm_long_double_little
 };
+const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN] = {
+  &floatformat_bfloat16_big,
+  &floatformat_bfloat16_little
+};
 
 /* Should opaque types be resolved?  */
 
@@ -5739,6 +5743,9 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
   builtin_type->builtin_float
     = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
 		       "float", gdbarch_float_format (gdbarch));
+  builtin_type->builtin_bfloat16
+    = arch_float_type (gdbarch, gdbarch_bfloat16_bit (gdbarch),
+		       "bfloat16", gdbarch_bfloat16_format (gdbarch));
   builtin_type->builtin_double
     = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
 		       "double", gdbarch_double_format (gdbarch));
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index eaa4cff608d..961b87d43d9 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1857,6 +1857,7 @@ struct builtin_type
   struct type *builtin_unsigned_short;
   struct type *builtin_unsigned_int;
   struct type *builtin_unsigned_long;
+  struct type *builtin_bfloat16;
   struct type *builtin_half;
   struct type *builtin_float;
   struct type *builtin_double;
@@ -1991,7 +1992,7 @@ extern const struct floatformat *floatformats_ia64_quad[BFD_ENDIAN_UNKNOWN];
 extern const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN];
 extern const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN];
 extern const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN];
-
+extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN];
 
 /* Allocate space for storing data associated with a particular
    type.  We ensure that the space is allocated using the same
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 648974455f6..51c5a644d5d 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -3110,6 +3110,7 @@ i386_zmm_type (struct gdbarch *gdbarch)
 	int8_t v64_int8[64];
 	double v8_double[8];
 	float v16_float[16];
+	bfloat16_t v32_bfloat16[32];
       };
 #endif
 
@@ -3117,6 +3118,8 @@ i386_zmm_type (struct gdbarch *gdbarch)
 
       t = arch_composite_type (gdbarch,
 			       "__gdb_builtin_type_vec512i", TYPE_CODE_UNION);
+      append_composite_type_field (t, "v32_bfloat16",
+				   init_vector_type (bt->builtin_bfloat16, 32));
       append_composite_type_field (t, "v16_float",
 				   init_vector_type (bt->builtin_float, 16));
       append_composite_type_field (t, "v8_double",
@@ -3163,6 +3166,7 @@ i386_ymm_type (struct gdbarch *gdbarch)
         int8_t v32_int8[32];
         double v4_double[4];
         float v8_float[8];
+        bfloat16_t v16_bfloat16[16];
       };
 #endif
 
@@ -3170,6 +3174,8 @@ i386_ymm_type (struct gdbarch *gdbarch)
 
       t = arch_composite_type (gdbarch,
 			       "__gdb_builtin_type_vec256i", TYPE_CODE_UNION);
+      append_composite_type_field (t, "v16_bfloat16",
+				   init_vector_type (bt->builtin_bfloat16, 16));
       append_composite_type_field (t, "v8_float",
 				   init_vector_type (bt->builtin_float, 8));
       append_composite_type_field (t, "v4_double",
@@ -8483,6 +8489,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
      alignment.  */
   set_gdbarch_long_double_bit (gdbarch, 96);
 
+  /* Support of bfloat16 format.  */
+  set_gdbarch_bfloat16_format (gdbarch, floatformats_bfloat16);
+
   /* Support for floating-point data type variants.  */
   set_gdbarch_floatformat_for_type (gdbarch, i386_floatformat_for_type);
 
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 20d624c0c65..6778b93400b 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -141,6 +141,11 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
 	  m_type = arch_float_type (m_gdbarch, -1, "builtin_type_i387_ext",
 				    floatformats_i387_ext);
 	  return;
+
+	case TDESC_TYPE_BFLOAT16:
+	  m_type = arch_float_type (m_gdbarch, -1, "builtin_type_bfloat16",
+				    floatformats_bfloat16);
+	  return;
 	}
 
       internal_error (__FILE__, __LINE__,
diff --git a/gdb/testsuite/gdb.arch/x86-avx512bf16.c b/gdb/testsuite/gdb.arch/x86-avx512bf16.c
new file mode 100644
index 00000000000..fdc378818ac
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/x86-avx512bf16.c
@@ -0,0 +1,166 @@
+/* Test program for bfloat16 of AVX 512 registers.
+
+   Copyright 2020 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include "x86-cpuid.h"
+
+typedef struct
+{
+  float f[4];
+} v4sd_t;
+
+typedef struct
+{
+  float f[8];
+} v8sd_t;
+
+typedef struct
+{
+  float f[16];
+} v16sd_t;
+
+v4sd_t xmm_data[] =
+{
+  { {  0.0,  0.125,  0.25,  0.375 } },
+  { {  0.5,  0.625,  0.75,  0.875 } },
+  { {  1.0,  1.125,  1.25,  1.375 } },
+  { {  1.5,  1.625,  1.75,  1.875 } },
+  { {  2.0,  2.125,  2.25,  2.375 } },
+  { {  2.5,  2.625,  2.75,  2.875 } },
+  { {  3.0,  3.125,  3.25,  3.375 } },
+  { {  3.5,  3.625,  3.75,  3.875 } },
+};
+
+v8sd_t ymm_data[] =
+{
+  { {  8.0,  8.25,  8.5,  8.75,  9.0,  9.25,  9.5,  9.75 } },
+  { { 10.0, 10.25, 10.5, 10.75, 11.0, 11.25, 11.5, 11.75 } },
+  { { 12.0, 12.25, 12.5, 12.75, 13.0, 13.25, 13.5, 13.75 } },
+  { { 14.0, 14.25, 14.5, 14.75, 15.0, 15.25, 15.5, 15.75 } },
+  { { 16.0, 16.25, 16.5, 16.75, 17.0, 17.25, 17.5, 17.75 } },
+  { { 18.0, 18.25, 18.5, 18.75, 19.0, 19.25, 19.5, 19.75 } },
+  { { 20.0, 20.25, 20.5, 20.75, 21.0, 21.25, 21.5, 21.75 } },
+  { { 22.0, 22.25, 22.5, 22.75, 23.0, 23.25, 23.5, 23.75 } },
+};
+
+v16sd_t zmm_data[] =
+{
+  { { 20.0,  20.5,  21.0,  21.5,  22.0,  22.5,  23.0,  23.5,  24.0,  24.5,
+      25.0,  25.5,  26.0,  26.5,  27.0,  27.5 } },
+  { { 28.0,  28.5,  29.0,  29.5,  30.0,  30.5,  31.0,  31.5,  32.0,  32.5,
+      33.0,  33.5,  34.0,  34.5,  35.0,  35.5 } },
+  { { 36.0,  36.5,  37.0,  37.5,  38.0,  38.5,  39.0,  39.5,  40.0,  40.5,
+      41.0,  41.5,  42.0,  42.5,  43.0,  43.5 } },
+  { { 44.0,  44.5,  45.0,  45.5,  46.0,  46.5,  47.0,  47.5,  48.0,  48.5,
+      49.0,  49.5,  50.0,  50.5,  51.0,  51.5 } },
+  { { 52.0,  52.5,  53.0,  53.5,  54.0,  54.5,  55.0,  55.5,  56.0,  56.5,
+      57.0,  57.5,  58.0,  58.5,  59.0,  59.5 } },
+  { { 60.0,  60.5,  61.0,  61.5,  62.0,  62.5,  63.0,  63.5,  64.0,  64.5,
+      65.0,  65.5,  66.0,  66.5,  67.0,  67.5 } },
+  { { 68.0,  68.5,  69.0,  69.5,  70.0,  70.5,  71.0,  71.5,  72.0,  72.5,
+      73.0,  73.5,  74.0,  74.5,  75.0,  75.5 } },
+  { { 76.0,  76.5,  77.0,  77.5,  78.0,  78.5,  79.0,  79.5,  80.0,  80.5,
+      81.0,  81.5,  82.0,  82.5,  83.0,  83.5 } },
+};
+
+void
+move_data_to_xmm_reg (void)
+{
+  asm ("vmovups 0(%0), %%xmm0 \n\t"
+       "vmovups 16(%0), %%xmm1 \n\t"
+       "vmovups 32(%0), %%xmm2 \n\t"
+       "vmovups 48(%0), %%xmm3 \n\t"
+       "vmovups 64(%0), %%xmm4 \n\t"
+       "vmovups 80(%0), %%xmm5 \n\t"
+       "vmovups 96(%0), %%xmm6 \n\t"
+       "vmovups 112(%0), %%xmm7 \n\t"
+       : /* no output operands  */
+       : "r" (xmm_data));
+}
+
+void
+move_data_to_ymm_reg (void)
+{
+  asm ("vmovups 0(%0), %%ymm0 \n\t"
+       "vmovups 32(%0), %%ymm1 \n\t"
+       "vmovups 64(%0), %%ymm2 \n\t"
+       "vmovups 96(%0), %%ymm3 \n\t"
+       "vmovups 128(%0), %%ymm4 \n\t"
+       "vmovups 160(%0), %%ymm5 \n\t"
+       "vmovups 192(%0), %%ymm6 \n\t"
+       "vmovups 224(%0), %%ymm7 \n\t"
+       : /* no output operands  */
+       : "r" (ymm_data));
+}
+
+void
+move_data_to_zmm_reg (void)
+{
+  asm ("vmovups 0(%0), %%zmm0 \n\t"
+       "vmovups 64(%0), %%zmm1 \n\t"
+       "vmovups 128(%0), %%zmm2 \n\t"
+       "vmovups 192(%0), %%zmm3 \n\t"
+       "vmovups 256(%0), %%zmm4 \n\t"
+       "vmovups 320(%0), %%zmm5 \n\t"
+       "vmovups 384(%0), %%zmm6 \n\t"
+       "vmovups 448(%0), %%zmm7 \n\t"
+       : /* no output operands  */
+       : "r" (zmm_data));
+}
+
+void
+convert_xmm_from_float_to_bfloat16 (void)
+{
+  asm("vcvtne2ps2bf16 %xmm0, %xmm1, %xmm0");
+  asm("vcvtne2ps2bf16 %xmm6, %xmm7, %xmm6");
+}
+
+void
+convert_ymm_from_float_to_bfloat16 (void)
+{
+  asm("vcvtne2ps2bf16 %ymm0, %ymm1, %ymm0");
+  asm("vcvtne2ps2bf16 %ymm6, %ymm7, %ymm6");
+}
+
+void
+convert_zmm_from_float_to_bfloat16 (void)
+{
+  asm("vcvtne2ps2bf16 %zmm0, %zmm1, %zmm0");
+  asm("vcvtne2ps2bf16 %zmm6, %zmm7, %zmm6");
+}
+
+int
+main (int argc, char **argv)
+{
+  /* Move initial values from array to registers and read from XMM regs.  */
+  move_data_to_xmm_reg ();
+  convert_xmm_from_float_to_bfloat16 ();
+  asm ("nop"); /* first breakpoint here  */
+
+  /* Move initial values from array to registers and read from YMM regs.  */
+  move_data_to_ymm_reg ();
+  convert_ymm_from_float_to_bfloat16 ();
+  asm ("nop"); /* second breakpoint here  */
+
+  /* Move initial values from array to registers and read from ZMM regs.  */
+  move_data_to_zmm_reg ();
+  convert_zmm_from_float_to_bfloat16 ();
+  asm ("nop"); /* third breakpoint here  */
+
+  return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/x86-avx512bf16.exp b/gdb/testsuite/gdb.arch/x86-avx512bf16.exp
new file mode 100644
index 00000000000..5f90d8aca28
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/x86-avx512bf16.exp
@@ -0,0 +1,74 @@
+# Copyright 2020 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Please email any bugs, comments, and/or additions to this file to:
+# bug-gdb@gnu.org
+
+# Test bfloat16 support in AVX512 registers
+
+if { [skip_avx512bf16_tests] } {
+    unsupported "target does not support AVX512BF16"
+    return -1
+}
+
+standard_testfile
+
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+    return -1
+}
+
+if { ![runto_main] } {
+    unsupported "could not run to main"
+    return -1
+}
+
+# Test xmm
+set line1 [gdb_get_line_number "first breakpoint here"]
+gdb_breakpoint $line1
+gdb_continue_to_breakpoint "line1" ".*$srcfile:$line1.*"
+
+gdb_test "print \$xmm0.v8_bfloat16" \
+    "= \\{0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875\\}"
+
+gdb_test "print \$xmm6.v8_bfloat16" \
+    "= \\{3, 3.125, 3.25, 3.375, 3.5, 3.625, 3.75, 3.875\\}"
+
+# Test ymm
+set line2 [gdb_get_line_number "second breakpoint here"]
+gdb_breakpoint $line2
+gdb_continue_to_breakpoint "line2" ".*$srcfile:$line2.*"
+
+gdb_test "print \$ymm0.v16_bfloat16\[1\]" "= 8.25"
+gdb_test "print \$ymm6.v16_bfloat16\[1\]" "= 20.25"
+
+# Test zmm
+set line3 [gdb_get_line_number "third breakpoint here"]
+gdb_breakpoint $line3
+gdb_continue_to_breakpoint "line3" ".*$srcfile:$line3.*"
+
+gdb_test "print \$zmm0.v32_bfloat16\[1\]" "= 20.5"
+gdb_test "print \$zmm6.v32_bfloat16\[1\]" "= 68.5"
+
+# Test setting of bfloat values
+gdb_test_no_output "set var \$xmm0.v8_bfloat16\[0\] = 32.25" \
+    "set %xmm0.v8_bfloat16\[0\]"
+gdb_test_no_output "set var \$ymm8.v16_bfloat16\[1\] = 33.5" \
+    "set %ymm8.v16_bfloat16\[1\]"
+gdb_test_no_output "set var \$zmm16.v32_bfloat16\[2\] = 22.75" \
+    "set %zmm16.v32_bfloat16\[2\]"
+
+gdb_test "p \$xmm0.v8_bfloat16\[0\]" "= 32.25"
+gdb_test "p \$ymm8.v16_bfloat16\[1\]" "= 33.5"
+gdb_test "p \$zmm16.v32_bfloat16\[2\]" "= 22.75"
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 78dae17b0c7..fd8b5936166 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -3061,6 +3061,57 @@ gdb_caching_proc skip_tsx_tests {
     return $skip_tsx_tests
 }
 
+# Run a test on the target to see if it supports avx512bf16.  Return 0 if so,
+# 1 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
+
+gdb_caching_proc skip_avx512bf16_tests {
+    global srcdir subdir gdb_prompt inferior_exited_re
+
+    set me "skip_avx512bf16_tests"
+    if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
+        verbose "$me:  target does not support avx512bf16, returning 1" 2
+        return 1
+    }
+
+    # Compile a test program.
+    set src {
+        int main() {
+            asm volatile ("vcvtne2ps2bf16 %xmm0, %xmm1, %xmm0");
+            return 0;
+        }
+    }
+    if {![gdb_simple_compile $me $src executable]} {
+        return 1
+    }
+
+    # No error message, compilation succeeded so now run it via gdb.
+
+    gdb_exit
+    gdb_start
+    gdb_reinitialize_dir $srcdir/$subdir
+    gdb_load "$obj"
+    gdb_run_cmd
+    gdb_expect {
+        -re ".*Illegal instruction.*${gdb_prompt} $" {
+            verbose -log "$me:  avx512bf16 hardware not detected."
+            set skip_avx512bf16_tests 1
+        }
+        -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
+            verbose -log "$me:  avx512bf16 hardware detected."
+            set skip_avx512bf16_tests 0
+        }
+        default {
+            warning "\n$me:  default case taken."
+            set skip_avx512bf16_tests 1
+        }
+    }
+    gdb_exit
+    remote_file build delete $obj
+
+    verbose "$me:  returning $skip_avx512bf16_tests" 2
+    return $skip_avx512bf16_tests
+}
+
 # Run a test on the target to see if it supports btrace hardware.  Return 0 if so,
 # 1 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
 
diff --git a/gdbsupport/tdesc.cc b/gdbsupport/tdesc.cc
index 624588b6563..c2a3af700e3 100644
--- a/gdbsupport/tdesc.cc
+++ b/gdbsupport/tdesc.cc
@@ -54,7 +54,8 @@ static tdesc_type_builtin tdesc_predefined_types[] =
   { "ieee_single", TDESC_TYPE_IEEE_SINGLE },
   { "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
   { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
-  { "i387_ext", TDESC_TYPE_I387_EXT }
+  { "i387_ext", TDESC_TYPE_I387_EXT },
+  { "bfloat16", TDESC_TYPE_BFLOAT16 }
 };
 
 void tdesc_feature::accept (tdesc_element_visitor &v) const
diff --git a/gdbsupport/tdesc.h b/gdbsupport/tdesc.h
index fdc2a6a3708..14b5b5fc9b3 100644
--- a/gdbsupport/tdesc.h
+++ b/gdbsupport/tdesc.h
@@ -173,6 +173,7 @@ enum tdesc_type_kind
   TDESC_TYPE_IEEE_DOUBLE,
   TDESC_TYPE_ARM_FPA_EXT,
   TDESC_TYPE_I387_EXT,
+  TDESC_TYPE_BFLOAT16,
 
   /* Types defined by a target feature.  */
   TDESC_TYPE_VECTOR,
diff --git a/include/floatformat.h b/include/floatformat.h
index ce8d6d4add8..b3338eb63ad 100644
--- a/include/floatformat.h
+++ b/include/floatformat.h
@@ -133,6 +133,9 @@ extern const struct floatformat floatformat_ia64_quad_little;
 /* IBM long double (double+double).  */
 extern const struct floatformat floatformat_ibm_long_double_big;
 extern const struct floatformat floatformat_ibm_long_double_little;
+/* Intel bfloat16.  */
+extern const struct floatformat floatformat_bfloat16_big;
+extern const struct floatformat floatformat_bfloat16_little;
 
 /* Convert from FMT to a double.
    FROM is the address of the extended float.
diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
index 2fd5e688ec4..6b9b03288e2 100644
--- a/libiberty/floatformat.c
+++ b/libiberty/floatformat.c
@@ -389,7 +389,24 @@ const struct floatformat floatformat_ibm_long_double_little =
   floatformat_ibm_long_double_is_valid,
   &floatformat_ieee_double_little
 };
-\f
+
+const struct floatformat floatformat_bfloat16_big =
+{
+  floatformat_big, 16, 0, 1, 8, 127, 255, 9, 7,
+  floatformat_intbit_no,
+  "floatformat_bfloat16_big",
+  floatformat_always_valid,
+  NULL
+};
+
+const struct floatformat floatformat_bfloat16_little =
+{
+  floatformat_little, 16, 0, 1, 8, 127, 255, 9, 7,
+  floatformat_intbit_no,
+  "floatformat_bfloat16_little",
+  floatformat_always_valid,
+  NULL
+};
 
 #ifndef min
 #define min(a, b) ((a) < (b) ? (a) : (b))
-- 
2.25.4

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/2] i386-tdep: Fix naming in zmm and ymm type descriptions.
  2020-07-21 15:52 ` [PATCH 1/2] i386-tdep: Fix naming in zmm and ymm type descriptions Felix Willgerodt
@ 2020-07-22 18:45   ` Kevin Buettner
  0 siblings, 0 replies; 8+ messages in thread
From: Kevin Buettner @ 2020-07-22 18:45 UTC (permalink / raw)
  To: Felix Willgerodt via Gdb-patches

On Tue, 21 Jul 2020 17:52:54 +0200
Felix Willgerodt via Gdb-patches <gdb-patches@sourceware.org> wrote:

> gdb/Changelog:
> 2020-07-02  Felix Willgerodt  <felix.willgerodt@intel.com>
> 
> 	* i386-tdep.c (i386_zmm_type): Fix field names.
> 	(i386_ymm_type): Fix field names.
> 
> 2020-07-21  Felix Willgerodt  <felix.willgerodt@intel.com>
> ---
>  gdb/i386-tdep.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
> index 9b905c1996a..648974455f6 100644
> --- a/gdb/i386-tdep.c
> +++ b/gdb/i386-tdep.c
> @@ -3103,13 +3103,13 @@ i386_zmm_type (struct gdbarch *gdbarch)
>  #if 0
>        union __gdb_builtin_type_vec512i
>        {
> -	int128_t uint128[4];
> -	int64_t v4_int64[8];
> -	int32_t v8_int32[16];
> -	int16_t v16_int16[32];
> -	int8_t v32_int8[64];
> -	double v4_double[8];
> -	float v8_float[16];
> +	int128_t v4_int128[4];
> +	int64_t v8_int64[8];
> +	int32_t v16_int32[16];
> +	int16_t v32_int16[32];
> +	int8_t v64_int8[64];
> +	double v8_double[8];
> +	float v16_float[16];
>        };
>  #endif
>  
> @@ -3156,13 +3156,13 @@ i386_ymm_type (struct gdbarch *gdbarch)
>  #if 0
>        union __gdb_builtin_type_vec256i
>        {
> -        int128_t uint128[2];
> -        int64_t v2_int64[4];
> -        int32_t v4_int32[8];
> -        int16_t v8_int16[16];
> -        int8_t v16_int8[32];
> -        double v2_double[4];
> -        float v4_float[8];
> +        int128_t v2_int128[2];
> +        int64_t v4_int64[4];
> +        int32_t v8_int32[8];
> +        int16_t v16_int16[16];
> +        int8_t v32_int8[32];
> +        double v4_double[4];
> +        float v8_float[8];
>        };
>  #endif

This is okay.

Kevin


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] Add bfloat16 support for AVX512 register view.
  2020-07-21 15:52 ` [PATCH 2/2] Add bfloat16 support for AVX512 register view Felix Willgerodt
@ 2020-07-22 22:19   ` Kevin Buettner
  2020-07-24  8:06     ` Willgerodt, Felix
  2020-07-22 22:27   ` Luis Machado
  1 sibling, 1 reply; 8+ messages in thread
From: Kevin Buettner @ 2020-07-22 22:19 UTC (permalink / raw)
  To: Felix Willgerodt via Gdb-patches

Hi Felix,

See my comments inline below.

Assuming you get approval on the include and libiberty portions, I
think this should be pushed (without another round trip back to this
list) after addressing my concerns.

On Tue, 21 Jul 2020 17:52:55 +0200
Felix Willgerodt via Gdb-patches <gdb-patches@sourceware.org> wrote:

> This adds support for the bfloat16 datatype, which can be seen as a short
> version of FP32, skipping the least significant 16 bits of the mantissa.
> Since the datatype is currently only supported by the AVX512 registers,
> the printing of bfloat16 values is only supported for xmm, ymm and zmm
> registers.
> 
> gdb/ChangeLog:
> 2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
> 	    Felix Willgerodt  <Felix.Willgerodt@intel.com>
> 
> 	* gdbarch.sh: Added bfloat16 type.
> 	* gdbarch.c: Regenerated.
> 	* gdbarch.h: Regenerated.
> 	* gdbtypes.c (floatformats_bfloat16): New struct.
> 	(gdbtypes_post_init): Add builtin_bfloat16.
> 	* gdbtypes.h (struct builtin_type) <builtin_bfloat16>: New member.
> 	(floatformats_bfloat16): New struct.
> 	* i386-tdep.c (i386_zmm_type): Add field "v32_bfloat16"
> 	(i386_ymm_type): Add field "v16_bfloat16"
> 	(i386_gdbarch_init): Add set_gdbarch_bfloat16_format.
> 	* target-descriptions.c (make_gdb_type): Add case TDESC_TYPE_BFLOAT16.
> 	* gdbsupport/tdesc.cc (tdesc_predefined_types): New member bfloat16.
> 	* gdbsupport/tdesc.h (tdesc_type_kind): New member TDESC_TYPE_BFLOAT16.
> 
> gdb/features/ChangeLog:

I think this is just gdb/ChangeLog, not gdb/features/ChangeLog.

> 2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
> 	    Felix Willgerodt  <Felix.Willgerodt@intel.com>
> 
> 	* features/64bit-avx512.c
> 	(create_feature_i386_64bit_avx512): Add vector v8bf.
> 	(create_feature_i386_64bit_avx512): Add field v8_bfloat16.
> 	* features/64bit-avx512.xml: Likewise.
> 	* features/64bit-sse.c
> 	(create_feature_i386_64bit_sse): Add vector v8bf.
> 	(create_feature_i386_64bit_sse): Add field v8_bfloat16.
> 	* features/64bit-sse.xml: Likewise.

These files are in features/i386.

Also, the .c files were (re)generated from the .xml files, right?

> gdb/testsuite/ChangeLog:
> 2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
> 	    Felix Willgerodt  <Felix.Willgerodt@intel.com>
> 
> 	* x86-avx512bf16.c: New file.
> 	* x86-avx512bf16.exp: Likewise.
> 	* lib/gdb.exp (skip_avx512bf16_tests): New function.
> 
> include/ChangeLog:
> 2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
> 
> 	* floatformat.h: Add struct floatformat_intel_bfloat16_big.
> 	Add struct floatformat_intel_bfloat16_little.
> 
> libiberty/ChangeLog:
> 2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
> 
> 	* floatformat.c: Add struct floatformat_intel_bfloat16_big.
> 	Add struct floatformat_intel_bfloat16_little.
> 
> 2020-07-21  Felix Willgerodt  <felix.willgerodt@intel.com>
> ---
>  gdb/features/i386/64bit-avx512.c          |   5 +
>  gdb/features/i386/64bit-avx512.xml        |   4 +-
>  gdb/features/i386/64bit-sse.c             |   5 +
>  gdb/features/i386/64bit-sse.xml           |   2 +
>  gdb/gdbarch.c                             |  45 ++++++
>  gdb/gdbarch.h                             |   8 +-
>  gdb/gdbarch.sh                            |   4 +-
>  gdb/gdbtypes.c                            |   7 +
>  gdb/gdbtypes.h                            |   3 +-
>  gdb/i386-tdep.c                           |   9 ++
>  gdb/target-descriptions.c                 |   5 +
>  gdb/testsuite/gdb.arch/x86-avx512bf16.c   | 166 ++++++++++++++++++++++
>  gdb/testsuite/gdb.arch/x86-avx512bf16.exp |  74 ++++++++++
>  gdb/testsuite/lib/gdb.exp                 |  51 +++++++
>  gdbsupport/tdesc.cc                       |   3 +-
>  gdbsupport/tdesc.h                        |   1 +
>  include/floatformat.h                     |   3 +
>  libiberty/floatformat.c                   |  19 ++-
>  18 files changed, 408 insertions(+), 6 deletions(-)
>  create mode 100644 gdb/testsuite/gdb.arch/x86-avx512bf16.c
>  create mode 100644 gdb/testsuite/gdb.arch/x86-avx512bf16.exp
> 
> diff --git a/gdb/features/i386/64bit-avx512.c b/gdb/features/i386/64bit-avx512.c
> index d12234c41ce..1bd49dcd9d5 100644
> --- a/gdb/features/i386/64bit-avx512.c
> +++ b/gdb/features/i386/64bit-avx512.c
> @@ -10,6 +10,9 @@ create_feature_i386_64bit_avx512 (struct target_desc *result, long regnum)
>  
>    feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512");
>    tdesc_type *element_type;
> +  element_type = tdesc_named_type (feature, "bfloat16");
> +  tdesc_create_vector (feature, "v8bf16", element_type, 8);
> +
>    element_type = tdesc_named_type (feature, "ieee_single");
>    tdesc_create_vector (feature, "v4f", element_type, 4);
>  
> @@ -31,6 +34,8 @@ create_feature_i386_64bit_avx512 (struct target_desc *result, long regnum)
>    tdesc_type_with_fields *type_with_fields;
>    type_with_fields = tdesc_create_union (feature, "vec128");
>    tdesc_type *field_type;
> +  field_type = tdesc_named_type (feature, "v8bf16");
> +  tdesc_add_field (type_with_fields, "v8_bfloat16", field_type);
>    field_type = tdesc_named_type (feature, "v4f");
>    tdesc_add_field (type_with_fields, "v4_float", field_type);
>    field_type = tdesc_named_type (feature, "v2d");
> diff --git a/gdb/features/i386/64bit-avx512.xml b/gdb/features/i386/64bit-avx512.xml
> index 4f02136533d..3636121e847 100644
> --- a/gdb/features/i386/64bit-avx512.xml
> +++ b/gdb/features/i386/64bit-avx512.xml
> @@ -7,13 +7,15 @@
>  
>  <!DOCTYPE feature SYSTEM "gdb-target.dtd">
>  <feature name="org.gnu.gdb.i386.avx512">
> -<vector id="v4f" type="ieee_single" count="4"/>
> +  <vector id="v8bf16" type="bfloat16" count="8"/>
> +  <vector id="v4f" type="ieee_single" count="4"/>
>    <vector id="v2d" type="ieee_double" count="2"/>
>    <vector id="v16i8" type="int8" count="16"/>
>    <vector id="v8i16" type="int16" count="8"/>
>    <vector id="v4i32" type="int32" count="4"/>
>    <vector id="v2i64" type="int64" count="2"/>
>    <union id="vec128">
> +    <field name="v8_bfloat16" type="v8bf16"/>
>      <field name="v4_float" type="v4f"/>
>      <field name="v2_double" type="v2d"/>
>      <field name="v16_int8" type="v16i8"/>
> diff --git a/gdb/features/i386/64bit-sse.c b/gdb/features/i386/64bit-sse.c
> index 48b5aa09793..645e3141337 100644
> --- a/gdb/features/i386/64bit-sse.c
> +++ b/gdb/features/i386/64bit-sse.c
> @@ -10,6 +10,9 @@ create_feature_i386_64bit_sse (struct target_desc *result, long regnum)
>  
>    feature = tdesc_create_feature (result, "org.gnu.gdb.i386.sse");
>    tdesc_type *element_type;
> +  element_type = tdesc_named_type (feature, "bfloat16");
> +  tdesc_create_vector (feature, "v8bf16", element_type, 8);
> +
>    element_type = tdesc_named_type (feature, "ieee_single");
>    tdesc_create_vector (feature, "v4f", element_type, 4);
>  
> @@ -31,6 +34,8 @@ create_feature_i386_64bit_sse (struct target_desc *result, long regnum)
>    tdesc_type_with_fields *type_with_fields;
>    type_with_fields = tdesc_create_union (feature, "vec128");
>    tdesc_type *field_type;
> +  field_type = tdesc_named_type (feature, "v8bf16");
> +  tdesc_add_field (type_with_fields, "v8_bfloat16", field_type);
>    field_type = tdesc_named_type (feature, "v4f");
>    tdesc_add_field (type_with_fields, "v4_float", field_type);
>    field_type = tdesc_named_type (feature, "v2d");
> diff --git a/gdb/features/i386/64bit-sse.xml b/gdb/features/i386/64bit-sse.xml
> index 4ec1e7c1e36..e3dec544cf4 100644
> --- a/gdb/features/i386/64bit-sse.xml
> +++ b/gdb/features/i386/64bit-sse.xml
> @@ -7,6 +7,7 @@
>  
>  <!DOCTYPE feature SYSTEM "gdb-target.dtd">
>  <feature name="org.gnu.gdb.i386.sse">
> +  <vector id="v8bf16" type="bfloat16" count="8"/>
>    <vector id="v4f" type="ieee_single" count="4"/>
>    <vector id="v2d" type="ieee_double" count="2"/>
>    <vector id="v16i8" type="int8" count="16"/>
> @@ -14,6 +15,7 @@
>    <vector id="v4i32" type="int32" count="4"/>
>    <vector id="v2i64" type="int64" count="2"/>
>    <union id="vec128">
> +    <field name="v8_bfloat16" type="v8bf16"/>
>      <field name="v4_float" type="v4f"/>
>      <field name="v2_double" type="v2d"/>
>      <field name="v16_int8" type="v16i8"/>
> diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
> index 21ee840e88f..d9e5dcfbaf5 100644
> --- a/gdb/gdbarch.c
> +++ b/gdb/gdbarch.c
> @@ -166,6 +166,8 @@ struct gdbarch
>    int int_bit;
>    int long_bit;
>    int long_long_bit;
> +  int bfloat16_bit;
> +  const struct floatformat ** bfloat16_format;
>    int half_bit;
>    const struct floatformat ** half_format;
>    int float_bit;
> @@ -382,6 +384,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
>    gdbarch->int_bit = 4*TARGET_CHAR_BIT;
>    gdbarch->long_bit = 4*TARGET_CHAR_BIT;
>    gdbarch->long_long_bit = 2*gdbarch->long_bit;
> +  gdbarch->bfloat16_bit = 2*TARGET_CHAR_BIT;
>    gdbarch->half_bit = 2*TARGET_CHAR_BIT;
>    gdbarch->float_bit = 4*TARGET_CHAR_BIT;
>    gdbarch->double_bit = 8*TARGET_CHAR_BIT;
> @@ -521,6 +524,9 @@ verify_gdbarch (struct gdbarch *gdbarch)
>    /* Skip verify of int_bit, invalid_p == 0 */
>    /* Skip verify of long_bit, invalid_p == 0 */
>    /* Skip verify of long_long_bit, invalid_p == 0 */
> +  /* Skip verify of bfloat16_bit, invalid_p == 0 */
> +  if (gdbarch->bfloat16_format == 0)
> +    gdbarch->bfloat16_format = floatformats_bfloat16;
>    /* Skip verify of half_bit, invalid_p == 0 */
>    if (gdbarch->half_format == 0)
>      gdbarch->half_format = floatformats_ieee_half;
> @@ -804,6 +810,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
>    fprintf_unfiltered (file,
>                        "gdbarch_dump: bfd_arch_info = %s\n",
>                        gdbarch_bfd_arch_info (gdbarch)->printable_name);
> +  fprintf_unfiltered (file,
> +                      "gdbarch_dump: bfloat16_bit = %s\n",
> +                      plongest (gdbarch->bfloat16_bit));
> +  fprintf_unfiltered (file,
> +                      "gdbarch_dump: bfloat16_format = %s\n",
> +                      pformat (gdbarch->bfloat16_format));
>    fprintf_unfiltered (file,
>                        "gdbarch_dump: breakpoint_from_pc = <%s>\n",
>                        host_address_to_string (gdbarch->breakpoint_from_pc));
> @@ -1614,6 +1626,39 @@ set_gdbarch_long_long_bit (struct gdbarch *gdbarch,
>    gdbarch->long_long_bit = long_long_bit;
>  }
>  
> +int
> +gdbarch_bfloat16_bit (struct gdbarch *gdbarch)
> +{
> +  gdb_assert (gdbarch != NULL);
> +  /* Skip verify of bfloat16_bit, invalid_p == 0 */
> +  if (gdbarch_debug >= 2)
> +    fprintf_unfiltered (gdb_stdlog, "gdbarch_bfloat16_bit called\n");
> +  return gdbarch->bfloat16_bit;
> +}
> +
> +void
> +set_gdbarch_bfloat16_bit (struct gdbarch *gdbarch,
> +                          int bfloat16_bit)
> +{
> +  gdbarch->bfloat16_bit = bfloat16_bit;
> +}
> +
> +const struct floatformat **
> +gdbarch_bfloat16_format (struct gdbarch *gdbarch)
> +{
> +  gdb_assert (gdbarch != NULL);
> +  if (gdbarch_debug >= 2)
> +    fprintf_unfiltered (gdb_stdlog, "gdbarch_bfloat16_format called\n");
> +  return gdbarch->bfloat16_format;
> +}
> +
> +void
> +set_gdbarch_bfloat16_format (struct gdbarch *gdbarch,
> +                             const struct floatformat ** bfloat16_format)
> +{
> +  gdbarch->bfloat16_format = bfloat16_format;
> +}
> +
>  int
>  gdbarch_half_bit (struct gdbarch *gdbarch)
>  {
> diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
> index 0940156aeb8..c555fc2bc42 100644
> --- a/gdb/gdbarch.h
> +++ b/gdb/gdbarch.h
> @@ -158,12 +158,18 @@ extern void set_gdbarch_long_bit (struct gdbarch *gdbarch, int long_bit);
>  extern int gdbarch_long_long_bit (struct gdbarch *gdbarch);
>  extern void set_gdbarch_long_long_bit (struct gdbarch *gdbarch, int long_long_bit);
>  
> -/* The ABI default bit-size and format for "half", "float", "double", and
> +/* The ABI default bit-size and format for "bfloat16", "half", "float", "double", and
>     "long double".  These bit/format pairs should eventually be combined
>     into a single object.  For the moment, just initialize them as a pair.
>     Each format describes both the big and little endian layouts (if
>     useful). */
>  
> +extern int gdbarch_bfloat16_bit (struct gdbarch *gdbarch);
> +extern void set_gdbarch_bfloat16_bit (struct gdbarch *gdbarch, int bfloat16_bit);
> +
> +extern const struct floatformat ** gdbarch_bfloat16_format (struct gdbarch *gdbarch);
> +extern void set_gdbarch_bfloat16_format (struct gdbarch *gdbarch, const struct floatformat ** bfloat16_format);
> +
>  extern int gdbarch_half_bit (struct gdbarch *gdbarch);
>  extern void set_gdbarch_half_bit (struct gdbarch *gdbarch, int half_bit);
>  
> diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
> index 41e7b8d5cc3..f2f2b76d954 100755
> --- a/gdb/gdbarch.sh
> +++ b/gdb/gdbarch.sh
> @@ -325,12 +325,14 @@ v;int;long_bit;;;8 * sizeof (long);4*TARGET_CHAR_BIT;;0
>  # machine.
>  v;int;long_long_bit;;;8 * sizeof (LONGEST);2*gdbarch->long_bit;;0
>  
> -# The ABI default bit-size and format for "half", "float", "double", and
> +# The ABI default bit-size and format for "bfloat16", "half", "float", "double", and
>  # "long double".  These bit/format pairs should eventually be combined
>  # into a single object.  For the moment, just initialize them as a pair.
>  # Each format describes both the big and little endian layouts (if
>  # useful).
>  
> +v;int;bfloat16_bit;;;16;2*TARGET_CHAR_BIT;;0
> +v;const struct floatformat **;bfloat16_format;;;;;floatformats_bfloat16;;pformat (gdbarch->bfloat16_format)
>  v;int;half_bit;;;16;2*TARGET_CHAR_BIT;;0
>  v;const struct floatformat **;half_format;;;;;floatformats_ieee_half;;pformat (gdbarch->half_format)
>  v;int;float_bit;;;8 * sizeof (float);4*TARGET_CHAR_BIT;;0
> diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
> index e87648813ec..a9ce0e6c34c 100644
> --- a/gdb/gdbtypes.c
> +++ b/gdb/gdbtypes.c
> @@ -115,6 +115,10 @@ const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN] = {
>    &floatformat_ibm_long_double_big,
>    &floatformat_ibm_long_double_little
>  };
> +const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN] = {
> +  &floatformat_bfloat16_big,
> +  &floatformat_bfloat16_little
> +};
>  
>  /* Should opaque types be resolved?  */
>  
> @@ -5739,6 +5743,9 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
>    builtin_type->builtin_float
>      = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
>  		       "float", gdbarch_float_format (gdbarch));
> +  builtin_type->builtin_bfloat16
> +    = arch_float_type (gdbarch, gdbarch_bfloat16_bit (gdbarch),
> +		       "bfloat16", gdbarch_bfloat16_format (gdbarch));
>    builtin_type->builtin_double
>      = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
>  		       "double", gdbarch_double_format (gdbarch));
> diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
> index eaa4cff608d..961b87d43d9 100644
> --- a/gdb/gdbtypes.h
> +++ b/gdb/gdbtypes.h
> @@ -1857,6 +1857,7 @@ struct builtin_type
>    struct type *builtin_unsigned_short;
>    struct type *builtin_unsigned_int;
>    struct type *builtin_unsigned_long;
> +  struct type *builtin_bfloat16;
>    struct type *builtin_half;
>    struct type *builtin_float;
>    struct type *builtin_double;
> @@ -1991,7 +1992,7 @@ extern const struct floatformat *floatformats_ia64_quad[BFD_ENDIAN_UNKNOWN];
>  extern const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN];
>  extern const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN];
>  extern const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN];
> -
> +extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN];
>  
>  /* Allocate space for storing data associated with a particular
>     type.  We ensure that the space is allocated using the same
> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
> index 648974455f6..51c5a644d5d 100644
> --- a/gdb/i386-tdep.c
> +++ b/gdb/i386-tdep.c
> @@ -3110,6 +3110,7 @@ i386_zmm_type (struct gdbarch *gdbarch)
>  	int8_t v64_int8[64];
>  	double v8_double[8];
>  	float v16_float[16];
> +	bfloat16_t v32_bfloat16[32];
>        };
>  #endif
>  
> @@ -3117,6 +3118,8 @@ i386_zmm_type (struct gdbarch *gdbarch)
>  
>        t = arch_composite_type (gdbarch,
>  			       "__gdb_builtin_type_vec512i", TYPE_CODE_UNION);
> +      append_composite_type_field (t, "v32_bfloat16",
> +				   init_vector_type (bt->builtin_bfloat16, 32));
>        append_composite_type_field (t, "v16_float",
>  				   init_vector_type (bt->builtin_float, 16));
>        append_composite_type_field (t, "v8_double",
> @@ -3163,6 +3166,7 @@ i386_ymm_type (struct gdbarch *gdbarch)
>          int8_t v32_int8[32];
>          double v4_double[4];
>          float v8_float[8];
> +        bfloat16_t v16_bfloat16[16];
>        };
>  #endif
>  
> @@ -3170,6 +3174,8 @@ i386_ymm_type (struct gdbarch *gdbarch)
>  
>        t = arch_composite_type (gdbarch,
>  			       "__gdb_builtin_type_vec256i", TYPE_CODE_UNION);
> +      append_composite_type_field (t, "v16_bfloat16",
> +				   init_vector_type (bt->builtin_bfloat16, 16));
>        append_composite_type_field (t, "v8_float",
>  				   init_vector_type (bt->builtin_float, 8));
>        append_composite_type_field (t, "v4_double",
> @@ -8483,6 +8489,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
>       alignment.  */
>    set_gdbarch_long_double_bit (gdbarch, 96);
>  
> +  /* Support of bfloat16 format.  */
> +  set_gdbarch_bfloat16_format (gdbarch, floatformats_bfloat16);
> +
>    /* Support for floating-point data type variants.  */
>    set_gdbarch_floatformat_for_type (gdbarch, i386_floatformat_for_type);
>  
> diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
> index 20d624c0c65..6778b93400b 100644
> --- a/gdb/target-descriptions.c
> +++ b/gdb/target-descriptions.c
> @@ -141,6 +141,11 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
>  	  m_type = arch_float_type (m_gdbarch, -1, "builtin_type_i387_ext",
>  				    floatformats_i387_ext);
>  	  return;
> +
> +	case TDESC_TYPE_BFLOAT16:
> +	  m_type = arch_float_type (m_gdbarch, -1, "builtin_type_bfloat16",
> +				    floatformats_bfloat16);
> +	  return;
>  	}
>  
>        internal_error (__FILE__, __LINE__,
> diff --git a/gdb/testsuite/gdb.arch/x86-avx512bf16.c b/gdb/testsuite/gdb.arch/x86-avx512bf16.c
> new file mode 100644
> index 00000000000..fdc378818ac
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/x86-avx512bf16.c
> @@ -0,0 +1,166 @@
> +/* Test program for bfloat16 of AVX 512 registers.
> +
> +   Copyright 2020 Free Software Foundation, Inc.
> +
> +   This file is part of GDB.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#include "x86-cpuid.h"

Is x86-cpuid.h needed for this test?

> +
> +typedef struct
> +{
> +  float f[4];
> +} v4sd_t;
> +
> +typedef struct
> +{
> +  float f[8];
> +} v8sd_t;
> +
> +typedef struct
> +{
> +  float f[16];
> +} v16sd_t;
> +
> +v4sd_t xmm_data[] =
> +{
> +  { {  0.0,  0.125,  0.25,  0.375 } },
> +  { {  0.5,  0.625,  0.75,  0.875 } },
> +  { {  1.0,  1.125,  1.25,  1.375 } },
> +  { {  1.5,  1.625,  1.75,  1.875 } },
> +  { {  2.0,  2.125,  2.25,  2.375 } },
> +  { {  2.5,  2.625,  2.75,  2.875 } },
> +  { {  3.0,  3.125,  3.25,  3.375 } },
> +  { {  3.5,  3.625,  3.75,  3.875 } },
> +};
> +
> +v8sd_t ymm_data[] =
> +{
> +  { {  8.0,  8.25,  8.5,  8.75,  9.0,  9.25,  9.5,  9.75 } },
> +  { { 10.0, 10.25, 10.5, 10.75, 11.0, 11.25, 11.5, 11.75 } },
> +  { { 12.0, 12.25, 12.5, 12.75, 13.0, 13.25, 13.5, 13.75 } },
> +  { { 14.0, 14.25, 14.5, 14.75, 15.0, 15.25, 15.5, 15.75 } },
> +  { { 16.0, 16.25, 16.5, 16.75, 17.0, 17.25, 17.5, 17.75 } },
> +  { { 18.0, 18.25, 18.5, 18.75, 19.0, 19.25, 19.5, 19.75 } },
> +  { { 20.0, 20.25, 20.5, 20.75, 21.0, 21.25, 21.5, 21.75 } },
> +  { { 22.0, 22.25, 22.5, 22.75, 23.0, 23.25, 23.5, 23.75 } },
> +};
> +
> +v16sd_t zmm_data[] =
> +{
> +  { { 20.0,  20.5,  21.0,  21.5,  22.0,  22.5,  23.0,  23.5,  24.0,  24.5,
> +      25.0,  25.5,  26.0,  26.5,  27.0,  27.5 } },
> +  { { 28.0,  28.5,  29.0,  29.5,  30.0,  30.5,  31.0,  31.5,  32.0,  32.5,
> +      33.0,  33.5,  34.0,  34.5,  35.0,  35.5 } },
> +  { { 36.0,  36.5,  37.0,  37.5,  38.0,  38.5,  39.0,  39.5,  40.0,  40.5,
> +      41.0,  41.5,  42.0,  42.5,  43.0,  43.5 } },
> +  { { 44.0,  44.5,  45.0,  45.5,  46.0,  46.5,  47.0,  47.5,  48.0,  48.5,
> +      49.0,  49.5,  50.0,  50.5,  51.0,  51.5 } },
> +  { { 52.0,  52.5,  53.0,  53.5,  54.0,  54.5,  55.0,  55.5,  56.0,  56.5,
> +      57.0,  57.5,  58.0,  58.5,  59.0,  59.5 } },
> +  { { 60.0,  60.5,  61.0,  61.5,  62.0,  62.5,  63.0,  63.5,  64.0,  64.5,
> +      65.0,  65.5,  66.0,  66.5,  67.0,  67.5 } },
> +  { { 68.0,  68.5,  69.0,  69.5,  70.0,  70.5,  71.0,  71.5,  72.0,  72.5,
> +      73.0,  73.5,  74.0,  74.5,  75.0,  75.5 } },
> +  { { 76.0,  76.5,  77.0,  77.5,  78.0,  78.5,  79.0,  79.5,  80.0,  80.5,
> +      81.0,  81.5,  82.0,  82.5,  83.0,  83.5 } },
> +};
> +
> +void
> +move_data_to_xmm_reg (void)
> +{
> +  asm ("vmovups 0(%0), %%xmm0 \n\t"
> +       "vmovups 16(%0), %%xmm1 \n\t"
> +       "vmovups 32(%0), %%xmm2 \n\t"
> +       "vmovups 48(%0), %%xmm3 \n\t"
> +       "vmovups 64(%0), %%xmm4 \n\t"
> +       "vmovups 80(%0), %%xmm5 \n\t"
> +       "vmovups 96(%0), %%xmm6 \n\t"
> +       "vmovups 112(%0), %%xmm7 \n\t"
> +       : /* no output operands  */
> +       : "r" (xmm_data));
> +}
> +
> +void
> +move_data_to_ymm_reg (void)
> +{
> +  asm ("vmovups 0(%0), %%ymm0 \n\t"
> +       "vmovups 32(%0), %%ymm1 \n\t"
> +       "vmovups 64(%0), %%ymm2 \n\t"
> +       "vmovups 96(%0), %%ymm3 \n\t"
> +       "vmovups 128(%0), %%ymm4 \n\t"
> +       "vmovups 160(%0), %%ymm5 \n\t"
> +       "vmovups 192(%0), %%ymm6 \n\t"
> +       "vmovups 224(%0), %%ymm7 \n\t"
> +       : /* no output operands  */
> +       : "r" (ymm_data));
> +}
> +
> +void
> +move_data_to_zmm_reg (void)
> +{
> +  asm ("vmovups 0(%0), %%zmm0 \n\t"
> +       "vmovups 64(%0), %%zmm1 \n\t"
> +       "vmovups 128(%0), %%zmm2 \n\t"
> +       "vmovups 192(%0), %%zmm3 \n\t"
> +       "vmovups 256(%0), %%zmm4 \n\t"
> +       "vmovups 320(%0), %%zmm5 \n\t"
> +       "vmovups 384(%0), %%zmm6 \n\t"
> +       "vmovups 448(%0), %%zmm7 \n\t"
> +       : /* no output operands  */
> +       : "r" (zmm_data));
> +}
> +
> +void
> +convert_xmm_from_float_to_bfloat16 (void)
> +{
> +  asm("vcvtne2ps2bf16 %xmm0, %xmm1, %xmm0");
> +  asm("vcvtne2ps2bf16 %xmm6, %xmm7, %xmm6");
> +}
> +
> +void
> +convert_ymm_from_float_to_bfloat16 (void)
> +{
> +  asm("vcvtne2ps2bf16 %ymm0, %ymm1, %ymm0");
> +  asm("vcvtne2ps2bf16 %ymm6, %ymm7, %ymm6");
> +}
> +
> +void
> +convert_zmm_from_float_to_bfloat16 (void)
> +{
> +  asm("vcvtne2ps2bf16 %zmm0, %zmm1, %zmm0");
> +  asm("vcvtne2ps2bf16 %zmm6, %zmm7, %zmm6");
> +}
> +
> +int
> +main (int argc, char **argv)
> +{
> +  /* Move initial values from array to registers and read from XMM regs.  */
> +  move_data_to_xmm_reg ();
> +  convert_xmm_from_float_to_bfloat16 ();
> +  asm ("nop"); /* first breakpoint here  */
> +
> +  /* Move initial values from array to registers and read from YMM regs.  */
> +  move_data_to_ymm_reg ();
> +  convert_ymm_from_float_to_bfloat16 ();
> +  asm ("nop"); /* second breakpoint here  */
> +
> +  /* Move initial values from array to registers and read from ZMM regs.  */
> +  move_data_to_zmm_reg ();
> +  convert_zmm_from_float_to_bfloat16 ();
> +  asm ("nop"); /* third breakpoint here  */
> +
> +  return 0;
> +}
> diff --git a/gdb/testsuite/gdb.arch/x86-avx512bf16.exp b/gdb/testsuite/gdb.arch/x86-avx512bf16.exp
> new file mode 100644
> index 00000000000..5f90d8aca28
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/x86-avx512bf16.exp
> @@ -0,0 +1,74 @@
> +# Copyright 2020 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# Please email any bugs, comments, and/or additions to this file to:
> +# bug-gdb@gnu.org
> +
> +# Test bfloat16 support in AVX512 registers
> +
> +if { [skip_avx512bf16_tests] } {
> +    unsupported "target does not support AVX512BF16"
> +    return -1
> +}
> +
> +standard_testfile
> +
> +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
> +    return -1
> +}
> +
> +if { ![runto_main] } {
> +    unsupported "could not run to main"
> +    return -1
> +}
> +
> +# Test xmm
> +set line1 [gdb_get_line_number "first breakpoint here"]
> +gdb_breakpoint $line1
> +gdb_continue_to_breakpoint "line1" ".*$srcfile:$line1.*"
> +
> +gdb_test "print \$xmm0.v8_bfloat16" \
> +    "= \\{0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875\\}"
> +
> +gdb_test "print \$xmm6.v8_bfloat16" \
> +    "= \\{3, 3.125, 3.25, 3.375, 3.5, 3.625, 3.75, 3.875\\}"
> +
> +# Test ymm
> +set line2 [gdb_get_line_number "second breakpoint here"]
> +gdb_breakpoint $line2
> +gdb_continue_to_breakpoint "line2" ".*$srcfile:$line2.*"
> +
> +gdb_test "print \$ymm0.v16_bfloat16\[1\]" "= 8.25"
> +gdb_test "print \$ymm6.v16_bfloat16\[1\]" "= 20.25"
> +
> +# Test zmm
> +set line3 [gdb_get_line_number "third breakpoint here"]
> +gdb_breakpoint $line3
> +gdb_continue_to_breakpoint "line3" ".*$srcfile:$line3.*"
> +
> +gdb_test "print \$zmm0.v32_bfloat16\[1\]" "= 20.5"
> +gdb_test "print \$zmm6.v32_bfloat16\[1\]" "= 68.5"
> +
> +# Test setting of bfloat values
> +gdb_test_no_output "set var \$xmm0.v8_bfloat16\[0\] = 32.25" \
> +    "set %xmm0.v8_bfloat16\[0\]"
> +gdb_test_no_output "set var \$ymm8.v16_bfloat16\[1\] = 33.5" \
> +    "set %ymm8.v16_bfloat16\[1\]"
> +gdb_test_no_output "set var \$zmm16.v32_bfloat16\[2\] = 22.75" \
> +    "set %zmm16.v32_bfloat16\[2\]"
> +
> +gdb_test "p \$xmm0.v8_bfloat16\[0\]" "= 32.25"
> +gdb_test "p \$ymm8.v16_bfloat16\[1\]" "= 33.5"
> +gdb_test "p \$zmm16.v32_bfloat16\[2\]" "= 22.75"
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 78dae17b0c7..fd8b5936166 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -3061,6 +3061,57 @@ gdb_caching_proc skip_tsx_tests {
>      return $skip_tsx_tests
>  }
>  
> +# Run a test on the target to see if it supports avx512bf16.  Return 0 if so,
> +# 1 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
> +
> +gdb_caching_proc skip_avx512bf16_tests {
> +    global srcdir subdir gdb_prompt inferior_exited_re
> +
> +    set me "skip_avx512bf16_tests"
> +    if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
> +        verbose "$me:  target does not support avx512bf16, returning 1" 2
> +        return 1
> +    }
> +
> +    # Compile a test program.
> +    set src {
> +        int main() {
> +            asm volatile ("vcvtne2ps2bf16 %xmm0, %xmm1, %xmm0");
> +            return 0;
> +        }
> +    }
> +    if {![gdb_simple_compile $me $src executable]} {
> +        return 1
> +    }
> +
> +    # No error message, compilation succeeded so now run it via gdb.
> +
> +    gdb_exit
> +    gdb_start
> +    gdb_reinitialize_dir $srcdir/$subdir
> +    gdb_load "$obj"
> +    gdb_run_cmd
> +    gdb_expect {
> +        -re ".*Illegal instruction.*${gdb_prompt} $" {
> +            verbose -log "$me:  avx512bf16 hardware not detected."
> +            set skip_avx512bf16_tests 1
> +        }
> +        -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
> +            verbose -log "$me:  avx512bf16 hardware detected."
> +            set skip_avx512bf16_tests 0
> +        }
> +        default {
> +            warning "\n$me:  default case taken."
> +            set skip_avx512bf16_tests 1
> +        }
> +    }
> +    gdb_exit
> +    remote_file build delete $obj
> +
> +    verbose "$me:  returning $skip_avx512bf16_tests" 2
> +    return $skip_avx512bf16_tests
> +}
> +
>  # Run a test on the target to see if it supports btrace hardware.  Return 0 if so,
>  # 1 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
>  
> diff --git a/gdbsupport/tdesc.cc b/gdbsupport/tdesc.cc
> index 624588b6563..c2a3af700e3 100644
> --- a/gdbsupport/tdesc.cc
> +++ b/gdbsupport/tdesc.cc
> @@ -54,7 +54,8 @@ static tdesc_type_builtin tdesc_predefined_types[] =
>    { "ieee_single", TDESC_TYPE_IEEE_SINGLE },
>    { "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
>    { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
> -  { "i387_ext", TDESC_TYPE_I387_EXT }
> +  { "i387_ext", TDESC_TYPE_I387_EXT },
> +  { "bfloat16", TDESC_TYPE_BFLOAT16 }
>  };
>  
>  void tdesc_feature::accept (tdesc_element_visitor &v) const
> diff --git a/gdbsupport/tdesc.h b/gdbsupport/tdesc.h
> index fdc2a6a3708..14b5b5fc9b3 100644
> --- a/gdbsupport/tdesc.h
> +++ b/gdbsupport/tdesc.h
> @@ -173,6 +173,7 @@ enum tdesc_type_kind
>    TDESC_TYPE_IEEE_DOUBLE,
>    TDESC_TYPE_ARM_FPA_EXT,
>    TDESC_TYPE_I387_EXT,
> +  TDESC_TYPE_BFLOAT16,
>  
>    /* Types defined by a target feature.  */
>    TDESC_TYPE_VECTOR,
> diff --git a/include/floatformat.h b/include/floatformat.h
> index ce8d6d4add8..b3338eb63ad 100644
> --- a/include/floatformat.h
> +++ b/include/floatformat.h
> @@ -133,6 +133,9 @@ extern const struct floatformat floatformat_ia64_quad_little;
>  /* IBM long double (double+double).  */
>  extern const struct floatformat floatformat_ibm_long_double_big;
>  extern const struct floatformat floatformat_ibm_long_double_little;
> +/* Intel bfloat16.  */
> +extern const struct floatformat floatformat_bfloat16_big;
> +extern const struct floatformat floatformat_bfloat16_little;
>  
>  /* Convert from FMT to a double.
>     FROM is the address of the extended float.

See below; I think the lib/floatformat.h change needs approval from a GCC
maintainer.

> diff --git a/libiberty/floatformat.c b/libiberty/floatformat.c
> index 2fd5e688ec4..6b9b03288e2 100644
> --- a/libiberty/floatformat.c
> +++ b/libiberty/floatformat.c
> @@ -389,7 +389,24 @@ const struct floatformat floatformat_ibm_long_double_little =
>    floatformat_ibm_long_double_is_valid,
>    &floatformat_ieee_double_little
>  };
> -\f
> +
> +const struct floatformat floatformat_bfloat16_big =
> +{
> +  floatformat_big, 16, 0, 1, 8, 127, 255, 9, 7,
> +  floatformat_intbit_no,
> +  "floatformat_bfloat16_big",
> +  floatformat_always_valid,
> +  NULL
> +};
> +
> +const struct floatformat floatformat_bfloat16_little =
> +{
> +  floatformat_little, 16, 0, 1, 8, 127, 255, 9, 7,
> +  floatformat_intbit_no,
> +  "floatformat_bfloat16_little",
> +  floatformat_always_valid,
> +  NULL
> +};

The definitions of floatformat_bfloat16_{bit,little} look correct to
me, but I think it needs approval from someone else.  libiberty/README
says to send fixes to gcc-patches@gcc.gnu.org.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] Add bfloat16 support for AVX512 register view.
  2020-07-21 15:52 ` [PATCH 2/2] Add bfloat16 support for AVX512 register view Felix Willgerodt
  2020-07-22 22:19   ` Kevin Buettner
@ 2020-07-22 22:27   ` Luis Machado
  2020-07-24  8:06     ` Willgerodt, Felix
  1 sibling, 1 reply; 8+ messages in thread
From: Luis Machado @ 2020-07-22 22:27 UTC (permalink / raw)
  To: Felix Willgerodt, gdb-patches

Just one nit...

On 7/21/20 12:52 PM, Felix Willgerodt via Gdb-patches wrote:
> This adds support for the bfloat16 datatype, which can be seen as a short
> version of FP32, skipping the least significant 16 bits of the mantissa.
> Since the datatype is currently only supported by the AVX512 registers,
> the printing of bfloat16 values is only supported for xmm, ymm and zmm
> registers.
> 
> gdb/ChangeLog:
> 2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
> 	    Felix Willgerodt  <Felix.Willgerodt@intel.com>
> 
> 	* gdbarch.sh: Added bfloat16 type.
> 	* gdbarch.c: Regenerated.
> 	* gdbarch.h: Regenerated.
> 	* gdbtypes.c (floatformats_bfloat16): New struct.
> 	(gdbtypes_post_init): Add builtin_bfloat16.
> 	* gdbtypes.h (struct builtin_type) <builtin_bfloat16>: New member.
> 	(floatformats_bfloat16): New struct.
> 	* i386-tdep.c (i386_zmm_type): Add field "v32_bfloat16"
> 	(i386_ymm_type): Add field "v16_bfloat16"
> 	(i386_gdbarch_init): Add set_gdbarch_bfloat16_format.
> 	* target-descriptions.c (make_gdb_type): Add case TDESC_TYPE_BFLOAT16.
> 	* gdbsupport/tdesc.cc (tdesc_predefined_types): New member bfloat16.
> 	* gdbsupport/tdesc.h (tdesc_type_kind): New member TDESC_TYPE_BFLOAT16.
> 
> gdb/features/ChangeLog:
> 2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
> 	    Felix Willgerodt  <Felix.Willgerodt@intel.com>
> 
> 	* features/64bit-avx512.c
> 	(create_feature_i386_64bit_avx512): Add vector v8bf.
> 	(create_feature_i386_64bit_avx512): Add field v8_bfloat16.
> 	* features/64bit-avx512.xml: Likewise.
> 	* features/64bit-sse.c
> 	(create_feature_i386_64bit_sse): Add vector v8bf.
> 	(create_feature_i386_64bit_sse): Add field v8_bfloat16.
> 	* features/64bit-sse.xml: Likewise.
> 
> gdb/testsuite/ChangeLog:
> 2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
> 	    Felix Willgerodt  <Felix.Willgerodt@intel.com>
> 
> 	* x86-avx512bf16.c: New file.
> 	* x86-avx512bf16.exp: Likewise.
> 	* lib/gdb.exp (skip_avx512bf16_tests): New function.
> 
> include/ChangeLog:
> 2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
> 
> 	* floatformat.h: Add struct floatformat_intel_bfloat16_big.
> 	Add struct floatformat_intel_bfloat16_little.
> 
> libiberty/ChangeLog:
> 2020-07-07  Moritz Riesterer  <moritz.riesterer@intel.com>
> 
> 	* floatformat.c: Add struct floatformat_intel_bfloat16_big.
> 	Add struct floatformat_intel_bfloat16_little.
> 
> 2020-07-21  Felix Willgerodt  <felix.willgerodt@intel.com>
> ---
>   gdb/features/i386/64bit-avx512.c          |   5 +
>   gdb/features/i386/64bit-avx512.xml        |   4 +-
>   gdb/features/i386/64bit-sse.c             |   5 +
>   gdb/features/i386/64bit-sse.xml           |   2 +
>   gdb/gdbarch.c                             |  45 ++++++
>   gdb/gdbarch.h                             |   8 +-
>   gdb/gdbarch.sh                            |   4 +-
>   gdb/gdbtypes.c                            |   7 +
>   gdb/gdbtypes.h                            |   3 +-
>   gdb/i386-tdep.c                           |   9 ++
>   gdb/target-descriptions.c                 |   5 +
>   gdb/testsuite/gdb.arch/x86-avx512bf16.c   | 166 ++++++++++++++++++++++
>   gdb/testsuite/gdb.arch/x86-avx512bf16.exp |  74 ++++++++++
>   gdb/testsuite/lib/gdb.exp                 |  51 +++++++
>   gdbsupport/tdesc.cc                       |   3 +-
>   gdbsupport/tdesc.h                        |   1 +
>   include/floatformat.h                     |   3 +
>   libiberty/floatformat.c                   |  19 ++-
>   18 files changed, 408 insertions(+), 6 deletions(-)
>   create mode 100644 gdb/testsuite/gdb.arch/x86-avx512bf16.c
>   create mode 100644 gdb/testsuite/gdb.arch/x86-avx512bf16.exp
> 
> diff --git a/gdb/features/i386/64bit-avx512.c b/gdb/features/i386/64bit-avx512.c
> index d12234c41ce..1bd49dcd9d5 100644
> --- a/gdb/features/i386/64bit-avx512.c
> +++ b/gdb/features/i386/64bit-avx512.c
> @@ -10,6 +10,9 @@ create_feature_i386_64bit_avx512 (struct target_desc *result, long regnum)
>   
>     feature = tdesc_create_feature (result, "org.gnu.gdb.i386.avx512");
>     tdesc_type *element_type;
> +  element_type = tdesc_named_type (feature, "bfloat16");
> +  tdesc_create_vector (feature, "v8bf16", element_type, 8);
> +
>     element_type = tdesc_named_type (feature, "ieee_single");
>     tdesc_create_vector (feature, "v4f", element_type, 4);
>   
> @@ -31,6 +34,8 @@ create_feature_i386_64bit_avx512 (struct target_desc *result, long regnum)
>     tdesc_type_with_fields *type_with_fields;
>     type_with_fields = tdesc_create_union (feature, "vec128");
>     tdesc_type *field_type;
> +  field_type = tdesc_named_type (feature, "v8bf16");
> +  tdesc_add_field (type_with_fields, "v8_bfloat16", field_type);
>     field_type = tdesc_named_type (feature, "v4f");
>     tdesc_add_field (type_with_fields, "v4_float", field_type);
>     field_type = tdesc_named_type (feature, "v2d");
> diff --git a/gdb/features/i386/64bit-avx512.xml b/gdb/features/i386/64bit-avx512.xml
> index 4f02136533d..3636121e847 100644
> --- a/gdb/features/i386/64bit-avx512.xml
> +++ b/gdb/features/i386/64bit-avx512.xml
> @@ -7,13 +7,15 @@
>   
>   <!DOCTYPE feature SYSTEM "gdb-target.dtd">
>   <feature name="org.gnu.gdb.i386.avx512">
> -<vector id="v4f" type="ieee_single" count="4"/>
> +  <vector id="v8bf16" type="bfloat16" count="8"/>
> +  <vector id="v4f" type="ieee_single" count="4"/>
>     <vector id="v2d" type="ieee_double" count="2"/>
>     <vector id="v16i8" type="int8" count="16"/>
>     <vector id="v8i16" type="int16" count="8"/>
>     <vector id="v4i32" type="int32" count="4"/>
>     <vector id="v2i64" type="int64" count="2"/>
>     <union id="vec128">
> +    <field name="v8_bfloat16" type="v8bf16"/>
>       <field name="v4_float" type="v4f"/>
>       <field name="v2_double" type="v2d"/>
>       <field name="v16_int8" type="v16i8"/>
> diff --git a/gdb/features/i386/64bit-sse.c b/gdb/features/i386/64bit-sse.c
> index 48b5aa09793..645e3141337 100644
> --- a/gdb/features/i386/64bit-sse.c
> +++ b/gdb/features/i386/64bit-sse.c
> @@ -10,6 +10,9 @@ create_feature_i386_64bit_sse (struct target_desc *result, long regnum)
>   
>     feature = tdesc_create_feature (result, "org.gnu.gdb.i386.sse");
>     tdesc_type *element_type;
> +  element_type = tdesc_named_type (feature, "bfloat16");
> +  tdesc_create_vector (feature, "v8bf16", element_type, 8);
> +
>     element_type = tdesc_named_type (feature, "ieee_single");
>     tdesc_create_vector (feature, "v4f", element_type, 4);
>   
> @@ -31,6 +34,8 @@ create_feature_i386_64bit_sse (struct target_desc *result, long regnum)
>     tdesc_type_with_fields *type_with_fields;
>     type_with_fields = tdesc_create_union (feature, "vec128");
>     tdesc_type *field_type;
> +  field_type = tdesc_named_type (feature, "v8bf16");
> +  tdesc_add_field (type_with_fields, "v8_bfloat16", field_type);
>     field_type = tdesc_named_type (feature, "v4f");
>     tdesc_add_field (type_with_fields, "v4_float", field_type);
>     field_type = tdesc_named_type (feature, "v2d");
> diff --git a/gdb/features/i386/64bit-sse.xml b/gdb/features/i386/64bit-sse.xml
> index 4ec1e7c1e36..e3dec544cf4 100644
> --- a/gdb/features/i386/64bit-sse.xml
> +++ b/gdb/features/i386/64bit-sse.xml
> @@ -7,6 +7,7 @@
>   
>   <!DOCTYPE feature SYSTEM "gdb-target.dtd">
>   <feature name="org.gnu.gdb.i386.sse">
> +  <vector id="v8bf16" type="bfloat16" count="8"/>
>     <vector id="v4f" type="ieee_single" count="4"/>
>     <vector id="v2d" type="ieee_double" count="2"/>
>     <vector id="v16i8" type="int8" count="16"/>
> @@ -14,6 +15,7 @@
>     <vector id="v4i32" type="int32" count="4"/>
>     <vector id="v2i64" type="int64" count="2"/>
>     <union id="vec128">
> +    <field name="v8_bfloat16" type="v8bf16"/>
>       <field name="v4_float" type="v4f"/>
>       <field name="v2_double" type="v2d"/>
>       <field name="v16_int8" type="v16i8"/>
> diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
> index 21ee840e88f..d9e5dcfbaf5 100644
> --- a/gdb/gdbarch.c
> +++ b/gdb/gdbarch.c
> @@ -166,6 +166,8 @@ struct gdbarch
>     int int_bit;
>     int long_bit;
>     int long_long_bit;
> +  int bfloat16_bit;
> +  const struct floatformat ** bfloat16_format;
>     int half_bit;
>     const struct floatformat ** half_format;
>     int float_bit;
> @@ -382,6 +384,7 @@ gdbarch_alloc (const struct gdbarch_info *info,
>     gdbarch->int_bit = 4*TARGET_CHAR_BIT;
>     gdbarch->long_bit = 4*TARGET_CHAR_BIT;
>     gdbarch->long_long_bit = 2*gdbarch->long_bit;
> +  gdbarch->bfloat16_bit = 2*TARGET_CHAR_BIT;
>     gdbarch->half_bit = 2*TARGET_CHAR_BIT;
>     gdbarch->float_bit = 4*TARGET_CHAR_BIT;
>     gdbarch->double_bit = 8*TARGET_CHAR_BIT;
> @@ -521,6 +524,9 @@ verify_gdbarch (struct gdbarch *gdbarch)
>     /* Skip verify of int_bit, invalid_p == 0 */
>     /* Skip verify of long_bit, invalid_p == 0 */
>     /* Skip verify of long_long_bit, invalid_p == 0 */
> +  /* Skip verify of bfloat16_bit, invalid_p == 0 */
> +  if (gdbarch->bfloat16_format == 0)
> +    gdbarch->bfloat16_format = floatformats_bfloat16;
>     /* Skip verify of half_bit, invalid_p == 0 */
>     if (gdbarch->half_format == 0)
>       gdbarch->half_format = floatformats_ieee_half;
> @@ -804,6 +810,12 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
>     fprintf_unfiltered (file,
>                         "gdbarch_dump: bfd_arch_info = %s\n",
>                         gdbarch_bfd_arch_info (gdbarch)->printable_name);
> +  fprintf_unfiltered (file,
> +                      "gdbarch_dump: bfloat16_bit = %s\n",
> +                      plongest (gdbarch->bfloat16_bit));
> +  fprintf_unfiltered (file,
> +                      "gdbarch_dump: bfloat16_format = %s\n",
> +                      pformat (gdbarch->bfloat16_format));
>     fprintf_unfiltered (file,
>                         "gdbarch_dump: breakpoint_from_pc = <%s>\n",
>                         host_address_to_string (gdbarch->breakpoint_from_pc));
> @@ -1614,6 +1626,39 @@ set_gdbarch_long_long_bit (struct gdbarch *gdbarch,
>     gdbarch->long_long_bit = long_long_bit;
>   }
>   
> +int
> +gdbarch_bfloat16_bit (struct gdbarch *gdbarch)
> +{
> +  gdb_assert (gdbarch != NULL);
> +  /* Skip verify of bfloat16_bit, invalid_p == 0 */
> +  if (gdbarch_debug >= 2)
> +    fprintf_unfiltered (gdb_stdlog, "gdbarch_bfloat16_bit called\n");
> +  return gdbarch->bfloat16_bit;
> +}
> +
> +void
> +set_gdbarch_bfloat16_bit (struct gdbarch *gdbarch,
> +                          int bfloat16_bit)
> +{
> +  gdbarch->bfloat16_bit = bfloat16_bit;
> +}
> +
> +const struct floatformat **
> +gdbarch_bfloat16_format (struct gdbarch *gdbarch)
> +{
> +  gdb_assert (gdbarch != NULL);
> +  if (gdbarch_debug >= 2)
> +    fprintf_unfiltered (gdb_stdlog, "gdbarch_bfloat16_format called\n");
> +  return gdbarch->bfloat16_format;
> +}
> +
> +void
> +set_gdbarch_bfloat16_format (struct gdbarch *gdbarch,
> +                             const struct floatformat ** bfloat16_format)
> +{
> +  gdbarch->bfloat16_format = bfloat16_format;
> +}
> +
>   int
>   gdbarch_half_bit (struct gdbarch *gdbarch)
>   {
> diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
> index 0940156aeb8..c555fc2bc42 100644
> --- a/gdb/gdbarch.h
> +++ b/gdb/gdbarch.h
> @@ -158,12 +158,18 @@ extern void set_gdbarch_long_bit (struct gdbarch *gdbarch, int long_bit);
>   extern int gdbarch_long_long_bit (struct gdbarch *gdbarch);
>   extern void set_gdbarch_long_long_bit (struct gdbarch *gdbarch, int long_long_bit);
>   
> -/* The ABI default bit-size and format for "half", "float", "double", and
> +/* The ABI default bit-size and format for "bfloat16", "half", "float", "double", and
>      "long double".  These bit/format pairs should eventually be combined
>      into a single object.  For the moment, just initialize them as a pair.
>      Each format describes both the big and little endian layouts (if
>      useful). */
>   
> +extern int gdbarch_bfloat16_bit (struct gdbarch *gdbarch);
> +extern void set_gdbarch_bfloat16_bit (struct gdbarch *gdbarch, int bfloat16_bit);
> +
> +extern const struct floatformat ** gdbarch_bfloat16_format (struct gdbarch *gdbarch);
> +extern void set_gdbarch_bfloat16_format (struct gdbarch *gdbarch, const struct floatformat ** bfloat16_format);
> +
>   extern int gdbarch_half_bit (struct gdbarch *gdbarch);
>   extern void set_gdbarch_half_bit (struct gdbarch *gdbarch, int half_bit);
>   
> diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
> index 41e7b8d5cc3..f2f2b76d954 100755
> --- a/gdb/gdbarch.sh
> +++ b/gdb/gdbarch.sh
> @@ -325,12 +325,14 @@ v;int;long_bit;;;8 * sizeof (long);4*TARGET_CHAR_BIT;;0
>   # machine.
>   v;int;long_long_bit;;;8 * sizeof (LONGEST);2*gdbarch->long_bit;;0
>   
> -# The ABI default bit-size and format for "half", "float", "double", and
> +# The ABI default bit-size and format for "bfloat16", "half", "float", "double", and
>   # "long double".  These bit/format pairs should eventually be combined
>   # into a single object.  For the moment, just initialize them as a pair.
>   # Each format describes both the big and little endian layouts (if
>   # useful).
>   
> +v;int;bfloat16_bit;;;16;2*TARGET_CHAR_BIT;;0
> +v;const struct floatformat **;bfloat16_format;;;;;floatformats_bfloat16;;pformat (gdbarch->bfloat16_format)
>   v;int;half_bit;;;16;2*TARGET_CHAR_BIT;;0
>   v;const struct floatformat **;half_format;;;;;floatformats_ieee_half;;pformat (gdbarch->half_format)
>   v;int;float_bit;;;8 * sizeof (float);4*TARGET_CHAR_BIT;;0
> diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
> index e87648813ec..a9ce0e6c34c 100644
> --- a/gdb/gdbtypes.c
> +++ b/gdb/gdbtypes.c
> @@ -115,6 +115,10 @@ const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN] = {
>     &floatformat_ibm_long_double_big,
>     &floatformat_ibm_long_double_little
>   };
> +const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN] = {
> +  &floatformat_bfloat16_big,
> +  &floatformat_bfloat16_little
> +};
>   
>   /* Should opaque types be resolved?  */
>   
> @@ -5739,6 +5743,9 @@ gdbtypes_post_init (struct gdbarch *gdbarch)
>     builtin_type->builtin_float
>       = arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
>   		       "float", gdbarch_float_format (gdbarch));
> +  builtin_type->builtin_bfloat16
> +    = arch_float_type (gdbarch, gdbarch_bfloat16_bit (gdbarch),
> +		       "bfloat16", gdbarch_bfloat16_format (gdbarch));
>     builtin_type->builtin_double
>       = arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
>   		       "double", gdbarch_double_format (gdbarch));
> diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
> index eaa4cff608d..961b87d43d9 100644
> --- a/gdb/gdbtypes.h
> +++ b/gdb/gdbtypes.h
> @@ -1857,6 +1857,7 @@ struct builtin_type
>     struct type *builtin_unsigned_short;
>     struct type *builtin_unsigned_int;
>     struct type *builtin_unsigned_long;
> +  struct type *builtin_bfloat16;
>     struct type *builtin_half;
>     struct type *builtin_float;
>     struct type *builtin_double;
> @@ -1991,7 +1992,7 @@ extern const struct floatformat *floatformats_ia64_quad[BFD_ENDIAN_UNKNOWN];
>   extern const struct floatformat *floatformats_vax_f[BFD_ENDIAN_UNKNOWN];
>   extern const struct floatformat *floatformats_vax_d[BFD_ENDIAN_UNKNOWN];
>   extern const struct floatformat *floatformats_ibm_long_double[BFD_ENDIAN_UNKNOWN];
> -
> +extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN];
>   
>   /* Allocate space for storing data associated with a particular
>      type.  We ensure that the space is allocated using the same
> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
> index 648974455f6..51c5a644d5d 100644
> --- a/gdb/i386-tdep.c
> +++ b/gdb/i386-tdep.c
> @@ -3110,6 +3110,7 @@ i386_zmm_type (struct gdbarch *gdbarch)
>   	int8_t v64_int8[64];
>   	double v8_double[8];
>   	float v16_float[16];
> +	bfloat16_t v32_bfloat16[32];
>         };
>   #endif
>   
> @@ -3117,6 +3118,8 @@ i386_zmm_type (struct gdbarch *gdbarch)
>   
>         t = arch_composite_type (gdbarch,
>   			       "__gdb_builtin_type_vec512i", TYPE_CODE_UNION);
> +      append_composite_type_field (t, "v32_bfloat16",
> +				   init_vector_type (bt->builtin_bfloat16, 32));
>         append_composite_type_field (t, "v16_float",
>   				   init_vector_type (bt->builtin_float, 16));
>         append_composite_type_field (t, "v8_double",
> @@ -3163,6 +3166,7 @@ i386_ymm_type (struct gdbarch *gdbarch)
>           int8_t v32_int8[32];
>           double v4_double[4];
>           float v8_float[8];
> +        bfloat16_t v16_bfloat16[16];
>         };
>   #endif
>   
> @@ -3170,6 +3174,8 @@ i386_ymm_type (struct gdbarch *gdbarch)
>   
>         t = arch_composite_type (gdbarch,
>   			       "__gdb_builtin_type_vec256i", TYPE_CODE_UNION);
> +      append_composite_type_field (t, "v16_bfloat16",
> +				   init_vector_type (bt->builtin_bfloat16, 16));
>         append_composite_type_field (t, "v8_float",
>   				   init_vector_type (bt->builtin_float, 8));
>         append_composite_type_field (t, "v4_double",
> @@ -8483,6 +8489,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
>        alignment.  */
>     set_gdbarch_long_double_bit (gdbarch, 96);
>   
> +  /* Support of bfloat16 format.  */
> +  set_gdbarch_bfloat16_format (gdbarch, floatformats_bfloat16);
> +
>     /* Support for floating-point data type variants.  */
>     set_gdbarch_floatformat_for_type (gdbarch, i386_floatformat_for_type);
>   
> diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
> index 20d624c0c65..6778b93400b 100644
> --- a/gdb/target-descriptions.c
> +++ b/gdb/target-descriptions.c
> @@ -141,6 +141,11 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
>   	  m_type = arch_float_type (m_gdbarch, -1, "builtin_type_i387_ext",
>   				    floatformats_i387_ext);
>   	  return;
> +
> +	case TDESC_TYPE_BFLOAT16:
> +	  m_type = arch_float_type (m_gdbarch, -1, "builtin_type_bfloat16",
> +				    floatformats_bfloat16);
> +	  return;
>   	}
>   
>         internal_error (__FILE__, __LINE__,
> diff --git a/gdb/testsuite/gdb.arch/x86-avx512bf16.c b/gdb/testsuite/gdb.arch/x86-avx512bf16.c
> new file mode 100644
> index 00000000000..fdc378818ac
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/x86-avx512bf16.c
> @@ -0,0 +1,166 @@
> +/* Test program for bfloat16 of AVX 512 registers.
> +
> +   Copyright 2020 Free Software Foundation, Inc.
> +
> +   This file is part of GDB.
> +
> +   This program is free software; you can redistribute it and/or modify
> +   it under the terms of the GNU General Public License as published by
> +   the Free Software Foundation; either version 3 of the License, or
> +   (at your option) any later version.
> +
> +   This program is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +   GNU General Public License for more details.
> +
> +   You should have received a copy of the GNU General Public License
> +   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
> +
> +#include "x86-cpuid.h"
> +
> +typedef struct
> +{
> +  float f[4];
> +} v4sd_t;
> +
> +typedef struct
> +{
> +  float f[8];
> +} v8sd_t;
> +
> +typedef struct
> +{
> +  float f[16];
> +} v16sd_t;
> +
> +v4sd_t xmm_data[] =
> +{
> +  { {  0.0,  0.125,  0.25,  0.375 } },
> +  { {  0.5,  0.625,  0.75,  0.875 } },
> +  { {  1.0,  1.125,  1.25,  1.375 } },
> +  { {  1.5,  1.625,  1.75,  1.875 } },
> +  { {  2.0,  2.125,  2.25,  2.375 } },
> +  { {  2.5,  2.625,  2.75,  2.875 } },
> +  { {  3.0,  3.125,  3.25,  3.375 } },
> +  { {  3.5,  3.625,  3.75,  3.875 } },
> +};
> +
> +v8sd_t ymm_data[] =
> +{
> +  { {  8.0,  8.25,  8.5,  8.75,  9.0,  9.25,  9.5,  9.75 } },
> +  { { 10.0, 10.25, 10.5, 10.75, 11.0, 11.25, 11.5, 11.75 } },
> +  { { 12.0, 12.25, 12.5, 12.75, 13.0, 13.25, 13.5, 13.75 } },
> +  { { 14.0, 14.25, 14.5, 14.75, 15.0, 15.25, 15.5, 15.75 } },
> +  { { 16.0, 16.25, 16.5, 16.75, 17.0, 17.25, 17.5, 17.75 } },
> +  { { 18.0, 18.25, 18.5, 18.75, 19.0, 19.25, 19.5, 19.75 } },
> +  { { 20.0, 20.25, 20.5, 20.75, 21.0, 21.25, 21.5, 21.75 } },
> +  { { 22.0, 22.25, 22.5, 22.75, 23.0, 23.25, 23.5, 23.75 } },
> +};
> +
> +v16sd_t zmm_data[] =
> +{
> +  { { 20.0,  20.5,  21.0,  21.5,  22.0,  22.5,  23.0,  23.5,  24.0,  24.5,
> +      25.0,  25.5,  26.0,  26.5,  27.0,  27.5 } },
> +  { { 28.0,  28.5,  29.0,  29.5,  30.0,  30.5,  31.0,  31.5,  32.0,  32.5,
> +      33.0,  33.5,  34.0,  34.5,  35.0,  35.5 } },
> +  { { 36.0,  36.5,  37.0,  37.5,  38.0,  38.5,  39.0,  39.5,  40.0,  40.5,
> +      41.0,  41.5,  42.0,  42.5,  43.0,  43.5 } },
> +  { { 44.0,  44.5,  45.0,  45.5,  46.0,  46.5,  47.0,  47.5,  48.0,  48.5,
> +      49.0,  49.5,  50.0,  50.5,  51.0,  51.5 } },
> +  { { 52.0,  52.5,  53.0,  53.5,  54.0,  54.5,  55.0,  55.5,  56.0,  56.5,
> +      57.0,  57.5,  58.0,  58.5,  59.0,  59.5 } },
> +  { { 60.0,  60.5,  61.0,  61.5,  62.0,  62.5,  63.0,  63.5,  64.0,  64.5,
> +      65.0,  65.5,  66.0,  66.5,  67.0,  67.5 } },
> +  { { 68.0,  68.5,  69.0,  69.5,  70.0,  70.5,  71.0,  71.5,  72.0,  72.5,
> +      73.0,  73.5,  74.0,  74.5,  75.0,  75.5 } },
> +  { { 76.0,  76.5,  77.0,  77.5,  78.0,  78.5,  79.0,  79.5,  80.0,  80.5,
> +      81.0,  81.5,  82.0,  82.5,  83.0,  83.5 } },
> +};
> +
> +void
> +move_data_to_xmm_reg (void)
> +{
> +  asm ("vmovups 0(%0), %%xmm0 \n\t"
> +       "vmovups 16(%0), %%xmm1 \n\t"
> +       "vmovups 32(%0), %%xmm2 \n\t"
> +       "vmovups 48(%0), %%xmm3 \n\t"
> +       "vmovups 64(%0), %%xmm4 \n\t"
> +       "vmovups 80(%0), %%xmm5 \n\t"
> +       "vmovups 96(%0), %%xmm6 \n\t"
> +       "vmovups 112(%0), %%xmm7 \n\t"
> +       : /* no output operands  */
> +       : "r" (xmm_data));
> +}
> +
> +void
> +move_data_to_ymm_reg (void)
> +{
> +  asm ("vmovups 0(%0), %%ymm0 \n\t"
> +       "vmovups 32(%0), %%ymm1 \n\t"
> +       "vmovups 64(%0), %%ymm2 \n\t"
> +       "vmovups 96(%0), %%ymm3 \n\t"
> +       "vmovups 128(%0), %%ymm4 \n\t"
> +       "vmovups 160(%0), %%ymm5 \n\t"
> +       "vmovups 192(%0), %%ymm6 \n\t"
> +       "vmovups 224(%0), %%ymm7 \n\t"
> +       : /* no output operands  */
> +       : "r" (ymm_data));
> +}
> +
> +void
> +move_data_to_zmm_reg (void)
> +{
> +  asm ("vmovups 0(%0), %%zmm0 \n\t"
> +       "vmovups 64(%0), %%zmm1 \n\t"
> +       "vmovups 128(%0), %%zmm2 \n\t"
> +       "vmovups 192(%0), %%zmm3 \n\t"
> +       "vmovups 256(%0), %%zmm4 \n\t"
> +       "vmovups 320(%0), %%zmm5 \n\t"
> +       "vmovups 384(%0), %%zmm6 \n\t"
> +       "vmovups 448(%0), %%zmm7 \n\t"
> +       : /* no output operands  */
> +       : "r" (zmm_data));
> +}
> +
> +void
> +convert_xmm_from_float_to_bfloat16 (void)
> +{
> +  asm("vcvtne2ps2bf16 %xmm0, %xmm1, %xmm0");
> +  asm("vcvtne2ps2bf16 %xmm6, %xmm7, %xmm6");
> +}
> +
> +void
> +convert_ymm_from_float_to_bfloat16 (void)
> +{
> +  asm("vcvtne2ps2bf16 %ymm0, %ymm1, %ymm0");
> +  asm("vcvtne2ps2bf16 %ymm6, %ymm7, %ymm6");
> +}
> +
> +void
> +convert_zmm_from_float_to_bfloat16 (void)
> +{
> +  asm("vcvtne2ps2bf16 %zmm0, %zmm1, %zmm0");
> +  asm("vcvtne2ps2bf16 %zmm6, %zmm7, %zmm6");
> +}
> +
> +int
> +main (int argc, char **argv)
> +{
> +  /* Move initial values from array to registers and read from XMM regs.  */
> +  move_data_to_xmm_reg ();
> +  convert_xmm_from_float_to_bfloat16 ();
> +  asm ("nop"); /* first breakpoint here  */
> +
> +  /* Move initial values from array to registers and read from YMM regs.  */
> +  move_data_to_ymm_reg ();
> +  convert_ymm_from_float_to_bfloat16 ();
> +  asm ("nop"); /* second breakpoint here  */
> +
> +  /* Move initial values from array to registers and read from ZMM regs.  */
> +  move_data_to_zmm_reg ();
> +  convert_zmm_from_float_to_bfloat16 ();
> +  asm ("nop"); /* third breakpoint here  */
> +
> +  return 0;
> +}
> diff --git a/gdb/testsuite/gdb.arch/x86-avx512bf16.exp b/gdb/testsuite/gdb.arch/x86-avx512bf16.exp
> new file mode 100644
> index 00000000000..5f90d8aca28
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/x86-avx512bf16.exp
> @@ -0,0 +1,74 @@
> +# Copyright 2020 Free Software Foundation, Inc.
> +
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 3 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
> +
> +# Please email any bugs, comments, and/or additions to this file to:
> +# bug-gdb@gnu.org
> +
> +# Test bfloat16 support in AVX512 registers
> +
> +if { [skip_avx512bf16_tests] } {
> +    unsupported "target does not support AVX512BF16"
> +    return -1
> +}
> +
> +standard_testfile
> +
> +if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
> +    return -1
> +}
> +
> +if { ![runto_main] } {
> +    unsupported "could not run to main"
> +    return -1
> +}
> +
> +# Test xmm
> +set line1 [gdb_get_line_number "first breakpoint here"]
> +gdb_breakpoint $line1
> +gdb_continue_to_breakpoint "line1" ".*$srcfile:$line1.*"
> +
> +gdb_test "print \$xmm0.v8_bfloat16" \
> +    "= \\{0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875\\}"
> +
> +gdb_test "print \$xmm6.v8_bfloat16" \
> +    "= \\{3, 3.125, 3.25, 3.375, 3.5, 3.625, 3.75, 3.875\\}"
> +
> +# Test ymm
> +set line2 [gdb_get_line_number "second breakpoint here"]
> +gdb_breakpoint $line2
> +gdb_continue_to_breakpoint "line2" ".*$srcfile:$line2.*"
> +
> +gdb_test "print \$ymm0.v16_bfloat16\[1\]" "= 8.25"
> +gdb_test "print \$ymm6.v16_bfloat16\[1\]" "= 20.25"
> +
> +# Test zmm
> +set line3 [gdb_get_line_number "third breakpoint here"]
> +gdb_breakpoint $line3
> +gdb_continue_to_breakpoint "line3" ".*$srcfile:$line3.*"
> +
> +gdb_test "print \$zmm0.v32_bfloat16\[1\]" "= 20.5"
> +gdb_test "print \$zmm6.v32_bfloat16\[1\]" "= 68.5"
> +
> +# Test setting of bfloat values
> +gdb_test_no_output "set var \$xmm0.v8_bfloat16\[0\] = 32.25" \
> +    "set %xmm0.v8_bfloat16\[0\]"
> +gdb_test_no_output "set var \$ymm8.v16_bfloat16\[1\] = 33.5" \
> +    "set %ymm8.v16_bfloat16\[1\]"
> +gdb_test_no_output "set var \$zmm16.v32_bfloat16\[2\] = 22.75" \
> +    "set %zmm16.v32_bfloat16\[2\]"
> +
> +gdb_test "p \$xmm0.v8_bfloat16\[0\]" "= 32.25"
> +gdb_test "p \$ymm8.v16_bfloat16\[1\]" "= 33.5"
> +gdb_test "p \$zmm16.v32_bfloat16\[2\]" "= 22.75"
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 78dae17b0c7..fd8b5936166 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -3061,6 +3061,57 @@ gdb_caching_proc skip_tsx_tests {
>       return $skip_tsx_tests
>   }
>   
> +# Run a test on the target to see if it supports avx512bf16.  Return 0 if so,
> +# 1 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
> +
> +gdb_caching_proc skip_avx512bf16_tests {
> +    global srcdir subdir gdb_prompt inferior_exited_re
> +
> +    set me "skip_avx512bf16_tests"
> +    if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } {
> +        verbose "$me:  target does not support avx512bf16, returning 1" 2
> +        return 1
> +    }
> +
> +    # Compile a test program.
> +    set src {
> +        int main() {
> +            asm volatile ("vcvtne2ps2bf16 %xmm0, %xmm1, %xmm0");
> +            return 0;
> +        }
> +    }
> +    if {![gdb_simple_compile $me $src executable]} {
> +        return 1
> +    }
> +
> +    # No error message, compilation succeeded so now run it via gdb.
> +
> +    gdb_exit
> +    gdb_start
> +    gdb_reinitialize_dir $srcdir/$subdir
> +    gdb_load "$obj"
> +    gdb_run_cmd
> +    gdb_expect {
> +        -re ".*Illegal instruction.*${gdb_prompt} $" {
> +            verbose -log "$me:  avx512bf16 hardware not detected."
> +            set skip_avx512bf16_tests 1
> +        }
> +        -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
> +            verbose -log "$me:  avx512bf16 hardware detected."
> +            set skip_avx512bf16_tests 0
> +        }
> +        default {
> +            warning "\n$me:  default case taken."
> +            set skip_avx512bf16_tests 1
> +        }
> +    }
> +    gdb_exit
> +    remote_file build delete $obj
> +
> +    verbose "$me:  returning $skip_avx512bf16_tests" 2
> +    return $skip_avx512bf16_tests
> +}
> +
>   # Run a test on the target to see if it supports btrace hardware.  Return 0 if so,
>   # 1 if it does not.  Based on 'check_vmx_hw_available' from the GCC testsuite.
>   
> diff --git a/gdbsupport/tdesc.cc b/gdbsupport/tdesc.cc
> index 624588b6563..c2a3af700e3 100644
> --- a/gdbsupport/tdesc.cc
> +++ b/gdbsupport/tdesc.cc
> @@ -54,7 +54,8 @@ static tdesc_type_builtin tdesc_predefined_types[] =
>     { "ieee_single", TDESC_TYPE_IEEE_SINGLE },
>     { "ieee_double", TDESC_TYPE_IEEE_DOUBLE },
>     { "arm_fpa_ext", TDESC_TYPE_ARM_FPA_EXT },
> -  { "i387_ext", TDESC_TYPE_I387_EXT }
> +  { "i387_ext", TDESC_TYPE_I387_EXT },
> +  { "bfloat16", TDESC_TYPE_BFLOAT16 }
>   };
>   
>   void tdesc_feature::accept (tdesc_element_visitor &v) const
> diff --git a/gdbsupport/tdesc.h b/gdbsupport/tdesc.h
> index fdc2a6a3708..14b5b5fc9b3 100644
> --- a/gdbsupport/tdesc.h
> +++ b/gdbsupport/tdesc.h
> @@ -173,6 +173,7 @@ enum tdesc_type_kind
>     TDESC_TYPE_IEEE_DOUBLE,
>     TDESC_TYPE_ARM_FPA_EXT,
>     TDESC_TYPE_I387_EXT,
> +  TDESC_TYPE_BFLOAT16,
>   
>     /* Types defined by a target feature.  */
>     TDESC_TYPE_VECTOR,
> diff --git a/include/floatformat.h b/include/floatformat.h
> index ce8d6d4add8..b3338eb63ad 100644
> --- a/include/floatformat.h
> +++ b/include/floatformat.h
> @@ -133,6 +133,9 @@ extern const struct floatformat floatformat_ia64_quad_little;
>   /* IBM long double (double+double).  */
>   extern const struct floatformat floatformat_ibm_long_double_big;
>   extern const struct floatformat floatformat_ibm_long_double_little;
> +/* Intel bfloat16.  */
> +extern const struct floatformat floatformat_bfloat16_big;
> +extern const struct floatformat floatformat_bfloat16_little;
>   

Since bfloat16 is not Intel-specific, I'd drop that part of the comment.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH 2/2] Add bfloat16 support for AVX512 register view.
  2020-07-22 22:19   ` Kevin Buettner
@ 2020-07-24  8:06     ` Willgerodt, Felix
  0 siblings, 0 replies; 8+ messages in thread
From: Willgerodt, Felix @ 2020-07-24  8:06 UTC (permalink / raw)
  To: Kevin Buettner, Felix Willgerodt via Gdb-patches

Thanks for the review.

>> gdb/features/ChangeLog:

> I think this is just gdb/ChangeLog, not gdb/features/ChangeLog.

Will be fixed in the next iteration.

>> 	* features/64bit-sse.xml: Likewise.

>These files are in features/i386.

>Also, the .c files were (re)generated from the .xml files, right?

Fixed and yes they were generated via features/Makefile.

>> +   You should have received a copy of the GNU General Public License
>> +   along with this program.  If not, see 
>> + <http://www.gnu.org/licenses/>.  */
>> +
>> +#include "x86-cpuid.h"

>Is x86-cpuid.h needed for this test?

That was a leftover from a previous iteration. Removed.

> The definitions of floatformat_bfloat16_{bit,little} look correct to me, but I think it needs approval from someone else.  libiberty/README says to send fixes to gcc-patches@gcc.gnu.org.

Thanks for the hint, I didn't see that. I will add gcc-patches@gcc.gnu.org in the next iteration.

Felix

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: [PATCH 2/2] Add bfloat16 support for AVX512 register view.
  2020-07-22 22:27   ` Luis Machado
@ 2020-07-24  8:06     ` Willgerodt, Felix
  0 siblings, 0 replies; 8+ messages in thread
From: Willgerodt, Felix @ 2020-07-24  8:06 UTC (permalink / raw)
  To: Luis Machado, gdb-patches

Thanks for the review!

> Since bfloat16 is not Intel-specific, I'd drop that part of the comment.

Will be fixed in the next iteration.

Felix
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Gary Kershaw
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-07-24  8:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21 15:52 [PATCH 0/2] avx512 bfloat16 support Felix Willgerodt
2020-07-21 15:52 ` [PATCH 1/2] i386-tdep: Fix naming in zmm and ymm type descriptions Felix Willgerodt
2020-07-22 18:45   ` Kevin Buettner
2020-07-21 15:52 ` [PATCH 2/2] Add bfloat16 support for AVX512 register view Felix Willgerodt
2020-07-22 22:19   ` Kevin Buettner
2020-07-24  8:06     ` Willgerodt, Felix
2020-07-22 22:27   ` Luis Machado
2020-07-24  8:06     ` Willgerodt, Felix

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).