[v2,5/5] gdb: add Intel AMX tile registers as user registers

Message ID 20261030115016.45786-6-stephan.rohr@intel.com
State New
Headers
Series Add Intel AMX support |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Rohr, Stephan Oct. 30, 2026, 11:50 a.m. UTC
  From: "Rohr, Stephan" <stephan.rohr@intel.com>

Add the user registers $tmm0 ... $tmm7 for the raw tile registers
$tmm0_raw ... $tmm7_raw.  The type of a user register is resolved at
runtime from the dimensions configured in TILECFG.

The user registers are implemented by applying a view type on the
raw tile register.  The rows of the view have fixed stride.  Reading and
writing an element through the view accesses the same bytes in the raw
tile register.

The user registers are part of the "matrix" and "all" register groups,
so that "info registers matrix" and "info all-registers" list them.  The
tilecfg pseudo register is part of the "matrix" register group as well.

Remote targets are naturally supported as reading and writing goes
through the raw tile registers.
---
 gdb/NEWS                             |   2 +
 gdb/amd64-tdep.c                     |  83 ++++++++++++
 gdb/doc/gdb.texinfo                  |  13 +-
 gdb/i386-tdep.c                      |  98 +++++++++++++++
 gdb/i386-tdep.h                      |  81 ++++++++++++
 gdb/testsuite/gdb.arch/amd64-amx.c   |   9 ++
 gdb/testsuite/gdb.arch/amd64-amx.exp | 182 +++++++++++++++++++++++++--
 7 files changed, 458 insertions(+), 10 deletions(-)
  

Comments

Eli Zaretskii Oct. 30, 2026, 12:50 p.m. UTC | #1
> From: Stephan Rohr <stephan.rohr@intel.com>
> Cc: pedro@palves.net,
> 	eliz@gnu.org,
> 	jhb@FreeBSD.org,
> 	luis.machado@arm.com
> Date: Fri, 30 Oct 2026 11:50:16 +0000
> 
> From: "Rohr, Stephan" <stephan.rohr@intel.com>
> 
> Add the user registers $tmm0 ... $tmm7 for the raw tile registers
> $tmm0_raw ... $tmm7_raw.  The type of a user register is resolved at
> runtime from the dimensions configured in TILECFG.
> 
> The user registers are implemented by applying a view type on the
> raw tile register.  The rows of the view have fixed stride.  Reading and
> writing an element through the view accesses the same bytes in the raw
> tile register.
> 
> The user registers are part of the "matrix" and "all" register groups,
> so that "info registers matrix" and "info all-registers" list them.  The
> tilecfg pseudo register is part of the "matrix" register group as well.
> 
> Remote targets are naturally supported as reading and writing goes
> through the raw tile registers.
> ---
>  gdb/NEWS                             |   2 +
>  gdb/amd64-tdep.c                     |  83 ++++++++++++
>  gdb/doc/gdb.texinfo                  |  13 +-
>  gdb/i386-tdep.c                      |  98 +++++++++++++++
>  gdb/i386-tdep.h                      |  81 ++++++++++++
>  gdb/testsuite/gdb.arch/amd64-amx.c   |   9 ++
>  gdb/testsuite/gdb.arch/amd64-amx.exp | 182 +++++++++++++++++++++++++--
>  7 files changed, 458 insertions(+), 10 deletions(-)

OK for the documentation parts, thanks.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
  
Joos, Christina Nov. 3, 2026, 3:19 p.m. UTC | #2
Hi Stephan, 

Thank you for this patch. 

I tested some edge cases and found the following:

1) Assert for $tilecfg.colsb[0]=200
~~~
gdb) set $tilecfg.colsb[0]=200
(gdb) p $tmm0_raw
$1 = {0 <repeats 16 times>}
(gdb) p $tilecfg
$2 = {palette = 0, start_row = 0, colsb = {200, 0, 0, 0, 0, 0, 0, 0}, rows = {0, 0, 0, 0, 0, 0, 0, 0}}
(gdb) p $tmm0
/tmp/gdb/i386-tdep.c:3298: internal-error: i386_tmm_type: Assertion `colsb > 0 && colsb <= tilecfg_reg::MAX_BYTES_PER_ROW' failed.
A problem internal to GDB has been detected, further debugging may prove unreliable.
----- Backtrace -----
0x60228446351d gdb_internal_backtrace_1
        /tmp/gdb/bt-utils.c:122
0x602284463569 _Z22gdb_internal_backtracev
        /tmp/gdb/bt-utils.c:173
[...]
~~~

2) I have one open regarding how we should display values when the data
type is too large for colsb, for example:
~~~
(gdb) set $tilecfg.colsb[0]=2
(gdb) p $tmm0
$4 = {m_int8 = {{0, 0}, {0, 0}}, m_uint8 = {{0, 0}, {0, 0}}, m_int32 = 0x0, m_bf16 = {{0}, {0}}, m_fp32 = 0x0} 
~~~ 
or for the case colsb[0]=3.

Besides that, only some minor issues, please see below.

> -----Original Message-----
> From: Stephan Rohr <stephan.rohr@intel.com>
> Sent: Freitag, 30. Oktober 2026 12:50
> To: gdb-patches@sourceware.org
> Cc: pedro@palves.net; eliz@gnu.org; jhb@FreeBSD.org;
> luis.machado@arm.com
> Subject: [PATCH v2 5/5] gdb: add Intel AMX tile registers as user registers
> 
> From: "Rohr, Stephan" <stephan.rohr@intel.com>
> 
> Add the user registers $tmm0 ... $tmm7 for the raw tile registers $tmm0_raw
> ... $tmm7_raw.  The type of a user register is resolved at runtime from the
> dimensions configured in TILECFG.
> 
> The user registers are implemented by applying a view type on the raw tile
> register.  The rows of the view have fixed stride.  Reading and writing an
> element through the view accesses the same bytes in the raw tile register.
> 
> The user registers are part of the "matrix" and "all" register groups, so that
> "info registers matrix" and "info all-registers" list them.  The tilecfg pseudo
> register is part of the "matrix" register group as well.

I wonder if the tilecfg register should be in the matrix group, although it isn’t
really a matrix register. But it is also nice that we show it together with the tiles
when we run "info registers matrix", so in my view both is ok.

You could consider moving the patch for the matrix group before the initial AMX
patch that introduces tile raw, and tilecfg raw  + pseudo register.
Then you could assign the right group to the tilecfg pseudo register when you
introduce it (and test it).

> Remote targets are naturally supported as reading and writing goes through
> the raw tile registers.
> ---
>  gdb/NEWS                             |   2 +
>  gdb/amd64-tdep.c                     |  83 ++++++++++++
>  gdb/doc/gdb.texinfo                  |  13 +-
>  gdb/i386-tdep.c                      |  98 +++++++++++++++
>  gdb/i386-tdep.h                      |  81 ++++++++++++
>  gdb/testsuite/gdb.arch/amd64-amx.c   |   9 ++
>  gdb/testsuite/gdb.arch/amd64-amx.exp | 182
> +++++++++++++++++++++++++--
>  7 files changed, 458 insertions(+), 10 deletions(-)
> 
> diff --git a/gdb/NEWS b/gdb/NEWS
> index 47ecba246a0..1c60f307d53 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -11,6 +11,8 @@
>    Support displaying and modifying Intel AMX raw registers
>    $tmm0_raw - $tmm7_raw and the $tilecfg_raw register.  The $tilecfg
>    pseudo register provides a parsed view of the tile configuration.
> +  The $tmm0 - $tmm7 user registers display the raw tile registers
> + according  to the configuration in $tilecfg.
> 
>  * GDB now distinguishes between the GNU (MinGW) and MSVC Windows
> ABIs.
> 
> diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index
> 13242e293b5..6d421c85080 100644
> --- a/gdb/amd64-tdep.c
> +++ b/gdb/amd64-tdep.c
> @@ -34,8 +34,10 @@
>  #include "gdbcore.h"
>  #include "objfiles.h"
>  #include "regcache.h"
> +#include "reggroups.h"
>  #include "regset.h"
>  #include "symfile.h"
> +#include "user-regs.h"
>  #include "disasm.h"
>  #include "amd64-tdep.h"
>  #include "i387-tdep.h"
> @@ -199,6 +201,25 @@ static const char *amd64_tmm_raw_names[] = {
>      "tmm4_raw", "tmm5_raw", "tmm6_raw", "tmm7_raw"
>  };
> 
> +/* Register names for the tmm user registers.  */
> +
> +static const char *amd64_tmm_user_names[] = {
> +    "tmm0", "tmm1", "tmm2", "tmm3",
> +    "tmm4", "tmm5", "tmm6", "tmm7"
> +};
> +
> +/* Batons for the tmm user registers.  */
> +
> +static const int amd64_tmm_user_batons[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
> +
> +/* Register groups for the tmm user registers.  */
> +
> +static const reggroup *const amd64_tmm_groups[] = {
> +    matrix_reggroup,
> +    all_reggroup
> +};
> +
> +
>  /* DWARF Register Number Mapping as defined in the System V psABI,
>     section 3.6.  */
> 
> @@ -632,6 +653,62 @@ amd64_ax_pseudo_register_collect (struct gdbarch
> *gdbarch,
> 
> 

Nit: too many new lines. 

> +
> +/* Read ROWS and COLSB from TILECFG for tile TMMNUM.  Return the
> maximum number
> +   of rows and the maximum number of bytes respectively for an unconfigured
> +   tile.  */
> +
> +static void
> +amd64_tmm_dimensions (const tilecfg_reg &tilecfg, int tmmnum, uint8_t
> *rows,
> +		      uint16_t *colsb)
> +{
> +  *rows = tilecfg.rows (tmmnum);
> +  *colsb = tilecfg.bytes_per_row (tmmnum);
> +
> +  if (*rows == 0)
> +    *rows = tilecfg_reg::MAX_ROWS;
> +  if (*colsb == 0)
> +    *colsb = tilecfg_reg::MAX_BYTES_PER_ROW; }
> +
> +/* Return the tile configuration for NEXT_FRAME.  */
> +
> +static tilecfg_reg
> +amd64_read_tilecfg (const frame_info_ptr &next_frame) {
> +  gdbarch *gdbarch = frame_unwind_arch (next_frame);
> +  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> +  value *tilecfg_raw_val = value_of_register (tdep->tilecfg_raw_regnum,
> +					      next_frame);
> +
> +  return tilecfg_reg (tilecfg_raw_val->contents ()); }
> +
> +/* Read a tmm user register with dynamic resolution of the configured
> +   dimensions.  BATON is the tile number.  */
> +
> +static value *
> +amd64_value_of_tmm_user_reg (const frame_info_ptr &frame, const void
> +*baton) {
> +  gdbarch *gdbarch = get_frame_arch (frame);
> +  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> +  frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
> +  int tmmnum = *(const int *) baton;
> +
> +  /* Read the register's dimensions from tilecfg.  */  tilecfg_reg
> + tilecfg = amd64_read_tilecfg (next_frame);  uint8_t rows;  uint16_t
> + colsb;  amd64_tmm_dimensions (tilecfg, tmmnum, &rows, &colsb);
> +
> +  /* "i386_tmm_type" builds a union with one view per element type, e.g.,
> +     "int8" and "uint8".  The rows have a fixed stride such that elements are
> +     at the same offsets as in the raw register.  */
> +  return value::allocate_register_lazy (next_frame,
> +					tdep->tmm_raw_regnum + tmmnum,
> +					i386_tmm_type (gdbarch, rows,
> colsb)); }
> +
>  /* Register classes as defined in the psABI.  */
> 
>  enum amd64_reg_class
> @@ -3863,6 +3940,12 @@ amd64_init_abi (struct gdbarch_info info, struct
> gdbarch *gdbarch,
>  					amd64_in_indirect_branch_thunk);
> 
>    register_amd64_ravenscar_ops (gdbarch);
> +
> +  /* Add tile registers tmm0 to tmm7 as user registers.  */
> +  for (int i = 0; i < tdep->num_tmm_raw_regs; i++)
> +    user_reg_add (gdbarch, amd64_tmm_user_names[i],
> +		  amd64_value_of_tmm_user_reg,
> &amd64_tmm_user_batons[i],
> +		  amd64_tmm_groups);
>  }
> 
>  /* Initialize ARCH for x86-64, no osabi.  */ diff --git a/gdb/doc/gdb.texinfo
> b/gdb/doc/gdb.texinfo index ba9d3df1ac5..15b351e8c02 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -27466,7 +27466,11 @@ omitting reserved bits.  The tile registers are
> supplied as the raw registers  contents of a tile with its maximum dimensions
> of @w{16 rows} of
>  @w{64 bytes}.  The raw tile registers hold one @code{uint512} per row and
> only  the elements within the dimensions configured in @samp{tilecfg} hold
> data.
> -For example:
> +Additional user registers @samp{tmm0}, @samp{tmm1}, @dots{},
> +@samp{tmm7} present the raw registers with the dimensions configured in
> +@samp{tilecfg}.  They are part of the @code{matrix} and @code{all}
> +register groups, so that @code{info registers matrix} and @code{info
> +all-registers} list them.  For example:
> 
>  @smallexample
>  (gdb) print/x $tilecfg_raw
> @@ -27482,8 +27486,15 @@ $3 = @{621397352980713455329738752,
> 932096029507240269422067969,
>  $4 = @{@{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0 <repeats 52 times>@},
>    @{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0 <repeats 52 times>@},
>    @{0 <repeats 64 times>@} <repeats 14 times>@}
> +(gdb) print $tmm1.m_int8
> +$5 = @{@{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2@},
> +  @{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3@}@}
>  @end smallexample
> 
> +In this example, @code{$tmm1.m_int8} shows the tile as signed 8-bit
> +integers with the dimensions configured in @samp{tilecfg} for
> +@samp{tmm1}: 2 rows (@code{rows}) of 12 bytes (@code{colsb}).
> +
>  @node Alpha
>  @subsection Alpha
> 
> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index
> a25abfbd1bc..21d4bf6f4a9 100644
> --- a/gdb/i386-tdep.c
> +++ b/gdb/i386-tdep.c
> @@ -47,6 +47,7 @@
>  #include "i386-tdep.h"
>  #include "i387-tdep.h"
>  #include "gdbsupport/x86-xstate.h"
> +#include "gdbsupport/array-view.h"
>  #include "x86-tdep.h"
>  #include "expop.h"
> 
> @@ -447,6 +448,22 @@ i386_pseudo_register_name (struct gdbarch
> *gdbarch, int regnum)
>    internal_error (_("invalid regnum"));  }
> 
> +/* AMX tilecfg_reg constructor.  */
> +
> +tilecfg_reg::tilecfg_reg (gdb::array_view<const gdb_byte> raw_tilecfg)
> +{
> +  gdb_assert (raw_tilecfg.size () == X86_AMX_TILECFG_SIZE);
> +
> +  /* Read the TILECFG column and row values.  */
> +  for (int i = 0; i < NUM_TILES; i++)
> +    {
> +      const int offset = COLUMN_OFFSET + i * 2;
> +      uint16_t colsb = extract_unsigned_integer (raw_tilecfg.slice (offset, 2),
> +						 BFD_ENDIAN_LITTLE);
> +      m_tiles[i] = { colsb, raw_tilecfg[ROW_OFFSET + i] };
> +    }
> +}
> +
>  /* Convert SVR4 DWARF register number REG to the appropriate register
> number
>     used by GDB.  */
> 
> @@ -3250,6 +3267,84 @@ i386_mmx_type (struct gdbarch *gdbarch)
>    return tdep->i386_mmx_type;
>  }
> 
> +/* Return a view of a tile with ROWS rows of COLS elements of type ELT_TYPE.
> +   The rows have a fixed stride of TILECFG_REG::MAX_BYTES_PER_ROW.  */
> +
> +static type *
> +i386_tmm_view_type (gdbarch *gdbarch, type *elt_type, int cols, int
> +rows) {
> +  type *row_type = init_vector_type (elt_type, cols);
> +
> +  type_allocator alloc (gdbarch);
> +  type *range_type
> +    = create_static_range_type (alloc, builtin_type (gdbarch)->builtin_int,
> +				0, rows - 1);
> +  dynamic_prop stride;
> +  stride.set_const_val (tilecfg_reg::MAX_BYTES_PER_ROW);
> +
> +  type *t = create_array_type_with_stride (alloc, row_type, range_type,
> +					   &stride, true);
> +  t->set_is_vector (true);
> +  return t;
> +}
> +
> +/* See i386-tdep.h.  */
> +
> +type *
> +i386_tmm_type (gdbarch *gdbarch, uint8_t rows, uint16_t colsb) {
> +  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> +  gdb_assert (rows > 0 && rows <= tilecfg_reg::MAX_ROWS);
> +  gdb_assert (colsb > 0 && colsb <= tilecfg_reg::MAX_BYTES_PER_ROW);
> +
> +  /* Cache the tmm type based on the configured dimension.  */
> + uint32_t key = ((uint32_t) rows << 16) | colsb;  auto it =
> + tdep->i386_tmm_types.find (key);  if (it != tdep->i386_tmm_types.end
> + ())
> +    return it->second;
> +
> +  const struct builtin_type *bt = builtin_type (gdbarch);
> +
> +  /* The type we're building is this:
> +
> +     union __gdb_builtin_type_matrix1024i
> +       {
> +	 int8_t m_int8[rows][colsb];
> +	 uint8_t m_uint8[rows][colsb];
> +	 int32_t m_int32[rows][colsb / 4];
> +	 bfloat16_t m_bf16[rows][colsb / 2];
> +	 float m_fp32[rows][colsb / 4];
> +       };  */
> +
> +  type *t = arch_composite_type (gdbarch, "builtin_type_tile",
> + TYPE_CODE_UNION);
> +
> +  append_composite_type_field
> +    (t, "m_int8",
> +     i386_tmm_view_type (gdbarch, bt->builtin_int8, colsb, rows));
> +
> +  append_composite_type_field
> +    (t, "m_uint8",
> +     i386_tmm_view_type (gdbarch, bt->builtin_uint8, colsb, rows));
> +
> +  append_composite_type_field
> +    (t, "m_int32",
> +     i386_tmm_view_type (gdbarch, bt->builtin_int32, colsb / 4, rows));
> +
> +  append_composite_type_field
> +    (t, "m_bf16",
> +     i386_tmm_view_type (gdbarch, bt->builtin_bfloat16, colsb / 2,
> + rows));
> +
> +  append_composite_type_field
> +    (t, "m_fp32",
> +     i386_tmm_view_type (gdbarch, bt->builtin_float, colsb / 4, rows));
> +
> +  t->set_is_vector (true);
> +  t->set_name ("builtin_type_tile");
> +  tdep->i386_tmm_types.emplace (key, t);
> +
> +  return t;
> +}
> +
>  /* The type of the TILECFG registers.  */
> 
>  static type *
> @@ -4372,6 +4467,9 @@ i386_register_reggroup_p (struct gdbarch *gdbarch,
> int regnum,
>    tilecfg_regnum_p = i386_tilecfg_regnum_p (gdbarch, regnum);
>    tilecfg_raw_regnum_p = i386_tilecfg_raw_regnum_p (gdbarch, regnum);
> 
> +  if (group == matrix_reggroup)
> +    return tilecfg_regnum_p;
> +
>    avx512_p = ((tdep->xcr0 & X86_XSTATE_AVX_AVX512_MASK)
>  	      == X86_XSTATE_AVX_AVX512_MASK);
>    avx_p = ((tdep->xcr0 & X86_XSTATE_AVX_AVX512_MASK) diff --git
> a/gdb/i386-tdep.h b/gdb/i386-tdep.h index 898a76dfb50..e9393580194
> 100644
> --- a/gdb/i386-tdep.h
> +++ b/gdb/i386-tdep.h
> @@ -23,6 +23,7 @@
>  #include "gdbarch.h"
>  #include "infrun.h"
>  #include "expression.h"
> +#include "gdbsupport/unordered_map.h"
>  #include "gdbsupport/x86-xstate.h"
> 
>  class frame_info_ptr;
> @@ -287,6 +288,9 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
>    struct type *i387_ext_type = nullptr;
>    type *i386_tilecfg_type = nullptr;
> 
> +  /* Type cache for tile user registers.  */
> + gdb::unordered_map<uint32_t, type *> i386_tmm_types;
> +
>    /* If the registers containing the i386 Linux TLS related global
>       descriptor table information are available.  This is used to decide
>       whether to add the NT_386_TLS note to the core file or not.  */ @@ -437,6
> +441,12 @@ extern void i386_ax_pseudo_register_collect (struct gdbarch
> *gdbarch,
>  					     struct agent_expr *ax,
>  					     int regnum);
> 
> +/* Return the type of an Intel AMX tile that is configured to hold ROWS rows
> +   of COLSB bytes each.  */
> +
> +extern type *i386_tmm_type (gdbarch *gdbarch, uint8_t rows,
> +			    uint16_t colsb);
> +
>  /* Segment selectors.  */
>  #define I386_SEL_RPL	0x0003  /* Requester's Privilege Level mask.  */
>  #define I386_SEL_UPL	0x0003	/* User Privilege Level.  */
> @@ -536,4 +546,75 @@ extern bool i386_stap_is_single_operand (struct
> gdbarch *gdbarch,  extern expr::operation_up i386_stap_parse_special_token
>       (struct gdbarch *gdbarch, struct stap_parse_info *p);
> 
> +/* TILECFG register.
> +   0       palette
> +   1       start_row
> +   2-15    reserved, must be zero
> +   16-17   tile0.colsb Tile 0 bytes per row.
> +   18-19   tile1.colsb Tile 1 bytes per row.
> +   20-21   tile2.colsb Tile 2 bytes per row.
> +   ...     (sequence continues)
> +   30-31   tile7.colsb Tile 7 bytes per row.
> +   32-47   reserved, must be zero
> +   48      tile0.rows Tile 0 rows.
> +   49      tile1.rows Tile 1 rows.
> +   50      tile2.rows Tile 2 rows.
> +   ...     (sequence continues)
> +   55      tile7.rows Tile 7 rows.
> +   56-63   reserved, must be zero.  */

The class description reads as if you'd store the entire register.

Maybe adding sth. like

/* The tile dimensions configured in TILECFG.  */

as last line and consider calling it "tile_dimensions", only ?

> +class tilecfg_reg
> +{
> +public:
> +  /* Construct it from raw tilecfg data.  */
> +  explicit tilecfg_reg (gdb::array_view<const gdb_byte> raw_tilecfg);
> +
> +  /* Get number of configured bytes per row for tile P.  */  inline
> + uint16_t  bytes_per_row (uint8_t p) const  {
> +    gdb_assert (p < NUM_TILES);
> +    return m_tiles[p].colsb;
> +  }
> +
> +  /* Get number of configured rows for tile P.  */  inline uint8_t
> + rows (uint8_t p) const  {
> +    gdb_assert (p < NUM_TILES);
> +    return m_tiles[p].rows;
> +  }
> +
> +  /* Maximum possible values for the current target.  */  static const
> + uint16_t MAX_ROWS = 16;  static const uint16_t MAX_BYTES_PER_ROW = 64;
> +
> +private:
> +  /* Offsets of the colsb and rows arrays.  */
> +  static const uint16_t COLUMN_OFFSET = 16;
> +  static const uint16_t ROW_OFFSET = 48;
> +
> +  /* Size of the tiles.  */
> +  static const uint16_t NUM_TILES = X86_AMX_NUM_TMM_REGISTERS;
> +
> +  /* The configuration of a single tile.  */  struct tile  {
> +    /* Number of configured bytes per row.  */
> +    uint16_t colsb = 0;
> +
> +    /* Number of configured rows.  */
> +    uint8_t rows = 0;
> +
> +    bool
> +    operator== (const tile &t) const
> +    {
> +      return colsb == t.colsb && rows == t.rows;
> +    }
> +  };

I think the operator is unused.

> +
> +  /* The configuration of each tile.  */
> +  std::array<tile, NUM_TILES> m_tiles {}; };
> +
>  #endif /* GDB_I386_TDEP_H */
> diff --git a/gdb/testsuite/gdb.arch/amd64-amx.c
> b/gdb/testsuite/gdb.arch/amd64-amx.c
> index 5dca29ad183..8233ada65b5 100644
> --- a/gdb/testsuite/gdb.arch/amd64-amx.c
> +++ b/gdb/testsuite/gdb.arch/amd64-amx.c
> @@ -47,6 +47,12 @@ int8_t int8_matrix[2][8] = { { -1, -1, -1, -1, 1, 1, 1, 1 },
> float fp32_matrix[2][2] = { { 1.0, 1.125 },
>  			    { 1.25, 1.375 } };
> 
> +/* The bfloat16 values 0, 0.125, 0.25, 0.375 and 0.5, 0.625, 0.75, 0.875.
> +   We use encoded bf16 values to avoid a dependency on compilers
> supporting
> +   Intel AMX but not the __bf16 data type.  */ uint16_t
> +bf16_matrix[2][4] = { { 0x0000, 0x3e00, 0x3e80, 0x3ec0 },
> +			       { 0x3f00, 0x3f20, 0x3f40, 0x3f60 } };
> +
> 
>  static void
>  tfmaps_calc (void)
> @@ -79,6 +85,8 @@ tfmaps_calc (void)
>    tc.cols[C] = M * 4;
> 
>    /* Tiles for testing the remaining element types.  */
> +  tc.rows[3] = 2;
> +  tc.cols[3] = 8;
>    tc.rows[4] = 2;
>    tc.cols[4] = 8;
>    tc.rows[5] = 2;
> @@ -87,6 +95,7 @@ tfmaps_calc (void)
>    _tile_loadconfig (&tc);
> 
>    /* Load additional types for type testing.  */
> +  _tile_loadd (3, bf16_matrix, 4 * 2);
>    _tile_loadd (4, fp32_matrix, 2 * 4);
>    _tile_loadd (5, int8_matrix, 4 * 2);
> 
> diff --git a/gdb/testsuite/gdb.arch/amd64-amx.exp
> b/gdb/testsuite/gdb.arch/amd64-amx.exp
> index af92e2d37a0..1974160abb6 100644
> --- a/gdb/testsuite/gdb.arch/amd64-amx.exp
> +++ b/gdb/testsuite/gdb.arch/amd64-amx.exp
> @@ -38,12 +38,12 @@ proc test_zeroed_tile {reg} {
> 
>  proc test_loaded_tiles {} {
>      gdb_test "print/x \$tilecfg_raw" \
> -	[join {"= 0x20200020302000000000000000000000000000000000" \
> -
> "000000000080008000000100010000c000000000000000000000000000000
> 01"} ""]
> +	[join {"= 0x20202020302000000000000000000000000000000000" \
> +
> "000000000080008000800100010000c000000000000000000000000000000
> 01"}
> +""]
> 
>      gdb_test "print \$tilecfg" \
>  	[string_to_regexp "= {palette = 1, start_row = 0,\
> -	     colsb = {12, 16, 16, 0, 8, 8, 0, 0}, rows = {2, 3, 2, 0, 2, 2, 0, 0}}"]
> +	     colsb = {12, 16, 16, 8, 8, 8, 0, 0}, rows = {2, 3, 2, 2, 2, 2, 0,
> +0}}"]
> 
>      gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm0_raw" \
>  	[join {"= \\{\\{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,\ @@ -52,6 +52,11 @@
> proc test_loaded_tiles {} {
>  	    "\\{0 <repeats 64 times>\\} <repeats 14 times>\\}"} \
>  	    ", "]
> 
> +    gdb_test "print \$tmm0.m_uint8" \
> +	[join {"= \\{\\{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2\\}" \
> +	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3\\}\\}"} \
> +	    ", "]
> +
>      gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm1_raw" \
>  	[join {"= \\{\\{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,\
>  		     0 <repeats 48 times>\\}" \
> @@ -62,26 +67,48 @@ proc test_loaded_tiles {} {
>  	    "\\{0 <repeats 64 times>\\} <repeats 13 times>\\}"} \
>  	    ", "]
> 
> +    gdb_test "print \$tmm1.m_uint8" \
> +	[join {"= \\{\\{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3\\}" \
> +	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4\\}" \
> +	    "\\{2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5\\}\\}"} \
> +	    ", "]
> +
>      gdb_test "print (int\[16\]\[16\]) \$tmm2_raw" \
>  	[join {"= \\{\\{20, 32, 44, 56, 0 <repeats 12 times>\\}" \
>  	    "\\{32, 56, 80, 104, 0 <repeats 12 times>\\}" \
>  	    "\\{0 <repeats 16 times>\\} <repeats 14 times>\\}"} \
>  	    ", "]
> 
> +    gdb_test "print \$tmm2.m_int32" \
> +	"= \\{\\{20, 32, 44, 56\\}, \\{32, 56, 80, 104\\}\\}"
> +
> +    gdb_test "print \$tmm3.m_bf16" \
> +	[join {"= \\{\\{0, 0.125, 0.25, 0.375\\}" \
> +	    "\\{0.5, 0.625, 0.75, 0.875\\}\\}"} \
> +	    ", "]
> +
>      gdb_test "print (float\[16\]\[16\]) \$tmm4_raw" \
>  	[join {"= \\{\\{1, 1.125, 0 <repeats 14 times>\\}" \
>  	    "\\{1.25, 1.375, 0 <repeats 14 times>\\}" \
>  	    "\\{0 <repeats 16 times>\\} <repeats 14 times>\\}"} \
>  	    ", "]
> 
> +    gdb_test "print \$tmm4.m_fp32" "= \\{\\{1, 1.125\\}, \\{1.25, 1.375\\}\\}"
> +
>      gdb_test "print/d (int8_t\[16\]\[64\]) \$tmm5_raw" \
>  	[join {"= \\{\\{-1, -1, -1, -1, 1, 1, 1, 1, 0 <repeats 56 times>\\}" \
>  	    "\\{1, 1, 1, 1, -5, -5, -5, -5, 0 <repeats 56 times>\\}" \
>  	    "\\{0 <repeats 64 times>\\} <repeats 14 times>\\}"} \
>  	    ", "]
> 
> -    foreach i {3 6 7} {
> +    gdb_test "print \$tmm5.m_int8" \
> +	[join {"= \\{\\{-1, -1, -1, -1, 1, 1, 1, 1\\}" \
> +	    "\\{1, 1, 1, 1, -5, -5, -5, -5\\}\\}"} \
> +	    ", "]
> +
> +    for {set i 6} {$i < 8} {incr i} {
>  	test_zeroed_tile "\$tmm${i}_raw"
> +	test_zeroed_tile "\$tmm${i}"
>      }
>  }
> 
> @@ -119,28 +146,126 @@ with_test_prefix "read tiles" {  set gcorefile
> $binfile.gcore  set gcore_generated [gdb_gcore_cmd $gcorefile "save a core
> file"]
> 
> -# Test setting tiles.
> +# Test setting tiles.  The raw registers and the user registers both
> +map to # the same tile data.  A write to one of them must be reflected
> +in the other # one.
>  with_test_prefix "setting tiles" {
> +    # Write to a raw register.
>      gdb_test_no_output "set ((uint8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\] = 1"
>      gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm0_raw" \
>  	[join {"= \\{\\{1, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,\
>  		     0 <repeats 52 times>\\}" \
>  	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0 <repeats 52 times>\\}" \
>  	    "\\{0 <repeats 64 times>\\} <repeats 14 times>\\}"} \
> -	    ", "]
> +	    ", "] \
> +	"print tmm0_raw.m_uint8 after raw write"
> +
> +    # The user register must reflect the write to the raw register.
> +    gdb_test "print \$tmm0.m_uint8" \
> +	[join {"= \\{\\{1, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2\\}" \
> +	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3\\}\\}"} \
> +	    ", "] \
> +	"print tmm0.m_uint8 user register after raw write"
> +
> +    # Write to another element of the same tile via the user register.
> +    gdb_test_no_output "set \$tmm0.m_uint8\[0\]\[1\] = 2"
> +    gdb_test "print \$tmm0.m_uint8" \
> +	[join {"= \\{\\{1, 2, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2\\}" \
> +	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3\\}\\}"} \
> +	    ", "] \
> +	"print tmm0.m_uint8 after user write"
> +
> +    # The raw register must reflect the write to the user register.
> +    gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm0_raw" \
> +	[join {"= \\{\\{1, 2, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,\
> +		     0 <repeats 52 times>\\}" \
> +	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0 <repeats 52 times>\\}" \
> +	    "\\{0 <repeats 64 times>\\} <repeats 14 times>\\}"} \
> +	    ", "] \
> +	"print tmm0_raw.m_uint8 after user write"
> 
> +    # A whole row can be set at once.  The remaining elements of the row are
> +    # zeroed.
>      gdb_test_no_output "set ((int\[16\]\[16\]) \$tmm2_raw)\[0\] = {1, 1, 1}"
>      gdb_test "print (int\[16\]\[16\]) \$tmm2_raw" \
>  	[join {"= \\{\\{1, 1, 1, 0 <repeats 13 times>\\}" \
>  	    "\\{32, 56, 80, 104, 0 <repeats 12 times>\\}" \
>  	    "\\{0 <repeats 16 times>\\} <repeats 14 times>\\}"} \
> -	    ", "]
> +	    ", "] \
> +	"print tmm2_raw.m_int32 after raw write"
> +    gdb_test "print \$tmm2.m_int32" \
> +	[join {"= \\{\\{1, 1, 1, 0\\}" \
> +	    "\\{32, 56, 80, 104\\}\\}"} \
> +	    ", "] \
> +	"print tmm2.m_int32 after raw write"
> +
> +    gdb_test_no_output "set \$tmm2.m_int32\[0\] = {2, 2, 2}"
> +    gdb_test "print \$tmm2.m_int32" \
> +	[join {"= \\{\\{2, 2, 2, 0\\}" \
> +	    "\\{32, 56, 80, 104\\}\\}"} \
> +	    ", "] \
> +	"print tmm2.m_int32 after user write"
> +    gdb_test "print (int\[16\]\[16\]) \$tmm2_raw" \
> +	[join {"= \\{\\{2, 2, 2, 0 <repeats 13 times>\\}" \
> +	    "\\{32, 56, 80, 104, 0 <repeats 12 times>\\}" \
> +	    "\\{0 <repeats 16 times>\\} <repeats 14 times>\\}"} \
> +	    ", "] \
> +	"print tmm2_raw.m_int32 after user write"
> +
> +    # 0x3f00 is the bfloat16 encoding of 0.5.
> +    gdb_test_no_output \
> +	"set ((uint16_t\[16\]\[32\]) \$tmm0_raw)\[0\]\[0\] = 0x3f00"
> +    gdb_test "print \$tmm0.m_bf16\[0\]\[0\]" "= 0.5"
> +
> +    gdb_test_no_output "set \$tmm0.m_bf16\[0\]\[1\] = 0.25"
> +    gdb_test "print \$tmm0.m_bf16\[0\]\[1\]" "= 0.25"
> +    gdb_test "print/x ((uint16_t\[16\]\[32\]) \$tmm0_raw)\[0\]\[1\]" "=
> 0x3e80"
> 
>      gdb_test_no_output "set ((float\[16\]\[16\]) \$tmm0_raw)\[0\]\[0\] =
> 0.75"
> -    gdb_test "print ((float\[16\]\[16\]) \$tmm0_raw)\[0\]\[0\]" "= 0.75"
> +    gdb_test "print ((float\[16\]\[16\]) \$tmm0_raw)\[0\]\[0\]" "= 0.75" \
> +	"print tmm0_raw.m_fp32\[0\]\[0\] after raw write"
> +    gdb_test "print \$tmm0.m_fp32\[0\]\[0\]" "= 0.75" \
> +	"print tmm0.m_fp32\[0\]\[0\] after raw write"
> +
> +    gdb_test_no_output "set \$tmm0.m_fp32\[0\]\[0\] = 0.5"
> +    gdb_test "print \$tmm0.m_fp32\[0\]\[0\]" "= 0.5" \
> +	"print tmm0.m_fp32\[0\]\[0\] after user write"
> +    gdb_test "print ((float\[16\]\[16\]) \$tmm0_raw)\[0\]\[0\]" "= 0.5" \
> +	"print tmm0_raw.m_fp32\[0\]\[0\] after user write"
> 
>      gdb_test_no_output "set ((int8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\] = -1"
> -    gdb_test "print/d ((int8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\]" "= -1"
> +    gdb_test "print/d ((int8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\]" "= -1" \
> +	"print tmm0_raw.m_int8\[0\]\[0\] after raw write"
> +    gdb_test "print \$tmm0.m_int8\[0\]\[0\]" "= -1" \
> +	"print tmm0.m_int8\[0\]\[0\] after raw write"
> +
> +    gdb_test_no_output "set \$tmm0.m_int8\[0\]\[0\] = -3"
> +    gdb_test "print \$tmm0.m_int8\[0\]\[0\]" "= -3" \
> +	"print tmm0.m_int8\[0\]\[0\] after user write"
> +    gdb_test "print/d ((int8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\]" "= -3" \
> +	"print tmm0_raw.m_int8\[0\]\[0\] after user write"
> +}
> +
> +# Test the value history with the tmm user registers.
> +with_test_prefix "test value history" {
> +    set tmm0 \
> +	[join {"= \\{\\{-3, 0, 0, 63, 1, 1, 1, 1, 2, 2, 2, 2\\}" \
> +	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3\\}\\}"} \
> +	    ", "]
> +
> +    gdb_test "print \$tmm0.m_int8" $tmm0 \
> +	"print tmm0 before re-configuration"
> +
> +    # Re-configure the tile and modify its contents.  Test the value recorded
> +    # in value history.  It must match w.r.t. shape and content.
> +    gdb_test_no_output "set \$tilecfg.colsb\[0\] = 4"
> +    gdb_test_no_output "set \$tmm0.m_int8\[0\]\[0\] = 9"
> +    gdb_test "print \$" $tmm0 "print tmm0 from the value history"
> +    gdb_test "print \$tmm0.m_int8" \
> +	[join {"= \\{\\{9, 0, 0, 63\\}" \
> +	    "\\{1, 1, 1, 1\\}\\}"} \
> +	    ", "] \
> +	"print tmm0 after re-configuration"
>  }
> 
>  # Test generic setting.
> @@ -167,6 +292,45 @@ with_test_prefix "set tilecfg" {
>  	     colsb = {0, 0, 0, 0, 0, 0, 0, 0}, rows = {4, 0, 0, 0, 0, 0, 0, 0}}"]  }
> 
> +# Return the Intel AMX registers listed in the output of COMMAND.
> +
> +proc amx_regs_in_output {command} {
> +    set output [capture_command_output $command ""]
> +    set regs {}
> +    foreach {-> reg} [regexp -all -inline -line \
> +			 {^(tilecfg(?:_raw)?|tmm[0-7](?:_raw)?)[ \t]} $output]

Nit: more than 80 characters

> {
> +	lappend regs $reg
> +    }
> +    verbose -log "Intel AMX registers in \"$command\": $regs"
> +    return $regs
> +}
> +
> +# The tilecfg pseudo register and the tile user registers are in the #
> +"all" and "matrix" register groups.  The raw registers are only in the
> +# "save" and "restore" register groups.
> +with_test_prefix "register groups" {
> +    set matrix_regs {tilecfg}
> +    set raw_regs {tilecfg_raw}
> +    for {set i 0} {$i < 8} {incr i} {
> +	lappend matrix_regs tmm$i
> +	lappend raw_regs tmm${i}_raw
> +    }
> +
> +    foreach {command expected} [list \
> +	"info registers" {} \
> +	"info all-registers" $matrix_regs \
> +	"info registers general" {} \
> +	"info registers all" $matrix_regs \
> +	"info registers matrix" $matrix_regs \
> +	"info registers vector" {} \
> +	"info registers float" {} \
> +	"info registers system" {} \
> +	"info registers save" $raw_regs \
> +	"info registers restore" $raw_regs] {
> +	gdb_assert {[amx_regs_in_output $command] eq $expected}
> $command
> +    }
> +}
> +
>  # Test the core file generated by gcore.  We expect the registers values that  #
> the live process had before the core file is generated.
>  if {$gcore_generated} {
> --
> 2.43.0
> 
> ________________________________________
> Intel Deutschland GmbH
> 
> Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany
> 
> Tel: +49 (89) 99143-0
> 
> www.intel.de
> 
> Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran
> Sitaraman
> 
> Chairperson of the Supervisory Board: Sonja Pierer
> 
> Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB
> 186928
> 
> This e-mail and any attachments may contain confidential material for the sole
> use of the intended recipient(s). Any review or distribution by others is strictly
> prohibited. If you are not the intended recipient, please contact the sender and
> delete all copies.
> 

________________________________________
Intel Deutschland GmbH 

Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany 

Tel: +49 (89) 99143-0 

www.intel.de 

Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman

Chairperson of the Supervisory Board: Sonja Pierer

Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
  
Joos, Christina Nov. 4, 2026, 9 a.m. UTC | #3
Hi Stephan, 

> -----Original Message-----
> From: Joos, Christina <christina.joos@intel.com>
> Sent: Dienstag, 3. November 2026 16:19
> To: Rohr, Stephan <stephan.rohr@intel.com>; gdb-patches@sourceware.org
> Cc: pedro@palves.net; eliz@gnu.org; jhb@FreeBSD.org;
> luis.machado@arm.com
> Subject: RE: [PATCH v2 5/5] gdb: add Intel AMX tile registers as user registers
> 
> Hi Stephan,
> 
> Thank you for this patch.
> 
> I tested some edge cases and found the following:
> 
> 1) Assert for $tilecfg.colsb[0]=200
> ~~~
> gdb) set $tilecfg.colsb[0]=200
> (gdb) p $tmm0_raw
> $1 = {0 <repeats 16 times>}
> (gdb) p $tilecfg
> $2 = {palette = 0, start_row = 0, colsb = {200, 0, 0, 0, 0, 0, 0, 0}, rows = {0, 0, 0,
> 0, 0, 0, 0, 0}}
> (gdb) p $tmm0
> /tmp/gdb/i386-tdep.c:3298: internal-error: i386_tmm_type: Assertion `colsb >
> 0 && colsb <= tilecfg_reg::MAX_BYTES_PER_ROW' failed.
> A problem internal to GDB has been detected, further debugging may prove
> unreliable.
> ----- Backtrace -----
> 0x60228446351d gdb_internal_backtrace_1
>         /tmp/gdb/bt-utils.c:122
> 0x602284463569 _Z22gdb_internal_backtracev
>         /tmp/gdb/bt-utils.c:173
> [...]
> ~~~
> 
> 2) I have one open regarding how we should display values when the data
> type is too large for colsb, for example:
> ~~~
> (gdb) set $tilecfg.colsb[0]=2
> (gdb) p $tmm0
> $4 = {m_int8 = {{0, 0}, {0, 0}}, m_uint8 = {{0, 0}, {0, 0}}, m_int32 = 0x0, m_bf16
> = {{0}, {0}}, m_fp32 = 0x0}
> ~~~
> or for the case colsb[0]=3.

This depends on the interpretations supported by the AMX hardware.
I believe we need to investigate this further to clarify what we want to display in the individual cases.

Thanks for all the work on this topic!
Christina
________________________________________
Intel Deutschland GmbH 

Registered Address: Dornacher Strasse 1, 85622 Feldkirchen, Germany 

Tel: +49 (89) 99143-0 

www.intel.de 

Managing Directors: Candice Moore, Jeffrey Schneiderman, Ramachandran Sitaraman

Chairperson of the Supervisory Board: Sonja Pierer

Registered Seat: Munich Commercial Register B: Amtsgericht Munich HRB 186928

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
  

Patch

diff --git a/gdb/NEWS b/gdb/NEWS
index 47ecba246a0..1c60f307d53 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -11,6 +11,8 @@ 
   Support displaying and modifying Intel AMX raw registers
   $tmm0_raw - $tmm7_raw and the $tilecfg_raw register.  The $tilecfg
   pseudo register provides a parsed view of the tile configuration.
+  The $tmm0 - $tmm7 user registers display the raw tile registers according
+  to the configuration in $tilecfg.
 
 * GDB now distinguishes between the GNU (MinGW) and MSVC Windows ABIs.
 
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 13242e293b5..6d421c85080 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -34,8 +34,10 @@ 
 #include "gdbcore.h"
 #include "objfiles.h"
 #include "regcache.h"
+#include "reggroups.h"
 #include "regset.h"
 #include "symfile.h"
+#include "user-regs.h"
 #include "disasm.h"
 #include "amd64-tdep.h"
 #include "i387-tdep.h"
@@ -199,6 +201,25 @@  static const char *amd64_tmm_raw_names[] = {
     "tmm4_raw", "tmm5_raw", "tmm6_raw", "tmm7_raw"
 };
 
+/* Register names for the tmm user registers.  */
+
+static const char *amd64_tmm_user_names[] = {
+    "tmm0", "tmm1", "tmm2", "tmm3",
+    "tmm4", "tmm5", "tmm6", "tmm7"
+};
+
+/* Batons for the tmm user registers.  */
+
+static const int amd64_tmm_user_batons[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
+
+/* Register groups for the tmm user registers.  */
+
+static const reggroup *const amd64_tmm_groups[] = {
+    matrix_reggroup,
+    all_reggroup
+};
+
+
 /* DWARF Register Number Mapping as defined in the System V psABI,
    section 3.6.  */
 
@@ -632,6 +653,62 @@  amd64_ax_pseudo_register_collect (struct gdbarch *gdbarch,
 
 
 
+
+/* Read ROWS and COLSB from TILECFG for tile TMMNUM.  Return the maximum number
+   of rows and the maximum number of bytes respectively for an unconfigured
+   tile.  */
+
+static void
+amd64_tmm_dimensions (const tilecfg_reg &tilecfg, int tmmnum, uint8_t *rows,
+		      uint16_t *colsb)
+{
+  *rows = tilecfg.rows (tmmnum);
+  *colsb = tilecfg.bytes_per_row (tmmnum);
+
+  if (*rows == 0)
+    *rows = tilecfg_reg::MAX_ROWS;
+  if (*colsb == 0)
+    *colsb = tilecfg_reg::MAX_BYTES_PER_ROW;
+}
+
+/* Return the tile configuration for NEXT_FRAME.  */
+
+static tilecfg_reg
+amd64_read_tilecfg (const frame_info_ptr &next_frame)
+{
+  gdbarch *gdbarch = frame_unwind_arch (next_frame);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  value *tilecfg_raw_val = value_of_register (tdep->tilecfg_raw_regnum,
+					      next_frame);
+
+  return tilecfg_reg (tilecfg_raw_val->contents ());
+}
+
+/* Read a tmm user register with dynamic resolution of the configured
+   dimensions.  BATON is the tile number.  */
+
+static value *
+amd64_value_of_tmm_user_reg (const frame_info_ptr &frame, const void *baton)
+{
+  gdbarch *gdbarch = get_frame_arch (frame);
+  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  frame_info_ptr next_frame = get_next_frame_sentinel_okay (frame);
+  int tmmnum = *(const int *) baton;
+
+  /* Read the register's dimensions from tilecfg.  */
+  tilecfg_reg tilecfg = amd64_read_tilecfg (next_frame);
+  uint8_t rows;
+  uint16_t colsb;
+  amd64_tmm_dimensions (tilecfg, tmmnum, &rows, &colsb);
+
+  /* "i386_tmm_type" builds a union with one view per element type, e.g.,
+     "int8" and "uint8".  The rows have a fixed stride such that elements are
+     at the same offsets as in the raw register.  */
+  return value::allocate_register_lazy (next_frame,
+					tdep->tmm_raw_regnum + tmmnum,
+					i386_tmm_type (gdbarch, rows, colsb));
+}
+
 /* Register classes as defined in the psABI.  */
 
 enum amd64_reg_class
@@ -3863,6 +3940,12 @@  amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
 					amd64_in_indirect_branch_thunk);
 
   register_amd64_ravenscar_ops (gdbarch);
+
+  /* Add tile registers tmm0 to tmm7 as user registers.  */
+  for (int i = 0; i < tdep->num_tmm_raw_regs; i++)
+    user_reg_add (gdbarch, amd64_tmm_user_names[i],
+		  amd64_value_of_tmm_user_reg, &amd64_tmm_user_batons[i],
+		  amd64_tmm_groups);
 }
 
 /* Initialize ARCH for x86-64, no osabi.  */
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index ba9d3df1ac5..15b351e8c02 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27466,7 +27466,11 @@  omitting reserved bits.  The tile registers are supplied as the raw registers
 contents of a tile with its maximum dimensions of @w{16 rows} of
 @w{64 bytes}.  The raw tile registers hold one @code{uint512} per row and only
 the elements within the dimensions configured in @samp{tilecfg} hold data.
-For example:
+Additional user registers @samp{tmm0}, @samp{tmm1}, @dots{}, @samp{tmm7}
+present the raw registers with the dimensions configured in
+@samp{tilecfg}.  They are part of the @code{matrix} and @code{all}
+register groups, so that @code{info registers matrix} and @code{info
+all-registers} list them.  For example:
 
 @smallexample
 (gdb) print/x $tilecfg_raw
@@ -27482,8 +27486,15 @@  $3 = @{621397352980713455329738752, 932096029507240269422067969,
 $4 = @{@{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 0 <repeats 52 times>@},
   @{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0 <repeats 52 times>@},
   @{0 <repeats 64 times>@} <repeats 14 times>@}
+(gdb) print $tmm1.m_int8
+$5 = @{@{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2@},
+  @{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3@}@}
 @end smallexample
 
+In this example, @code{$tmm1.m_int8} shows the tile as signed 8-bit
+integers with the dimensions configured in @samp{tilecfg} for
+@samp{tmm1}: 2 rows (@code{rows}) of 12 bytes (@code{colsb}).
+
 @node Alpha
 @subsection Alpha
 
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index a25abfbd1bc..21d4bf6f4a9 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -47,6 +47,7 @@ 
 #include "i386-tdep.h"
 #include "i387-tdep.h"
 #include "gdbsupport/x86-xstate.h"
+#include "gdbsupport/array-view.h"
 #include "x86-tdep.h"
 #include "expop.h"
 
@@ -447,6 +448,22 @@  i386_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
   internal_error (_("invalid regnum"));
 }
 
+/* AMX tilecfg_reg constructor.  */
+
+tilecfg_reg::tilecfg_reg (gdb::array_view<const gdb_byte> raw_tilecfg)
+{
+  gdb_assert (raw_tilecfg.size () == X86_AMX_TILECFG_SIZE);
+
+  /* Read the TILECFG column and row values.  */
+  for (int i = 0; i < NUM_TILES; i++)
+    {
+      const int offset = COLUMN_OFFSET + i * 2;
+      uint16_t colsb = extract_unsigned_integer (raw_tilecfg.slice (offset, 2),
+						 BFD_ENDIAN_LITTLE);
+      m_tiles[i] = { colsb, raw_tilecfg[ROW_OFFSET + i] };
+    }
+}
+
 /* Convert SVR4 DWARF register number REG to the appropriate register number
    used by GDB.  */
 
@@ -3250,6 +3267,84 @@  i386_mmx_type (struct gdbarch *gdbarch)
   return tdep->i386_mmx_type;
 }
 
+/* Return a view of a tile with ROWS rows of COLS elements of type ELT_TYPE.
+   The rows have a fixed stride of TILECFG_REG::MAX_BYTES_PER_ROW.  */
+
+static type *
+i386_tmm_view_type (gdbarch *gdbarch, type *elt_type, int cols, int rows)
+{
+  type *row_type = init_vector_type (elt_type, cols);
+
+  type_allocator alloc (gdbarch);
+  type *range_type
+    = create_static_range_type (alloc, builtin_type (gdbarch)->builtin_int,
+				0, rows - 1);
+  dynamic_prop stride;
+  stride.set_const_val (tilecfg_reg::MAX_BYTES_PER_ROW);
+
+  type *t = create_array_type_with_stride (alloc, row_type, range_type,
+					   &stride, true);
+  t->set_is_vector (true);
+  return t;
+}
+
+/* See i386-tdep.h.  */
+
+type *
+i386_tmm_type (gdbarch *gdbarch, uint8_t rows, uint16_t colsb)
+{
+  i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+  gdb_assert (rows > 0 && rows <= tilecfg_reg::MAX_ROWS);
+  gdb_assert (colsb > 0 && colsb <= tilecfg_reg::MAX_BYTES_PER_ROW);
+
+  /* Cache the tmm type based on the configured dimension.  */
+  uint32_t key = ((uint32_t) rows << 16) | colsb;
+  auto it = tdep->i386_tmm_types.find (key);
+  if (it != tdep->i386_tmm_types.end ())
+    return it->second;
+
+  const struct builtin_type *bt = builtin_type (gdbarch);
+
+  /* The type we're building is this:
+
+     union __gdb_builtin_type_matrix1024i
+       {
+	 int8_t m_int8[rows][colsb];
+	 uint8_t m_uint8[rows][colsb];
+	 int32_t m_int32[rows][colsb / 4];
+	 bfloat16_t m_bf16[rows][colsb / 2];
+	 float m_fp32[rows][colsb / 4];
+       };  */
+
+  type *t = arch_composite_type (gdbarch, "builtin_type_tile", TYPE_CODE_UNION);
+
+  append_composite_type_field
+    (t, "m_int8",
+     i386_tmm_view_type (gdbarch, bt->builtin_int8, colsb, rows));
+
+  append_composite_type_field
+    (t, "m_uint8",
+     i386_tmm_view_type (gdbarch, bt->builtin_uint8, colsb, rows));
+
+  append_composite_type_field
+    (t, "m_int32",
+     i386_tmm_view_type (gdbarch, bt->builtin_int32, colsb / 4, rows));
+
+  append_composite_type_field
+    (t, "m_bf16",
+     i386_tmm_view_type (gdbarch, bt->builtin_bfloat16, colsb / 2, rows));
+
+  append_composite_type_field
+    (t, "m_fp32",
+     i386_tmm_view_type (gdbarch, bt->builtin_float, colsb / 4, rows));
+
+  t->set_is_vector (true);
+  t->set_name ("builtin_type_tile");
+  tdep->i386_tmm_types.emplace (key, t);
+
+  return t;
+}
+
 /* The type of the TILECFG registers.  */
 
 static type *
@@ -4372,6 +4467,9 @@  i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
   tilecfg_regnum_p = i386_tilecfg_regnum_p (gdbarch, regnum);
   tilecfg_raw_regnum_p = i386_tilecfg_raw_regnum_p (gdbarch, regnum);
 
+  if (group == matrix_reggroup)
+    return tilecfg_regnum_p;
+
   avx512_p = ((tdep->xcr0 & X86_XSTATE_AVX_AVX512_MASK)
 	      == X86_XSTATE_AVX_AVX512_MASK);
   avx_p = ((tdep->xcr0 & X86_XSTATE_AVX_AVX512_MASK)
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index 898a76dfb50..e9393580194 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -23,6 +23,7 @@ 
 #include "gdbarch.h"
 #include "infrun.h"
 #include "expression.h"
+#include "gdbsupport/unordered_map.h"
 #include "gdbsupport/x86-xstate.h"
 
 class frame_info_ptr;
@@ -287,6 +288,9 @@  struct i386_gdbarch_tdep : gdbarch_tdep_base
   struct type *i387_ext_type = nullptr;
   type *i386_tilecfg_type = nullptr;
 
+  /* Type cache for tile user registers.  */
+  gdb::unordered_map<uint32_t, type *> i386_tmm_types;
+
   /* If the registers containing the i386 Linux TLS related global
      descriptor table information are available.  This is used to decide
      whether to add the NT_386_TLS note to the core file or not.  */
@@ -437,6 +441,12 @@  extern void i386_ax_pseudo_register_collect (struct gdbarch *gdbarch,
 					     struct agent_expr *ax,
 					     int regnum);
 
+/* Return the type of an Intel AMX tile that is configured to hold ROWS rows
+   of COLSB bytes each.  */
+
+extern type *i386_tmm_type (gdbarch *gdbarch, uint8_t rows,
+			    uint16_t colsb);
+
 /* Segment selectors.  */
 #define I386_SEL_RPL	0x0003  /* Requester's Privilege Level mask.  */
 #define I386_SEL_UPL	0x0003	/* User Privilege Level.  */
@@ -536,4 +546,75 @@  extern bool i386_stap_is_single_operand (struct gdbarch *gdbarch,
 extern expr::operation_up i386_stap_parse_special_token
      (struct gdbarch *gdbarch, struct stap_parse_info *p);
 
+/* TILECFG register.
+   0       palette
+   1       start_row
+   2-15    reserved, must be zero
+   16-17   tile0.colsb Tile 0 bytes per row.
+   18-19   tile1.colsb Tile 1 bytes per row.
+   20-21   tile2.colsb Tile 2 bytes per row.
+   ...     (sequence continues)
+   30-31   tile7.colsb Tile 7 bytes per row.
+   32-47   reserved, must be zero
+   48      tile0.rows Tile 0 rows.
+   49      tile1.rows Tile 1 rows.
+   50      tile2.rows Tile 2 rows.
+   ...     (sequence continues)
+   55      tile7.rows Tile 7 rows.
+   56-63   reserved, must be zero.  */
+
+class tilecfg_reg
+{
+public:
+  /* Construct it from raw tilecfg data.  */
+  explicit tilecfg_reg (gdb::array_view<const gdb_byte> raw_tilecfg);
+
+  /* Get number of configured bytes per row for tile P.  */
+  inline uint16_t
+  bytes_per_row (uint8_t p) const
+  {
+    gdb_assert (p < NUM_TILES);
+    return m_tiles[p].colsb;
+  }
+
+  /* Get number of configured rows for tile P.  */
+  inline uint8_t
+  rows (uint8_t p) const
+  {
+    gdb_assert (p < NUM_TILES);
+    return m_tiles[p].rows;
+  }
+
+  /* Maximum possible values for the current target.  */
+  static const uint16_t MAX_ROWS = 16;
+  static const uint16_t MAX_BYTES_PER_ROW = 64;
+
+private:
+  /* Offsets of the colsb and rows arrays.  */
+  static const uint16_t COLUMN_OFFSET = 16;
+  static const uint16_t ROW_OFFSET = 48;
+
+  /* Size of the tiles.  */
+  static const uint16_t NUM_TILES = X86_AMX_NUM_TMM_REGISTERS;
+
+  /* The configuration of a single tile.  */
+  struct tile
+  {
+    /* Number of configured bytes per row.  */
+    uint16_t colsb = 0;
+
+    /* Number of configured rows.  */
+    uint8_t rows = 0;
+
+    bool
+    operator== (const tile &t) const
+    {
+      return colsb == t.colsb && rows == t.rows;
+    }
+  };
+
+  /* The configuration of each tile.  */
+  std::array<tile, NUM_TILES> m_tiles {};
+};
+
 #endif /* GDB_I386_TDEP_H */
diff --git a/gdb/testsuite/gdb.arch/amd64-amx.c b/gdb/testsuite/gdb.arch/amd64-amx.c
index 5dca29ad183..8233ada65b5 100644
--- a/gdb/testsuite/gdb.arch/amd64-amx.c
+++ b/gdb/testsuite/gdb.arch/amd64-amx.c
@@ -47,6 +47,12 @@  int8_t int8_matrix[2][8] = { { -1, -1, -1, -1, 1, 1, 1, 1 },
 float fp32_matrix[2][2] = { { 1.0, 1.125 },
 			    { 1.25, 1.375 } };
 
+/* The bfloat16 values 0, 0.125, 0.25, 0.375 and 0.5, 0.625, 0.75, 0.875.
+   We use encoded bf16 values to avoid a dependency on compilers supporting
+   Intel AMX but not the __bf16 data type.  */
+uint16_t bf16_matrix[2][4] = { { 0x0000, 0x3e00, 0x3e80, 0x3ec0 },
+			       { 0x3f00, 0x3f20, 0x3f40, 0x3f60 } };
+
 
 static void
 tfmaps_calc (void)
@@ -79,6 +85,8 @@  tfmaps_calc (void)
   tc.cols[C] = M * 4;
 
   /* Tiles for testing the remaining element types.  */
+  tc.rows[3] = 2;
+  tc.cols[3] = 8;
   tc.rows[4] = 2;
   tc.cols[4] = 8;
   tc.rows[5] = 2;
@@ -87,6 +95,7 @@  tfmaps_calc (void)
   _tile_loadconfig (&tc);
 
   /* Load additional types for type testing.  */
+  _tile_loadd (3, bf16_matrix, 4 * 2);
   _tile_loadd (4, fp32_matrix, 2 * 4);
   _tile_loadd (5, int8_matrix, 4 * 2);
 
diff --git a/gdb/testsuite/gdb.arch/amd64-amx.exp b/gdb/testsuite/gdb.arch/amd64-amx.exp
index af92e2d37a0..1974160abb6 100644
--- a/gdb/testsuite/gdb.arch/amd64-amx.exp
+++ b/gdb/testsuite/gdb.arch/amd64-amx.exp
@@ -38,12 +38,12 @@  proc test_zeroed_tile {reg} {
 
 proc test_loaded_tiles {} {
     gdb_test "print/x \$tilecfg_raw" \
-	[join {"= 0x20200020302000000000000000000000000000000000" \
-	    "000000000080008000000100010000c00000000000000000000000000000001"} ""]
+	[join {"= 0x20202020302000000000000000000000000000000000" \
+	    "000000000080008000800100010000c00000000000000000000000000000001"} ""]
 
     gdb_test "print \$tilecfg" \
 	[string_to_regexp "= {palette = 1, start_row = 0,\
-	     colsb = {12, 16, 16, 0, 8, 8, 0, 0}, rows = {2, 3, 2, 0, 2, 2, 0, 0}}"]
+	     colsb = {12, 16, 16, 8, 8, 8, 0, 0}, rows = {2, 3, 2, 2, 2, 2, 0, 0}}"]
 
     gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm0_raw" \
 	[join {"= \\{\\{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,\
@@ -52,6 +52,11 @@  proc test_loaded_tiles {} {
 	    "\\{0 <repeats 64 times>\\} <repeats 14 times>\\}"} \
 	    ", "]
 
+    gdb_test "print \$tmm0.m_uint8" \
+	[join {"= \\{\\{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2\\}" \
+	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3\\}\\}"} \
+	    ", "]
+
     gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm1_raw" \
 	[join {"= \\{\\{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,\
 		     0 <repeats 48 times>\\}" \
@@ -62,26 +67,48 @@  proc test_loaded_tiles {} {
 	    "\\{0 <repeats 64 times>\\} <repeats 13 times>\\}"} \
 	    ", "]
 
+    gdb_test "print \$tmm1.m_uint8" \
+	[join {"= \\{\\{0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3\\}" \
+	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4\\}" \
+	    "\\{2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5\\}\\}"} \
+	    ", "]
+
     gdb_test "print (int\[16\]\[16\]) \$tmm2_raw" \
 	[join {"= \\{\\{20, 32, 44, 56, 0 <repeats 12 times>\\}" \
 	    "\\{32, 56, 80, 104, 0 <repeats 12 times>\\}" \
 	    "\\{0 <repeats 16 times>\\} <repeats 14 times>\\}"} \
 	    ", "]
 
+    gdb_test "print \$tmm2.m_int32" \
+	"= \\{\\{20, 32, 44, 56\\}, \\{32, 56, 80, 104\\}\\}"
+
+    gdb_test "print \$tmm3.m_bf16" \
+	[join {"= \\{\\{0, 0.125, 0.25, 0.375\\}" \
+	    "\\{0.5, 0.625, 0.75, 0.875\\}\\}"} \
+	    ", "]
+
     gdb_test "print (float\[16\]\[16\]) \$tmm4_raw" \
 	[join {"= \\{\\{1, 1.125, 0 <repeats 14 times>\\}" \
 	    "\\{1.25, 1.375, 0 <repeats 14 times>\\}" \
 	    "\\{0 <repeats 16 times>\\} <repeats 14 times>\\}"} \
 	    ", "]
 
+    gdb_test "print \$tmm4.m_fp32" "= \\{\\{1, 1.125\\}, \\{1.25, 1.375\\}\\}"
+
     gdb_test "print/d (int8_t\[16\]\[64\]) \$tmm5_raw" \
 	[join {"= \\{\\{-1, -1, -1, -1, 1, 1, 1, 1, 0 <repeats 56 times>\\}" \
 	    "\\{1, 1, 1, 1, -5, -5, -5, -5, 0 <repeats 56 times>\\}" \
 	    "\\{0 <repeats 64 times>\\} <repeats 14 times>\\}"} \
 	    ", "]
 
-    foreach i {3 6 7} {
+    gdb_test "print \$tmm5.m_int8" \
+	[join {"= \\{\\{-1, -1, -1, -1, 1, 1, 1, 1\\}" \
+	    "\\{1, 1, 1, 1, -5, -5, -5, -5\\}\\}"} \
+	    ", "]
+
+    for {set i 6} {$i < 8} {incr i} {
 	test_zeroed_tile "\$tmm${i}_raw"
+	test_zeroed_tile "\$tmm${i}"
     }
 }
 
@@ -119,28 +146,126 @@  with_test_prefix "read tiles" {
 set gcorefile $binfile.gcore
 set gcore_generated [gdb_gcore_cmd $gcorefile "save a core file"]
 
-# Test setting tiles.
+# Test setting tiles.  The raw registers and the user registers both map to
+# the same tile data.  A write to one of them must be reflected in the other
+# one.
 with_test_prefix "setting tiles" {
+    # Write to a raw register.
     gdb_test_no_output "set ((uint8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\] = 1"
     gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm0_raw" \
 	[join {"= \\{\\{1, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,\
 		     0 <repeats 52 times>\\}" \
 	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0 <repeats 52 times>\\}" \
 	    "\\{0 <repeats 64 times>\\} <repeats 14 times>\\}"} \
-	    ", "]
+	    ", "] \
+	"print tmm0_raw.m_uint8 after raw write"
+
+    # The user register must reflect the write to the raw register.
+    gdb_test "print \$tmm0.m_uint8" \
+	[join {"= \\{\\{1, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2\\}" \
+	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3\\}\\}"} \
+	    ", "] \
+	"print tmm0.m_uint8 user register after raw write"
+
+    # Write to another element of the same tile via the user register.
+    gdb_test_no_output "set \$tmm0.m_uint8\[0\]\[1\] = 2"
+    gdb_test "print \$tmm0.m_uint8" \
+	[join {"= \\{\\{1, 2, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2\\}" \
+	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3\\}\\}"} \
+	    ", "] \
+	"print tmm0.m_uint8 after user write"
+
+    # The raw register must reflect the write to the user register.
+    gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm0_raw" \
+	[join {"= \\{\\{1, 2, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,\
+		     0 <repeats 52 times>\\}" \
+	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0 <repeats 52 times>\\}" \
+	    "\\{0 <repeats 64 times>\\} <repeats 14 times>\\}"} \
+	    ", "] \
+	"print tmm0_raw.m_uint8 after user write"
 
+    # A whole row can be set at once.  The remaining elements of the row are
+    # zeroed.
     gdb_test_no_output "set ((int\[16\]\[16\]) \$tmm2_raw)\[0\] = {1, 1, 1}"
     gdb_test "print (int\[16\]\[16\]) \$tmm2_raw" \
 	[join {"= \\{\\{1, 1, 1, 0 <repeats 13 times>\\}" \
 	    "\\{32, 56, 80, 104, 0 <repeats 12 times>\\}" \
 	    "\\{0 <repeats 16 times>\\} <repeats 14 times>\\}"} \
-	    ", "]
+	    ", "] \
+	"print tmm2_raw.m_int32 after raw write"
+    gdb_test "print \$tmm2.m_int32" \
+	[join {"= \\{\\{1, 1, 1, 0\\}" \
+	    "\\{32, 56, 80, 104\\}\\}"} \
+	    ", "] \
+	"print tmm2.m_int32 after raw write"
+
+    gdb_test_no_output "set \$tmm2.m_int32\[0\] = {2, 2, 2}"
+    gdb_test "print \$tmm2.m_int32" \
+	[join {"= \\{\\{2, 2, 2, 0\\}" \
+	    "\\{32, 56, 80, 104\\}\\}"} \
+	    ", "] \
+	"print tmm2.m_int32 after user write"
+    gdb_test "print (int\[16\]\[16\]) \$tmm2_raw" \
+	[join {"= \\{\\{2, 2, 2, 0 <repeats 13 times>\\}" \
+	    "\\{32, 56, 80, 104, 0 <repeats 12 times>\\}" \
+	    "\\{0 <repeats 16 times>\\} <repeats 14 times>\\}"} \
+	    ", "] \
+	"print tmm2_raw.m_int32 after user write"
+
+    # 0x3f00 is the bfloat16 encoding of 0.5.
+    gdb_test_no_output \
+	"set ((uint16_t\[16\]\[32\]) \$tmm0_raw)\[0\]\[0\] = 0x3f00"
+    gdb_test "print \$tmm0.m_bf16\[0\]\[0\]" "= 0.5"
+
+    gdb_test_no_output "set \$tmm0.m_bf16\[0\]\[1\] = 0.25"
+    gdb_test "print \$tmm0.m_bf16\[0\]\[1\]" "= 0.25"
+    gdb_test "print/x ((uint16_t\[16\]\[32\]) \$tmm0_raw)\[0\]\[1\]" "= 0x3e80"
 
     gdb_test_no_output "set ((float\[16\]\[16\]) \$tmm0_raw)\[0\]\[0\] = 0.75"
-    gdb_test "print ((float\[16\]\[16\]) \$tmm0_raw)\[0\]\[0\]" "= 0.75"
+    gdb_test "print ((float\[16\]\[16\]) \$tmm0_raw)\[0\]\[0\]" "= 0.75" \
+	"print tmm0_raw.m_fp32\[0\]\[0\] after raw write"
+    gdb_test "print \$tmm0.m_fp32\[0\]\[0\]" "= 0.75" \
+	"print tmm0.m_fp32\[0\]\[0\] after raw write"
+
+    gdb_test_no_output "set \$tmm0.m_fp32\[0\]\[0\] = 0.5"
+    gdb_test "print \$tmm0.m_fp32\[0\]\[0\]" "= 0.5" \
+	"print tmm0.m_fp32\[0\]\[0\] after user write"
+    gdb_test "print ((float\[16\]\[16\]) \$tmm0_raw)\[0\]\[0\]" "= 0.5" \
+	"print tmm0_raw.m_fp32\[0\]\[0\] after user write"
 
     gdb_test_no_output "set ((int8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\] = -1"
-    gdb_test "print/d ((int8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\]" "= -1"
+    gdb_test "print/d ((int8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\]" "= -1" \
+	"print tmm0_raw.m_int8\[0\]\[0\] after raw write"
+    gdb_test "print \$tmm0.m_int8\[0\]\[0\]" "= -1" \
+	"print tmm0.m_int8\[0\]\[0\] after raw write"
+
+    gdb_test_no_output "set \$tmm0.m_int8\[0\]\[0\] = -3"
+    gdb_test "print \$tmm0.m_int8\[0\]\[0\]" "= -3" \
+	"print tmm0.m_int8\[0\]\[0\] after user write"
+    gdb_test "print/d ((int8_t\[16\]\[64\]) \$tmm0_raw)\[0\]\[0\]" "= -3" \
+	"print tmm0_raw.m_int8\[0\]\[0\] after user write"
+}
+
+# Test the value history with the tmm user registers.
+with_test_prefix "test value history" {
+    set tmm0 \
+	[join {"= \\{\\{-3, 0, 0, 63, 1, 1, 1, 1, 2, 2, 2, 2\\}" \
+	    "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3\\}\\}"} \
+	    ", "]
+
+    gdb_test "print \$tmm0.m_int8" $tmm0 \
+	"print tmm0 before re-configuration"
+
+    # Re-configure the tile and modify its contents.  Test the value recorded
+    # in value history.  It must match w.r.t. shape and content.
+    gdb_test_no_output "set \$tilecfg.colsb\[0\] = 4"
+    gdb_test_no_output "set \$tmm0.m_int8\[0\]\[0\] = 9"
+    gdb_test "print \$" $tmm0 "print tmm0 from the value history"
+    gdb_test "print \$tmm0.m_int8" \
+	[join {"= \\{\\{9, 0, 0, 63\\}" \
+	    "\\{1, 1, 1, 1\\}\\}"} \
+	    ", "] \
+	"print tmm0 after re-configuration"
 }
 
 # Test generic setting.
@@ -167,6 +292,45 @@  with_test_prefix "set tilecfg" {
 	     colsb = {0, 0, 0, 0, 0, 0, 0, 0}, rows = {4, 0, 0, 0, 0, 0, 0, 0}}"]
 }
 
+# Return the Intel AMX registers listed in the output of COMMAND.
+
+proc amx_regs_in_output {command} {
+    set output [capture_command_output $command ""]
+    set regs {}
+    foreach {-> reg} [regexp -all -inline -line \
+			 {^(tilecfg(?:_raw)?|tmm[0-7](?:_raw)?)[ \t]} $output] {
+	lappend regs $reg
+    }
+    verbose -log "Intel AMX registers in \"$command\": $regs"
+    return $regs
+}
+
+# The tilecfg pseudo register and the tile user registers are in the
+# "all" and "matrix" register groups.  The raw registers are only in the
+# "save" and "restore" register groups.
+with_test_prefix "register groups" {
+    set matrix_regs {tilecfg}
+    set raw_regs {tilecfg_raw}
+    for {set i 0} {$i < 8} {incr i} {
+	lappend matrix_regs tmm$i
+	lappend raw_regs tmm${i}_raw
+    }
+
+    foreach {command expected} [list \
+	"info registers" {} \
+	"info all-registers" $matrix_regs \
+	"info registers general" {} \
+	"info registers all" $matrix_regs \
+	"info registers matrix" $matrix_regs \
+	"info registers vector" {} \
+	"info registers float" {} \
+	"info registers system" {} \
+	"info registers save" $raw_regs \
+	"info registers restore" $raw_regs] {
+	gdb_assert {[amx_regs_in_output $command] eq $expected} $command
+    }
+}
+
 # Test the core file generated by gcore.  We expect the registers values that
 # the live process had before the core file is generated.
 if {$gcore_generated} {