* [PATCH v2 0/5] Add Intel AMX support
@ 2026-10-30 11:50 Stephan Rohr
2026-10-30 11:50 ` [PATCH v2 1/5] gdb: define additional integer built-in types Stephan Rohr
` (4 more replies)
0 siblings, 5 replies; 15+ messages in thread
From: Stephan Rohr @ 2026-10-30 11:50 UTC (permalink / raw)
To: gdb-patches; +Cc: pedro, eliz, jhb, luis.machado
From: "Rohr, Stephan" <stephan.rohr@intel.com>
Hi all,
this is our version 2 of the "Add AMX support" series to bring Intel AMX
support to upstream GDB.
Patch
gdb: define additional integer built-in types
adds additional 256-bit and 512-bit integer types similar to the patch
we posted in v1. 256-bit types are currently not used but added for
completeness.
Patch
gdb, gdbserver: Add Intel AMX registers.
implements basic support by adding the raw Intel AMX registers
$tmm0_raw .. $tmm7_raw and both the raw $tilecfg_raw and a $tilecfg
pseudo register. $tilecfg provides a parsed and user friendly view
of the raw register. The raw tile registers are added as a vector of
uint512 to avoid polluting the screen when printing a raw tile register.
The raw registers are hidden by removing them from the "all" and
"general" register groups.
Patch
gdb: support register groups for user registers
adds support to include user registers in register groups. We use this
in the following patches to include the tile user registers in the "info
registers all" command. By default, user registers are not added to any
group so that the current behavior is preserved for the existing user
registers.
Next, we add a new register group "matrix" to include both the $tilecfg
pseudo register and the tile user registers.
Patch
gdb: add Intel AMX tile registers as user registers
implements the tile registers as user registers. The registers are
printed with respect to the configured dimensions using an array type with
a fixed stride. This naturally supports remote targets and writing the
registers, too. The tile user registers are added to the "all" and
"matrix" register groups.
Changes since v1
================
v1: https://sourceware.org/pipermail/gdb-patches/2022-May/188790.html
v1 patch 1/4: gdb: define int512 and uint512 as built-in types
The patch now introduces additional 256-bit integer types for
completeness.
v1 patch 2/4: gdb, gdbserver: Add AMX registers
- The patch now only adds the raw tile registers, the raw tilecfg register
and a tilecfg pseudo-register.
- The raw registers naturally support the user history.
- I386_MAX_REGISTER_SIZE is 1024 bytes, the size of a single raw tile
register.
- Removed the dynamically sized tile pseudo registers and replaced them
with user registers as part of this series.
- Addressed Pedro's feedback on tilecfg_reg, no std::pair any more, members
are initialized at their declaration, and a fixed-size std::array replaces
the vector that was sized by a delegated constructor.
- Addressed Eli's documentation feedback (index entries, @acronym, @dots,
long lines). The documentation was largely rewritten. A NEWS entry
was added.
v1 patch 3/4: gdb, gdbserver: Allocate only a sane amount of buffer when
fetching registers
Dropped. The maximum register size is now 1024 bytes.
v1 patch 4/4: gdb: Clear tilecfg.start_row for any PC modification
Not included in this series. We can confirm the concerns raised by
Pedro when unconditionally resetting start_row in write_pc. We are
planning to submit a proper fix in a second series which will also
include fixes for:
- Write $pc, e.g., set $pc = <value>.
- Inferior calls.
- The jump command.
I appreciate your feedback.
Thanks
Stephan
Aleksandar Paunovic (1):
gdb: define additional integer built-in types
Felix Willgerodt (1):
gdb, gdbserver: Add Intel AMX registers.
Rohr, Stephan (3):
gdb: support register groups for user registers
gdb: add a "matrix" register group
gdb: add Intel AMX tile registers as user registers
gdb/NEWS | 17 ++
gdb/amd64-linux-tdep.c | 2 +
gdb/amd64-tdep.c | 150 ++++++++++-
gdb/amd64-tdep.h | 3 +
gdb/arch/amd64.c | 4 +
gdb/arch/x86-linux-tdesc-features.c | 5 +-
gdb/doc/gdb.texinfo | 68 ++++-
gdb/features/Makefile | 1 +
gdb/features/i386/64bit-amx.c | 26 ++
gdb/features/i386/64bit-amx.xml | 26 ++
gdb/gdbtypes.c | 8 +
gdb/gdbtypes.h | 4 +
gdb/i386-tdep.c | 230 ++++++++++++++++-
gdb/i386-tdep.h | 106 +++++++-
gdb/i387-tdep.c | 196 ++++++++++++++-
gdb/i387-tdep.h | 6 +
gdb/infcmd.c | 28 +++
gdb/nat/x86-xstate.c | 2 +
gdb/reggroups.c | 3 +
gdb/reggroups.h | 1 +
gdb/target-debug.h | 2 +
gdb/target-descriptions.c | 12 +
gdb/testsuite/gdb.arch/amd64-amx.c | 124 ++++++++++
gdb/testsuite/gdb.arch/amd64-amx.exp | 356 +++++++++++++++++++++++++++
gdb/testsuite/lib/amd64-amx.h | 41 +++
gdb/testsuite/lib/gdb.exp | 75 ++++++
gdb/user-regs.c | 46 +++-
gdb/user-regs.h | 17 +-
gdbserver/i387-fp.cc | 70 +++++-
gdbserver/linux-x86-low.cc | 2 +
gdbsupport/tdesc.cc | 4 +
gdbsupport/tdesc.h | 4 +
gdbsupport/x86-xstate.h | 26 +-
33 files changed, 1630 insertions(+), 35 deletions(-)
create mode 100644 gdb/features/i386/64bit-amx.c
create mode 100644 gdb/features/i386/64bit-amx.xml
create mode 100644 gdb/testsuite/gdb.arch/amd64-amx.c
create mode 100644 gdb/testsuite/gdb.arch/amd64-amx.exp
create mode 100644 gdb/testsuite/lib/amd64-amx.h
--
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.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 1/5] gdb: define additional integer built-in types
2026-10-30 11:50 [PATCH v2 0/5] Add Intel AMX support Stephan Rohr
@ 2026-10-30 11:50 ` Stephan Rohr
2026-10-30 12:45 ` Eli Zaretskii
2026-10-30 11:50 ` [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers Stephan Rohr
` (3 subsequent siblings)
4 siblings, 1 reply; 15+ messages in thread
From: Stephan Rohr @ 2026-10-30 11:50 UTC (permalink / raw)
To: gdb-patches; +Cc: pedro, eliz, jhb, luis.machado
From: Aleksandar Paunovic <aleksandar.paunovic@intel.com>
Allow using int256/int512 and uint256/uint512 as built-in types,
particularly for the target descriptions.
This is in preparation to add Intel AMX registers.
Co-Authored-By: Stephan Rohr <stephan.rohr@intel.com>
---
gdb/doc/gdb.texinfo | 4 ++++
gdb/gdbtypes.c | 8 ++++++++
gdb/gdbtypes.h | 4 ++++
gdb/target-descriptions.c | 12 ++++++++++++
gdbsupport/tdesc.cc | 4 ++++
gdbsupport/tdesc.h | 4 ++++
6 files changed, 36 insertions(+)
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 66152d2582e..53773780b56 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -49859,6 +49859,8 @@ Boolean type, occupying a single bit.
@itemx int32
@itemx int64
@itemx int128
+@itemx int256
+@itemx int512
Signed integer types holding the specified number of bits.
@item uint8
@@ -49867,6 +49869,8 @@ Signed integer types holding the specified number of bits.
@itemx uint32
@itemx uint64
@itemx uint128
+@itemx uint256
+@itemx uint512
Unsigned integer types holding the specified number of bits.
@item code_ptr
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index f86549aca88..132f30a08b7 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5727,6 +5727,14 @@ create_gdbtypes_data (struct gdbarch *gdbarch)
= init_integer_type (alloc, 128, 0, "int128_t");
builtin_type->builtin_uint128
= init_integer_type (alloc, 128, 1, "uint128_t");
+ builtin_type->builtin_int256
+ = init_integer_type (alloc, 256, 0, "int256_t");
+ builtin_type->builtin_uint256
+ = init_integer_type (alloc, 256, 1, "uint256_t");
+ builtin_type->builtin_int512
+ = init_integer_type (alloc, 512, 0, "int512_t");
+ builtin_type->builtin_uint512
+ = init_integer_type (alloc, 512, 1, "uint512_t");
builtin_type->builtin_int8->set_nottext (true);
builtin_type->builtin_uint8->set_nottext (true);
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 2c49b83246c..afb9a65ee3d 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2144,6 +2144,10 @@ struct builtin_type
struct type *builtin_uint64 = nullptr;
struct type *builtin_int128 = nullptr;
struct type *builtin_uint128 = nullptr;
+ struct type *builtin_int256 = nullptr;
+ struct type *builtin_uint256 = nullptr;
+ struct type *builtin_int512 = nullptr;
+ struct type *builtin_uint512 = nullptr;
/* Wide character types. */
struct type *builtin_char16 = nullptr;
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index e1821fe7114..f8e102872ca 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -86,6 +86,12 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
case TDESC_TYPE_INT128:
m_type = builtin_type (m_gdbarch)->builtin_int128;
return;
+ case TDESC_TYPE_INT256:
+ m_type = builtin_type (m_gdbarch)->builtin_int256;
+ return;
+ case TDESC_TYPE_INT512:
+ m_type = builtin_type (m_gdbarch)->builtin_int512;
+ return;
case TDESC_TYPE_UINT8:
m_type = builtin_type (m_gdbarch)->builtin_uint8;
return;
@@ -101,6 +107,12 @@ make_gdb_type (struct gdbarch *gdbarch, struct tdesc_type *ttype)
case TDESC_TYPE_UINT128:
m_type = builtin_type (m_gdbarch)->builtin_uint128;
return;
+ case TDESC_TYPE_UINT256:
+ m_type = builtin_type (m_gdbarch)->builtin_uint256;
+ return;
+ case TDESC_TYPE_UINT512:
+ m_type = builtin_type (m_gdbarch)->builtin_uint512;
+ return;
case TDESC_TYPE_CODE_PTR:
m_type = builtin_type (m_gdbarch)->builtin_func_ptr;
return;
diff --git a/gdbsupport/tdesc.cc b/gdbsupport/tdesc.cc
index 4b6aa815c81..19995a2d407 100644
--- a/gdbsupport/tdesc.cc
+++ b/gdbsupport/tdesc.cc
@@ -42,11 +42,15 @@ static tdesc_type_builtin tdesc_predefined_types[] =
{ "int32", TDESC_TYPE_INT32 },
{ "int64", TDESC_TYPE_INT64 },
{ "int128", TDESC_TYPE_INT128 },
+ { "int256", TDESC_TYPE_INT256 },
+ { "int512", TDESC_TYPE_INT512 },
{ "uint8", TDESC_TYPE_UINT8 },
{ "uint16", TDESC_TYPE_UINT16 },
{ "uint32", TDESC_TYPE_UINT32 },
{ "uint64", TDESC_TYPE_UINT64 },
{ "uint128", TDESC_TYPE_UINT128 },
+ { "uint256", TDESC_TYPE_UINT256 },
+ { "uint512", TDESC_TYPE_UINT512 },
{ "code_ptr", TDESC_TYPE_CODE_PTR },
{ "data_ptr", TDESC_TYPE_DATA_PTR },
{ "ieee_half", TDESC_TYPE_IEEE_HALF },
diff --git a/gdbsupport/tdesc.h b/gdbsupport/tdesc.h
index a2ef21987bf..cadaa38410c 100644
--- a/gdbsupport/tdesc.h
+++ b/gdbsupport/tdesc.h
@@ -163,11 +163,15 @@ enum tdesc_type_kind
TDESC_TYPE_INT32,
TDESC_TYPE_INT64,
TDESC_TYPE_INT128,
+ TDESC_TYPE_INT256,
+ TDESC_TYPE_INT512,
TDESC_TYPE_UINT8,
TDESC_TYPE_UINT16,
TDESC_TYPE_UINT32,
TDESC_TYPE_UINT64,
TDESC_TYPE_UINT128,
+ TDESC_TYPE_UINT256,
+ TDESC_TYPE_UINT512,
TDESC_TYPE_CODE_PTR,
TDESC_TYPE_DATA_PTR,
TDESC_TYPE_IEEE_HALF,
--
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.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers.
2026-10-30 11:50 [PATCH v2 0/5] Add Intel AMX support Stephan Rohr
2026-10-30 11:50 ` [PATCH v2 1/5] gdb: define additional integer built-in types Stephan Rohr
@ 2026-10-30 11:50 ` Stephan Rohr
2026-10-30 12:47 ` Eli Zaretskii
` (2 more replies)
2026-10-30 11:50 ` [PATCH v2 3/5] gdb: support register groups for user registers Stephan Rohr
` (2 subsequent siblings)
4 siblings, 3 replies; 15+ messages in thread
From: Stephan Rohr @ 2026-10-30 11:50 UTC (permalink / raw)
To: gdb-patches; +Cc: pedro, eliz, jhb, luis.machado
From: Felix Willgerodt <felix.willgerodt@intel.com>
Intel Advanced Matrix Extensions (AMX) adds one 64-byte TILECFG register
and eight 1024-byte tile registers TMM0, TMM1, ..., TMM7. The tile
registers each represent a matrix, whose dimensions are configured via
TILECFG. In XSAVE, all tiles are represented in the 8kB TILEDATA section.
Future platforms are free to add new palettes, which are run-time
configurable partitionings of the TILEDATA space. Currently only
palette 0 (initialized zero state) and palette 1 exist. New palettes
might change any of the following parameters, which are defined in the
palette_table (which can be accessed via CPUID):
define palette_table[id]:
uint16_t total_tile_bytes
uint16_t bytes_per_tile
uint16_t bytes_per_row
uint16_t max_names
uint16_t max_rows
More information about Intel AMX can be found in the Intel Software
Developer's Manual, September 2026.
The $tilecfg register is implemented as a pseudo register. For convenience,
reserved bytes are not shown. To also be able to show the full register,
$tilecfg_raw is implemented as a uint512 value.
The $tmm0_raw-$tmm7_raw registers hold the contents of the tiles. Each is
shown with the maximum dimensions of 16 rows of 64 bytes. Only the elements
within the dimensions configured in $tilecfg hold data.
To hide the raw registers, they are added to the "save" and "restore"
register groups only. A following patch introduces user registers and adds
the tile user registers to the "all" group such that the tile registers show
up in the "info registers all" command.
Intel AMX is supported for 64-bit only.
Co-Authored-By: Stephan Rohr <stephan.rohr@intel.com>
---
gdb/NEWS | 5 +
gdb/amd64-linux-tdep.c | 2 +
gdb/amd64-tdep.c | 67 ++++++++-
gdb/amd64-tdep.h | 3 +
gdb/arch/amd64.c | 4 +
gdb/arch/x86-linux-tdesc-features.c | 5 +-
gdb/doc/gdb.texinfo | 40 ++++++
gdb/features/Makefile | 1 +
gdb/features/i386/64bit-amx.c | 26 ++++
gdb/features/i386/64bit-amx.xml | 26 ++++
gdb/i386-tdep.c | 132 +++++++++++++++++-
gdb/i386-tdep.h | 25 +++-
gdb/i387-tdep.c | 196 +++++++++++++++++++++++++--
gdb/i387-tdep.h | 6 +
gdb/nat/x86-xstate.c | 2 +
gdb/target-debug.h | 2 +
gdb/testsuite/gdb.arch/amd64-amx.c | 115 ++++++++++++++++
gdb/testsuite/gdb.arch/amd64-amx.exp | 192 ++++++++++++++++++++++++++
gdb/testsuite/lib/amd64-amx.h | 41 ++++++
gdb/testsuite/lib/gdb.exp | 75 ++++++++++
gdbserver/i387-fp.cc | 70 +++++++++-
gdbserver/linux-x86-low.cc | 2 +
gdbsupport/x86-xstate.h | 26 +++-
23 files changed, 1042 insertions(+), 21 deletions(-)
create mode 100644 gdb/features/i386/64bit-amx.c
create mode 100644 gdb/features/i386/64bit-amx.xml
create mode 100644 gdb/testsuite/gdb.arch/amd64-amx.c
create mode 100644 gdb/testsuite/gdb.arch/amd64-amx.exp
create mode 100644 gdb/testsuite/lib/amd64-amx.h
diff --git a/gdb/NEWS b/gdb/NEWS
index 7303ec0e460..2047e7376fb 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -7,6 +7,11 @@
Support displaying and modifying Intel APX registers (Extended GPRs
$r16 - $r31) including byte, word and dword pseudo registers.
+* Support for Intel AMX registers on GNU/Linux.
+ 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.
+
* GDB now distinguishes between the GNU (MinGW) and MSVC Windows ABIs.
The "set osabi" command accepts two new values, "Windows-GNU" and
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index 81e66be75c1..28e18ed47d2 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -115,6 +115,8 @@ int amd64_linux_gregset_reg_offset[] =
-1, /* CET user mode register PL3_SSP. */
-1, -1, -1, -1, -1, -1, -1, -1, /* r16 ... r31. */
-1, -1, -1, -1, -1, -1, -1, -1,
+ -1, /* TILECFG register (AMX). */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* tmm0_raw ... tmm7_raw (AMX). */
/* End of hardware registers */
21 * 8, 22 * 8, /* fs_base and gs_base. */
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 18b8f2a4c0b..13242e293b5 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -188,6 +188,17 @@ static const char * const amd64_pkeys_names[] = {
"pkru"
};
+static const char *amd64_tilecfg_raw_names[] = {
+ "tilecfg_raw"
+};
+
+/* Register names for the raw AMX tile registers. */
+
+static const char *amd64_tmm_raw_names[] = {
+ "tmm0_raw", "tmm1_raw", "tmm2_raw", "tmm3_raw",
+ "tmm4_raw", "tmm5_raw", "tmm6_raw", "tmm7_raw"
+};
+
/* DWARF Register Number Mapping as defined in the System V psABI,
section 3.6. */
@@ -429,6 +440,12 @@ static const char * const amd64_apx_dword_names[] =
static_assert (ARRAY_SIZE (amd64_apx_dword_names)
== AMD64_APX_NUM_DWORD_REGS + 1);
+/* Register name for tilecfg pseudo-register. */
+
+static const char *amd64_tilecfg_names[] = {
+ "tilecfg"
+};
+
/* Return the name of register REGNUM. */
static const char *
@@ -441,6 +458,8 @@ amd64_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
return amd64_ymm_names[regnum - tdep->ymm0_regnum];
else if (i386_ymm_avx512_regnum_p (gdbarch, regnum))
return amd64_ymm_avx512_names[regnum - tdep->ymm16_regnum];
+ else if (i386_tilecfg_regnum_p (gdbarch, regnum))
+ return amd64_tilecfg_names[regnum - tdep->tilecfg_regnum];
else if (i386_dword_regnum_p (gdbarch, regnum))
return tdep->dword_names[regnum - tdep->eax_regnum];
else
@@ -521,6 +540,22 @@ amd64_pseudo_register_read_value (gdbarch *gdbarch, const frame_info_ptr &next_f
const int gpnum = amd64_raw_dword_register (tdep, regnum);
return pseudo_from_raw_part (next_frame, regnum, gpnum, 0);
}
+ else if (i386_tilecfg_regnum_p (gdbarch, regnum))
+ {
+ /* Read tilecfg. */
+ value *pseudo_reg_val
+ = value::allocate_register (next_frame, regnum);
+ value *raw_reg_val = value_of_register (tdep->tilecfg_raw_regnum,
+ next_frame);
+ /* Copy palette and start_row. See tilecfg_type (). */
+ raw_reg_val->contents_copy (pseudo_reg_val, 0, 0, 2 * 1);
+ /* Copy all colsb. */
+ raw_reg_val->contents_copy (pseudo_reg_val, 2, 16, 2 * 8);
+ /* Copy all rows. */
+ raw_reg_val->contents_copy (pseudo_reg_val, 18, 48, 1 * 8);
+
+ return pseudo_reg_val;
+ }
else
return i386_pseudo_register_read_value (gdbarch, next_frame, regnum);
}
@@ -547,6 +582,22 @@ amd64_pseudo_register_write (gdbarch *gdbarch, const frame_info_ptr &next_frame,
const int gpnum = amd64_raw_dword_register (tdep, regnum);
pseudo_to_raw_part (next_frame, buf, gpnum, 0);
}
+ else if (i386_tilecfg_regnum_p (gdbarch, regnum))
+ {
+ const int raw_reg_num = tdep->tilecfg_raw_regnum;
+ const int raw_size = register_size (gdbarch, raw_reg_num);
+ gdb::byte_vector raw_buf (raw_size, 0);
+ /* Copy palette and start_row. See tilecfg_type (). */
+ memcpy (raw_buf.data (), buf.data (), 2 * 1);
+ /* Copy all colsb. */
+ memcpy (raw_buf.data () + 16, buf.data () + 2, 2 * 8);
+ /* Copy all rows. */
+ memcpy (raw_buf.data () + 48, buf.data () + 18, 1 * 8);
+
+ put_frame_register_bytes
+ (next_frame, raw_reg_num, 0,
+ gdb::make_array_view (raw_buf.data (), raw_size));
+ }
else
i386_pseudo_register_write (gdbarch, next_frame, regnum, buf);
}
@@ -3706,6 +3757,19 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch,
tdep->num_dword_regs = AMD64_NUM_DWORD_REGS;
}
+ if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.amx") != nullptr)
+ {
+ tdep->tilecfg_raw_register_names = amd64_tilecfg_raw_names;
+ tdep->tilecfg_raw_regnum = AMD64_AMX_TILECFG_RAW_REGNUM;
+
+ tdep->tilecfg_register_names = amd64_tilecfg_names;
+ tdep->num_tilecfg_regs = 1;
+
+ tdep->tmm_raw_register_names = amd64_tmm_raw_names;
+ tdep->tmm_raw_regnum = AMD64_AMX_TMM0_RAW_REGNUM;
+ tdep->num_tmm_raw_regs = 8;
+ }
+
/* Avoid wiring in the MMX registers for now. */
tdep->num_mmx_regs = 0;
@@ -3858,7 +3922,7 @@ const struct target_desc *
amd64_target_description (uint64_t xstate_bv, bool segments)
{
static const_target_desc_up amd64_tdescs \
- [2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*CET_U*/][2/*APX*/] \
+ [2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*CET_U*/][2/*APX*/][2/*AMX*/] \
[2/*segments*/] = {};
const_target_desc_up &tdesc
= amd64_tdescs[(xstate_bv & X86_XSTATE_AVX) ? 1 : 0]
@@ -3866,6 +3930,7 @@ amd64_target_description (uint64_t xstate_bv, bool segments)
[(xstate_bv & X86_XSTATE_PKRU) ? 1 : 0]
[(xstate_bv & X86_XSTATE_CET_U) ? 1 : 0]
[(xstate_bv & X86_XSTATE_APX_F) ? 1 : 0]
+ [(xstate_bv & X86_XSTATE_AMX) ? 1 : 0]
[segments ? 1 : 0];
if (tdesc == nullptr)
diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
index 93b3cb61b17..02172ccfa14 100644
--- a/gdb/amd64-tdep.h
+++ b/gdb/amd64-tdep.h
@@ -84,6 +84,9 @@ enum amd64_regnum
AMD64_PL3_SSP_REGNUM,
AMD64_R16_REGNUM,
AMD64_R31_REGNUM = AMD64_R16_REGNUM + 15,
+ AMD64_AMX_TILECFG_RAW_REGNUM,
+ AMD64_AMX_TMM0_RAW_REGNUM,
+ AMD64_AMX_TMM7_RAW_REGNUM = AMD64_AMX_TMM0_RAW_REGNUM + 7,
AMD64_FSBASE_REGNUM,
AMD64_GSBASE_REGNUM
};
diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
index 3992bbf512e..60932f420b3 100644
--- a/gdb/arch/amd64.c
+++ b/gdb/arch/amd64.c
@@ -22,6 +22,7 @@
#include "../features/i386/64bit-avx.c"
#include "../features/i386/64bit-avx512.c"
+#include "../features/i386/64bit-amx.c"
#include "../features/i386/64bit-core.c"
#include "../features/i386/64bit-apx.c"
#include "../features/i386/64bit-linux.c"
@@ -82,5 +83,8 @@ amd64_create_target_description (uint64_t xstate_bv, bool is_x32,
if (xstate_bv & X86_XSTATE_APX_F)
regnum = create_feature_i386_64bit_apx (tdesc.get (), regnum);
+ if (xstate_bv & X86_XSTATE_AMX)
+ regnum = create_feature_i386_64bit_amx (tdesc.get (), regnum);
+
return tdesc;
}
diff --git a/gdb/arch/x86-linux-tdesc-features.c b/gdb/arch/x86-linux-tdesc-features.c
index 0191f326834..90722d4dd58 100644
--- a/gdb/arch/x86-linux-tdesc-features.c
+++ b/gdb/arch/x86-linux-tdesc-features.c
@@ -66,6 +66,7 @@ struct x86_xstate_feature {
static constexpr x86_xstate_feature x86_linux_all_xstate_features[] = {
/* Feature, i386, amd64, x32. */
{ X86_XSTATE_APX_F, false, true, true },
+ { X86_XSTATE_AMX, false, true, true },
{ X86_XSTATE_CET_U, false, true, true },
{ X86_XSTATE_PKRU, true, true, true },
{ X86_XSTATE_AVX512, true, true, true },
@@ -155,8 +156,8 @@ x86_linux_xstate_bv_to_tdesc_idx (uint64_t xstate_bv)
represents the bit order within the generated index number.
i386 | x87 sse avx avx512 pkru
- amd64 | avx avx512 pkru
- i32 | avx avx512 pkru
+ amd64 | avx avx512 pkru amx
+ i32 | avx avx512 pkru amx
The features are ordered so that for each mode (i386, amd64, i32) the
generated index will form a continuous range. */
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 53773780b56..9e3b6fca669 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27448,6 +27448,41 @@ stack. @value{GDBN} corrects this value to avoid a control protection
exception. For more details on displaced stepping, see @ref{displaced-stepping}.
@end itemize
+@subsubsection Intel Advanced Matrix Extensions
+@cindex Intel Advanced Matrix Extensions
+@cindex AMX, Intel
+
+Intel @dfn{Advanced Matrix Extensions} (@acronym{AMX}) add one 64-byte
+@samp{tilecfg} register and eight 1024-byte tile registers @samp{tmm0},
+@samp{tmm1}, @dots{}, @samp{tmm7} for amd64. The tile registers each
+represent a matrix, whose dimensions are configured via @samp{tilecfg}.
+Future platforms might also partition the register area of 8192 bytes
+between a different number of tiles.
+
+@value{GDBN} provides a user-friendly view of the @samp{tilecfg} register,
+omitting reserved bits. The tile registers are supplied as the raw registers
+@samp{tmm0_raw}, @samp{tmm1_raw}, @dots{}, @samp{tmm7_raw}, which show the
+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:
+
+@smallexample
+(gdb) print/x $tilecfg_raw
+$1 = 0x102010000000000000000000000000000000000000000000000000000000c0
+ 00c000800000000000000000000000000000001
+(gdb) print $tilecfg
+$2 = @{palette = 1, start_row = 0, colsb = @{8, 12, 12, 0, 0, 0, 0, 0@},
+ rows = @{1, 2, 1, 0, 0, 0, 0, 0@}@}
+(gdb) print $tmm1_raw
+$3 = @{621397352980713455329738752, 932096029507240269422067969,
+ 0 <repeats 14 times>@}
+(gdb) print/d (uint8_t[16][64]) $tmm1_raw
+$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>@}
+@end smallexample
+
@node Alpha
@subsection Alpha
@@ -50888,6 +50923,11 @@ The @samp{org.gnu.gdb.i386.apx} feature is optional. It should describe
@samp{r16} - @samp{r31} with 64 bits each. All Intel @acronym{APX}
registers are valid only on amd64.
+The @samp{org.gnu.gdb.i386.amx} feature is optional. It should describe
+one configuration register @samp{tilecfg_raw} that has 64 bytes, and the
+eight tile registers @samp{tmm0_raw} @dots{} @samp{tmm7_raw}, each of which
+has 1024 bytes. All Intel @acronym{AMX} registers are valid only for amd64.
+
@node LoongArch Features
@subsection LoongArch Features
@cindex target descriptions, LoongArch Features
diff --git a/gdb/features/Makefile b/gdb/features/Makefile
index 0ab24bca000..15e715aab70 100644
--- a/gdb/features/Makefile
+++ b/gdb/features/Makefile
@@ -241,6 +241,7 @@ FEATURE_XMLFILES = aarch64-core.xml \
i386/64bit-core.xml \
i386/64bit-segments.xml \
i386/64bit-avx.xml \
+ i386/64bit-amx.xml \
i386/64bit-linux.xml \
i386/64bit-sse.xml \
i386/pkeys.xml \
diff --git a/gdb/features/i386/64bit-amx.c b/gdb/features/i386/64bit-amx.c
new file mode 100644
index 00000000000..14779ec1fb7
--- /dev/null
+++ b/gdb/features/i386/64bit-amx.c
@@ -0,0 +1,26 @@
+/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
+ Original: 64bit-amx.xml */
+
+#include "gdbsupport/tdesc.h"
+
+static int
+create_feature_i386_64bit_amx (struct target_desc *result, long regnum)
+{
+ struct tdesc_feature *feature;
+
+ feature = tdesc_create_feature (result, "org.gnu.gdb.i386.amx");
+ tdesc_type *element_type;
+ element_type = tdesc_named_type (feature, "uint512");
+ tdesc_create_vector (feature, "v_ui512", element_type, 16);
+
+ tdesc_create_reg (feature, "tilecfg_raw", regnum++, 1, NULL, 512, "uint512");
+ tdesc_create_reg (feature, "tmm0_raw", regnum++, 1, NULL, 8192, "v_ui512");
+ tdesc_create_reg (feature, "tmm1_raw", regnum++, 1, NULL, 8192, "v_ui512");
+ tdesc_create_reg (feature, "tmm2_raw", regnum++, 1, NULL, 8192, "v_ui512");
+ tdesc_create_reg (feature, "tmm3_raw", regnum++, 1, NULL, 8192, "v_ui512");
+ tdesc_create_reg (feature, "tmm4_raw", regnum++, 1, NULL, 8192, "v_ui512");
+ tdesc_create_reg (feature, "tmm5_raw", regnum++, 1, NULL, 8192, "v_ui512");
+ tdesc_create_reg (feature, "tmm6_raw", regnum++, 1, NULL, 8192, "v_ui512");
+ tdesc_create_reg (feature, "tmm7_raw", regnum++, 1, NULL, 8192, "v_ui512");
+ return regnum;
+}
diff --git a/gdb/features/i386/64bit-amx.xml b/gdb/features/i386/64bit-amx.xml
new file mode 100644
index 00000000000..a40c6c65f6d
--- /dev/null
+++ b/gdb/features/i386/64bit-amx.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!-- Copyright (C) 2020-2026 Free Software Foundation, Inc.
+
+ Copying and distribution of this file, with or without modification,
+ are permitted in any medium without royalty provided the copyright
+ notice and this notice are preserved. -->
+
+<!DOCTYPE feature SYSTEM "gdb-target.dtd">
+<feature name="org.gnu.gdb.i386.amx">
+ <!-- One uint512 value per row of a tile. -->
+ <vector id="v_ui512" type="uint512" count="16"/>
+
+ <!-- The raw contents of the tile configuration register. -->
+ <reg name="tilecfg_raw" bitsize="512" type="uint512"/>
+
+ <!-- The raw contents of the eight tiles, each of which is 16 rows of
+ 64 bytes. -->
+ <reg name="tmm0_raw" bitsize="8192" type="v_ui512"/>
+ <reg name="tmm1_raw" bitsize="8192" type="v_ui512"/>
+ <reg name="tmm2_raw" bitsize="8192" type="v_ui512"/>
+ <reg name="tmm3_raw" bitsize="8192" type="v_ui512"/>
+ <reg name="tmm4_raw" bitsize="8192" type="v_ui512"/>
+ <reg name="tmm5_raw" bitsize="8192" type="v_ui512"/>
+ <reg name="tmm6_raw" bitsize="8192" type="v_ui512"/>
+ <reg name="tmm7_raw" bitsize="8192" type="v_ui512"/>
+</feature>
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 071d8e004ae..a25abfbd1bc 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -378,6 +378,34 @@ i386_pkru_regnum_p (struct gdbarch *gdbarch, int regnum)
return regnum >= 0 && regnum < I387_NUM_PKEYS_REGS;
}
+/* AMX tilecfg register? */
+
+bool
+i386_tilecfg_regnum_p (gdbarch *gdbarch, int regnum)
+{
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+ return regnum >= 0 && regnum == tdep->tilecfg_regnum;
+}
+
+/* Raw AMX tile register? */
+
+bool
+i386_tmm_raw_regnum_p (gdbarch *gdbarch, int regnum)
+{
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+ return (tdep->tmm_raw_regnum <= regnum
+ && regnum < tdep->tmm_raw_regnum + tdep->num_tmm_raw_regs);
+}
+
+/* AMX tilecfg_raw register? */
+
+static bool
+i386_tilecfg_raw_regnum_p (gdbarch *gdbarch, int regnum)
+{
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+ return regnum >= 0 && regnum == tdep->tilecfg_raw_regnum;
+}
+
/* Return the name of register REGNUM, or the empty string if it is
an anonymous register. */
@@ -3222,6 +3250,47 @@ i386_mmx_type (struct gdbarch *gdbarch)
return tdep->i386_mmx_type;
}
+/* The type of the TILECFG registers. */
+
+static type *
+i386_tilecfg_type (gdbarch *gdbarch)
+{
+ i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
+
+ if (!tdep->i386_tilecfg_type)
+ {
+ const struct builtin_type *bt = builtin_type (gdbarch);
+
+ /* The type we're building is this:
+
+ struct __gdb_builtin_type_tilecfg
+ {
+ uint8_t palette;
+ uint8_t start_row;
+ uint16_t colsb[8];
+ uint8_t rows[8];
+ };
+
+ Bytes 2-15, 32-47 and 56-63 of the register are reserved, so the
+ colsb and rows arrays are packed together here. */
+
+ type *t = arch_composite_type (gdbarch, "builtin_type_tilecfg",
+ TYPE_CODE_STRUCT);
+
+ append_composite_type_field (t, "palette", bt->builtin_uint8);
+ append_composite_type_field (t, "start_row", bt->builtin_uint8);
+ append_composite_type_field
+ (t, "colsb", lookup_array_range_type (bt->builtin_uint16, 0, 7));
+ append_composite_type_field
+ (t, "rows", lookup_array_range_type (bt->builtin_uint8, 0, 7));
+
+ t->set_name ("builtin_type_tilecfg");
+ tdep->i386_tilecfg_type = t;
+ }
+
+ return tdep->i386_tilecfg_type;
+}
+
/* Return the GDB type object for the "standard" data type of data in
register REGNUM. */
@@ -3236,6 +3305,8 @@ i386_pseudo_register_type (struct gdbarch *gdbarch, int regnum)
return i386_ymm_type (gdbarch);
else if (i386_zmm_regnum_p (gdbarch, regnum))
return i386_zmm_type (gdbarch);
+ else if (i386_tilecfg_regnum_p (gdbarch, regnum))
+ return i386_tilecfg_type (gdbarch);
else
{
const struct builtin_type *bt = builtin_type (gdbarch);
@@ -4269,7 +4340,8 @@ i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
int fp_regnum_p, mmx_regnum_p, xmm_regnum_p, mxcsr_regnum_p,
ymm_regnum_p, ymmh_regnum_p, ymm_avx512_regnum_p, ymmh_avx512_regnum_p,
zmm_regnum_p, zmmh_regnum_p, xmm_avx512_regnum_p, avx512_p, avx_p,
- sse_p, pkru_regnum_p;
+ sse_p, pkru_regnum_p, tilecfg_regnum_p, tmm_raw_regnum_p,
+ tilecfg_raw_regnum_p;
/* Don't include pseudo registers, except for MMX, in any register
groups. */
@@ -4296,6 +4368,9 @@ i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
ymm_regnum_p = i386_ymm_regnum_p (gdbarch, regnum);
ymm_avx512_regnum_p = i386_ymm_avx512_regnum_p (gdbarch, regnum);
zmm_regnum_p = i386_zmm_regnum_p (gdbarch, regnum);
+ tmm_raw_regnum_p = i386_tmm_raw_regnum_p (gdbarch, regnum);
+ tilecfg_regnum_p = i386_tilecfg_regnum_p (gdbarch, regnum);
+ tilecfg_raw_regnum_p = i386_tilecfg_raw_regnum_p (gdbarch, regnum);
avx512_p = ((tdep->xcr0 & X86_XSTATE_AVX_AVX512_MASK)
== X86_XSTATE_AVX_AVX512_MASK);
@@ -4329,6 +4404,11 @@ i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
|| zmmh_regnum_p))
return false;
+ /* For "info reg all", don't include the raw Intel AMX registers. */
+ if (group == all_reggroup
+ && (tmm_raw_regnum_p || tilecfg_raw_regnum_p))
+ return false;
+
if (group == general_reggroup)
return (!fp_regnum_p
&& !mmx_regnum_p
@@ -4341,7 +4421,10 @@ i386_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
&& !ymmh_avx512_regnum_p
&& !zmm_regnum_p
&& !zmmh_regnum_p
- && !pkru_regnum_p);
+ && !pkru_regnum_p
+ && !tmm_raw_regnum_p
+ && !tilecfg_regnum_p
+ && !tilecfg_raw_regnum_p);
return default_register_reggroup_p (gdbarch, regnum, group);
}
@@ -8520,7 +8603,7 @@ i386_xcr0_from_tdesc (const struct target_desc *tdesc)
const struct tdesc_feature *feature_sse, *feature_avx,
*feature_avx512, *feature_pkeys,
- *feature_apx;
+ *feature_apx, *feature_amx;
/* Get core registers. */
feature_core = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.core");
@@ -8542,6 +8625,9 @@ i386_xcr0_from_tdesc (const struct target_desc *tdesc)
/* Try PKEYS */
feature_pkeys = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pkeys");
+ /* Try Intel AMX. */
+ feature_amx = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.amx");
+
/* The XCR0 bits. */
uint64_t xcr0 = X86_XSTATE_X87;
@@ -8572,6 +8658,9 @@ i386_xcr0_from_tdesc (const struct target_desc *tdesc)
if (feature_pkeys)
xcr0 |= X86_XSTATE_PKRU;
+ if (feature_amx)
+ xcr0 |= X86_XSTATE_AMX;
+
return xcr0;
}
@@ -8584,7 +8673,7 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
const struct tdesc_feature *feature_sse, *feature_avx, *feature_avx512,
*feature_pkeys, *feature_segments,
- *feature_pl3_ssp, *feature_apx;
+ *feature_pl3_ssp, *feature_apx, *feature_amx;
int i, num_regs, valid_p;
if (! tdesc_has_registers (tdesc))
@@ -8616,6 +8705,9 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
/* Try Shadow Stack. */
feature_pl3_ssp = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pl3_ssp");
+ /* Try Intel AMX. */
+ feature_amx = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.amx");
+
valid_p = 1;
/* The XCR0 bits. */
@@ -8752,6 +8844,26 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
tdep->ssp_regnum, "pl3_ssp");
}
+ if (feature_amx != nullptr
+ && tdep->tilecfg_raw_regnum != -1
+ && tdep->tilecfg_raw_register_names != nullptr
+ && tdep->tmm_raw_regnum != -1
+ && tdep->tmm_raw_register_names != nullptr)
+ {
+ tdep->xcr0 |= X86_XSTATE_TILECFG;
+
+ valid_p &= tdesc_numbered_register (feature_amx, tdesc_data,
+ tdep->tilecfg_raw_regnum,
+ tdep->tilecfg_raw_register_names[0]);
+
+ tdep->xcr0 |= X86_XSTATE_TILEDATA;
+
+ for (i = 0; i < tdep->num_tmm_raw_regs; i++)
+ valid_p &= tdesc_numbered_register (feature_amx, tdesc_data,
+ tdep->tmm_raw_regnum + i,
+ tdep->tmm_raw_register_names[i]);
+ }
+
return valid_p;
}
@@ -9010,7 +9122,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
+ tdep->num_mmx_regs
+ tdep->num_ymm_regs
+ tdep->num_ymm_avx512_regs
- + tdep->num_zmm_regs));
+ + tdep->num_zmm_regs
+ + tdep->num_tilecfg_regs));
/* Target description may be changed. */
tdesc = tdep->tdesc;
@@ -9062,6 +9175,15 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
else
tdep->zmm0_regnum = -1;
+ if (tdep->num_tilecfg_regs != 0)
+ {
+ /* Support TILECFG pseudo-register if it is available. */
+ tdep->tilecfg_regnum = mm0_regnum;
+ mm0_regnum += tdep->num_tilecfg_regs;
+ }
+ else
+ tdep->tilecfg_regnum = -1;
+
if (tdep->num_mmx_regs != 0)
{
/* Support MMX pseudo-register if MMX hasn't been disabled. */
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index bdafd523834..898a76dfb50 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -225,6 +225,26 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
set this to a value >= 0. */
int ssp_regnum = -1;
+ /* Register number for the raw tilecfg register and the tilecfg pseudo
+ register. If supported, set them to a value >= 0. */
+ int tilecfg_regnum = -1;
+ int tilecfg_raw_regnum = -1;
+
+ /* Number of tilecfg registers, including pseudo register. */
+ int num_tilecfg_regs = 0;
+
+ /* Register number for the first raw tile register, tmm0_raw. If supported,
+ set this to a value >= 0. */
+ int tmm_raw_regnum = -1;
+
+ /* Number of raw tile registers. */
+ int num_tmm_raw_regs = 0;
+
+ /* Intel AMX register names. */
+ const char * const *tilecfg_raw_register_names = nullptr;
+ const char * const *tilecfg_register_names = nullptr;
+ const char * const *tmm_raw_register_names = nullptr;
+
/* Register number for %fsbase. If supported, set this to a value
>= 0. */
int fsbase_regnum = -1;
@@ -265,6 +285,7 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
struct type *i386_ymm_type = nullptr;
struct type *i386_zmm_type = nullptr;
struct type *i387_ext_type = nullptr;
+ type *i386_tilecfg_type = nullptr;
/* If the registers containing the i386 Linux TLS related global
descriptor table information are available. This is used to decide
@@ -379,7 +400,7 @@ enum record_i386_regnum
#define I386_NUM_XREGS 9
/* Size of the largest register. */
-#define I386_MAX_REGISTER_SIZE 64
+#define I386_MAX_REGISTER_SIZE 1024
/* Types for i386-specific registers. */
extern struct type *i387_ext_type (struct gdbarch *gdbarch);
@@ -396,6 +417,8 @@ extern int i386_k_regnum_p (struct gdbarch *gdbarch, int regnum);
extern int i386_zmm_regnum_p (struct gdbarch *gdbarch, int regnum);
extern int i386_zmmh_regnum_p (struct gdbarch *gdbarch, int regnum);
extern bool i386_pkru_regnum_p (struct gdbarch *gdbarch, int regnum);
+extern bool i386_tilecfg_regnum_p (gdbarch *gdbarch, int regnum);
+extern bool i386_tmm_raw_regnum_p (gdbarch *gdbarch, int regnum);
extern const char *i386_pseudo_register_name (struct gdbarch *gdbarch,
int regnum);
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 8f972338b3d..e7b4b53462f 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -939,6 +939,30 @@ static int xsave_pkeys_offset[] =
(xsave + (tdep)->xsave_layout.pkru_offset \
+ xsave_pkeys_offset[regnum - I387_PKRU_REGNUM (tdep)])
+static int xsave_tilecfg_raw_offset[] =
+{
+ 0 * 64 /* tilecfg. */
+};
+
+#define XSAVE_TILECFG_RAW_ADDR(tdep, xsave, regnum) \
+ (xsave + (tdep)->xsave_layout.tilecfg_offset \
+ + xsave_tilecfg_raw_offset[regnum - I387_TILECFG_RAW_REGNUM (tdep)])
+
+static int xsave_tmm_raw_offset[] =
+{
+ 0 * X86_AMX_TMM_SIZE, /* tmm0_raw. */
+ 1 * X86_AMX_TMM_SIZE, /* tmm1_raw. */
+ 2 * X86_AMX_TMM_SIZE, /* tmm2_raw. */
+ 3 * X86_AMX_TMM_SIZE, /* tmm3_raw. */
+ 4 * X86_AMX_TMM_SIZE, /* tmm4_raw. */
+ 5 * X86_AMX_TMM_SIZE, /* tmm5_raw. */
+ 6 * X86_AMX_TMM_SIZE, /* tmm6_raw. */
+ 7 * X86_AMX_TMM_SIZE, /* tmm7_raw. */
+};
+
+#define XSAVE_TMM_RAW_ADDR(tdep, xsave, regnum) \
+ (xsave + (tdep)->xsave_layout.tiledata_offset \
+ + xsave_tmm_raw_offset[regnum - I387_TMM0_RAW_REGNUM (tdep)])
/* See i387-tdep.h. */
@@ -946,14 +970,40 @@ bool
i387_guess_xsave_layout (uint64_t xcr0, size_t xsave_size,
x86_xsave_layout &layout)
{
- if (HAS_PKRU (xcr0) && (xsave_size == 2696 || xsave_size == 11008))
+ if (HAS_AMX (xcr0) && xsave_size == 11008)
+ {
+ /* Intel CPUs supporting AMX. */
+ layout.avx_offset = 576;
+ layout.apx_offset = 960;
+ layout.k_offset = 1088;
+ layout.zmm_h_offset = 1152;
+ layout.zmm_offset = 1664;
+ layout.pkru_offset = 2688;
+ layout.tilecfg_offset = 2752;
+ layout.tiledata_offset = 2816;
+ }
+ else if (HAS_PKRU (xcr0) && (xsave_size == 2696 || xsave_size == 11008))
{
/* Intel CPUs supporting PKRU.
- GDB does not yet support Intel AMX, but CPUs with AMX have
- a larger XSAVE_SIZE (11008). We must handle this size here,
- otherwise we cannot read any xsave registers from OS generated
- core files on AMX systems. The AMX registers themselves will
- still not be readable though. */
+
+ XCR0 in core files generated by the gcore command in GDB is based on
+ tdep->xcr0, which i387_collect_xsave writes. tdep->xcr0 is derived
+ from the target description, which does not contain Intel AMX for a
+ 32-bit debuggee.
+
+ For remote targets, core files generated by the gcore command have an
+ XSAVE size based on i387_fallback_xsave_layout, which is therefore
+ only 2696 bytes for a 32-bit debuggee.
+
+ Native targets derive the XSAVE layout from the XCR0 as reported by
+ the kernel, see x86_linux_tdesc_for_tid. It has the full XSAVE size
+ of 11008 bytes on systems with Intel AMX. For a 32-bit debuggee,
+ tdep->xcr0 does not include Intel AMX, see i386_validate_tdesc_p,
+ while i386_gdbarch_init still stores the native layout in
+ tdep->xsave_layout. The gcore command writes the XSAVE note with that
+ size and with tdep->xcr0, e.g. with XCR0 0x2e7 and 11008 bytes.
+ Thus, we must also accept an XSAVE size of 11008 bytes here, to avoid
+ a warning about an unexpected XSAVE size. */
layout.avx_offset = 576;
/* Intel APX can be available on CPUs supporting Intel PKRU with or
without Intel AMX support. */
@@ -1004,7 +1054,20 @@ i387_fallback_xsave_layout (uint64_t xcr0)
{
x86_xsave_layout layout;
- if (HAS_PKRU (xcr0))
+ if (HAS_AMX (xcr0))
+ {
+ /* Intel CPUs supporting AMX. */
+ layout.avx_offset = 576;
+ layout.apx_offset = 960;
+ layout.k_offset = 1088;
+ layout.zmm_h_offset = 1152;
+ layout.zmm_offset = 1664;
+ layout.pkru_offset = 2688;
+ layout.tilecfg_offset = 2752;
+ layout.tiledata_offset = 2816;
+ layout.sizeof_xsave = 11008;
+ }
+ else if (HAS_PKRU (xcr0))
{
/* Intel CPUs supporting PKRU. */
layout.avx_offset = 576;
@@ -1086,8 +1149,11 @@ i387_supply_xsave (struct regcache *regcache, int regnum,
avx512_xmm_avx512 = 0x80,
pkeys = 0x100,
apx = 0x200,
+ tilecfg_raw = 0x400,
+ tmm_raw = 0x800,
all = x87 | sse | avxh | avx512_k | avx512_zmm0_h | avx512_zmm16_h
| avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys | apx
+ | tilecfg_raw | tmm_raw
} regclass;
gdb_assert (regs != NULL);
@@ -1099,6 +1165,11 @@ i387_supply_xsave (struct regcache *regcache, int regnum,
else if (regnum >= I387_R16_REGNUM (tdep)
&& regnum < I387_APX_END_REGNUM (tdep))
regclass = apx;
+ else if (regnum == I387_TILECFG_RAW_REGNUM (tdep))
+ regclass = tilecfg_raw;
+ else if (regnum >= I387_TMM0_RAW_REGNUM (tdep)
+ && regnum < I387_TMMEND_RAW_REGNUM (tdep))
+ regclass = tmm_raw;
else if (regnum >= I387_PKRU_REGNUM (tdep)
&& regnum < I387_PKEYSEND_REGNUM (tdep))
regclass = pkeys;
@@ -1152,6 +1223,21 @@ i387_supply_xsave (struct regcache *regcache, int regnum,
regcache->raw_supply (regnum, XSAVE_APX_EGPR_ADDR (tdep, regs, regnum));
return;
+ case tilecfg_raw:
+ if ((clear_bv & X86_XSTATE_TILECFG))
+ regcache->raw_supply_zeroed (regnum);
+ else
+ regcache->raw_supply (regnum,
+ XSAVE_TILECFG_RAW_ADDR (tdep, regs, regnum));
+ return;
+
+ case tmm_raw:
+ if ((clear_bv & X86_XSTATE_TILEDATA))
+ regcache->raw_supply_zeroed (regnum);
+ else
+ regcache->raw_supply (regnum, XSAVE_TMM_RAW_ADDR (tdep, regs, regnum));
+ return;
+
case pkeys:
if ((clear_bv & X86_XSTATE_PKRU))
regcache->raw_supply_zeroed (regnum);
@@ -1346,6 +1432,32 @@ i387_supply_xsave (struct regcache *regcache, int regnum,
}
}
+ /* Handle the tilecfg register. */
+ if ((tdep->xcr0 & X86_XSTATE_TILECFG) != 0)
+ {
+ if ((clear_bv & X86_XSTATE_TILECFG) != 0)
+ regcache->raw_supply_zeroed (I387_TILECFG_RAW_REGNUM (tdep));
+ else
+ {
+ i = I387_TILECFG_RAW_REGNUM (tdep);
+ regcache->raw_supply (i,
+ XSAVE_TILECFG_RAW_ADDR (tdep, regs, i));
+ }
+ }
+
+ /* Handle the raw tile registers. */
+ if ((tdep->xcr0 & X86_XSTATE_TILEDATA) != 0)
+ {
+ for (i = I387_TMM0_RAW_REGNUM (tdep);
+ i < I387_TMMEND_RAW_REGNUM (tdep); i++)
+ {
+ if ((clear_bv & X86_XSTATE_TILEDATA) != 0)
+ regcache->raw_supply_zeroed (i);
+ else
+ regcache->raw_supply (i, XSAVE_TMM_RAW_ADDR (tdep, regs, i));
+ }
+ }
+
/* Handle the XMM registers. */
if ((tdep->xcr0 & X86_XSTATE_SSE))
{
@@ -1505,8 +1617,11 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
avx512_xmm_avx512 = 0x100,
pkeys = 0x200,
apx = 0x400,
+ tilecfg = 0x800,
+ tmm_raw = 0x1000,
all = x87 | sse | avxh | avx512_k | avx512_zmm0_h | avx512_zmm16_h
- | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys | apx
+ | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys | apx | tilecfg
+ | tmm_raw
} regclass;
gdb_assert (tdep->st0_regnum >= I386_ST0_REGNUM);
@@ -1517,6 +1632,11 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
else if (regnum >= I387_R16_REGNUM (tdep)
&& regnum < I387_APX_END_REGNUM (tdep))
regclass = apx;
+ else if (regnum == I387_TILECFG_RAW_REGNUM (tdep))
+ regclass = tilecfg;
+ else if (regnum >= I387_TMM0_RAW_REGNUM (tdep)
+ && regnum < I387_TMMEND_RAW_REGNUM (tdep))
+ regclass = tmm_raw;
else if (regnum >= I387_PKRU_REGNUM (tdep)
&& regnum < I387_PKEYSEND_REGNUM (tdep))
regclass = pkeys;
@@ -1589,6 +1709,19 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
memset (XSAVE_APX_EGPR_ADDR (tdep, regs, i), 0, 8);
}
+ if ((clear_bv & X86_XSTATE_TILECFG))
+ {
+ i = I387_TILECFG_RAW_REGNUM (tdep);
+ memset (XSAVE_TILECFG_RAW_ADDR (tdep, regs, i), 0, 64);
+ }
+
+ if ((clear_bv & X86_XSTATE_TILEDATA))
+ {
+ i = I387_TMM0_RAW_REGNUM (tdep);
+ memset (XSAVE_TMM_RAW_ADDR (tdep, regs, i), 0,
+ X86_AMX_TILEDATA_SIZE);
+ }
+
if ((clear_bv & X86_XSTATE_PKRU))
for (i = I387_PKRU_REGNUM (tdep);
i < I387_PKEYSEND_REGNUM (tdep); i++)
@@ -1672,6 +1805,33 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
}
}
+ /* Check if the tilecfg register is changed. */
+ if ((tdep->xcr0 & X86_XSTATE_TILECFG))
+ {
+ i = I387_TILECFG_RAW_REGNUM (tdep);
+ regcache->raw_collect (i, raw);
+ p = XSAVE_TILECFG_RAW_ADDR (tdep, regs, i);
+ if (memcmp (raw, p, 64) != 0)
+ {
+ xstate_bv |= X86_XSTATE_TILECFG;
+ memcpy (p, raw, 64);
+ }
+ }
+
+ /* Check if any raw tile register is changed. */
+ if ((tdep->xcr0 & X86_XSTATE_TILEDATA))
+ for (i = I387_TMM0_RAW_REGNUM (tdep);
+ i < I387_TMMEND_RAW_REGNUM (tdep); i++)
+ {
+ regcache->raw_collect (i, raw);
+ p = XSAVE_TMM_RAW_ADDR (tdep, regs, i);
+ if (memcmp (raw, p, X86_AMX_TMM_SIZE) != 0)
+ {
+ xstate_bv |= X86_XSTATE_TILEDATA;
+ memcpy (p, raw, X86_AMX_TMM_SIZE);
+ }
+ }
+
/* Check if any PKEYS registers are changed. */
if ((tdep->xcr0 & X86_XSTATE_PKRU))
for (i = I387_PKRU_REGNUM (tdep);
@@ -1814,6 +1974,16 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
}
}
}
+ else if (regclass == tmm_raw)
+ {
+ regcache->raw_collect (regnum, raw);
+ p = XSAVE_TMM_RAW_ADDR (tdep, regs, regnum);
+ if (memcmp (raw, p, 1024) != 0)
+ {
+ xstate_bv |= X86_XSTATE_TILEDATA;
+ memcpy (p, raw, 1024);
+ }
+ }
else
{
/* Check if REGNUM is changed. */
@@ -1834,6 +2004,16 @@ i387_collect_xsave (const struct regcache *regcache, int regnum,
}
break;
+ case tilecfg:
+ /* This is a tilecfg register. */
+ p = XSAVE_TILECFG_RAW_ADDR (tdep, regs, regnum);
+ if (memcmp (raw, p, 64) != 0)
+ {
+ xstate_bv |= X86_XSTATE_TILECFG;
+ memcpy (p, raw, 64);
+ }
+ break;
+
case pkeys:
/* This is a PKEYS register. */
p = XSAVE_PKEYS_ADDR (tdep, regs, regnum);
diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h
index f029c1e5119..6055b122cba 100644
--- a/gdb/i387-tdep.h
+++ b/gdb/i387-tdep.h
@@ -43,14 +43,18 @@ struct x86_xsave_layout;
/* Set of constants used for 32 and 64-bit. */
#define I387_NUM_K_REGS 8
#define I387_NUM_PKEYS_REGS 1
+#define I387_NUM_TILECFG_REGS 1
#define I387_PKRU_REGNUM(tdep) ((tdep)->pkru_regnum)
#define I387_K0_REGNUM(tdep) ((tdep)->k0_regnum)
#define I387_NUM_ZMMH_REGS(tdep) ((tdep)->num_zmm_regs)
+#define I387_NUM_TMM_RAW_REGS(tdep) ((tdep)->num_tmm_raw_regs)
#define I387_ZMM0H_REGNUM(tdep) ((tdep)->zmm0h_regnum)
#define I387_ZMM16H_REGNUM(tdep) ((tdep)->zmm0h_regnum + 16)
#define I387_NUM_YMM_AVX512_REGS(tdep) ((tdep)->num_ymm_avx512_regs)
#define I387_YMM16H_REGNUM(tdep) ((tdep)->ymm16h_regnum)
+#define I387_TILECFG_RAW_REGNUM(tdep) ((tdep)->tilecfg_raw_regnum)
+#define I387_TMM0_RAW_REGNUM(tdep) ((tdep)->tmm_raw_regnum)
#define I387_FCTRL_REGNUM(tdep) (I387_ST0_REGNUM (tdep) + 8)
#define I387_FSTAT_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 1)
@@ -83,6 +87,8 @@ struct x86_xsave_layout;
#define I387_PKEYSEND_REGNUM(tdep) \
(I387_PKRU_REGNUM (tdep) + I387_NUM_PKEYS_REGS)
+#define I387_TMMEND_RAW_REGNUM(tdep) \
+ (I387_TMM0_RAW_REGNUM (tdep) + I387_NUM_TMM_RAW_REGS (tdep))
/* Print out the i387 floating point state. */
diff --git a/gdb/nat/x86-xstate.c b/gdb/nat/x86-xstate.c
index f0f0b00e859..75719b98746 100644
--- a/gdb/nat/x86-xstate.c
+++ b/gdb/nat/x86-xstate.c
@@ -61,5 +61,7 @@ x86_fetch_xsave_layout (uint64_t xcr0, int len)
layout.zmm_h_offset = xsave_feature_offset (xcr0, X86_XSTATE_ZMM_H_ID);
layout.zmm_offset = xsave_feature_offset (xcr0, X86_XSTATE_ZMM_ID);
layout.pkru_offset = xsave_feature_offset (xcr0, X86_XSTATE_PKRU_ID);
+ layout.tilecfg_offset = xsave_feature_offset (xcr0, X86_XSTATE_TILECFG_ID);
+ layout.tiledata_offset = xsave_feature_offset (xcr0, X86_XSTATE_TILEDATA_ID);
return layout;
}
diff --git a/gdb/target-debug.h b/gdb/target-debug.h
index 949847b181c..9e096a18b7b 100644
--- a/gdb/target-debug.h
+++ b/gdb/target-debug.h
@@ -381,6 +381,8 @@ target_debug_print_x86_xsave_layout (const x86_xsave_layout &layout)
POFFS(zmm);
POFFS(pkru);
POFFS(apx);
+ POFFS(tilecfg);
+ POFFS(tiledata);
#undef POFFS
diff --git a/gdb/testsuite/gdb.arch/amd64-amx.c b/gdb/testsuite/gdb.arch/amd64-amx.c
new file mode 100644
index 00000000000..5dca29ad183
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-amx.c
@@ -0,0 +1,115 @@
+/* Test program for Intel AMX registers.
+
+ Copyright 2022-2026 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 <immintrin.h>
+#include <stdint.h>
+
+#include "amd64-amx.h"
+
+#define TILE int
+
+#define N 2
+#define K 3
+#define M 4
+
+uint8_t memA[N][4 * K] = { { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2 },
+ { 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 } };
+
+uint8_t memB[K][4 * M] = {
+ { 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 },
+};
+
+uint32_t memC[N][M] = { 0 };
+
+/* Data for type testing. */
+
+int8_t int8_matrix[2][8] = { { -1, -1, -1, -1, 1, 1, 1, 1 },
+ { 1, 1, 1, 1, -5, -5, -5, -5 } };
+
+float fp32_matrix[2][2] = { { 1.0, 1.125 },
+ { 1.25, 1.375 } };
+
+
+static void
+tfmaps_calc (void)
+{
+ const int strideA = 4 * K;
+ const int strideB = 4 * M;
+ const int strideC = 4 * M;
+
+ /* Configure. */
+ struct tileconfig_t
+ {
+ uint8_t palette_id;
+ uint8_t startRow;
+ uint8_t reserved[14];
+ uint16_t cols[16];
+ uint8_t rows[16];
+ };
+
+ struct tileconfig_t tc = { 1 };
+
+ const TILE A = 0;
+ const TILE B = 1;
+ const TILE C = 2;
+
+ tc.rows[A] = N;
+ tc.cols[A] = K * 4;
+ tc.rows[B] = K;
+ tc.cols[B] = M * 4;
+ tc.rows[C] = N;
+ tc.cols[C] = M * 4;
+
+ /* Tiles for testing the remaining element types. */
+ tc.rows[4] = 2;
+ tc.cols[4] = 8;
+ tc.rows[5] = 2;
+ tc.cols[5] = 8;
+
+ _tile_loadconfig (&tc);
+
+ /* Load additional types for type testing. */
+ _tile_loadd (4, fp32_matrix, 2 * 4);
+ _tile_loadd (5, int8_matrix, 4 * 2);
+
+ /* Computation. */
+ _tile_loadd (0, memA, strideA);
+ _tile_loadd (1, memB, strideB);
+ _tile_dpbuud (2, 0, 1);
+ _tile_stored (2, memC, strideC);
+
+ /* Provoke a SIGSEGV while the tiles are still live, so that the OS
+ writes a core file containing them. */
+ *(volatile int *) 0; /* Crash. */
+}
+
+
+int
+main (void)
+{
+ /* Ask the OS to configure Intel AMX in xsave. */
+ if (amx_enable () != 0)
+ return -1;
+
+ tfmaps_calc ();
+
+ return 0;
+}
diff --git a/gdb/testsuite/gdb.arch/amd64-amx.exp b/gdb/testsuite/gdb.arch/amd64-amx.exp
new file mode 100644
index 00000000000..af92e2d37a0
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-amx.exp
@@ -0,0 +1,192 @@
+# Copyright 2022-2026 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/>.
+
+# This file tests basic Intel AMX functionality. The raw tile registers
+# always show a tile with its maximum dimensions, that is 16 rows of 64 bytes.
+# Only the elements configured in $tilecfg hold data.
+
+require allow_amx_tests
+
+standard_testfile
+if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
+ {debug additional_flags=-mamx-tile additional_flags=-mamx-int8}]} {
+ return
+}
+
+if {![runto_main]} {
+ return
+}
+
+proc test_zeroed_tile {reg} {
+ gdb_test "print/d (uint8_t\[16\]\[64\]) $reg" \
+ "= \\{\\{0 <repeats 64 times>\\} <repeats 16 times>\\}"
+}
+
+# Check the tile registers as loaded by the program at the "Crash" line.
+
+proc test_loaded_tiles {} {
+ gdb_test "print/x \$tilecfg_raw" \
+ [join {"= 0x20200020302000000000000000000000000000000000" \
+ "000000000080008000000100010000c00000000000000000000000000000001"} ""]
+
+ 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}}"]
+
+ gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm0_raw" \
+ [join {"= \\{\\{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_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>\\}" \
+ "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4,\
+ 0 <repeats 48 times>\\}" \
+ "\\{2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,\
+ 0 <repeats 48 times>\\}" \
+ "\\{0 <repeats 64 times>\\} <repeats 13 times>\\}"} \
+ ", "]
+
+ 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 (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/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} {
+ test_zeroed_tile "\$tmm${i}_raw"
+ }
+}
+
+# Restart gdb, load the core file generated by gcore or the OS
+# and check reading registers from the core file.
+
+proc test_corefile {core_filename} {
+ clean_restart $::testfile
+
+ gdb_test "core $core_filename" "Core was generated by .*" \
+ "load core file"
+
+ test_loaded_tiles
+}
+
+# Registers should be displayed as zeroed before Intel AMX enablement.
+with_test_prefix "before Intel AMX is enabled" {
+ gdb_test "print \$tilecfg_raw" "= 0"
+ for {set i 0} {$i < 8} {incr i} {
+ test_zeroed_tile "\$tmm${i}_raw"
+ }
+}
+
+# Continue until the program provokes a SIGSEGV. This is required to test
+# reading tile registers from the OS generated core file below.
+set line [gdb_get_line_number "Crash"]
+gdb_breakpoint $line
+gdb_continue_to_breakpoint "tiles are loaded" ".*$srcfile:$line.*"
+
+with_test_prefix "read tiles" {
+ test_loaded_tiles
+}
+
+# Write a core file before modifying the tile registers.
+set gcorefile $binfile.gcore
+set gcore_generated [gdb_gcore_cmd $gcorefile "save a core file"]
+
+# Test setting tiles.
+with_test_prefix "setting tiles" {
+ 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>\\}"} \
+ ", "]
+
+ 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>\\}"} \
+ ", "]
+
+ 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_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"
+}
+
+# Test generic setting.
+with_test_prefix "set tilecfg raw" {
+ gdb_test_no_output "set \$tilecfg_raw = 0"
+ gdb_test_no_output "set \$tilecfg.palette = 1"
+
+ gdb_test "print/x \$tilecfg_raw" "= 0x1"
+ gdb_test "print \$tilecfg" \
+ [string_to_regexp "= {palette = 1, start_row = 0,\
+ colsb = {0, 0, 0, 0, 0, 0, 0, 0}, rows = {0, 0, 0, 0, 0, 0, 0, 0}}"]
+}
+
+with_test_prefix "set tilecfg" {
+ gdb_test_no_output "set \$tilecfg.palette = 0x2"
+ gdb_test_no_output "set \$tilecfg.start_row = 0x3"
+ gdb_test_no_output "set \$tilecfg.rows\[0\] = 0x4"
+
+ gdb_test "print/x \$tilecfg_raw" \
+ [join {"= 0x40000000000000000000000000000000000000000000" \
+ "00000000000000000000000000000000000000000000000000302"} ""]
+ gdb_test "print \$tilecfg" \
+ [string_to_regexp "= {palette = 2, start_row = 3,\
+ colsb = {0, 0, 0, 0, 0, 0, 0, 0}, rows = {4, 0, 0, 0, 0, 0, 0, 0}}"]
+}
+
+# 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} {
+ with_test_prefix "gcore core file" {
+ test_corefile $gcorefile
+ }
+}
+
+# Like the above, but test the core file generated by the OS.
+with_test_prefix "OS generated core file" {
+ # This test relies on reading address zero triggering a SIGSEGV.
+ # If address zero is readable skip this test.
+ if {[is_address_zero_readable]} {
+ unsupported "address zero is readable"
+ } else {
+ set corefile [core_find $binfile]
+ if {$corefile eq ""} {
+ unsupported "unable to generate core file"
+ } else {
+ test_corefile $corefile
+ }
+ }
+}
diff --git a/gdb/testsuite/lib/amd64-amx.h b/gdb/testsuite/lib/amd64-amx.h
new file mode 100644
index 00000000000..4b2d0b7ba71
--- /dev/null
+++ b/gdb/testsuite/lib/amd64-amx.h
@@ -0,0 +1,41 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2026 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/>. */
+
+#ifndef AMD64_AMX_H
+#define AMD64_AMX_H
+
+#include <asm/prctl.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+/* Intel AMX requires Linux 5.16. ARCH_XCOMP_TILEDATA is added in Linux 6.4.
+ Add fallback for previous kernels. */
+
+#ifndef ARCH_XCOMP_TILEDATA
+#define ARCH_XCOMP_TILEDATA 18
+#endif
+
+/* Ask the OS to configure Intel AMX in xsave. Tile data registers are
+ only usable after this succeeded. Return zero on success. */
+
+static inline int
+amx_enable (void)
+{
+ return syscall (SYS_arch_prctl, ARCH_REQ_XCOMP_PERM, ARCH_XCOMP_TILEDATA);
+}
+
+#endif /* AMD64_AMX_H */
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index bc6725b948f..c24cfd5dfbd 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -4635,6 +4635,81 @@ gdb_caching_proc allow_ssp_tests {} {
return $allow_ssp_tests
}
+# Run a test on the target to see if it supports AMX. Return 1 if so,
+# 0 if it does not.
+
+gdb_caching_proc allow_amx_tests {} {
+ global srcdir subdir gdb_prompt inferior_exited_re
+
+ set me "allow_amx_tests"
+ if { ![istarget "x86_64-*-*"] } {
+ verbose "$me: target does not support AMX" 2
+ return 0
+ }
+
+ # Compile a test program.
+ set src {
+ #include <stdint.h>
+ #include <immintrin.h>
+
+ #include "amd64-amx.h"
+
+ int
+ main ()
+ {
+ if (amx_enable () != 0)
+ return 1;
+
+ struct tileconfig_t {
+ uint8_t palette_id;
+ uint8_t startRow;
+ uint8_t reserved[14];
+ uint16_t cols[16];
+ uint8_t rows[16];
+ };
+
+ struct tileconfig_t tc = {1};
+ _tile_loadconfig (&tc);
+ _tile_release ();
+
+ return 0;
+ }
+ }
+ set compile_flags "additional_flags=-mamx-tile"
+ if {![gdb_simple_compile $me $src executable $compile_flags]} {
+ return 0
+ }
+
+ # 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
+ set allow_amx_tests 0
+ gdb_expect {
+ -re ".*Illegal instruction.*${gdb_prompt} $" {
+ verbose -log "$me: AMX hardware not detected."
+ }
+ -re ".*$inferior_exited_re with code.*${gdb_prompt} $" {
+ verbose -log "$me: AMX not enabled by the OS."
+ }
+ -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
+ verbose -log "$me: AMX hardware detected."
+ set allow_amx_tests 1
+ }
+ default {
+ warning "\n$me: default case taken."
+ }
+ }
+ gdb_exit
+ remote_file build delete $obj
+
+ verbose "$me: returning $allow_amx_tests" 2
+ return $allow_amx_tests
+}
+
# Run a test on the target to see if it supports avx512bf16. Return 1 if so,
# 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
diff --git a/gdbserver/i387-fp.cc b/gdbserver/i387-fp.cc
index 90f146a74d2..7d195c554ce 100644
--- a/gdbserver/i387-fp.cc
+++ b/gdbserver/i387-fp.cc
@@ -138,6 +138,14 @@ public:
32 bits. */
unsigned char *pkru_space ()
{ return xsave () + xsave_layout.pkru_offset; }
+
+ /* Memory address for the TILECFG register, which is 64 bytes. */
+ unsigned char *tilecfg_space ()
+ { return xsave () + xsave_layout.tilecfg_offset; }
+
+ /* Memory address of the TILEDATA state component. */
+ unsigned char *tiledata_space ()
+ { return xsave () + xsave_layout.tiledata_offset; }
};
static_assert (sizeof(i387_xsave) == 576);
@@ -260,7 +268,7 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
unsigned long val, val2;
unsigned long long xstate_bv = 0;
unsigned long long clear_bv = 0;
- char raw[64];
+ char raw[1024];
unsigned char *p;
/* Amd64 has 16 xmm regs; I386 has 8 xmm regs. */
@@ -321,6 +329,12 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
if (amd64 && (clear_bv & X86_XSTATE_APX_F) != 0)
for (i = 0; i < num_apx_registers; i++)
memset (fp->apx_space () + i * 8, 0, 8);
+
+ if (amd64 && (clear_bv & X86_XSTATE_AMX) != 0)
+ {
+ memset (fp->tilecfg_space (), 0, X86_AMX_TILECFG_SIZE);
+ memset (fp->tiledata_space (), 0, X86_AMX_TILEDATA_SIZE);
+ }
}
/* Check if any x87 registers are changed. */
@@ -462,6 +476,35 @@ i387_cache_to_xsave (struct regcache *regcache, void *buf)
}
}
+ /* Check if TILECFG register is changed (only for amd64). */
+ if (amd64 && ((x86_xstate_bv & X86_XSTATE_TILECFG) != 0))
+ {
+ collect_register_by_name (regcache, "tilecfg_raw", raw);
+ p = fp->tilecfg_space ();
+ if (memcmp (raw, p, X86_AMX_TILECFG_SIZE) != 0)
+ {
+ xstate_bv |= X86_XSTATE_TILECFG;
+ memcpy (p, raw, X86_AMX_TILECFG_SIZE);
+ }
+ }
+
+ /* Check if any raw tile register is changed (only for amd64). */
+ if (amd64 && ((x86_xstate_bv & X86_XSTATE_TILEDATA) != 0))
+ {
+ int tmm0_raw_regnum = find_regno (regcache->tdesc, "tmm0_raw");
+
+ for (i = 0; i < X86_AMX_NUM_TMM_REGISTERS; i++)
+ {
+ collect_register (regcache, tmm0_raw_regnum + i, raw);
+ p = fp->tiledata_space () + i * X86_AMX_TMM_SIZE;
+ if (memcmp (raw, p, X86_AMX_TMM_SIZE) != 0)
+ {
+ xstate_bv |= X86_XSTATE_TILEDATA;
+ memcpy (p, raw, X86_AMX_TMM_SIZE);
+ }
+ }
+ }
+
if ((x86_xstate_bv & X86_XSTATE_SSE) || (x86_xstate_bv & X86_XSTATE_AVX))
{
collect_register_by_name (regcache, "mxcsr", raw);
@@ -833,6 +876,31 @@ i387_xsave_to_cache (struct regcache *regcache, const void *buf)
}
}
+ if (amd64 && (x86_xstate_bv & X86_XSTATE_AMX) != 0)
+ {
+ int tilecfg_regnum = find_regno (regcache->tdesc, "tilecfg_raw");
+ int tmm0_raw_regnum = find_regno (regcache->tdesc, "tmm0_raw");
+
+ if ((clear_bv & X86_XSTATE_TILECFG) != 0)
+ supply_register_zeroed (regcache, tilecfg_regnum);
+ else
+ {
+ p = fp->tilecfg_space ();
+ supply_register (regcache, tilecfg_regnum, p);
+ }
+
+ if ((clear_bv & X86_XSTATE_TILEDATA) != 0)
+ for (i = 0; i < X86_AMX_NUM_TMM_REGISTERS; i++)
+ supply_register_zeroed (regcache, tmm0_raw_regnum + i);
+ else
+ {
+ p = fp->tiledata_space ();
+ for (i = 0; i < X86_AMX_NUM_TMM_REGISTERS; i++)
+ supply_register (regcache, tmm0_raw_regnum + i,
+ p + i * X86_AMX_TMM_SIZE);
+ }
+ }
+
if ((clear_bv & (X86_XSTATE_SSE | X86_XSTATE_AVX))
== (X86_XSTATE_SSE | X86_XSTATE_AVX))
{
diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
index f893821fa48..24473ae1916 100644
--- a/gdbserver/linux-x86-low.cc
+++ b/gdbserver/linux-x86-low.cc
@@ -263,6 +263,8 @@ static const int x86_64_regmap[] =
-1, /* CET user mode register PL3_SSP. */
-1, -1, -1, -1, -1, -1, -1, -1, /* r16...r31 (APX). */
-1, -1, -1, -1, -1, -1, -1, -1,
+ -1, /* AMX TILECFG register. */
+ -1, -1, -1, -1, -1, -1, -1, -1, /* AMX tmm0_raw ... tmm7_raw. */
};
#define X86_64_NUM_REGS (sizeof (x86_64_regmap) / sizeof (x86_64_regmap[0]))
diff --git a/gdbsupport/x86-xstate.h b/gdbsupport/x86-xstate.h
index 3cb75ccfed6..368c34426b1 100644
--- a/gdbsupport/x86-xstate.h
+++ b/gdbsupport/x86-xstate.h
@@ -29,6 +29,8 @@
#define X86_XSTATE_ZMM_ID 7
#define X86_XSTATE_PKRU_ID 9
#define X86_XSTATE_CET_U_ID 11
+#define X86_XSTATE_TILECFG_ID 17
+#define X86_XSTATE_TILEDATA_ID 18
#define X86_XSTATE_APX_F_ID 19
/* The extended state feature bits. */
@@ -47,6 +49,11 @@
#define X86_XSTATE_PKRU (1ULL << X86_XSTATE_PKRU_ID)
#define X86_XSTATE_CET_U (1ULL << X86_XSTATE_CET_U_ID)
+/* AMX adds two feature bits. Both must be enabled. */
+#define X86_XSTATE_TILECFG (1ULL << X86_XSTATE_TILECFG_ID)
+#define X86_XSTATE_TILEDATA (1ULL << X86_XSTATE_TILEDATA_ID)
+#define X86_XSTATE_AMX (X86_XSTATE_TILECFG | X86_XSTATE_TILEDATA)
+
/* Total size of the XSAVE area extended region and offsets of
register states within the region. Offsets are set to 0 to
indicate the absence of the associated registers. */
@@ -60,6 +67,8 @@ struct x86_xsave_layout
int zmm_h_offset = 0;
int zmm_offset = 0;
int pkru_offset = 0;
+ int tilecfg_offset = 0;
+ int tiledata_offset = 0;
};
constexpr bool operator== (const x86_xsave_layout &lhs,
@@ -71,7 +80,9 @@ constexpr bool operator== (const x86_xsave_layout &lhs,
&& lhs.k_offset == rhs.k_offset
&& lhs.zmm_h_offset == rhs.zmm_h_offset
&& lhs.zmm_offset == rhs.zmm_offset
- && lhs.pkru_offset == rhs.pkru_offset;
+ && lhs.pkru_offset == rhs.pkru_offset
+ && lhs.tilecfg_offset == rhs.tilecfg_offset
+ && lhs.tiledata_offset == rhs.tiledata_offset;
}
constexpr bool operator!= (const x86_xsave_layout &lhs,
@@ -90,21 +101,30 @@ constexpr bool operator!= (const x86_xsave_layout &lhs,
| X86_XSTATE_AVX512 | X86_XSTATE_PKRU)
#define X86_XSTATE_AVX_AVX512_PKU_APX_MASK\
(X86_XSTATE_AVX_AVX512_PKU_MASK | X86_XSTATE_APX_F)
+#define X86_XSTATE_AVX_AVX512_PKU_APX_AMX_MASK\
+ (X86_XSTATE_AVX_AVX512_PKU_APX_MASK | X86_XSTATE_AMX)
/* Supported mask of state-component bitmap xstate_bv. The SDM defines
xstate_bv as XCR0 | IA32_XSS. */
-#define X86_XSTATE_ALL_MASK (X86_XSTATE_AVX_AVX512_PKU_APX_MASK\
- | X86_XSTATE_CET_U)
+#define X86_XSTATE_ALL_MASK\
+ (X86_XSTATE_AVX_AVX512_PKU_APX_AMX_MASK | X86_XSTATE_CET_U)
#define X86_XSTATE_SSE_SIZE 576
#define X86_XSTATE_AVX_SIZE 832
+/* Size of the AMX TILECFG register and of the raw tile registers. */
+
+#define X86_AMX_TILECFG_SIZE 64
+#define X86_AMX_TMM_SIZE 1024
+#define X86_AMX_NUM_TMM_REGISTERS 8
+#define X86_AMX_TILEDATA_SIZE (X86_AMX_NUM_TMM_REGISTERS * X86_AMX_TMM_SIZE)
#define HAS_AVX(XCR0) (((XCR0) & X86_XSTATE_AVX) != 0)
#define HAS_AVX512(XCR0) (((XCR0) & X86_XSTATE_AVX512) != 0)
#define HAS_APX(XCR0) (((XCR0) & X86_XSTATE_APX_F) != 0)
#define HAS_PKRU(XCR0) (((XCR0) & X86_XSTATE_PKRU) != 0)
+#define HAS_AMX(XCR0) (((XCR0) & X86_XSTATE_AMX) != 0)
/* Initial value for fctrl register, as defined in the X86 manual, and
confirmed in the (Linux) kernel source. When the x87 floating point
--
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.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 3/5] gdb: support register groups for user registers
2026-10-30 11:50 [PATCH v2 0/5] Add Intel AMX support Stephan Rohr
2026-10-30 11:50 ` [PATCH v2 1/5] gdb: define additional integer built-in types Stephan Rohr
2026-10-30 11:50 ` [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers Stephan Rohr
@ 2026-10-30 11:50 ` Stephan Rohr
2026-10-30 12:48 ` Eli Zaretskii
2026-10-30 11:50 ` [PATCH v2 4/5] gdb: add a "matrix" register group Stephan Rohr
2026-10-30 11:50 ` [PATCH v2 5/5] gdb: add Intel AMX tile registers as user registers Stephan Rohr
4 siblings, 1 reply; 15+ messages in thread
From: Stephan Rohr @ 2026-10-30 11:50 UTC (permalink / raw)
To: gdb-patches; +Cc: pedro, eliz, jhb, luis.machado
From: "Rohr, Stephan" <stephan.rohr@intel.com>
User registers are not part of any register group and user registers
are not listed with the "info registers <group>" command. Neither do
"info registers" and "info all-registers".
Allow an optional set of register groups when adding a user register.
Update the "info registers" commands to print user registers, too.
This is in preparation for adding the Intel AMX tile registers as user
registers.
---
gdb/NEWS | 7 +++++++
gdb/doc/gdb.texinfo | 7 +++++--
gdb/infcmd.c | 28 +++++++++++++++++++++++++++
gdb/user-regs.c | 46 +++++++++++++++++++++++++++++++++++++++------
gdb/user-regs.h | 17 +++++++++++++----
5 files changed, 93 insertions(+), 12 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 2047e7376fb..4869f3595be 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -88,6 +88,13 @@ info locals
The new "-shadowed on|off" option overrides the "set print shadowed"
setting for a single invocation of the command.
+info registers
+info all-registers
+info registers REGGROUP
+ These commands now also print the user registers that are part of the
+ "general" register group, the "all" register group, or of REGGROUP,
+ respectively.
+
*** Changes in GDB 18
* Support for the Common Trace Format (CTF) has been removed. GDB now
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 9e3b6fca669..72b87401c5c 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -13772,7 +13772,8 @@ and vector registers (in the selected stack frame).
@item info registers @var{reggroup} @dots{}
Print the name and value of the registers in each of the specified
@var{reggroup}s. The @var{reggroup} can be any of those returned by
-@code{maint print reggroups} (@pxref{Maintenance Commands}).
+@code{maint print reggroups} (@pxref{Maintenance Commands}). This
+includes the user registers that are part of a @var{reggroup}.
@item info registers @var{regname} @dots{}
Print the @dfn{relativized} value of each specified register @var{regname}.
@@ -42832,7 +42833,9 @@ include the four ``standard'' registers @code{$fp}, @code{$pc},
@code{$sp}, and @code{$ps}. @xref{standard registers}. User
registers can be used in expressions in the same way as the canonical
register names, but only the latter are listed by the @code{info
-registers} and @code{maint print registers} commands.
+registers} and @code{maint print registers} commands. The exceptions are
+user registers that are part of a register group, which @code{info registers
+@var{reggroup}} lists (@pxref{info_registers_reggroup}).
@kindex maint print section-scripts
@cindex info for known .debug_gdb_scripts-loaded scripts
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index d7544168362..a1a31b65a07 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2533,6 +2533,27 @@ default_print_registers_info (struct gdbarch *gdbarch,
}
}
+/* Print the user registers of GDBARCH in FRAME that are part of GROUP
+ to FILE. */
+
+static void
+print_user_registers_in_group (gdbarch *gdbarch, ui_file *file,
+ const frame_info_ptr &frame,
+ const reggroup *group)
+{
+ /* User registers lie above the range of normal registers. */
+ for (int regnum = gdbarch_num_cooked_regs (gdbarch);; regnum++)
+ {
+ const char *regname = user_reg_map_regnum_to_name (gdbarch, regnum);
+ if (regname == nullptr)
+ break;
+
+ if (user_reg_reggroup_p (gdbarch, regnum, group))
+ default_print_one_register_info (file, regname,
+ value_of_user_reg (regnum, frame));
+ }
+}
+
void
registers_info (const char *addr_exp, bool fpregs)
{
@@ -2548,6 +2569,11 @@ registers_info (const char *addr_exp, bool fpregs)
{
gdbarch_print_registers_info (gdbarch, gdb_stdout,
frame, -1, fpregs);
+
+ /* Print all user registers that are in the all register group or the
+ general register group, respectively. */
+ print_user_registers_in_group (gdbarch, gdb_stdout, frame,
+ fpregs ? all_reggroup : general_reggroup);
return;
}
@@ -2632,6 +2658,8 @@ registers_info (const char *addr_exp, bool fpregs)
gdb_stdout, frame,
regnum, fpregs);
}
+
+ print_user_registers_in_group (gdbarch, gdb_stdout, frame, group);
continue;
}
}
diff --git a/gdb/user-regs.c b/gdb/user-regs.c
index f1c6c9a1b24..1e6280ef593 100644
--- a/gdb/user-regs.c
+++ b/gdb/user-regs.c
@@ -25,6 +25,8 @@
#include "arch-utils.h"
#include "command.h"
#include "cli/cli-cmds.h"
+#include "reggroups.h"
+#include <algorithm>
/* A table of user registers.
@@ -45,6 +47,10 @@ struct user_reg
syscall. */
struct value *(*xread) (const frame_info_ptr &frame, const void *baton);
const void *baton;
+ /* The register groups the register is part of. The array is owned by
+ the caller of user_reg_add or user_reg_add_builtin. */
+ const reggroup *const *groups;
+ size_t num_groups;
struct user_reg *next;
};
@@ -63,15 +69,26 @@ struct gdb_user_regs
static void
append_user_reg (struct gdb_user_regs *regs, const char *name,
user_reg_read_ftype *xread, const void *baton,
+ gdb::array_view<const reggroup *const> groups,
struct user_reg *reg)
{
/* The caller is responsible for allocating memory needed to store
- the register. By doing this, the function can operate on a
- register list stored in the common heap or a specific obstack. */
+ the register and its GROUPS. By doing this, the function can operate
+ on a register list stored in the common heap or a specific obstack. */
gdb_assert (reg != NULL);
+
+ /* User registers provide a different view of hardware registers. They
+ shall not be added to the "save" or "restore" register groups. */
+ for (const reggroup *group : groups)
+ gdb_assert (group != nullptr
+ && group != save_reggroup
+ && group != restore_reggroup);
+
reg->name = name;
reg->xread = xread;
reg->baton = baton;
+ reg->groups = groups.data ();
+ reg->num_groups = groups.size ();
reg->next = NULL;
if (regs->last == nullptr)
regs->last = ®s->first;
@@ -85,9 +102,10 @@ static struct gdb_user_regs builtin_user_regs;
void
user_reg_add_builtin (const char *name, user_reg_read_ftype *xread,
- const void *baton)
+ const void *baton,
+ gdb::array_view<const reggroup *const> groups)
{
- append_user_reg (&builtin_user_regs, name, xread, baton,
+ append_user_reg (&builtin_user_regs, name, xread, baton, groups,
XNEW (struct user_reg));
}
@@ -110,6 +128,7 @@ get_user_regs (struct gdbarch *gdbarch)
reg != NULL;
reg = reg->next)
append_user_reg (regs, reg->name, reg->xread, reg->baton,
+ gdb::make_array_view (reg->groups, reg->num_groups),
OBSTACK_ZALLOC (obstack, struct user_reg));
user_regs_data.set (gdbarch, regs);
}
@@ -119,11 +138,12 @@ get_user_regs (struct gdbarch *gdbarch)
void
user_reg_add (struct gdbarch *gdbarch, const char *name,
- user_reg_read_ftype *xread, const void *baton)
+ user_reg_read_ftype *xread, const void *baton,
+ gdb::array_view<const reggroup *const> groups)
{
struct gdb_user_regs *regs = get_user_regs (gdbarch);
gdb_assert (regs != NULL);
- append_user_reg (regs, name, xread, baton,
+ append_user_reg (regs, name, xread, baton, groups,
GDBARCH_OBSTACK_ZALLOC (gdbarch, struct user_reg));
}
@@ -194,6 +214,20 @@ user_reg_map_regnum_to_name (struct gdbarch *gdbarch, int regnum)
}
}
+/* See user-regs.h. */
+
+bool
+user_reg_reggroup_p (struct gdbarch *gdbarch, int regnum,
+ const reggroup *group)
+{
+ int maxregs = gdbarch_num_cooked_regs (gdbarch);
+ struct user_reg *reg = usernum_to_user_reg (gdbarch, regnum - maxregs);
+
+ gdb_assert (reg != nullptr);
+ return (std::find (reg->groups, reg->groups + reg->num_groups, group)
+ != reg->groups + reg->num_groups);
+}
+
struct value *
value_of_user_reg (int regnum, const frame_info_ptr &frame)
{
diff --git a/gdb/user-regs.h b/gdb/user-regs.h
index 7fdb05db4b1..8e08e677950 100644
--- a/gdb/user-regs.h
+++ b/gdb/user-regs.h
@@ -38,8 +38,11 @@
of assumed to be read-only. Should it, for instance, return a
register descriptor that contains all the relevant access methods. */
+#include "gdbsupport/array-view.h"
+
class frame_info_ptr;
struct gdbarch;
+struct reggroup;
/* Given an architecture, map a user visible register name onto its
index. */
@@ -61,12 +64,18 @@ typedef struct value *(user_reg_read_ftype) (const frame_info_ptr &frame,
extern struct value *value_of_user_reg (int regnum, const frame_info_ptr &frame);
/* Add a builtin register (present in all architectures). */
-extern void user_reg_add_builtin (const char *name,
- user_reg_read_ftype *read,
- const void *baton);
+extern void user_reg_add_builtin
+ (const char *name, user_reg_read_ftype *read, const void *baton,
+ gdb::array_view<const reggroup *const> groups = {});
/* Add a per-architecture frame register. */
extern void user_reg_add (struct gdbarch *gdbarch, const char *name,
- user_reg_read_ftype *read, const void *baton);
+ user_reg_read_ftype *read, const void *baton,
+ gdb::array_view<const reggroup *const> groups = {});
+
+/* Return true if the user register REGNUM is a member of GROUP. */
+
+extern bool user_reg_reggroup_p (struct gdbarch *gdbarch, int regnum,
+ const reggroup *group);
#endif /* GDB_USER_REGS_H */
--
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.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 4/5] gdb: add a "matrix" register group
2026-10-30 11:50 [PATCH v2 0/5] Add Intel AMX support Stephan Rohr
` (2 preceding siblings ...)
2026-10-30 11:50 ` [PATCH v2 3/5] gdb: support register groups for user registers Stephan Rohr
@ 2026-10-30 11:50 ` Stephan Rohr
2026-10-30 12:49 ` Eli Zaretskii
2026-10-30 11:50 ` [PATCH v2 5/5] gdb: add Intel AMX tile registers as user registers Stephan Rohr
4 siblings, 1 reply; 15+ messages in thread
From: Stephan Rohr @ 2026-10-30 11:50 UTC (permalink / raw)
To: gdb-patches; +Cc: pedro, eliz, jhb, luis.machado
From: "Rohr, Stephan" <stephan.rohr@intel.com>
Add "matrix" as a new standard register group, next to the "vector"
register group. Architectures can use it for registers that hold
matrices, which can then be listed with "info registers matrix".
By default, no register is part of the group.
This is in preparation to add Intel AMX registers as user registers.
---
gdb/NEWS | 3 +++
gdb/doc/gdb.texinfo | 6 ++++--
gdb/reggroups.c | 3 +++
gdb/reggroups.h | 1 +
4 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 4869f3595be..47ecba246a0 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -49,6 +49,9 @@
source is modified. Source tracking can be enabled with 'set
breakpoint source-tracking enabled on'.
+* A new standard register group "matrix" has been added. Its registers can
+ be printed with "info registers matrix".
+
* New targets
i386 Windows/MSVC i[34567]86-*-windows-msvc
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 72b87401c5c..ba9d3df1ac5 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -42788,6 +42788,7 @@ The register groups info looks like this:
float user
all user
vector user
+ matrix user
system user
save internal
restore internal
@@ -49868,8 +49869,9 @@ architecture's normal floating point format) of the correct size for
@item group
The register group to which this register belongs. It can be one of the
-standard register groups @code{general}, @code{float}, @code{vector} or an
-arbitrary string. Group names should be limited to alphanumeric characters.
+standard register groups @code{general}, @code{float}, @code{vector},
+@code{matrix} or an arbitrary string. Group names should be limited to
+alphanumeric characters.
If a group name is made up of multiple words the words may be separated by
hyphens; e.g.@: @code{special-group} or @code{ultra-special-group}. If no
@var{group} is specified, @value{GDBN} will not display the register in
diff --git a/gdb/reggroups.c b/gdb/reggroups.c
index b0d3fd82185..a0f86baa5ac 100644
--- a/gdb/reggroups.c
+++ b/gdb/reggroups.c
@@ -58,6 +58,7 @@ struct reggroups
add (float_reggroup);
add (system_reggroup);
add (vector_reggroup);
+ add (matrix_reggroup);
add (all_reggroup);
add (save_reggroup);
add (restore_reggroup);
@@ -240,6 +241,7 @@ static const reggroup general_group = { "general", USER_REGGROUP };
static const reggroup float_group = { "float", USER_REGGROUP };
static const reggroup system_group = { "system", USER_REGGROUP };
static const reggroup vector_group = { "vector", USER_REGGROUP };
+static const reggroup matrix_group = { "matrix", USER_REGGROUP };
static const reggroup all_group = { "all", USER_REGGROUP };
static const reggroup save_group = { "save", INTERNAL_REGGROUP };
static const reggroup restore_group = { "restore", INTERNAL_REGGROUP };
@@ -248,6 +250,7 @@ const reggroup *const general_reggroup = &general_group;
const reggroup *const float_reggroup = &float_group;
const reggroup *const system_reggroup = &system_group;
const reggroup *const vector_reggroup = &vector_group;
+const reggroup *const matrix_reggroup = &matrix_group;
const reggroup *const all_reggroup = &all_group;
const reggroup *const save_reggroup = &save_group;
const reggroup *const restore_reggroup = &restore_group;
diff --git a/gdb/reggroups.h b/gdb/reggroups.h
index 47824d5427e..a827c775992 100644
--- a/gdb/reggroups.h
+++ b/gdb/reggroups.h
@@ -68,6 +68,7 @@ extern const reggroup *const general_reggroup;
extern const reggroup *const float_reggroup;
extern const reggroup *const system_reggroup;
extern const reggroup *const vector_reggroup;
+extern const reggroup *const matrix_reggroup;
extern const reggroup *const all_reggroup;
/* Pre-defined, internal, register groups. */
--
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.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2 5/5] gdb: add Intel AMX tile registers as user registers
2026-10-30 11:50 [PATCH v2 0/5] Add Intel AMX support Stephan Rohr
` (3 preceding siblings ...)
2026-10-30 11:50 ` [PATCH v2 4/5] gdb: add a "matrix" register group Stephan Rohr
@ 2026-10-30 11:50 ` Stephan Rohr
2026-10-30 12:50 ` Eli Zaretskii
2026-11-03 15:19 ` Joos, Christina
4 siblings, 2 replies; 15+ messages in thread
From: Stephan Rohr @ 2026-10-30 11:50 UTC (permalink / raw)
To: gdb-patches; +Cc: pedro, eliz, jhb, luis.machado
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(-)
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,
\f
+
+/* 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} {
--
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.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 1/5] gdb: define additional integer built-in types
2026-10-30 11:50 ` [PATCH v2 1/5] gdb: define additional integer built-in types Stephan Rohr
@ 2026-10-30 12:45 ` Eli Zaretskii
0 siblings, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2026-10-30 12:45 UTC (permalink / raw)
To: Stephan Rohr; +Cc: gdb-patches, pedro, jhb, luis.machado
> 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:12 +0000
>
> From: Aleksandar Paunovic <aleksandar.paunovic@intel.com>
>
> Allow using int256/int512 and uint256/uint512 as built-in types,
> particularly for the target descriptions.
>
> This is in preparation to add Intel AMX registers.
>
> Co-Authored-By: Stephan Rohr <stephan.rohr@intel.com>
> ---
> gdb/doc/gdb.texinfo | 4 ++++
> gdb/gdbtypes.c | 8 ++++++++
> gdb/gdbtypes.h | 4 ++++
> gdb/target-descriptions.c | 12 ++++++++++++
> gdbsupport/tdesc.cc | 4 ++++
> gdbsupport/tdesc.h | 4 ++++
> 6 files changed, 36 insertions(+)
Thanks, the gdb.texinfo part isokay.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers.
2026-10-30 11:50 ` [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers Stephan Rohr
@ 2026-10-30 12:47 ` Eli Zaretskii
2026-11-03 10:44 ` Joos, Christina
2026-11-03 14:40 ` Joos, Christina
2 siblings, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2026-10-30 12:47 UTC (permalink / raw)
To: Stephan Rohr; +Cc: gdb-patches, pedro, jhb, luis.machado
> 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:13 +0000
>
> From: Felix Willgerodt <felix.willgerodt@intel.com>
>
> Intel Advanced Matrix Extensions (AMX) adds one 64-byte TILECFG register
> and eight 1024-byte tile registers TMM0, TMM1, ..., TMM7. The tile
> registers each represent a matrix, whose dimensions are configured via
> TILECFG. In XSAVE, all tiles are represented in the 8kB TILEDATA section.
>
> Future platforms are free to add new palettes, which are run-time
> configurable partitionings of the TILEDATA space. Currently only
> palette 0 (initialized zero state) and palette 1 exist. New palettes
> might change any of the following parameters, which are defined in the
> palette_table (which can be accessed via CPUID):
>
> define palette_table[id]:
> uint16_t total_tile_bytes
> uint16_t bytes_per_tile
> uint16_t bytes_per_row
> uint16_t max_names
> uint16_t max_rows
>
> More information about Intel AMX can be found in the Intel Software
> Developer's Manual, September 2026.
>
> The $tilecfg register is implemented as a pseudo register. For convenience,
> reserved bytes are not shown. To also be able to show the full register,
> $tilecfg_raw is implemented as a uint512 value.
>
> The $tmm0_raw-$tmm7_raw registers hold the contents of the tiles. Each is
> shown with the maximum dimensions of 16 rows of 64 bytes. Only the elements
> within the dimensions configured in $tilecfg hold data.
>
> To hide the raw registers, they are added to the "save" and "restore"
> register groups only. A following patch introduces user registers and adds
> the tile user registers to the "all" group such that the tile registers show
> up in the "info registers all" command.
>
> Intel AMX is supported for 64-bit only.
>
> Co-Authored-By: Stephan Rohr <stephan.rohr@intel.com>
> ---
> gdb/NEWS | 5 +
> gdb/amd64-linux-tdep.c | 2 +
> gdb/amd64-tdep.c | 67 ++++++++-
> gdb/amd64-tdep.h | 3 +
> gdb/arch/amd64.c | 4 +
> gdb/arch/x86-linux-tdesc-features.c | 5 +-
> gdb/doc/gdb.texinfo | 40 ++++++
> gdb/features/Makefile | 1 +
> gdb/features/i386/64bit-amx.c | 26 ++++
> gdb/features/i386/64bit-amx.xml | 26 ++++
> gdb/i386-tdep.c | 132 +++++++++++++++++-
> gdb/i386-tdep.h | 25 +++-
> gdb/i387-tdep.c | 196 +++++++++++++++++++++++++--
> gdb/i387-tdep.h | 6 +
> gdb/nat/x86-xstate.c | 2 +
> gdb/target-debug.h | 2 +
> gdb/testsuite/gdb.arch/amd64-amx.c | 115 ++++++++++++++++
> gdb/testsuite/gdb.arch/amd64-amx.exp | 192 ++++++++++++++++++++++++++
> gdb/testsuite/lib/amd64-amx.h | 41 ++++++
> gdb/testsuite/lib/gdb.exp | 75 ++++++++++
> gdbserver/i387-fp.cc | 70 +++++++++-
> gdbserver/linux-x86-low.cc | 2 +
> gdbsupport/x86-xstate.h | 26 +++-
> 23 files changed, 1042 insertions(+), 21 deletions(-)
> create mode 100644 gdb/features/i386/64bit-amx.c
> create mode 100644 gdb/features/i386/64bit-amx.xml
> create mode 100644 gdb/testsuite/gdb.arch/amd64-amx.c
> create mode 100644 gdb/testsuite/gdb.arch/amd64-amx.exp
> create mode 100644 gdb/testsuite/lib/amd64-amx.h
Thanks, the documentation parts are okay.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 3/5] gdb: support register groups for user registers
2026-10-30 11:50 ` [PATCH v2 3/5] gdb: support register groups for user registers Stephan Rohr
@ 2026-10-30 12:48 ` Eli Zaretskii
0 siblings, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2026-10-30 12:48 UTC (permalink / raw)
To: Stephan Rohr; +Cc: gdb-patches, pedro, jhb, luis.machado
> 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:14 +0000
>
> From: "Rohr, Stephan" <stephan.rohr@intel.com>
>
> User registers are not part of any register group and user registers
> are not listed with the "info registers <group>" command. Neither do
> "info registers" and "info all-registers".
>
> Allow an optional set of register groups when adding a user register.
> Update the "info registers" commands to print user registers, too.
>
> This is in preparation for adding the Intel AMX tile registers as user
> registers.
> ---
> gdb/NEWS | 7 +++++++
> gdb/doc/gdb.texinfo | 7 +++++--
> gdb/infcmd.c | 28 +++++++++++++++++++++++++++
> gdb/user-regs.c | 46 +++++++++++++++++++++++++++++++++++++++------
> gdb/user-regs.h | 17 +++++++++++++----
> 5 files changed, 93 insertions(+), 12 deletions(-)
The documentation parts are okay, thanks.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 4/5] gdb: add a "matrix" register group
2026-10-30 11:50 ` [PATCH v2 4/5] gdb: add a "matrix" register group Stephan Rohr
@ 2026-10-30 12:49 ` Eli Zaretskii
0 siblings, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2026-10-30 12:49 UTC (permalink / raw)
To: Stephan Rohr; +Cc: gdb-patches, pedro, jhb, luis.machado
> 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:15 +0000
>
> From: "Rohr, Stephan" <stephan.rohr@intel.com>
>
> Add "matrix" as a new standard register group, next to the "vector"
> register group. Architectures can use it for registers that hold
> matrices, which can then be listed with "info registers matrix".
>
> By default, no register is part of the group.
>
> This is in preparation to add Intel AMX registers as user registers.
> ---
> gdb/NEWS | 3 +++
> gdb/doc/gdb.texinfo | 6 ++++--
> gdb/reggroups.c | 3 +++
> gdb/reggroups.h | 1 +
> 4 files changed, 11 insertions(+), 2 deletions(-)
The documentation parts are okay, thanks.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2 5/5] gdb: add Intel AMX tile registers as user registers
2026-10-30 11:50 ` [PATCH v2 5/5] gdb: add Intel AMX tile registers as user registers Stephan Rohr
@ 2026-10-30 12:50 ` Eli Zaretskii
2026-11-03 15:19 ` Joos, Christina
1 sibling, 0 replies; 15+ messages in thread
From: Eli Zaretskii @ 2026-10-30 12:50 UTC (permalink / raw)
To: Stephan Rohr; +Cc: gdb-patches, pedro, jhb, luis.machado
> 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>
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers.
2026-10-30 11:50 ` [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers Stephan Rohr
2026-10-30 12:47 ` Eli Zaretskii
@ 2026-11-03 10:44 ` Joos, Christina
2026-11-03 14:40 ` Joos, Christina
2 siblings, 0 replies; 15+ messages in thread
From: Joos, Christina @ 2026-11-03 10:44 UTC (permalink / raw)
To: Rohr, Stephan, gdb-patches; +Cc: pedro, eliz, jhb, luis.machado
Hi Stephan,
Thank you for this patch. I have two comments: one for the gdbserver part and one for the test.
Besides that, I mostly found 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 2/5] gdb, gdbserver: Add Intel AMX registers.
>
> From: Felix Willgerodt <felix.willgerodt@intel.com>
>
> Intel Advanced Matrix Extensions (AMX) adds one 64-byte TILECFG register
> and eight 1024-byte tile registers TMM0, TMM1, ..., TMM7. The tile
> registers each represent a matrix, whose dimensions are configured via
> TILECFG. In XSAVE, all tiles are represented in the 8kB TILEDATA section.
>
> Future platforms are free to add new palettes, which are run-time
> configurable partitionings of the TILEDATA space. Currently only
> palette 0 (initialized zero state) and palette 1 exist. New palettes
> might change any of the following parameters, which are defined in the
> palette_table (which can be accessed via CPUID):
>
> define palette_table[id]:
> uint16_t total_tile_bytes
> uint16_t bytes_per_tile
> uint16_t bytes_per_row
> uint16_t max_names
> uint16_t max_rows
>
> More information about Intel AMX can be found in the Intel Software
> Developer's Manual, September 2026.
>
> The $tilecfg register is implemented as a pseudo register. For convenience,
> reserved bytes are not shown. To also be able to show the full register,
> $tilecfg_raw is implemented as a uint512 value.
>
> The $tmm0_raw-$tmm7_raw registers hold the contents of the tiles. Each is
> shown with the maximum dimensions of 16 rows of 64 bytes. Only the
> elements
> within the dimensions configured in $tilecfg hold data.
> To hide the raw registers, they are added to the "save" and "restore"
> register groups only. A following patch introduces user registers and adds
> the tile user registers to the "all" group such that the tile registers show
> up in the "info registers all" command.
Since you're describing the exact groups for the raw registers, I think you could
also describe which group the tilecfg pseudo registers has configured.
> Intel AMX is supported for 64-bit only.
>
> Co-Authored-By: Stephan Rohr <stephan.rohr@intel.com>
> ---
> gdb/NEWS | 5 +
> gdb/amd64-linux-tdep.c | 2 +
> gdb/amd64-tdep.c | 67 ++++++++-
> gdb/amd64-tdep.h | 3 +
> gdb/arch/amd64.c | 4 +
> gdb/arch/x86-linux-tdesc-features.c | 5 +-
> gdb/doc/gdb.texinfo | 40 ++++++
> gdb/features/Makefile | 1 +
> gdb/features/i386/64bit-amx.c | 26 ++++
> gdb/features/i386/64bit-amx.xml | 26 ++++
> gdb/i386-tdep.c | 132 +++++++++++++++++-
> gdb/i386-tdep.h | 25 +++-
> gdb/i387-tdep.c | 196 +++++++++++++++++++++++++--
> gdb/i387-tdep.h | 6 +
> gdb/nat/x86-xstate.c | 2 +
> gdb/target-debug.h | 2 +
> gdb/testsuite/gdb.arch/amd64-amx.c | 115 ++++++++++++++++
> gdb/testsuite/gdb.arch/amd64-amx.exp | 192
> ++++++++++++++++++++++++++
> gdb/testsuite/lib/amd64-amx.h | 41 ++++++
> gdb/testsuite/lib/gdb.exp | 75 ++++++++++
> gdbserver/i387-fp.cc | 70 +++++++++-
> gdbserver/linux-x86-low.cc | 2 +
> gdbsupport/x86-xstate.h | 26 +++-
> 23 files changed, 1042 insertions(+), 21 deletions(-)
> create mode 100644 gdb/features/i386/64bit-amx.c
> create mode 100644 gdb/features/i386/64bit-amx.xml
> create mode 100644 gdb/testsuite/gdb.arch/amd64-amx.c
> create mode 100644 gdb/testsuite/gdb.arch/amd64-amx.exp
> create mode 100644 gdb/testsuite/lib/amd64-amx.h
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index 7303ec0e460..2047e7376fb 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -7,6 +7,11 @@
> Support displaying and modifying Intel APX registers (Extended GPRs
> $r16 - $r31) including byte, word and dword pseudo registers.
>
> +* Support for Intel AMX registers on GNU/Linux.
> + 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.
> +
> * GDB now distinguishes between the GNU (MinGW) and MSVC Windows
> ABIs.
>
> The "set osabi" command accepts two new values, "Windows-GNU" and
> diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
> index 81e66be75c1..28e18ed47d2 100644
> --- a/gdb/amd64-linux-tdep.c
> +++ b/gdb/amd64-linux-tdep.c
> @@ -115,6 +115,8 @@ int amd64_linux_gregset_reg_offset[] =
> -1, /* CET user mode register PL3_SSP. */
> -1, -1, -1, -1, -1, -1, -1, -1, /* r16 ... r31. */
> -1, -1, -1, -1, -1, -1, -1, -1,
> + -1, /* TILECFG register (AMX). */
> + -1, -1, -1, -1, -1, -1, -1, -1, /* tmm0_raw ... tmm7_raw (AMX). */
>
> /* End of hardware registers */
> 21 * 8, 22 * 8, /* fs_base and gs_base. */
> diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
> index 18b8f2a4c0b..13242e293b5 100644
> --- a/gdb/amd64-tdep.c
> +++ b/gdb/amd64-tdep.c
> @@ -188,6 +188,17 @@ static const char * const amd64_pkeys_names[] = {
> "pkru"
> };
>
> +static const char *amd64_tilecfg_raw_names[] = {
> + "tilecfg_raw"
> +};
> +
> +/* Register names for the raw AMX tile registers. */
> +
> +static const char *amd64_tmm_raw_names[] = {
> + "tmm0_raw", "tmm1_raw", "tmm2_raw", "tmm3_raw",
> + "tmm4_raw", "tmm5_raw", "tmm6_raw", "tmm7_raw"
> +};
> +
Those 2 arrays below should be "static const char * const", like the arrays above.
> /* DWARF Register Number Mapping as defined in the System V psABI,
> section 3.6. */
>
> @@ -429,6 +440,12 @@ static const char * const amd64_apx_dword_names[]
> =
> static_assert (ARRAY_SIZE (amd64_apx_dword_names)
> == AMD64_APX_NUM_DWORD_REGS + 1);
>
> +/* Register name for tilecfg pseudo-register. */
> +
> +static const char *amd64_tilecfg_names[] = {
> + "tilecfg"
> +};
> +
> /* Return the name of register REGNUM. */
>
> static const char *
> @@ -441,6 +458,8 @@ amd64_pseudo_register_name (struct gdbarch
> *gdbarch, int regnum)
> return amd64_ymm_names[regnum - tdep->ymm0_regnum];
> else if (i386_ymm_avx512_regnum_p (gdbarch, regnum))
> return amd64_ymm_avx512_names[regnum - tdep->ymm16_regnum];
> + else if (i386_tilecfg_regnum_p (gdbarch, regnum))
> + return amd64_tilecfg_names[regnum - tdep->tilecfg_regnum];
> else if (i386_dword_regnum_p (gdbarch, regnum))
> return tdep->dword_names[regnum - tdep->eax_regnum];
> else
> @@ -521,6 +540,22 @@ amd64_pseudo_register_read_value (gdbarch
> *gdbarch, const frame_info_ptr &next_f
> const int gpnum = amd64_raw_dword_register (tdep, regnum);
> return pseudo_from_raw_part (next_frame, regnum, gpnum, 0);
> }
> + else if (i386_tilecfg_regnum_p (gdbarch, regnum))
> + {
> + /* Read tilecfg. */
> + value *pseudo_reg_val
> + = value::allocate_register (next_frame, regnum);
> + value *raw_reg_val = value_of_register (tdep->tilecfg_raw_regnum,
> + next_frame);
> + /* Copy palette and start_row. See tilecfg_type (). */
> + raw_reg_val->contents_copy (pseudo_reg_val, 0, 0, 2 * 1);
> + /* Copy all colsb. */
> + raw_reg_val->contents_copy (pseudo_reg_val, 2, 16, 2 * 8);
> + /* Copy all rows. */
> + raw_reg_val->contents_copy (pseudo_reg_val, 18, 48, 1 * 8);
> +
> + return pseudo_reg_val;
> + }
> else
> return i386_pseudo_register_read_value (gdbarch, next_frame, regnum);
> }
> @@ -547,6 +582,22 @@ amd64_pseudo_register_write (gdbarch *gdbarch,
> const frame_info_ptr &next_frame,
> const int gpnum = amd64_raw_dword_register (tdep, regnum);
> pseudo_to_raw_part (next_frame, buf, gpnum, 0);
> }
> + else if (i386_tilecfg_regnum_p (gdbarch, regnum))
> + {
> + const int raw_reg_num = tdep->tilecfg_raw_regnum;
> + const int raw_size = register_size (gdbarch, raw_reg_num);
> + gdb::byte_vector raw_buf (raw_size, 0);
> + /* Copy palette and start_row. See tilecfg_type (). */
> + memcpy (raw_buf.data (), buf.data (), 2 * 1);
> + /* Copy all colsb. */
> + memcpy (raw_buf.data () + 16, buf.data () + 2, 2 * 8);
> + /* Copy all rows. */
> + memcpy (raw_buf.data () + 48, buf.data () + 18, 1 * 8);
> +
> + put_frame_register_bytes
> + (next_frame, raw_reg_num, 0,
> + gdb::make_array_view (raw_buf.data (), raw_size));
> + }
> else
> i386_pseudo_register_write (gdbarch, next_frame, regnum, buf);
> }
> @@ -3706,6 +3757,19 @@ amd64_init_abi (struct gdbarch_info info, struct
> gdbarch *gdbarch,
> tdep->num_dword_regs = AMD64_NUM_DWORD_REGS;
> }
>
> + if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.amx") != nullptr)
> + {
> + tdep->tilecfg_raw_register_names = amd64_tilecfg_raw_names;
> + tdep->tilecfg_raw_regnum = AMD64_AMX_TILECFG_RAW_REGNUM;
> +
> + tdep->tilecfg_register_names = amd64_tilecfg_names;
tilecfg_register_names is configured but never used.
> + tdep->num_tilecfg_regs = 1;
> +
> + tdep->tmm_raw_register_names = amd64_tmm_raw_names;
> + tdep->tmm_raw_regnum = AMD64_AMX_TMM0_RAW_REGNUM;
> + tdep->num_tmm_raw_regs = 8;
> + }
> +
> /* Avoid wiring in the MMX registers for now. */
> tdep->num_mmx_regs = 0;
>
> @@ -3858,7 +3922,7 @@ const struct target_desc *
> amd64_target_description (uint64_t xstate_bv, bool segments)
> {
> static const_target_desc_up amd64_tdescs \
> - [2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*CET_U*/][2/*APX*/] \
> + [2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*CET_U*/][2/*APX*/][2/*AMX*/]
> \
> [2/*segments*/] = {};
> const_target_desc_up &tdesc
> = amd64_tdescs[(xstate_bv & X86_XSTATE_AVX) ? 1 : 0]
> @@ -3866,6 +3930,7 @@ amd64_target_description (uint64_t xstate_bv, bool
> segments)
> [(xstate_bv & X86_XSTATE_PKRU) ? 1 : 0]
> [(xstate_bv & X86_XSTATE_CET_U) ? 1 : 0]
> [(xstate_bv & X86_XSTATE_APX_F) ? 1 : 0]
> + [(xstate_bv & X86_XSTATE_AMX) ? 1 : 0]
> [segments ? 1 : 0];
>
> if (tdesc == nullptr)
> diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
> index 93b3cb61b17..02172ccfa14 100644
> --- a/gdb/amd64-tdep.h
> +++ b/gdb/amd64-tdep.h
> @@ -84,6 +84,9 @@ enum amd64_regnum
> AMD64_PL3_SSP_REGNUM,
> AMD64_R16_REGNUM,
> AMD64_R31_REGNUM = AMD64_R16_REGNUM + 15,
> + AMD64_AMX_TILECFG_RAW_REGNUM,
> + AMD64_AMX_TMM0_RAW_REGNUM,
> + AMD64_AMX_TMM7_RAW_REGNUM =
> AMD64_AMX_TMM0_RAW_REGNUM + 7,
> AMD64_FSBASE_REGNUM,
> AMD64_GSBASE_REGNUM
> };
> diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
> index 3992bbf512e..60932f420b3 100644
> --- a/gdb/arch/amd64.c
> +++ b/gdb/arch/amd64.c
> @@ -22,6 +22,7 @@
>
> #include "../features/i386/64bit-avx.c"
> #include "../features/i386/64bit-avx512.c"
> +#include "../features/i386/64bit-amx.c"
> #include "../features/i386/64bit-core.c"
> #include "../features/i386/64bit-apx.c"
> #include "../features/i386/64bit-linux.c"
> @@ -82,5 +83,8 @@ amd64_create_target_description (uint64_t xstate_bv,
> bool is_x32,
> if (xstate_bv & X86_XSTATE_APX_F)
> regnum = create_feature_i386_64bit_apx (tdesc.get (), regnum);
>
> + if (xstate_bv & X86_XSTATE_AMX)
> + regnum = create_feature_i386_64bit_amx (tdesc.get (), regnum);
> +
> return tdesc;
> }
> diff --git a/gdb/arch/x86-linux-tdesc-features.c b/gdb/arch/x86-linux-tdesc-
> features.c
> index 0191f326834..90722d4dd58 100644
> --- a/gdb/arch/x86-linux-tdesc-features.c
> +++ b/gdb/arch/x86-linux-tdesc-features.c
> @@ -66,6 +66,7 @@ struct x86_xstate_feature {
> static constexpr x86_xstate_feature x86_linux_all_xstate_features[] = {
> /* Feature, i386, amd64, x32. */
> { X86_XSTATE_APX_F, false, true, true },
> + { X86_XSTATE_AMX, false, true, true },
> { X86_XSTATE_CET_U, false, true, true },
> { X86_XSTATE_PKRU, true, true, true },
> { X86_XSTATE_AVX512, true, true, true },
> @@ -155,8 +156,8 @@ x86_linux_xstate_bv_to_tdesc_idx (uint64_t
> xstate_bv)
> represents the bit order within the generated index number.
>
> i386 | x87 sse avx avx512 pkru
> - amd64 | avx avx512 pkru
> - i32 | avx avx512 pkru
> + amd64 | avx avx512 pkru amx
> + i32 | avx avx512 pkru amx
>
> The features are ordered so that for each mode (i386, amd64, i32) the
> generated index will form a continuous range. */
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 53773780b56..9e3b6fca669 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -27448,6 +27448,41 @@ stack. @value{GDBN} corrects this value to
> avoid a control protection
> exception. For more details on displaced stepping, see @ref{displaced-
> stepping}.
> @end itemize
>
> +@subsubsection Intel Advanced Matrix Extensions
> +@cindex Intel Advanced Matrix Extensions
> +@cindex AMX, Intel
> +
> +Intel @dfn{Advanced Matrix Extensions} (@acronym{AMX}) add one 64-byte
> +@samp{tilecfg} register and eight 1024-byte tile registers @samp{tmm0},
> +@samp{tmm1}, @dots{}, @samp{tmm7} for amd64. The tile registers each
> +represent a matrix, whose dimensions are configured via @samp{tilecfg}.
> +Future platforms might also partition the register area of 8192 bytes
> +between a different number of tiles.
> +
> +@value{GDBN} provides a user-friendly view of the @samp{tilecfg} register,
> +omitting reserved bits. The tile registers are supplied as the raw registers
> +@samp{tmm0_raw}, @samp{tmm1_raw}, @dots{}, @samp{tmm7_raw},
> which show the
> +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:
> +
> +@smallexample
> +(gdb) print/x $tilecfg_raw
> +$1 =
> 0x10201000000000000000000000000000000000000000000000000000000
> 0c0
> + 00c000800000000000000000000000000000001
> +(gdb) print $tilecfg
> +$2 = @{palette = 1, start_row = 0, colsb = @{8, 12, 12, 0, 0, 0, 0, 0@},
> + rows = @{1, 2, 1, 0, 0, 0, 0, 0@}@}
> +(gdb) print $tmm1_raw
> +$3 = @{621397352980713455329738752,
> 932096029507240269422067969,
> + 0 <repeats 14 times>@}
> +(gdb) print/d (uint8_t[16][64]) $tmm1_raw
> +$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>@}
> +@end smallexample
> +
> @node Alpha
> @subsection Alpha
>
> @@ -50888,6 +50923,11 @@ The @samp{org.gnu.gdb.i386.apx} feature is
> optional. It should describe
> @samp{r16} - @samp{r31} with 64 bits each. All Intel @acronym{APX}
> registers are valid only on amd64.
>
> +The @samp{org.gnu.gdb.i386.amx} feature is optional. It should describe
> +one configuration register @samp{tilecfg_raw} that has 64 bytes, and the
> +eight tile registers @samp{tmm0_raw} @dots{} @samp{tmm7_raw}, each of
> which
> +has 1024 bytes. All Intel @acronym{AMX} registers are valid only for amd64.
> +
> @node LoongArch Features
> @subsection LoongArch Features
> @cindex target descriptions, LoongArch Features
> diff --git a/gdb/features/Makefile b/gdb/features/Makefile
> index 0ab24bca000..15e715aab70 100644
> --- a/gdb/features/Makefile
> +++ b/gdb/features/Makefile
> @@ -241,6 +241,7 @@ FEATURE_XMLFILES = aarch64-core.xml \
> i386/64bit-core.xml \
> i386/64bit-segments.xml \
> i386/64bit-avx.xml \
> + i386/64bit-amx.xml \
> i386/64bit-linux.xml \
> i386/64bit-sse.xml \
> i386/pkeys.xml \
> diff --git a/gdb/features/i386/64bit-amx.c b/gdb/features/i386/64bit-amx.c
> new file mode 100644
> index 00000000000..14779ec1fb7
> --- /dev/null
> +++ b/gdb/features/i386/64bit-amx.c
> @@ -0,0 +1,26 @@
> +/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
> + Original: 64bit-amx.xml */
> +
> +#include "gdbsupport/tdesc.h"
> +
> +static int
> +create_feature_i386_64bit_amx (struct target_desc *result, long regnum)
> +{
> + struct tdesc_feature *feature;
> +
> + feature = tdesc_create_feature (result, "org.gnu.gdb.i386.amx");
> + tdesc_type *element_type;
> + element_type = tdesc_named_type (feature, "uint512");
> + tdesc_create_vector (feature, "v_ui512", element_type, 16);
> +
> + tdesc_create_reg (feature, "tilecfg_raw", regnum++, 1, NULL, 512,
> "uint512");
> + tdesc_create_reg (feature, "tmm0_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm1_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm2_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm3_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm4_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm5_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm6_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm7_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + return regnum;
> +}
> diff --git a/gdb/features/i386/64bit-amx.xml b/gdb/features/i386/64bit-
> amx.xml
> new file mode 100644
> index 00000000000..a40c6c65f6d
> --- /dev/null
> +++ b/gdb/features/i386/64bit-amx.xml
> @@ -0,0 +1,26 @@
> +<?xml version="1.0"?>
> +<!-- Copyright (C) 2020-2026 Free Software Foundation, Inc.
> +
> + Copying and distribution of this file, with or without modification,
> + are permitted in any medium without royalty provided the copyright
> + notice and this notice are preserved. -->
> +
> +<!DOCTYPE feature SYSTEM "gdb-target.dtd">
> +<feature name="org.gnu.gdb.i386.amx">
> + <!-- One uint512 value per row of a tile. -->
> + <vector id="v_ui512" type="uint512" count="16"/>
> +
> + <!-- The raw contents of the tile configuration register. -->
> + <reg name="tilecfg_raw" bitsize="512" type="uint512"/>
> +
> + <!-- The raw contents of the eight tiles, each of which is 16 rows of
> + 64 bytes. -->
> + <reg name="tmm0_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm1_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm2_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm3_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm4_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm5_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm6_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm7_raw" bitsize="8192" type="v_ui512"/>
> +</feature>
> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
> index 071d8e004ae..a25abfbd1bc 100644
> --- a/gdb/i386-tdep.c
> +++ b/gdb/i386-tdep.c
> @@ -378,6 +378,34 @@ i386_pkru_regnum_p (struct gdbarch *gdbarch, int
> regnum)
> return regnum >= 0 && regnum < I387_NUM_PKEYS_REGS;
> }
>
> +/* AMX tilecfg register? */
> +
> +bool
> +i386_tilecfg_regnum_p (gdbarch *gdbarch, int regnum)
> +{
> + i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> + return regnum >= 0 && regnum == tdep->tilecfg_regnum;
> +}
> +
> +/* Raw AMX tile register? */
> +
> +bool
> +i386_tmm_raw_regnum_p (gdbarch *gdbarch, int regnum)
> +{
> + i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> + return (tdep->tmm_raw_regnum <= regnum
> + && regnum < tdep->tmm_raw_regnum + tdep-
> >num_tmm_raw_regs);
> +}
> +
> +/* AMX tilecfg_raw register? */
> +
> +static bool
> +i386_tilecfg_raw_regnum_p (gdbarch *gdbarch, int regnum)
> +{
> + i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> + return regnum >= 0 && regnum == tdep->tilecfg_raw_regnum;
> +}
> +
> /* Return the name of register REGNUM, or the empty string if it is
> an anonymous register. */
>
> @@ -3222,6 +3250,47 @@ i386_mmx_type (struct gdbarch *gdbarch)
> return tdep->i386_mmx_type;
> }
>
> +/* The type of the TILECFG registers. */
> +
> +static type *
> +i386_tilecfg_type (gdbarch *gdbarch)
> +{
> + i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> +
> + if (!tdep->i386_tilecfg_type)
> + {
> + const struct builtin_type *bt = builtin_type (gdbarch);
> +
> + /* The type we're building is this:
> +
> + struct __gdb_builtin_type_tilecfg
> + {
> + uint8_t palette;
> + uint8_t start_row;
> + uint16_t colsb[8];
> + uint8_t rows[8];
> + };
> +
> + Bytes 2-15, 32-47 and 56-63 of the register are reserved, so the
> + colsb and rows arrays are packed together here. */
> +
> + type *t = arch_composite_type (gdbarch, "builtin_type_tilecfg",
> + TYPE_CODE_STRUCT);
> +
> + append_composite_type_field (t, "palette", bt->builtin_uint8);
> + append_composite_type_field (t, "start_row", bt->builtin_uint8);
> + append_composite_type_field
> + (t, "colsb", lookup_array_range_type (bt->builtin_uint16, 0, 7));
> + append_composite_type_field
> + (t, "rows", lookup_array_range_type (bt->builtin_uint8, 0, 7));
> +
> + t->set_name ("builtin_type_tilecfg");
> + tdep->i386_tilecfg_type = t;
> + }
> +
> + return tdep->i386_tilecfg_type;
> +}
> +
> /* Return the GDB type object for the "standard" data type of data in
> register REGNUM. */
>
> @@ -3236,6 +3305,8 @@ i386_pseudo_register_type (struct gdbarch
> *gdbarch, int regnum)
> return i386_ymm_type (gdbarch);
> else if (i386_zmm_regnum_p (gdbarch, regnum))
> return i386_zmm_type (gdbarch);
> + else if (i386_tilecfg_regnum_p (gdbarch, regnum))
> + return i386_tilecfg_type (gdbarch);
> else
> {
> const struct builtin_type *bt = builtin_type (gdbarch);
> @@ -4269,7 +4340,8 @@ i386_register_reggroup_p (struct gdbarch *gdbarch,
> int regnum,
> int fp_regnum_p, mmx_regnum_p, xmm_regnum_p, mxcsr_regnum_p,
> ymm_regnum_p, ymmh_regnum_p, ymm_avx512_regnum_p,
> ymmh_avx512_regnum_p,
> zmm_regnum_p, zmmh_regnum_p, xmm_avx512_regnum_p, avx512_p,
> avx_p,
> - sse_p, pkru_regnum_p;
> + sse_p, pkru_regnum_p, tilecfg_regnum_p, tmm_raw_regnum_p,
> + tilecfg_raw_regnum_p;
>
> /* Don't include pseudo registers, except for MMX, in any register
> groups. */
> @@ -4296,6 +4368,9 @@ i386_register_reggroup_p (struct gdbarch *gdbarch,
> int regnum,
> ymm_regnum_p = i386_ymm_regnum_p (gdbarch, regnum);
> ymm_avx512_regnum_p = i386_ymm_avx512_regnum_p (gdbarch, regnum);
> zmm_regnum_p = i386_zmm_regnum_p (gdbarch, regnum);
> + tmm_raw_regnum_p = i386_tmm_raw_regnum_p (gdbarch, regnum);
> + tilecfg_regnum_p = i386_tilecfg_regnum_p (gdbarch, regnum);
> + tilecfg_raw_regnum_p = i386_tilecfg_raw_regnum_p (gdbarch, regnum);
>
> avx512_p = ((tdep->xcr0 & X86_XSTATE_AVX_AVX512_MASK)
> == X86_XSTATE_AVX_AVX512_MASK);
> @@ -4329,6 +4404,11 @@ i386_register_reggroup_p (struct gdbarch
> *gdbarch, int regnum,
> || zmmh_regnum_p))
> return false;
>
> + /* For "info reg all", don't include the raw Intel AMX registers. */
> + if (group == all_reggroup
> + && (tmm_raw_regnum_p || tilecfg_raw_regnum_p))
> + return false;
> +
> if (group == general_reggroup)
> return (!fp_regnum_p
> && !mmx_regnum_p
> @@ -4341,7 +4421,10 @@ i386_register_reggroup_p (struct gdbarch
> *gdbarch, int regnum,
> && !ymmh_avx512_regnum_p
> && !zmm_regnum_p
> && !zmmh_regnum_p
> - && !pkru_regnum_p);
> + && !pkru_regnum_p
> + && !tmm_raw_regnum_p
> + && !tilecfg_regnum_p
> + && !tilecfg_raw_regnum_p);
>
> return default_register_reggroup_p (gdbarch, regnum, group);
> }
> @@ -8520,7 +8603,7 @@ i386_xcr0_from_tdesc (const struct target_desc
> *tdesc)
>
> const struct tdesc_feature *feature_sse, *feature_avx,
> *feature_avx512, *feature_pkeys,
> - *feature_apx;
> + *feature_apx, *feature_amx;
>
> /* Get core registers. */
> feature_core = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.core");
> @@ -8542,6 +8625,9 @@ i386_xcr0_from_tdesc (const struct target_desc
> *tdesc)
> /* Try PKEYS */
> feature_pkeys = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pkeys");
>
> + /* Try Intel AMX. */
> + feature_amx = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.amx");
> +
> /* The XCR0 bits. */
> uint64_t xcr0 = X86_XSTATE_X87;
>
> @@ -8572,6 +8658,9 @@ i386_xcr0_from_tdesc (const struct target_desc
> *tdesc)
> if (feature_pkeys)
> xcr0 |= X86_XSTATE_PKRU;
>
> + if (feature_amx)
> + xcr0 |= X86_XSTATE_AMX;
> +
> return xcr0;
> }
>
> @@ -8584,7 +8673,7 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
>
> const struct tdesc_feature *feature_sse, *feature_avx, *feature_avx512,
> *feature_pkeys, *feature_segments,
> - *feature_pl3_ssp, *feature_apx;
> + *feature_pl3_ssp, *feature_apx, *feature_amx;
> int i, num_regs, valid_p;
>
> if (! tdesc_has_registers (tdesc))
> @@ -8616,6 +8705,9 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
> /* Try Shadow Stack. */
> feature_pl3_ssp = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pl3_ssp");
>
> + /* Try Intel AMX. */
> + feature_amx = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.amx");
> +
> valid_p = 1;
>
> /* The XCR0 bits. */
> @@ -8752,6 +8844,26 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
> tdep->ssp_regnum, "pl3_ssp");
> }
>
> + if (feature_amx != nullptr
> + && tdep->tilecfg_raw_regnum != -1
> + && tdep->tilecfg_raw_register_names != nullptr
> + && tdep->tmm_raw_regnum != -1
> + && tdep->tmm_raw_register_names != nullptr)
> + {
> + tdep->xcr0 |= X86_XSTATE_TILECFG;
> +
> + valid_p &= tdesc_numbered_register (feature_amx, tdesc_data,
> + tdep->tilecfg_raw_regnum,
> + tdep-
> >tilecfg_raw_register_names[0]);
> +
> + tdep->xcr0 |= X86_XSTATE_TILEDATA;
> +
> + for (i = 0; i < tdep->num_tmm_raw_regs; i++)
> + valid_p &= tdesc_numbered_register (feature_amx, tdesc_data,
> + tdep->tmm_raw_regnum + i,
> + tdep->tmm_raw_register_names[i]);
> + }
> +
> return valid_p;
> }
>
> @@ -9010,7 +9122,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct
> gdbarch_list *arches)
> + tdep->num_mmx_regs
> + tdep->num_ymm_regs
> + tdep->num_ymm_avx512_regs
> - + tdep->num_zmm_regs));
> + + tdep->num_zmm_regs
> + + tdep->num_tilecfg_regs));
>
> /* Target description may be changed. */
> tdesc = tdep->tdesc;
> @@ -9062,6 +9175,15 @@ i386_gdbarch_init (struct gdbarch_info info, struct
> gdbarch_list *arches)
> else
> tdep->zmm0_regnum = -1;
>
> + if (tdep->num_tilecfg_regs != 0)
> + {
> + /* Support TILECFG pseudo-register if it is available. */
> + tdep->tilecfg_regnum = mm0_regnum;
> + mm0_regnum += tdep->num_tilecfg_regs;
> + }
> + else
> + tdep->tilecfg_regnum = -1;
> +
> if (tdep->num_mmx_regs != 0)
> {
> /* Support MMX pseudo-register if MMX hasn't been disabled. */
> diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
> index bdafd523834..898a76dfb50 100644
> --- a/gdb/i386-tdep.h
> +++ b/gdb/i386-tdep.h
> @@ -225,6 +225,26 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
> set this to a value >= 0. */
> int ssp_regnum = -1;
>
> + /* Register number for the raw tilecfg register and the tilecfg pseudo
> + register. If supported, set them to a value >= 0. */
> + int tilecfg_regnum = -1;
> + int tilecfg_raw_regnum = -1;
> +
> + /* Number of tilecfg registers, including pseudo register. */
> + int num_tilecfg_regs = 0;
> +
> + /* Register number for the first raw tile register, tmm0_raw. If supported,
> + set this to a value >= 0. */
> + int tmm_raw_regnum = -1;
> +
> + /* Number of raw tile registers. */
> + int num_tmm_raw_regs = 0;
> +
> + /* Intel AMX register names. */
> + const char * const *tilecfg_raw_register_names = nullptr;
> + const char * const *tilecfg_register_names = nullptr;
> + const char * const *tmm_raw_register_names = nullptr;
> +
> /* Register number for %fsbase. If supported, set this to a value
> >= 0. */
> int fsbase_regnum = -1;
> @@ -265,6 +285,7 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
> struct type *i386_ymm_type = nullptr;
> struct type *i386_zmm_type = nullptr;
> struct type *i387_ext_type = nullptr;
> + type *i386_tilecfg_type = nullptr;
>
> /* If the registers containing the i386 Linux TLS related global
> descriptor table information are available. This is used to decide
> @@ -379,7 +400,7 @@ enum record_i386_regnum
> #define I386_NUM_XREGS 9
>
> /* Size of the largest register. */
> -#define I386_MAX_REGISTER_SIZE 64
> +#define I386_MAX_REGISTER_SIZE 1024
>
> /* Types for i386-specific registers. */
> extern struct type *i387_ext_type (struct gdbarch *gdbarch);
> @@ -396,6 +417,8 @@ extern int i386_k_regnum_p (struct gdbarch *gdbarch,
> int regnum);
> extern int i386_zmm_regnum_p (struct gdbarch *gdbarch, int regnum);
> extern int i386_zmmh_regnum_p (struct gdbarch *gdbarch, int regnum);
> extern bool i386_pkru_regnum_p (struct gdbarch *gdbarch, int regnum);
> +extern bool i386_tilecfg_regnum_p (gdbarch *gdbarch, int regnum);
> +extern bool i386_tmm_raw_regnum_p (gdbarch *gdbarch, int regnum);
>
> extern const char *i386_pseudo_register_name (struct gdbarch *gdbarch,
> int regnum);
> diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
> index 8f972338b3d..e7b4b53462f 100644
> --- a/gdb/i387-tdep.c
> +++ b/gdb/i387-tdep.c
> @@ -939,6 +939,30 @@ static int xsave_pkeys_offset[] =
> (xsave + (tdep)->xsave_layout.pkru_offset \
> + xsave_pkeys_offset[regnum - I387_PKRU_REGNUM (tdep)])
>
> +static int xsave_tilecfg_raw_offset[] =
> +{
> + 0 * 64 /* tilecfg. */
> +};
> +
> +#define XSAVE_TILECFG_RAW_ADDR(tdep, xsave, regnum) \
> + (xsave + (tdep)->xsave_layout.tilecfg_offset \
> + + xsave_tilecfg_raw_offset[regnum - I387_TILECFG_RAW_REGNUM (tdep)])
> +
> +static int xsave_tmm_raw_offset[] =
> +{
> + 0 * X86_AMX_TMM_SIZE, /* tmm0_raw. */
> + 1 * X86_AMX_TMM_SIZE, /* tmm1_raw. */
> + 2 * X86_AMX_TMM_SIZE, /* tmm2_raw. */
> + 3 * X86_AMX_TMM_SIZE, /* tmm3_raw. */
> + 4 * X86_AMX_TMM_SIZE, /* tmm4_raw. */
> + 5 * X86_AMX_TMM_SIZE, /* tmm5_raw. */
> + 6 * X86_AMX_TMM_SIZE, /* tmm6_raw. */
> + 7 * X86_AMX_TMM_SIZE, /* tmm7_raw. */
> +};
> +
> +#define XSAVE_TMM_RAW_ADDR(tdep, xsave, regnum) \
> + (xsave + (tdep)->xsave_layout.tiledata_offset \
> + + xsave_tmm_raw_offset[regnum - I387_TMM0_RAW_REGNUM (tdep)])
>
> /* See i387-tdep.h. */
>
> @@ -946,14 +970,40 @@ bool
> i387_guess_xsave_layout (uint64_t xcr0, size_t xsave_size,
> x86_xsave_layout &layout)
> {
> - if (HAS_PKRU (xcr0) && (xsave_size == 2696 || xsave_size == 11008))
> + if (HAS_AMX (xcr0) && xsave_size == 11008)
> + {
> + /* Intel CPUs supporting AMX. */
> + layout.avx_offset = 576;
> + layout.apx_offset = 960;
> + layout.k_offset = 1088;
> + layout.zmm_h_offset = 1152;
> + layout.zmm_offset = 1664;
> + layout.pkru_offset = 2688;
> + layout.tilecfg_offset = 2752;
> + layout.tiledata_offset = 2816;
> + }
> + else if (HAS_PKRU (xcr0) && (xsave_size == 2696 || xsave_size == 11008))
> {
> /* Intel CPUs supporting PKRU.
> - GDB does not yet support Intel AMX, but CPUs with AMX have
> - a larger XSAVE_SIZE (11008). We must handle this size here,
> - otherwise we cannot read any xsave registers from OS generated
> - core files on AMX systems. The AMX registers themselves will
> - still not be readable though. */
> +
> + XCR0 in core files generated by the gcore command in GDB is based on
> + tdep->xcr0, which i387_collect_xsave writes. tdep->xcr0 is derived
> + from the target description, which does not contain Intel AMX for a
> + 32-bit debuggee.
> +
> + For remote targets, core files generated by the gcore command have
> an
> + XSAVE size based on i387_fallback_xsave_layout, which is therefore
> + only 2696 bytes for a 32-bit debuggee.
> +
> + Native targets derive the XSAVE layout from the XCR0 as reported by
> + the kernel, see x86_linux_tdesc_for_tid. It has the full XSAVE size
> + of 11008 bytes on systems with Intel AMX. For a 32-bit debuggee,
> + tdep->xcr0 does not include Intel AMX, see i386_validate_tdesc_p,
> + while i386_gdbarch_init still stores the native layout in
> + tdep->xsave_layout. The gcore command writes the XSAVE note with
> that
> + size and with tdep->xcr0, e.g. with XCR0 0x2e7 and 11008 bytes.
> + Thus, we must also accept an XSAVE size of 11008 bytes here, to avoid
> + a warning about an unexpected XSAVE size. */
> layout.avx_offset = 576;
> /* Intel APX can be available on CPUs supporting Intel PKRU with or
> without Intel AMX support. */
> @@ -1004,7 +1054,20 @@ i387_fallback_xsave_layout (uint64_t xcr0)
> {
> x86_xsave_layout layout;
>
> - if (HAS_PKRU (xcr0))
> + if (HAS_AMX (xcr0))
> + {
> + /* Intel CPUs supporting AMX. */
> + layout.avx_offset = 576;
> + layout.apx_offset = 960;
> + layout.k_offset = 1088;
> + layout.zmm_h_offset = 1152;
> + layout.zmm_offset = 1664;
> + layout.pkru_offset = 2688;
> + layout.tilecfg_offset = 2752;
> + layout.tiledata_offset = 2816;
> + layout.sizeof_xsave = 11008;
> + }
> + else if (HAS_PKRU (xcr0))
> {
> /* Intel CPUs supporting PKRU. */
> layout.avx_offset = 576;
> @@ -1086,8 +1149,11 @@ i387_supply_xsave (struct regcache *regcache, int
> regnum,
> avx512_xmm_avx512 = 0x80,
> pkeys = 0x100,
> apx = 0x200,
> + tilecfg_raw = 0x400,
> + tmm_raw = 0x800,
> all = x87 | sse | avxh | avx512_k | avx512_zmm0_h | avx512_zmm16_h
> | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys | apx
> + | tilecfg_raw | tmm_raw
> } regclass;
>
> gdb_assert (regs != NULL);
> @@ -1099,6 +1165,11 @@ i387_supply_xsave (struct regcache *regcache, int
> regnum,
> else if (regnum >= I387_R16_REGNUM (tdep)
> && regnum < I387_APX_END_REGNUM (tdep))
> regclass = apx;
> + else if (regnum == I387_TILECFG_RAW_REGNUM (tdep))
> + regclass = tilecfg_raw;
> + else if (regnum >= I387_TMM0_RAW_REGNUM (tdep)
> + && regnum < I387_TMMEND_RAW_REGNUM (tdep))
> + regclass = tmm_raw;
> else if (regnum >= I387_PKRU_REGNUM (tdep)
> && regnum < I387_PKEYSEND_REGNUM (tdep))
> regclass = pkeys;
> @@ -1152,6 +1223,21 @@ i387_supply_xsave (struct regcache *regcache, int
> regnum,
> regcache->raw_supply (regnum, XSAVE_APX_EGPR_ADDR (tdep, regs,
> regnum));
> return;
>
> + case tilecfg_raw:
> + if ((clear_bv & X86_XSTATE_TILECFG))
> + regcache->raw_supply_zeroed (regnum);
> + else
> + regcache->raw_supply (regnum,
> + XSAVE_TILECFG_RAW_ADDR (tdep, regs, regnum));
> + return;
> +
> + case tmm_raw:
> + if ((clear_bv & X86_XSTATE_TILEDATA))
> + regcache->raw_supply_zeroed (regnum);
> + else
> + regcache->raw_supply (regnum, XSAVE_TMM_RAW_ADDR (tdep, regs,
> regnum));
> + return;
> +
> case pkeys:
> if ((clear_bv & X86_XSTATE_PKRU))
> regcache->raw_supply_zeroed (regnum);
> @@ -1346,6 +1432,32 @@ i387_supply_xsave (struct regcache *regcache, int
> regnum,
> }
> }
>
> + /* Handle the tilecfg register. */
> + if ((tdep->xcr0 & X86_XSTATE_TILECFG) != 0)
> + {
> + if ((clear_bv & X86_XSTATE_TILECFG) != 0)
> + regcache->raw_supply_zeroed (I387_TILECFG_RAW_REGNUM
> (tdep));
> + else
> + {
> + i = I387_TILECFG_RAW_REGNUM (tdep);
> + regcache->raw_supply (i,
> + XSAVE_TILECFG_RAW_ADDR (tdep, regs, i));
> + }
> + }
> +
> + /* Handle the raw tile registers. */
> + if ((tdep->xcr0 & X86_XSTATE_TILEDATA) != 0)
> + {
> + for (i = I387_TMM0_RAW_REGNUM (tdep);
> + i < I387_TMMEND_RAW_REGNUM (tdep); i++)
> + {
> + if ((clear_bv & X86_XSTATE_TILEDATA) != 0)
> + regcache->raw_supply_zeroed (i);
> + else
> + regcache->raw_supply (i, XSAVE_TMM_RAW_ADDR (tdep, regs,
> i));
> + }
> + }
> +
> /* Handle the XMM registers. */
> if ((tdep->xcr0 & X86_XSTATE_SSE))
> {
> @@ -1505,8 +1617,11 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
> avx512_xmm_avx512 = 0x100,
> pkeys = 0x200,
> apx = 0x400,
> + tilecfg = 0x800,
> + tmm_raw = 0x1000,
> all = x87 | sse | avxh | avx512_k | avx512_zmm0_h | avx512_zmm16_h
> - | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys | apx
> + | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys | apx |
> tilecfg
> + | tmm_raw
> } regclass;
>
> gdb_assert (tdep->st0_regnum >= I386_ST0_REGNUM);
> @@ -1517,6 +1632,11 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
> else if (regnum >= I387_R16_REGNUM (tdep)
> && regnum < I387_APX_END_REGNUM (tdep))
> regclass = apx;
> + else if (regnum == I387_TILECFG_RAW_REGNUM (tdep))
> + regclass = tilecfg;
> + else if (regnum >= I387_TMM0_RAW_REGNUM (tdep)
> + && regnum < I387_TMMEND_RAW_REGNUM (tdep))
> + regclass = tmm_raw;
> else if (regnum >= I387_PKRU_REGNUM (tdep)
> && regnum < I387_PKEYSEND_REGNUM (tdep))
> regclass = pkeys;
> @@ -1589,6 +1709,19 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
> memset (XSAVE_APX_EGPR_ADDR (tdep, regs, i), 0, 8);
> }
>
> + if ((clear_bv & X86_XSTATE_TILECFG))
> + {
> + i = I387_TILECFG_RAW_REGNUM (tdep);
> + memset (XSAVE_TILECFG_RAW_ADDR (tdep, regs, i), 0, 64);
> + }
> +
> + if ((clear_bv & X86_XSTATE_TILEDATA))
> + {
> + i = I387_TMM0_RAW_REGNUM (tdep);
> + memset (XSAVE_TMM_RAW_ADDR (tdep, regs, i), 0,
> + X86_AMX_TILEDATA_SIZE);
> + }
> +
> if ((clear_bv & X86_XSTATE_PKRU))
> for (i = I387_PKRU_REGNUM (tdep);
> i < I387_PKEYSEND_REGNUM (tdep); i++)
> @@ -1672,6 +1805,33 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
> }
> }
>
> + /* Check if the tilecfg register is changed. */
> + if ((tdep->xcr0 & X86_XSTATE_TILECFG))
> + {
> + i = I387_TILECFG_RAW_REGNUM (tdep);
> + regcache->raw_collect (i, raw);
> + p = XSAVE_TILECFG_RAW_ADDR (tdep, regs, i);
> + if (memcmp (raw, p, 64) != 0)
> + {
> + xstate_bv |= X86_XSTATE_TILECFG;
> + memcpy (p, raw, 64);
> + }
> + }
> +
> + /* Check if any raw tile register is changed. */
> + if ((tdep->xcr0 & X86_XSTATE_TILEDATA))
> + for (i = I387_TMM0_RAW_REGNUM (tdep);
> + i < I387_TMMEND_RAW_REGNUM (tdep); i++)
> + {
> + regcache->raw_collect (i, raw);
> + p = XSAVE_TMM_RAW_ADDR (tdep, regs, i);
> + if (memcmp (raw, p, X86_AMX_TMM_SIZE) != 0)
> + {
> + xstate_bv |= X86_XSTATE_TILEDATA;
> + memcpy (p, raw, X86_AMX_TMM_SIZE);
> + }
> + }
> +
> /* Check if any PKEYS registers are changed. */
> if ((tdep->xcr0 & X86_XSTATE_PKRU))
> for (i = I387_PKRU_REGNUM (tdep);
> @@ -1814,6 +1974,16 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
> }
> }
> }
> + else if (regclass == tmm_raw)
> + {
> + regcache->raw_collect (regnum, raw);
> + p = XSAVE_TMM_RAW_ADDR (tdep, regs, regnum);
> + if (memcmp (raw, p, 1024) != 0)
> + {
> + xstate_bv |= X86_XSTATE_TILEDATA;
> + memcpy (p, raw, 1024);
> + }
> + }
> else
> {
> /* Check if REGNUM is changed. */
> @@ -1834,6 +2004,16 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
> }
> break;
>
> + case tilecfg:
> + /* This is a tilecfg register. */
> + p = XSAVE_TILECFG_RAW_ADDR (tdep, regs, regnum);
> + if (memcmp (raw, p, 64) != 0)
> + {
> + xstate_bv |= X86_XSTATE_TILECFG;
> + memcpy (p, raw, 64);
> + }
> + break;
> +
> case pkeys:
> /* This is a PKEYS register. */
> p = XSAVE_PKEYS_ADDR (tdep, regs, regnum);
> diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h
> index f029c1e5119..6055b122cba 100644
> --- a/gdb/i387-tdep.h
> +++ b/gdb/i387-tdep.h
> @@ -43,14 +43,18 @@ struct x86_xsave_layout;
> /* Set of constants used for 32 and 64-bit. */
> #define I387_NUM_K_REGS 8
> #define I387_NUM_PKEYS_REGS 1
> +#define I387_NUM_TILECFG_REGS 1
This define is unused.
> #define I387_PKRU_REGNUM(tdep) ((tdep)->pkru_regnum)
> #define I387_K0_REGNUM(tdep) ((tdep)->k0_regnum)
> #define I387_NUM_ZMMH_REGS(tdep) ((tdep)->num_zmm_regs)
> +#define I387_NUM_TMM_RAW_REGS(tdep) ((tdep)->num_tmm_raw_regs)
> #define I387_ZMM0H_REGNUM(tdep) ((tdep)->zmm0h_regnum)
> #define I387_ZMM16H_REGNUM(tdep) ((tdep)->zmm0h_regnum + 16)
> #define I387_NUM_YMM_AVX512_REGS(tdep) ((tdep)-
> >num_ymm_avx512_regs)
> #define I387_YMM16H_REGNUM(tdep) ((tdep)->ymm16h_regnum)
> +#define I387_TILECFG_RAW_REGNUM(tdep) ((tdep)->tilecfg_raw_regnum)
> +#define I387_TMM0_RAW_REGNUM(tdep) ((tdep)->tmm_raw_regnum)
>
> #define I387_FCTRL_REGNUM(tdep) (I387_ST0_REGNUM (tdep) + 8)
> #define I387_FSTAT_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 1)
> @@ -83,6 +87,8 @@ struct x86_xsave_layout;
>
> #define I387_PKEYSEND_REGNUM(tdep) \
> (I387_PKRU_REGNUM (tdep) + I387_NUM_PKEYS_REGS)
> +#define I387_TMMEND_RAW_REGNUM(tdep) \
> + (I387_TMM0_RAW_REGNUM (tdep) + I387_NUM_TMM_RAW_REGS (tdep))
>
> /* Print out the i387 floating point state. */
>
> diff --git a/gdb/nat/x86-xstate.c b/gdb/nat/x86-xstate.c
> index f0f0b00e859..75719b98746 100644
> --- a/gdb/nat/x86-xstate.c
> +++ b/gdb/nat/x86-xstate.c
> @@ -61,5 +61,7 @@ x86_fetch_xsave_layout (uint64_t xcr0, int len)
> layout.zmm_h_offset = xsave_feature_offset (xcr0, X86_XSTATE_ZMM_H_ID);
> layout.zmm_offset = xsave_feature_offset (xcr0, X86_XSTATE_ZMM_ID);
> layout.pkru_offset = xsave_feature_offset (xcr0, X86_XSTATE_PKRU_ID);
> + layout.tilecfg_offset = xsave_feature_offset (xcr0, X86_XSTATE_TILECFG_ID);
> + layout.tiledata_offset = xsave_feature_offset (xcr0,
> X86_XSTATE_TILEDATA_ID);
> return layout;
> }
> diff --git a/gdb/target-debug.h b/gdb/target-debug.h
> index 949847b181c..9e096a18b7b 100644
> --- a/gdb/target-debug.h
> +++ b/gdb/target-debug.h
> @@ -381,6 +381,8 @@ target_debug_print_x86_xsave_layout (const
> x86_xsave_layout &layout)
> POFFS(zmm);
> POFFS(pkru);
> POFFS(apx);
> + POFFS(tilecfg);
> + POFFS(tiledata);
>
> #undef POFFS
>
> diff --git a/gdb/testsuite/gdb.arch/amd64-amx.c
> b/gdb/testsuite/gdb.arch/amd64-amx.c
> new file mode 100644
> index 00000000000..5dca29ad183
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/amd64-amx.c
> @@ -0,0 +1,115 @@
> +/* Test program for Intel AMX registers.
> +
> + Copyright 2022-2026 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 <immintrin.h>
> +#include <stdint.h>
> +
> +#include "amd64-amx.h"
> +
> +#define TILE int
> +
> +#define N 2
> +#define K 3
> +#define M 4
> +
> +uint8_t memA[N][4 * K] = { { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2 },
> + { 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 } };
> +
> +uint8_t memB[K][4 * M] = {
> + { 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 },
> +};
> +
> +uint32_t memC[N][M] = { 0 };
> +
> +/* Data for type testing. */
> +
> +int8_t int8_matrix[2][8] = { { -1, -1, -1, -1, 1, 1, 1, 1 },
> + { 1, 1, 1, 1, -5, -5, -5, -5 } };
> +
> +float fp32_matrix[2][2] = { { 1.0, 1.125 },
> + { 1.25, 1.375 } };
> +
> +
> +static void
> +tfmaps_calc (void)
> +{
> + const int strideA = 4 * K;
> + const int strideB = 4 * M;
> + const int strideC = 4 * M;
> +
> + /* Configure. */
> + struct tileconfig_t
> + {
> + uint8_t palette_id;
> + uint8_t startRow;
> + uint8_t reserved[14];
> + uint16_t cols[16];
> + uint8_t rows[16];
> + };
> +
> + struct tileconfig_t tc = { 1 };
> +
> + const TILE A = 0;
> + const TILE B = 1;
> + const TILE C = 2;
> +
> + tc.rows[A] = N;
> + tc.cols[A] = K * 4;
> + tc.rows[B] = K;
> + tc.cols[B] = M * 4;
> + tc.rows[C] = N;
> + tc.cols[C] = M * 4;
> +
> + /* Tiles for testing the remaining element types. */
> + tc.rows[4] = 2;
> + tc.cols[4] = 8;
> + tc.rows[5] = 2;
> + tc.cols[5] = 8;
> +
> + _tile_loadconfig (&tc);
> +
> + /* Load additional types for type testing. */
> + _tile_loadd (4, fp32_matrix, 2 * 4);
> + _tile_loadd (5, int8_matrix, 4 * 2);
> +
> + /* Computation. */
> + _tile_loadd (0, memA, strideA);
> + _tile_loadd (1, memB, strideB);
> + _tile_dpbuud (2, 0, 1);
> + _tile_stored (2, memC, strideC);
> +
> + /* Provoke a SIGSEGV while the tiles are still live, so that the OS
> + writes a core file containing them. */
> + *(volatile int *) 0; /* Crash. */
> +}
> +
> +
> +int
> +main (void)
> +{
> + /* Ask the OS to configure Intel AMX in xsave. */
> + if (amx_enable () != 0)
> + return -1;
> +
> + tfmaps_calc ();
> +
> + return 0;
> +}
> diff --git a/gdb/testsuite/gdb.arch/amd64-amx.exp
> b/gdb/testsuite/gdb.arch/amd64-amx.exp
> new file mode 100644
> index 00000000000..af92e2d37a0
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/amd64-amx.exp
> @@ -0,0 +1,192 @@
> +# Copyright 2022-2026 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/>.
> +
> +# This file tests basic Intel AMX functionality. The raw tile registers
> +# always show a tile with its maximum dimensions, that is 16 rows of 64
> bytes.
> +# Only the elements configured in $tilecfg hold data.
I'd drop the last sentence. We can write to a tile with GDB even though the dimensions
in $tilecfg are 0 for that tile. This also applies to the sentence in the commit message.
> +require allow_amx_tests
> +
> +standard_testfile
> +if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
> + {debug additional_flags=-mamx-tile additional_flags=-mamx-int8}]} {
> + return
> +}
> +
> +if {![runto_main]} {
> + return
> +}
> +
> +proc test_zeroed_tile {reg} {
> + gdb_test "print/d (uint8_t\[16\]\[64\]) $reg" \
> + "= \\{\\{0 <repeats 64 times>\\} <repeats 16 times>\\}"
> +}
> +
> +# Check the tile registers as loaded by the program at the "Crash" line.
> +
> +proc test_loaded_tiles {} {
> + gdb_test "print/x \$tilecfg_raw" \
> + [join {"= 0x20200020302000000000000000000000000000000000" \
> +
> "000000000080008000000100010000c000000000000000000000000000000
> 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}}"]
> +
> + gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm0_raw" \
> + [join {"= \\{\\{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_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>\\}" \
> + "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4,\
> + 0 <repeats 48 times>\\}" \
> + "\\{2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,\
> + 0 <repeats 48 times>\\}" \
> + "\\{0 <repeats 64 times>\\} <repeats 13 times>\\}"} \
> + ", "]
> +
> + 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 (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/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} {
> + test_zeroed_tile "\$tmm${i}_raw"
> + }
> +}
> +
> +# Restart gdb, load the core file generated by gcore or the OS
> +# and check reading registers from the core file.
> +
> +proc test_corefile {core_filename} {
> + clean_restart $::testfile
> +
> + gdb_test "core $core_filename" "Core was generated by .*" \
> + "load core file"
> +
> + test_loaded_tiles
> +}
> +
> +# Registers should be displayed as zeroed before Intel AMX enablement.
> +with_test_prefix "before Intel AMX is enabled" {
> + gdb_test "print \$tilecfg_raw" "= 0"
> + for {set i 0} {$i < 8} {incr i} {
> + test_zeroed_tile "\$tmm${i}_raw"
> + }
> +}
> +
> +# Continue until the program provokes a SIGSEGV. This is required to test
> +# reading tile registers from the OS generated core file below.
> +set line [gdb_get_line_number "Crash"]
> +gdb_breakpoint $line
> +gdb_continue_to_breakpoint "tiles are loaded" ".*$srcfile:$line.*"
> +
> +with_test_prefix "read tiles" {
> + test_loaded_tiles
> +}
> +
> +# Write a core file before modifying the tile registers.
> +set gcorefile $binfile.gcore
> +set gcore_generated [gdb_gcore_cmd $gcorefile "save a core file"]
> +
> +# Test setting tiles.
> +with_test_prefix "setting tiles" {
> + 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>\\}"} \
> + ", "]
> +
> + 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>\\}"} \
> + ", "]
> +
> + 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_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"
> +}
> +
> +# Test generic setting.
> +with_test_prefix "set tilecfg raw" {
> + gdb_test_no_output "set \$tilecfg_raw = 0"
> + gdb_test_no_output "set \$tilecfg.palette = 1"
> +
> + gdb_test "print/x \$tilecfg_raw" "= 0x1"
> + gdb_test "print \$tilecfg" \
> + [string_to_regexp "= {palette = 1, start_row = 0,\
> + colsb = {0, 0, 0, 0, 0, 0, 0, 0}, rows = {0, 0, 0, 0, 0, 0, 0, 0}}"]
> +}
> +
Nit: you exceed 80 characters (also below)
> +with_test_prefix "set tilecfg" {
> + gdb_test_no_output "set \$tilecfg.palette = 0x2"
> + gdb_test_no_output "set \$tilecfg.start_row = 0x3"
> + gdb_test_no_output "set \$tilecfg.rows\[0\] = 0x4"
> +
> + gdb_test "print/x \$tilecfg_raw" \
> + [join {"= 0x40000000000000000000000000000000000000000000" \
> +
> "00000000000000000000000000000000000000000000000000302"} ""]
> + gdb_test "print \$tilecfg" \
> + [string_to_regexp "= {palette = 2, start_row = 3,\
> + colsb = {0, 0, 0, 0, 0, 0, 0, 0}, rows = {4, 0, 0, 0, 0, 0, 0, 0}}"]
> +}
> +
> +# 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} {
> + with_test_prefix "gcore core file" {
> + test_corefile $gcorefile
> + }
> +}
> +
> +# Like the above, but test the core file generated by the OS.
> +with_test_prefix "OS generated core file" {
> + # This test relies on reading address zero triggering a SIGSEGV.
> + # If address zero is readable skip this test.
> + if {[is_address_zero_readable]} {
> + unsupported "address zero is readable"
> + } else {
> + set corefile [core_find $binfile]
> + if {$corefile eq ""} {
> + unsupported "unable to generate core file"
> + } else {
> + test_corefile $corefile
> + }
> + }
> +}
We only check that we don't print the group checks with "info registers" in the user
regs patch, even though the handling for the registers introduced in this patch is here.
I think it would make sense to move these tests here, too.
> diff --git a/gdb/testsuite/lib/amd64-amx.h b/gdb/testsuite/lib/amd64-amx.h
> new file mode 100644
> index 00000000000..4b2d0b7ba71
> --- /dev/null
> +++ b/gdb/testsuite/lib/amd64-amx.h
> @@ -0,0 +1,41 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> + Copyright 2026 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/>. */
> +
> +#ifndef AMD64_AMX_H
> +#define AMD64_AMX_H
> +
> +#include <asm/prctl.h>
> +#include <sys/syscall.h>
> +#include <unistd.h>
> +
> +/* Intel AMX requires Linux 5.16. ARCH_XCOMP_TILEDATA is added in Linux
> 6.4.
> + Add fallback for previous kernels. */
> +
> +#ifndef ARCH_XCOMP_TILEDATA
> +#define ARCH_XCOMP_TILEDATA 18
> +#endif
> +
> +/* Ask the OS to configure Intel AMX in xsave. Tile data registers are
> + only usable after this succeeded. Return zero on success. */
> +
> +static inline int
> +amx_enable (void)
> +{
> + return syscall (SYS_arch_prctl, ARCH_REQ_XCOMP_PERM,
> ARCH_XCOMP_TILEDATA);
> +}
> +
> +#endif /* AMD64_AMX_H */
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index bc6725b948f..c24cfd5dfbd 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -4635,6 +4635,81 @@ gdb_caching_proc allow_ssp_tests {} {
> return $allow_ssp_tests
> }
>
> +# Run a test on the target to see if it supports AMX. Return 1 if so,
> +# 0 if it does not.
> +
> +gdb_caching_proc allow_amx_tests {} {
> + global srcdir subdir gdb_prompt inferior_exited_re
> +
> + set me "allow_amx_tests"
> + if { ![istarget "x86_64-*-*"] } {
> + verbose "$me: target does not support AMX" 2
> + return 0
> + }
> +
> + # Compile a test program.
> + set src {
> + #include <stdint.h>
> + #include <immintrin.h>
> +
> + #include "amd64-amx.h"
> +
> + int
> + main ()
> + {
> + if (amx_enable () != 0)
> + return 1;
> +
> + struct tileconfig_t {
> + uint8_t palette_id;
> + uint8_t startRow;
> + uint8_t reserved[14];
> + uint16_t cols[16];
> + uint8_t rows[16];
> + };
> +
> + struct tileconfig_t tc = {1};
> + _tile_loadconfig (&tc);
> + _tile_release ();
> +
> + return 0;
> + }
> + }
> + set compile_flags "additional_flags=-mamx-tile"
> + if {![gdb_simple_compile $me $src executable $compile_flags]} {
> + return 0
> + }
> +
> + # 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
> + set allow_amx_tests 0
> + gdb_expect {
> + -re ".*Illegal instruction.*${gdb_prompt} $" {
> + verbose -log "$me: AMX hardware not detected."
> + }
> + -re ".*$inferior_exited_re with code.*${gdb_prompt} $" {
> + verbose -log "$me: AMX not enabled by the OS."
> + }
> + -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
> + verbose -log "$me: AMX hardware detected."
> + set allow_amx_tests 1
> + }
> + default {
> + warning "\n$me: default case taken."
> + }
> + }
> + gdb_exit
> + remote_file build delete $obj
> +
> + verbose "$me: returning $allow_amx_tests" 2
> + return $allow_amx_tests
> +}
> +
> # Run a test on the target to see if it supports avx512bf16. Return 1 if so,
> # 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
>
> diff --git a/gdbserver/i387-fp.cc b/gdbserver/i387-fp.cc
> index 90f146a74d2..7d195c554ce 100644
> --- a/gdbserver/i387-fp.cc
> +++ b/gdbserver/i387-fp.cc
> @@ -138,6 +138,14 @@ public:
> 32 bits. */
> unsigned char *pkru_space ()
> { return xsave () + xsave_layout.pkru_offset; }
> +
> + /* Memory address for the TILECFG register, which is 64 bytes. */
> + unsigned char *tilecfg_space ()
> + { return xsave () + xsave_layout.tilecfg_offset; }
> +
> + /* Memory address of the TILEDATA state component. */
> + unsigned char *tiledata_space ()
> + { return xsave () + xsave_layout.tiledata_offset; }
> };
>
> static_assert (sizeof(i387_xsave) == 576);
> @@ -260,7 +268,7 @@ i387_cache_to_xsave (struct regcache *regcache, void
> *buf)
> unsigned long val, val2;
> unsigned long long xstate_bv = 0;
> unsigned long long clear_bv = 0;
> - char raw[64];
> + char raw[1024];
> unsigned char *p;
>
> /* Amd64 has 16 xmm regs; I386 has 8 xmm regs. */
> @@ -321,6 +329,12 @@ i387_cache_to_xsave (struct regcache *regcache,
> void *buf)
> if (amd64 && (clear_bv & X86_XSTATE_APX_F) != 0)
> for (i = 0; i < num_apx_registers; i++)
> memset (fp->apx_space () + i * 8, 0, 8);
> +
> + if (amd64 && (clear_bv & X86_XSTATE_AMX) != 0)
> + {
> + memset (fp->tilecfg_space (), 0, X86_AMX_TILECFG_SIZE);
> + memset (fp->tiledata_space (), 0, X86_AMX_TILEDATA_SIZE);
> + }
I think we should check clear_bv for X86_XSTATE_TILECFG and X86_XSTATE_TILEDATA
separately, given that each component is handled separately (in contrast to XCR0).
So I'd change it as follows:
- if (amd64 && (clear_bv & X86_XSTATE_AMX) != 0)
- {
- memset (fp->tilecfg_space (), 0, X86_AMX_TILECFG_SIZE);
- memset (fp->tiledata_space (), 0, X86_AMX_TILEDATA_SIZE);
- }
+ if (amd64 && (clear_bv & X86_XSTATE_TILECFG) != 0)
+ memset (fp->tilecfg_space (), 0, X86_AMX_TILECFG_SIZE);
+
+ if (amd64 && (clear_bv & X86_XSTATE_TILEDATA) != 0)
+ memset (fp->tiledata_space (), 0, X86_AMX_TILEDATA_SIZE);
>
> /* Check if any x87 registers are changed. */
> @@ -462,6 +476,35 @@ i387_cache_to_xsave (struct regcache *regcache,
> void *buf)
> }
> }
>
> + /* Check if TILECFG register is changed (only for amd64). */
> + if (amd64 && ((x86_xstate_bv & X86_XSTATE_TILECFG) != 0))
> + {
> + collect_register_by_name (regcache, "tilecfg_raw", raw);
> + p = fp->tilecfg_space ();
> + if (memcmp (raw, p, X86_AMX_TILECFG_SIZE) != 0)
> + {
> + xstate_bv |= X86_XSTATE_TILECFG;
> + memcpy (p, raw, X86_AMX_TILECFG_SIZE);
> + }
> + }
> +
> + /* Check if any raw tile register is changed (only for amd64). */
> + if (amd64 && ((x86_xstate_bv & X86_XSTATE_TILEDATA) != 0))
> + {
> + int tmm0_raw_regnum = find_regno (regcache->tdesc, "tmm0_raw");
> +
> + for (i = 0; i < X86_AMX_NUM_TMM_REGISTERS; i++)
> + {
> + collect_register (regcache, tmm0_raw_regnum + i, raw);
> + p = fp->tiledata_space () + i * X86_AMX_TMM_SIZE;
> + if (memcmp (raw, p, X86_AMX_TMM_SIZE) != 0)
> + {
> + xstate_bv |= X86_XSTATE_TILEDATA;
> + memcpy (p, raw, X86_AMX_TMM_SIZE);
> + }
> + }
> + }
> +
> if ((x86_xstate_bv & X86_XSTATE_SSE) || (x86_xstate_bv &
> X86_XSTATE_AVX))
> {
> collect_register_by_name (regcache, "mxcsr", raw);
> @@ -833,6 +876,31 @@ i387_xsave_to_cache (struct regcache *regcache,
> const void *buf)
> }
> }
>
> + if (amd64 && (x86_xstate_bv & X86_XSTATE_AMX) != 0)
> + {
> + int tilecfg_regnum = find_regno (regcache->tdesc, "tilecfg_raw");
> + int tmm0_raw_regnum = find_regno (regcache->tdesc, "tmm0_raw");
> +
> + if ((clear_bv & X86_XSTATE_TILECFG) != 0)
> + supply_register_zeroed (regcache, tilecfg_regnum);
> + else
> + {
> + p = fp->tilecfg_space ();
> + supply_register (regcache, tilecfg_regnum, p);
> + }
> +
> + if ((clear_bv & X86_XSTATE_TILEDATA) != 0)
> + for (i = 0; i < X86_AMX_NUM_TMM_REGISTERS; i++)
> + supply_register_zeroed (regcache, tmm0_raw_regnum + i);
> + else
> + {
> + p = fp->tiledata_space ();
> + for (i = 0; i < X86_AMX_NUM_TMM_REGISTERS; i++)
> + supply_register (regcache, tmm0_raw_regnum + i,
> + p + i * X86_AMX_TMM_SIZE);
> + }
> + }
> +
> if ((clear_bv & (X86_XSTATE_SSE | X86_XSTATE_AVX))
> == (X86_XSTATE_SSE | X86_XSTATE_AVX))
> {
> diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
> index f893821fa48..24473ae1916 100644
> --- a/gdbserver/linux-x86-low.cc
> +++ b/gdbserver/linux-x86-low.cc
> @@ -263,6 +263,8 @@ static const int x86_64_regmap[] =
> -1, /* CET user mode register PL3_SSP. */
> -1, -1, -1, -1, -1, -1, -1, -1, /* r16...r31 (APX). */
> -1, -1, -1, -1, -1, -1, -1, -1,
> + -1, /* AMX TILECFG register. */
> + -1, -1, -1, -1, -1, -1, -1, -1, /* AMX tmm0_raw ... tmm7_raw. */
> };
>
> #define X86_64_NUM_REGS (sizeof (x86_64_regmap) / sizeof
> (x86_64_regmap[0]))
> diff --git a/gdbsupport/x86-xstate.h b/gdbsupport/x86-xstate.h
> index 3cb75ccfed6..368c34426b1 100644
> --- a/gdbsupport/x86-xstate.h
> +++ b/gdbsupport/x86-xstate.h
> @@ -29,6 +29,8 @@
> #define X86_XSTATE_ZMM_ID 7
> #define X86_XSTATE_PKRU_ID 9
> #define X86_XSTATE_CET_U_ID 11
> +#define X86_XSTATE_TILECFG_ID 17
> +#define X86_XSTATE_TILEDATA_ID 18
> #define X86_XSTATE_APX_F_ID 19
>
> /* The extended state feature bits. */
> @@ -47,6 +49,11 @@
> #define X86_XSTATE_PKRU (1ULL << X86_XSTATE_PKRU_ID)
> #define X86_XSTATE_CET_U (1ULL << X86_XSTATE_CET_U_ID)
>
> +/* AMX adds two feature bits. Both must be enabled. */
> +#define X86_XSTATE_TILECFG (1ULL << X86_XSTATE_TILECFG_ID)
> +#define X86_XSTATE_TILEDATA (1ULL << X86_XSTATE_TILEDATA_ID)
> +#define X86_XSTATE_AMX (X86_XSTATE_TILECFG |
> X86_XSTATE_TILEDATA)
> +
> /* Total size of the XSAVE area extended region and offsets of
> register states within the region. Offsets are set to 0 to
> indicate the absence of the associated registers. */
> @@ -60,6 +67,8 @@ struct x86_xsave_layout
> int zmm_h_offset = 0;
> int zmm_offset = 0;
> int pkru_offset = 0;
> + int tilecfg_offset = 0;
> + int tiledata_offset = 0;
> };
>
> constexpr bool operator== (const x86_xsave_layout &lhs,
> @@ -71,7 +80,9 @@ constexpr bool operator== (const x86_xsave_layout &lhs,
> && lhs.k_offset == rhs.k_offset
> && lhs.zmm_h_offset == rhs.zmm_h_offset
> && lhs.zmm_offset == rhs.zmm_offset
> - && lhs.pkru_offset == rhs.pkru_offset;
> + && lhs.pkru_offset == rhs.pkru_offset
> + && lhs.tilecfg_offset == rhs.tilecfg_offset
> + && lhs.tiledata_offset == rhs.tiledata_offset;
> }
>
> constexpr bool operator!= (const x86_xsave_layout &lhs,
> @@ -90,21 +101,30 @@ constexpr bool operator!= (const x86_xsave_layout
> &lhs,
> | X86_XSTATE_AVX512 |
> X86_XSTATE_PKRU)
> #define X86_XSTATE_AVX_AVX512_PKU_APX_MASK\
> (X86_XSTATE_AVX_AVX512_PKU_MASK | X86_XSTATE_APX_F)
> +#define X86_XSTATE_AVX_AVX512_PKU_APX_AMX_MASK\
> + (X86_XSTATE_AVX_AVX512_PKU_APX_MASK | X86_XSTATE_AMX)
>
> /* Supported mask of state-component bitmap xstate_bv. The SDM defines
> xstate_bv as XCR0 | IA32_XSS. */
>
> -#define X86_XSTATE_ALL_MASK
> (X86_XSTATE_AVX_AVX512_PKU_APX_MASK\
> - | X86_XSTATE_CET_U)
> +#define X86_XSTATE_ALL_MASK\
> + (X86_XSTATE_AVX_AVX512_PKU_APX_AMX_MASK | X86_XSTATE_CET_U)
>
> #define X86_XSTATE_SSE_SIZE 576
> #define X86_XSTATE_AVX_SIZE 832
>
> +/* Size of the AMX TILECFG register and of the raw tile registers. */
> +
> +#define X86_AMX_TILECFG_SIZE 64
> +#define X86_AMX_TMM_SIZE 1024
> +#define X86_AMX_NUM_TMM_REGISTERS 8
> +#define X86_AMX_TILEDATA_SIZE (X86_AMX_NUM_TMM_REGISTERS *
> X86_AMX_TMM_SIZE)
>
> #define HAS_AVX(XCR0) (((XCR0) & X86_XSTATE_AVX) != 0)
> #define HAS_AVX512(XCR0) (((XCR0) & X86_XSTATE_AVX512) != 0)
> #define HAS_APX(XCR0) (((XCR0) & X86_XSTATE_APX_F) != 0)
> #define HAS_PKRU(XCR0) (((XCR0) & X86_XSTATE_PKRU) != 0)
> +#define HAS_AMX(XCR0) (((XCR0) & X86_XSTATE_AMX) != 0)
>
> /* Initial value for fctrl register, as defined in the X86 manual, and
> confirmed in the (Linux) kernel source. When the x87 floating point
> --
> 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.
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers.
2026-10-30 11:50 ` [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers Stephan Rohr
2026-10-30 12:47 ` Eli Zaretskii
2026-11-03 10:44 ` Joos, Christina
@ 2026-11-03 14:40 ` Joos, Christina
2 siblings, 0 replies; 15+ messages in thread
From: Joos, Christina @ 2026-11-03 14:40 UTC (permalink / raw)
To: Rohr, Stephan, gdb-patches; +Cc: pedro, eliz, jhb, luis.machado
> -----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 2/5] gdb, gdbserver: Add Intel AMX registers.
>
> From: Felix Willgerodt <felix.willgerodt@intel.com>
>
> Intel Advanced Matrix Extensions (AMX) adds one 64-byte TILECFG register
> and eight 1024-byte tile registers TMM0, TMM1, ..., TMM7. The tile
> registers each represent a matrix, whose dimensions are configured via
> TILECFG. In XSAVE, all tiles are represented in the 8kB TILEDATA section.
>
> Future platforms are free to add new palettes, which are run-time
> configurable partitionings of the TILEDATA space. Currently only
> palette 0 (initialized zero state) and palette 1 exist. New palettes
> might change any of the following parameters, which are defined in the
> palette_table (which can be accessed via CPUID):
>
> define palette_table[id]:
> uint16_t total_tile_bytes
> uint16_t bytes_per_tile
> uint16_t bytes_per_row
> uint16_t max_names
> uint16_t max_rows
>
> More information about Intel AMX can be found in the Intel Software
> Developer's Manual, September 2026.
>
> The $tilecfg register is implemented as a pseudo register. For convenience,
> reserved bytes are not shown. To also be able to show the full register,
> $tilecfg_raw is implemented as a uint512 value.
>
> The $tmm0_raw-$tmm7_raw registers hold the contents of the tiles. Each is
> shown with the maximum dimensions of 16 rows of 64 bytes. Only the
> elements
> within the dimensions configured in $tilecfg hold data.
>
> To hide the raw registers, they are added to the "save" and "restore"
> register groups only. A following patch introduces user registers and adds
> the tile user registers to the "all" group such that the tile registers show
> up in the "info registers all" command.
>
> Intel AMX is supported for 64-bit only.
>
> Co-Authored-By: Stephan Rohr <stephan.rohr@intel.com>
> ---
> gdb/NEWS | 5 +
> gdb/amd64-linux-tdep.c | 2 +
> gdb/amd64-tdep.c | 67 ++++++++-
> gdb/amd64-tdep.h | 3 +
> gdb/arch/amd64.c | 4 +
> gdb/arch/x86-linux-tdesc-features.c | 5 +-
> gdb/doc/gdb.texinfo | 40 ++++++
> gdb/features/Makefile | 1 +
> gdb/features/i386/64bit-amx.c | 26 ++++
> gdb/features/i386/64bit-amx.xml | 26 ++++
> gdb/i386-tdep.c | 132 +++++++++++++++++-
> gdb/i386-tdep.h | 25 +++-
> gdb/i387-tdep.c | 196 +++++++++++++++++++++++++--
> gdb/i387-tdep.h | 6 +
> gdb/nat/x86-xstate.c | 2 +
> gdb/target-debug.h | 2 +
> gdb/testsuite/gdb.arch/amd64-amx.c | 115 ++++++++++++++++
> gdb/testsuite/gdb.arch/amd64-amx.exp | 192
> ++++++++++++++++++++++++++
> gdb/testsuite/lib/amd64-amx.h | 41 ++++++
> gdb/testsuite/lib/gdb.exp | 75 ++++++++++
> gdbserver/i387-fp.cc | 70 +++++++++-
> gdbserver/linux-x86-low.cc | 2 +
> gdbsupport/x86-xstate.h | 26 +++-
> 23 files changed, 1042 insertions(+), 21 deletions(-)
> create mode 100644 gdb/features/i386/64bit-amx.c
> create mode 100644 gdb/features/i386/64bit-amx.xml
> create mode 100644 gdb/testsuite/gdb.arch/amd64-amx.c
> create mode 100644 gdb/testsuite/gdb.arch/amd64-amx.exp
> create mode 100644 gdb/testsuite/lib/amd64-amx.h
>
> diff --git a/gdb/NEWS b/gdb/NEWS
> index 7303ec0e460..2047e7376fb 100644
> --- a/gdb/NEWS
> +++ b/gdb/NEWS
> @@ -7,6 +7,11 @@
> Support displaying and modifying Intel APX registers (Extended GPRs
> $r16 - $r31) including byte, word and dword pseudo registers.
>
> +* Support for Intel AMX registers on GNU/Linux.
> + 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.
> +
> * GDB now distinguishes between the GNU (MinGW) and MSVC Windows
> ABIs.
>
> The "set osabi" command accepts two new values, "Windows-GNU" and
> diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
> index 81e66be75c1..28e18ed47d2 100644
> --- a/gdb/amd64-linux-tdep.c
> +++ b/gdb/amd64-linux-tdep.c
> @@ -115,6 +115,8 @@ int amd64_linux_gregset_reg_offset[] =
> -1, /* CET user mode register PL3_SSP. */
> -1, -1, -1, -1, -1, -1, -1, -1, /* r16 ... r31. */
> -1, -1, -1, -1, -1, -1, -1, -1,
> + -1, /* TILECFG register (AMX). */
> + -1, -1, -1, -1, -1, -1, -1, -1, /* tmm0_raw ... tmm7_raw (AMX). */
>
> /* End of hardware registers */
> 21 * 8, 22 * 8, /* fs_base and gs_base. */
> diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
> index 18b8f2a4c0b..13242e293b5 100644
> --- a/gdb/amd64-tdep.c
> +++ b/gdb/amd64-tdep.c
> @@ -188,6 +188,17 @@ static const char * const amd64_pkeys_names[] = {
> "pkru"
> };
>
> +static const char *amd64_tilecfg_raw_names[] = {
> + "tilecfg_raw"
> +};
> +
> +/* Register names for the raw AMX tile registers. */
> +
> +static const char *amd64_tmm_raw_names[] = {
> + "tmm0_raw", "tmm1_raw", "tmm2_raw", "tmm3_raw",
> + "tmm4_raw", "tmm5_raw", "tmm6_raw", "tmm7_raw"
> +};
> +
> /* DWARF Register Number Mapping as defined in the System V psABI,
> section 3.6. */
>
> @@ -429,6 +440,12 @@ static const char * const amd64_apx_dword_names[]
> =
> static_assert (ARRAY_SIZE (amd64_apx_dword_names)
> == AMD64_APX_NUM_DWORD_REGS + 1);
>
> +/* Register name for tilecfg pseudo-register. */
> +
> +static const char *amd64_tilecfg_names[] = {
> + "tilecfg"
> +};
> +
> /* Return the name of register REGNUM. */
>
> static const char *
> @@ -441,6 +458,8 @@ amd64_pseudo_register_name (struct gdbarch
> *gdbarch, int regnum)
> return amd64_ymm_names[regnum - tdep->ymm0_regnum];
> else if (i386_ymm_avx512_regnum_p (gdbarch, regnum))
> return amd64_ymm_avx512_names[regnum - tdep->ymm16_regnum];
> + else if (i386_tilecfg_regnum_p (gdbarch, regnum))
> + return amd64_tilecfg_names[regnum - tdep->tilecfg_regnum];
> else if (i386_dword_regnum_p (gdbarch, regnum))
> return tdep->dword_names[regnum - tdep->eax_regnum];
> else
> @@ -521,6 +540,22 @@ amd64_pseudo_register_read_value (gdbarch
> *gdbarch, const frame_info_ptr &next_f
> const int gpnum = amd64_raw_dword_register (tdep, regnum);
> return pseudo_from_raw_part (next_frame, regnum, gpnum, 0);
> }
> + else if (i386_tilecfg_regnum_p (gdbarch, regnum))
> + {
> + /* Read tilecfg. */
> + value *pseudo_reg_val
> + = value::allocate_register (next_frame, regnum);
> + value *raw_reg_val = value_of_register (tdep->tilecfg_raw_regnum,
> + next_frame);
> + /* Copy palette and start_row. See tilecfg_type (). */
> + raw_reg_val->contents_copy (pseudo_reg_val, 0, 0, 2 * 1);
> + /* Copy all colsb. */
> + raw_reg_val->contents_copy (pseudo_reg_val, 2, 16, 2 * 8);
> + /* Copy all rows. */
> + raw_reg_val->contents_copy (pseudo_reg_val, 18, 48, 1 * 8);
> +
> + return pseudo_reg_val;
> + }
> else
> return i386_pseudo_register_read_value (gdbarch, next_frame, regnum);
> }
> @@ -547,6 +582,22 @@ amd64_pseudo_register_write (gdbarch *gdbarch,
> const frame_info_ptr &next_frame,
> const int gpnum = amd64_raw_dword_register (tdep, regnum);
> pseudo_to_raw_part (next_frame, buf, gpnum, 0);
> }
> + else if (i386_tilecfg_regnum_p (gdbarch, regnum))
> + {
> + const int raw_reg_num = tdep->tilecfg_raw_regnum;
> + const int raw_size = register_size (gdbarch, raw_reg_num);
> + gdb::byte_vector raw_buf (raw_size, 0);
> + /* Copy palette and start_row. See tilecfg_type (). */
> + memcpy (raw_buf.data (), buf.data (), 2 * 1);
> + /* Copy all colsb. */
> + memcpy (raw_buf.data () + 16, buf.data () + 2, 2 * 8);
> + /* Copy all rows. */
> + memcpy (raw_buf.data () + 48, buf.data () + 18, 1 * 8);
> +
> + put_frame_register_bytes
> + (next_frame, raw_reg_num, 0,
> + gdb::make_array_view (raw_buf.data (), raw_size));
> + }
> else
> i386_pseudo_register_write (gdbarch, next_frame, regnum, buf);
> }
> @@ -3706,6 +3757,19 @@ amd64_init_abi (struct gdbarch_info info, struct
> gdbarch *gdbarch,
> tdep->num_dword_regs = AMD64_NUM_DWORD_REGS;
> }
>
> + if (tdesc_find_feature (tdesc, "org.gnu.gdb.i386.amx") != nullptr)
> + {
> + tdep->tilecfg_raw_register_names = amd64_tilecfg_raw_names;
> + tdep->tilecfg_raw_regnum = AMD64_AMX_TILECFG_RAW_REGNUM;
> +
> + tdep->tilecfg_register_names = amd64_tilecfg_names;
> + tdep->num_tilecfg_regs = 1;
> +
> + tdep->tmm_raw_register_names = amd64_tmm_raw_names;
> + tdep->tmm_raw_regnum = AMD64_AMX_TMM0_RAW_REGNUM;
> + tdep->num_tmm_raw_regs = 8;
> + }
> +
> /* Avoid wiring in the MMX registers for now. */
> tdep->num_mmx_regs = 0;
>
> @@ -3858,7 +3922,7 @@ const struct target_desc *
> amd64_target_description (uint64_t xstate_bv, bool segments)
> {
> static const_target_desc_up amd64_tdescs \
> - [2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*CET_U*/][2/*APX*/] \
> + [2/*AVX*/][2/*AVX512*/][2/*PKRU*/][2/*CET_U*/][2/*APX*/][2/*AMX*/]
> \
> [2/*segments*/] = {};
> const_target_desc_up &tdesc
> = amd64_tdescs[(xstate_bv & X86_XSTATE_AVX) ? 1 : 0]
> @@ -3866,6 +3930,7 @@ amd64_target_description (uint64_t xstate_bv, bool
> segments)
> [(xstate_bv & X86_XSTATE_PKRU) ? 1 : 0]
> [(xstate_bv & X86_XSTATE_CET_U) ? 1 : 0]
> [(xstate_bv & X86_XSTATE_APX_F) ? 1 : 0]
> + [(xstate_bv & X86_XSTATE_AMX) ? 1 : 0]
> [segments ? 1 : 0];
>
> if (tdesc == nullptr)
> diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
> index 93b3cb61b17..02172ccfa14 100644
> --- a/gdb/amd64-tdep.h
> +++ b/gdb/amd64-tdep.h
> @@ -84,6 +84,9 @@ enum amd64_regnum
> AMD64_PL3_SSP_REGNUM,
> AMD64_R16_REGNUM,
> AMD64_R31_REGNUM = AMD64_R16_REGNUM + 15,
> + AMD64_AMX_TILECFG_RAW_REGNUM,
> + AMD64_AMX_TMM0_RAW_REGNUM,
> + AMD64_AMX_TMM7_RAW_REGNUM =
> AMD64_AMX_TMM0_RAW_REGNUM + 7,
> AMD64_FSBASE_REGNUM,
> AMD64_GSBASE_REGNUM
> };
> diff --git a/gdb/arch/amd64.c b/gdb/arch/amd64.c
> index 3992bbf512e..60932f420b3 100644
> --- a/gdb/arch/amd64.c
> +++ b/gdb/arch/amd64.c
> @@ -22,6 +22,7 @@
>
> #include "../features/i386/64bit-avx.c"
> #include "../features/i386/64bit-avx512.c"
> +#include "../features/i386/64bit-amx.c"
> #include "../features/i386/64bit-core.c"
> #include "../features/i386/64bit-apx.c"
> #include "../features/i386/64bit-linux.c"
> @@ -82,5 +83,8 @@ amd64_create_target_description (uint64_t xstate_bv,
> bool is_x32,
> if (xstate_bv & X86_XSTATE_APX_F)
> regnum = create_feature_i386_64bit_apx (tdesc.get (), regnum);
>
> + if (xstate_bv & X86_XSTATE_AMX)
> + regnum = create_feature_i386_64bit_amx (tdesc.get (), regnum);
> +
> return tdesc;
> }
> diff --git a/gdb/arch/x86-linux-tdesc-features.c b/gdb/arch/x86-linux-tdesc-
> features.c
> index 0191f326834..90722d4dd58 100644
> --- a/gdb/arch/x86-linux-tdesc-features.c
> +++ b/gdb/arch/x86-linux-tdesc-features.c
> @@ -66,6 +66,7 @@ struct x86_xstate_feature {
> static constexpr x86_xstate_feature x86_linux_all_xstate_features[] = {
> /* Feature, i386, amd64, x32. */
> { X86_XSTATE_APX_F, false, true, true },
> + { X86_XSTATE_AMX, false, true, true },
> { X86_XSTATE_CET_U, false, true, true },
> { X86_XSTATE_PKRU, true, true, true },
> { X86_XSTATE_AVX512, true, true, true },
> @@ -155,8 +156,8 @@ x86_linux_xstate_bv_to_tdesc_idx (uint64_t
> xstate_bv)
> represents the bit order within the generated index number.
>
> i386 | x87 sse avx avx512 pkru
> - amd64 | avx avx512 pkru
> - i32 | avx avx512 pkru
> + amd64 | avx avx512 pkru amx
> + i32 | avx avx512 pkru amx
>
> The features are ordered so that for each mode (i386, amd64, i32) the
> generated index will form a continuous range. */
> diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
> index 53773780b56..9e3b6fca669 100644
> --- a/gdb/doc/gdb.texinfo
> +++ b/gdb/doc/gdb.texinfo
> @@ -27448,6 +27448,41 @@ stack. @value{GDBN} corrects this value to
> avoid a control protection
> exception. For more details on displaced stepping, see @ref{displaced-
> stepping}.
> @end itemize
>
> +@subsubsection Intel Advanced Matrix Extensions
> +@cindex Intel Advanced Matrix Extensions
> +@cindex AMX, Intel
> +
> +Intel @dfn{Advanced Matrix Extensions} (@acronym{AMX}) add one 64-byte
> +@samp{tilecfg} register and eight 1024-byte tile registers @samp{tmm0},
> +@samp{tmm1}, @dots{}, @samp{tmm7} for amd64. The tile registers each
> +represent a matrix, whose dimensions are configured via @samp{tilecfg}.
> +Future platforms might also partition the register area of 8192 bytes
> +between a different number of tiles.
> +
> +@value{GDBN} provides a user-friendly view of the @samp{tilecfg} register,
> +omitting reserved bits. The tile registers are supplied as the raw registers
> +@samp{tmm0_raw}, @samp{tmm1_raw}, @dots{}, @samp{tmm7_raw},
> which show the
> +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:
> +
> +@smallexample
> +(gdb) print/x $tilecfg_raw
> +$1 =
> 0x10201000000000000000000000000000000000000000000000000000000
> 0c0
> + 00c000800000000000000000000000000000001
> +(gdb) print $tilecfg
> +$2 = @{palette = 1, start_row = 0, colsb = @{8, 12, 12, 0, 0, 0, 0, 0@},
> + rows = @{1, 2, 1, 0, 0, 0, 0, 0@}@}
> +(gdb) print $tmm1_raw
> +$3 = @{621397352980713455329738752,
> 932096029507240269422067969,
> + 0 <repeats 14 times>@}
> +(gdb) print/d (uint8_t[16][64]) $tmm1_raw
> +$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>@}
> +@end smallexample
> +
> @node Alpha
> @subsection Alpha
>
> @@ -50888,6 +50923,11 @@ The @samp{org.gnu.gdb.i386.apx} feature is
> optional. It should describe
> @samp{r16} - @samp{r31} with 64 bits each. All Intel @acronym{APX}
> registers are valid only on amd64.
>
> +The @samp{org.gnu.gdb.i386.amx} feature is optional. It should describe
> +one configuration register @samp{tilecfg_raw} that has 64 bytes, and the
> +eight tile registers @samp{tmm0_raw} @dots{} @samp{tmm7_raw}, each of
> which
> +has 1024 bytes. All Intel @acronym{AMX} registers are valid only for amd64.
> +
> @node LoongArch Features
> @subsection LoongArch Features
> @cindex target descriptions, LoongArch Features
> diff --git a/gdb/features/Makefile b/gdb/features/Makefile
> index 0ab24bca000..15e715aab70 100644
> --- a/gdb/features/Makefile
> +++ b/gdb/features/Makefile
> @@ -241,6 +241,7 @@ FEATURE_XMLFILES = aarch64-core.xml \
> i386/64bit-core.xml \
> i386/64bit-segments.xml \
> i386/64bit-avx.xml \
> + i386/64bit-amx.xml \
> i386/64bit-linux.xml \
> i386/64bit-sse.xml \
> i386/pkeys.xml \
> diff --git a/gdb/features/i386/64bit-amx.c b/gdb/features/i386/64bit-amx.c
> new file mode 100644
> index 00000000000..14779ec1fb7
> --- /dev/null
> +++ b/gdb/features/i386/64bit-amx.c
> @@ -0,0 +1,26 @@
> +/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
> + Original: 64bit-amx.xml */
> +
> +#include "gdbsupport/tdesc.h"
> +
> +static int
> +create_feature_i386_64bit_amx (struct target_desc *result, long regnum)
> +{
> + struct tdesc_feature *feature;
> +
> + feature = tdesc_create_feature (result, "org.gnu.gdb.i386.amx");
> + tdesc_type *element_type;
> + element_type = tdesc_named_type (feature, "uint512");
> + tdesc_create_vector (feature, "v_ui512", element_type, 16);
> +
> + tdesc_create_reg (feature, "tilecfg_raw", regnum++, 1, NULL, 512,
> "uint512");
> + tdesc_create_reg (feature, "tmm0_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm1_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm2_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm3_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm4_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm5_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm6_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + tdesc_create_reg (feature, "tmm7_raw", regnum++, 1, NULL, 8192,
> "v_ui512");
> + return regnum;
> +}
> diff --git a/gdb/features/i386/64bit-amx.xml b/gdb/features/i386/64bit-
> amx.xml
> new file mode 100644
> index 00000000000..a40c6c65f6d
> --- /dev/null
> +++ b/gdb/features/i386/64bit-amx.xml
> @@ -0,0 +1,26 @@
> +<?xml version="1.0"?>
> +<!-- Copyright (C) 2020-2026 Free Software Foundation, Inc.
> +
> + Copying and distribution of this file, with or without modification,
> + are permitted in any medium without royalty provided the copyright
> + notice and this notice are preserved. -->
> +
> +<!DOCTYPE feature SYSTEM "gdb-target.dtd">
> +<feature name="org.gnu.gdb.i386.amx">
> + <!-- One uint512 value per row of a tile. -->
> + <vector id="v_ui512" type="uint512" count="16"/>
> +
> + <!-- The raw contents of the tile configuration register. -->
> + <reg name="tilecfg_raw" bitsize="512" type="uint512"/>
> +
> + <!-- The raw contents of the eight tiles, each of which is 16 rows of
> + 64 bytes. -->
> + <reg name="tmm0_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm1_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm2_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm3_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm4_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm5_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm6_raw" bitsize="8192" type="v_ui512"/>
> + <reg name="tmm7_raw" bitsize="8192" type="v_ui512"/>
> +</feature>
> diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
> index 071d8e004ae..a25abfbd1bc 100644
> --- a/gdb/i386-tdep.c
> +++ b/gdb/i386-tdep.c
> @@ -378,6 +378,34 @@ i386_pkru_regnum_p (struct gdbarch *gdbarch, int
> regnum)
> return regnum >= 0 && regnum < I387_NUM_PKEYS_REGS;
> }
>
> +/* AMX tilecfg register? */
> +
> +bool
> +i386_tilecfg_regnum_p (gdbarch *gdbarch, int regnum)
> +{
> + i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> + return regnum >= 0 && regnum == tdep->tilecfg_regnum;
> +}
> +
> +/* Raw AMX tile register? */
> +
> +bool
> +i386_tmm_raw_regnum_p (gdbarch *gdbarch, int regnum)
> +{
> + i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> + return (tdep->tmm_raw_regnum <= regnum
> + && regnum < tdep->tmm_raw_regnum + tdep-
> >num_tmm_raw_regs);
> +}
> +
> +/* AMX tilecfg_raw register? */
> +
> +static bool
> +i386_tilecfg_raw_regnum_p (gdbarch *gdbarch, int regnum)
> +{
> + i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> + return regnum >= 0 && regnum == tdep->tilecfg_raw_regnum;
> +}
> +
> /* Return the name of register REGNUM, or the empty string if it is
> an anonymous register. */
>
> @@ -3222,6 +3250,47 @@ i386_mmx_type (struct gdbarch *gdbarch)
> return tdep->i386_mmx_type;
> }
>
> +/* The type of the TILECFG registers. */
> +
> +static type *
> +i386_tilecfg_type (gdbarch *gdbarch)
> +{
> + i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);
> +
> + if (!tdep->i386_tilecfg_type)
> + {
> + const struct builtin_type *bt = builtin_type (gdbarch);
> +
> + /* The type we're building is this:
> +
> + struct __gdb_builtin_type_tilecfg
> + {
> + uint8_t palette;
> + uint8_t start_row;
> + uint16_t colsb[8];
> + uint8_t rows[8];
> + };
> +
> + Bytes 2-15, 32-47 and 56-63 of the register are reserved, so the
> + colsb and rows arrays are packed together here. */
> +
> + type *t = arch_composite_type (gdbarch, "builtin_type_tilecfg",
> + TYPE_CODE_STRUCT);
> +
> + append_composite_type_field (t, "palette", bt->builtin_uint8);
> + append_composite_type_field (t, "start_row", bt->builtin_uint8);
> + append_composite_type_field
> + (t, "colsb", lookup_array_range_type (bt->builtin_uint16, 0, 7));
> + append_composite_type_field
> + (t, "rows", lookup_array_range_type (bt->builtin_uint8, 0, 7));
> +
> + t->set_name ("builtin_type_tilecfg");
> + tdep->i386_tilecfg_type = t;
> + }
> +
> + return tdep->i386_tilecfg_type;
> +}
> +
> /* Return the GDB type object for the "standard" data type of data in
> register REGNUM. */
>
> @@ -3236,6 +3305,8 @@ i386_pseudo_register_type (struct gdbarch
> *gdbarch, int regnum)
> return i386_ymm_type (gdbarch);
> else if (i386_zmm_regnum_p (gdbarch, regnum))
> return i386_zmm_type (gdbarch);
> + else if (i386_tilecfg_regnum_p (gdbarch, regnum))
> + return i386_tilecfg_type (gdbarch);
> else
> {
> const struct builtin_type *bt = builtin_type (gdbarch);
> @@ -4269,7 +4340,8 @@ i386_register_reggroup_p (struct gdbarch *gdbarch,
> int regnum,
> int fp_regnum_p, mmx_regnum_p, xmm_regnum_p, mxcsr_regnum_p,
> ymm_regnum_p, ymmh_regnum_p, ymm_avx512_regnum_p,
> ymmh_avx512_regnum_p,
> zmm_regnum_p, zmmh_regnum_p, xmm_avx512_regnum_p, avx512_p,
> avx_p,
> - sse_p, pkru_regnum_p;
> + sse_p, pkru_regnum_p, tilecfg_regnum_p, tmm_raw_regnum_p,
> + tilecfg_raw_regnum_p;
>
> /* Don't include pseudo registers, except for MMX, in any register
> groups. */
> @@ -4296,6 +4368,9 @@ i386_register_reggroup_p (struct gdbarch *gdbarch,
> int regnum,
> ymm_regnum_p = i386_ymm_regnum_p (gdbarch, regnum);
> ymm_avx512_regnum_p = i386_ymm_avx512_regnum_p (gdbarch, regnum);
> zmm_regnum_p = i386_zmm_regnum_p (gdbarch, regnum);
> + tmm_raw_regnum_p = i386_tmm_raw_regnum_p (gdbarch, regnum);
> + tilecfg_regnum_p = i386_tilecfg_regnum_p (gdbarch, regnum);
> + tilecfg_raw_regnum_p = i386_tilecfg_raw_regnum_p (gdbarch, regnum);
>
> avx512_p = ((tdep->xcr0 & X86_XSTATE_AVX_AVX512_MASK)
> == X86_XSTATE_AVX_AVX512_MASK);
> @@ -4329,6 +4404,11 @@ i386_register_reggroup_p (struct gdbarch
> *gdbarch, int regnum,
> || zmmh_regnum_p))
> return false;
>
> + /* For "info reg all", don't include the raw Intel AMX registers. */
> + if (group == all_reggroup
> + && (tmm_raw_regnum_p || tilecfg_raw_regnum_p))
> + return false;
> +
> if (group == general_reggroup)
> return (!fp_regnum_p
> && !mmx_regnum_p
> @@ -4341,7 +4421,10 @@ i386_register_reggroup_p (struct gdbarch
> *gdbarch, int regnum,
> && !ymmh_avx512_regnum_p
> && !zmm_regnum_p
> && !zmmh_regnum_p
> - && !pkru_regnum_p);
> + && !pkru_regnum_p
> + && !tmm_raw_regnum_p
> + && !tilecfg_regnum_p
> + && !tilecfg_raw_regnum_p);
>
> return default_register_reggroup_p (gdbarch, regnum, group);
> }
> @@ -8520,7 +8603,7 @@ i386_xcr0_from_tdesc (const struct target_desc
> *tdesc)
>
> const struct tdesc_feature *feature_sse, *feature_avx,
> *feature_avx512, *feature_pkeys,
> - *feature_apx;
> + *feature_apx, *feature_amx;
>
> /* Get core registers. */
> feature_core = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.core");
> @@ -8542,6 +8625,9 @@ i386_xcr0_from_tdesc (const struct target_desc
> *tdesc)
> /* Try PKEYS */
> feature_pkeys = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pkeys");
>
> + /* Try Intel AMX. */
> + feature_amx = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.amx");
> +
> /* The XCR0 bits. */
> uint64_t xcr0 = X86_XSTATE_X87;
>
> @@ -8572,6 +8658,9 @@ i386_xcr0_from_tdesc (const struct target_desc
> *tdesc)
> if (feature_pkeys)
> xcr0 |= X86_XSTATE_PKRU;
>
> + if (feature_amx)
> + xcr0 |= X86_XSTATE_AMX;
> +
> return xcr0;
> }
>
> @@ -8584,7 +8673,7 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
>
> const struct tdesc_feature *feature_sse, *feature_avx, *feature_avx512,
> *feature_pkeys, *feature_segments,
> - *feature_pl3_ssp, *feature_apx;
> + *feature_pl3_ssp, *feature_apx, *feature_amx;
> int i, num_regs, valid_p;
>
> if (! tdesc_has_registers (tdesc))
> @@ -8616,6 +8705,9 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
> /* Try Shadow Stack. */
> feature_pl3_ssp = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.pl3_ssp");
>
> + /* Try Intel AMX. */
> + feature_amx = tdesc_find_feature (tdesc, "org.gnu.gdb.i386.amx");
> +
> valid_p = 1;
>
> /* The XCR0 bits. */
> @@ -8752,6 +8844,26 @@ i386_validate_tdesc_p (i386_gdbarch_tdep *tdep,
> tdep->ssp_regnum, "pl3_ssp");
> }
>
> + if (feature_amx != nullptr
> + && tdep->tilecfg_raw_regnum != -1
> + && tdep->tilecfg_raw_register_names != nullptr
> + && tdep->tmm_raw_regnum != -1
> + && tdep->tmm_raw_register_names != nullptr)
> + {
> + tdep->xcr0 |= X86_XSTATE_TILECFG;
> +
> + valid_p &= tdesc_numbered_register (feature_amx, tdesc_data,
> + tdep->tilecfg_raw_regnum,
> + tdep-
> >tilecfg_raw_register_names[0]);
> +
> + tdep->xcr0 |= X86_XSTATE_TILEDATA;
> +
> + for (i = 0; i < tdep->num_tmm_raw_regs; i++)
> + valid_p &= tdesc_numbered_register (feature_amx, tdesc_data,
> + tdep->tmm_raw_regnum + i,
> + tdep->tmm_raw_register_names[i]);
> + }
> +
> return valid_p;
> }
>
> @@ -9010,7 +9122,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct
> gdbarch_list *arches)
> + tdep->num_mmx_regs
> + tdep->num_ymm_regs
> + tdep->num_ymm_avx512_regs
> - + tdep->num_zmm_regs));
> + + tdep->num_zmm_regs
> + + tdep->num_tilecfg_regs));
>
> /* Target description may be changed. */
> tdesc = tdep->tdesc;
> @@ -9062,6 +9175,15 @@ i386_gdbarch_init (struct gdbarch_info info, struct
> gdbarch_list *arches)
> else
> tdep->zmm0_regnum = -1;
>
> + if (tdep->num_tilecfg_regs != 0)
> + {
> + /* Support TILECFG pseudo-register if it is available. */
> + tdep->tilecfg_regnum = mm0_regnum;
> + mm0_regnum += tdep->num_tilecfg_regs;
> + }
> + else
> + tdep->tilecfg_regnum = -1;
> +
> if (tdep->num_mmx_regs != 0)
> {
> /* Support MMX pseudo-register if MMX hasn't been disabled. */
> diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
> index bdafd523834..898a76dfb50 100644
> --- a/gdb/i386-tdep.h
> +++ b/gdb/i386-tdep.h
> @@ -225,6 +225,26 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
> set this to a value >= 0. */
> int ssp_regnum = -1;
>
> + /* Register number for the raw tilecfg register and the tilecfg pseudo
> + register. If supported, set them to a value >= 0. */
> + int tilecfg_regnum = -1;
> + int tilecfg_raw_regnum = -1;
> +
> + /* Number of tilecfg registers, including pseudo register. */
> + int num_tilecfg_regs = 0;
> +
> + /* Register number for the first raw tile register, tmm0_raw. If supported,
> + set this to a value >= 0. */
> + int tmm_raw_regnum = -1;
> +
> + /* Number of raw tile registers. */
> + int num_tmm_raw_regs = 0;
> +
> + /* Intel AMX register names. */
> + const char * const *tilecfg_raw_register_names = nullptr;
> + const char * const *tilecfg_register_names = nullptr;
> + const char * const *tmm_raw_register_names = nullptr;
> +
> /* Register number for %fsbase. If supported, set this to a value
> >= 0. */
> int fsbase_regnum = -1;
> @@ -265,6 +285,7 @@ struct i386_gdbarch_tdep : gdbarch_tdep_base
> struct type *i386_ymm_type = nullptr;
> struct type *i386_zmm_type = nullptr;
> struct type *i387_ext_type = nullptr;
> + type *i386_tilecfg_type = nullptr;
>
> /* If the registers containing the i386 Linux TLS related global
> descriptor table information are available. This is used to decide
> @@ -379,7 +400,7 @@ enum record_i386_regnum
> #define I386_NUM_XREGS 9
>
> /* Size of the largest register. */
> -#define I386_MAX_REGISTER_SIZE 64
> +#define I386_MAX_REGISTER_SIZE 1024
>
> /* Types for i386-specific registers. */
> extern struct type *i387_ext_type (struct gdbarch *gdbarch);
> @@ -396,6 +417,8 @@ extern int i386_k_regnum_p (struct gdbarch *gdbarch,
> int regnum);
> extern int i386_zmm_regnum_p (struct gdbarch *gdbarch, int regnum);
> extern int i386_zmmh_regnum_p (struct gdbarch *gdbarch, int regnum);
> extern bool i386_pkru_regnum_p (struct gdbarch *gdbarch, int regnum);
> +extern bool i386_tilecfg_regnum_p (gdbarch *gdbarch, int regnum);
> +extern bool i386_tmm_raw_regnum_p (gdbarch *gdbarch, int regnum);
>
> extern const char *i386_pseudo_register_name (struct gdbarch *gdbarch,
> int regnum);
> diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
> index 8f972338b3d..e7b4b53462f 100644
> --- a/gdb/i387-tdep.c
> +++ b/gdb/i387-tdep.c
> @@ -939,6 +939,30 @@ static int xsave_pkeys_offset[] =
> (xsave + (tdep)->xsave_layout.pkru_offset \
> + xsave_pkeys_offset[regnum - I387_PKRU_REGNUM (tdep)])
>
> +static int xsave_tilecfg_raw_offset[] =
> +{
> + 0 * 64 /* tilecfg. */
> +};
> +
> +#define XSAVE_TILECFG_RAW_ADDR(tdep, xsave, regnum) \
> + (xsave + (tdep)->xsave_layout.tilecfg_offset \
> + + xsave_tilecfg_raw_offset[regnum - I387_TILECFG_RAW_REGNUM (tdep)])
> +
> +static int xsave_tmm_raw_offset[] =
> +{
> + 0 * X86_AMX_TMM_SIZE, /* tmm0_raw. */
> + 1 * X86_AMX_TMM_SIZE, /* tmm1_raw. */
> + 2 * X86_AMX_TMM_SIZE, /* tmm2_raw. */
> + 3 * X86_AMX_TMM_SIZE, /* tmm3_raw. */
> + 4 * X86_AMX_TMM_SIZE, /* tmm4_raw. */
> + 5 * X86_AMX_TMM_SIZE, /* tmm5_raw. */
> + 6 * X86_AMX_TMM_SIZE, /* tmm6_raw. */
> + 7 * X86_AMX_TMM_SIZE, /* tmm7_raw. */
> +};
> +
> +#define XSAVE_TMM_RAW_ADDR(tdep, xsave, regnum) \
> + (xsave + (tdep)->xsave_layout.tiledata_offset \
> + + xsave_tmm_raw_offset[regnum - I387_TMM0_RAW_REGNUM (tdep)])
>
> /* See i387-tdep.h. */
>
> @@ -946,14 +970,40 @@ bool
> i387_guess_xsave_layout (uint64_t xcr0, size_t xsave_size,
> x86_xsave_layout &layout)
> {
> - if (HAS_PKRU (xcr0) && (xsave_size == 2696 || xsave_size == 11008))
> + if (HAS_AMX (xcr0) && xsave_size == 11008)
> + {
> + /* Intel CPUs supporting AMX. */
> + layout.avx_offset = 576;
> + layout.apx_offset = 960;
> + layout.k_offset = 1088;
> + layout.zmm_h_offset = 1152;
> + layout.zmm_offset = 1664;
> + layout.pkru_offset = 2688;
> + layout.tilecfg_offset = 2752;
> + layout.tiledata_offset = 2816;
> + }
> + else if (HAS_PKRU (xcr0) && (xsave_size == 2696 || xsave_size == 11008))
> {
> /* Intel CPUs supporting PKRU.
> - GDB does not yet support Intel AMX, but CPUs with AMX have
> - a larger XSAVE_SIZE (11008). We must handle this size here,
> - otherwise we cannot read any xsave registers from OS generated
> - core files on AMX systems. The AMX registers themselves will
> - still not be readable though. */
> +
> + XCR0 in core files generated by the gcore command in GDB is based on
> + tdep->xcr0, which i387_collect_xsave writes. tdep->xcr0 is derived
> + from the target description, which does not contain Intel AMX for a
> + 32-bit debuggee.
> +
> + For remote targets, core files generated by the gcore command have
> an
> + XSAVE size based on i387_fallback_xsave_layout, which is therefore
> + only 2696 bytes for a 32-bit debuggee.
> +
> + Native targets derive the XSAVE layout from the XCR0 as reported by
> + the kernel, see x86_linux_tdesc_for_tid. It has the full XSAVE size
> + of 11008 bytes on systems with Intel AMX. For a 32-bit debuggee,
> + tdep->xcr0 does not include Intel AMX, see i386_validate_tdesc_p,
> + while i386_gdbarch_init still stores the native layout in
> + tdep->xsave_layout. The gcore command writes the XSAVE note with
> that
> + size and with tdep->xcr0, e.g. with XCR0 0x2e7 and 11008 bytes.
> + Thus, we must also accept an XSAVE size of 11008 bytes here, to avoid
> + a warning about an unexpected XSAVE size. */
> layout.avx_offset = 576;
> /* Intel APX can be available on CPUs supporting Intel PKRU with or
> without Intel AMX support. */
> @@ -1004,7 +1054,20 @@ i387_fallback_xsave_layout (uint64_t xcr0)
> {
> x86_xsave_layout layout;
>
> - if (HAS_PKRU (xcr0))
> + if (HAS_AMX (xcr0))
> + {
> + /* Intel CPUs supporting AMX. */
> + layout.avx_offset = 576;
> + layout.apx_offset = 960;
> + layout.k_offset = 1088;
> + layout.zmm_h_offset = 1152;
> + layout.zmm_offset = 1664;
> + layout.pkru_offset = 2688;
> + layout.tilecfg_offset = 2752;
> + layout.tiledata_offset = 2816;
> + layout.sizeof_xsave = 11008;
> + }
> + else if (HAS_PKRU (xcr0))
> {
> /* Intel CPUs supporting PKRU. */
> layout.avx_offset = 576;
> @@ -1086,8 +1149,11 @@ i387_supply_xsave (struct regcache *regcache, int
> regnum,
> avx512_xmm_avx512 = 0x80,
> pkeys = 0x100,
> apx = 0x200,
> + tilecfg_raw = 0x400,
> + tmm_raw = 0x800,
> all = x87 | sse | avxh | avx512_k | avx512_zmm0_h | avx512_zmm16_h
> | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys | apx
> + | tilecfg_raw | tmm_raw
> } regclass;
>
> gdb_assert (regs != NULL);
> @@ -1099,6 +1165,11 @@ i387_supply_xsave (struct regcache *regcache, int
> regnum,
> else if (regnum >= I387_R16_REGNUM (tdep)
> && regnum < I387_APX_END_REGNUM (tdep))
> regclass = apx;
> + else if (regnum == I387_TILECFG_RAW_REGNUM (tdep))
> + regclass = tilecfg_raw;
> + else if (regnum >= I387_TMM0_RAW_REGNUM (tdep)
> + && regnum < I387_TMMEND_RAW_REGNUM (tdep))
> + regclass = tmm_raw;
> else if (regnum >= I387_PKRU_REGNUM (tdep)
> && regnum < I387_PKEYSEND_REGNUM (tdep))
> regclass = pkeys;
> @@ -1152,6 +1223,21 @@ i387_supply_xsave (struct regcache *regcache, int
> regnum,
> regcache->raw_supply (regnum, XSAVE_APX_EGPR_ADDR (tdep, regs,
> regnum));
> return;
>
> + case tilecfg_raw:
> + if ((clear_bv & X86_XSTATE_TILECFG))
> + regcache->raw_supply_zeroed (regnum);
> + else
> + regcache->raw_supply (regnum,
> + XSAVE_TILECFG_RAW_ADDR (tdep, regs, regnum));
> + return;
> +
> + case tmm_raw:
> + if ((clear_bv & X86_XSTATE_TILEDATA))
> + regcache->raw_supply_zeroed (regnum);
> + else
> + regcache->raw_supply (regnum, XSAVE_TMM_RAW_ADDR (tdep, regs,
> regnum));
> + return;
> +
> case pkeys:
> if ((clear_bv & X86_XSTATE_PKRU))
> regcache->raw_supply_zeroed (regnum);
> @@ -1346,6 +1432,32 @@ i387_supply_xsave (struct regcache *regcache, int
> regnum,
> }
> }
>
> + /* Handle the tilecfg register. */
> + if ((tdep->xcr0 & X86_XSTATE_TILECFG) != 0)
> + {
> + if ((clear_bv & X86_XSTATE_TILECFG) != 0)
> + regcache->raw_supply_zeroed (I387_TILECFG_RAW_REGNUM
> (tdep));
> + else
> + {
> + i = I387_TILECFG_RAW_REGNUM (tdep);
> + regcache->raw_supply (i,
> + XSAVE_TILECFG_RAW_ADDR (tdep, regs, i));
> + }
> + }
> +
> + /* Handle the raw tile registers. */
> + if ((tdep->xcr0 & X86_XSTATE_TILEDATA) != 0)
> + {
> + for (i = I387_TMM0_RAW_REGNUM (tdep);
> + i < I387_TMMEND_RAW_REGNUM (tdep); i++)
> + {
> + if ((clear_bv & X86_XSTATE_TILEDATA) != 0)
> + regcache->raw_supply_zeroed (i);
> + else
> + regcache->raw_supply (i, XSAVE_TMM_RAW_ADDR (tdep, regs,
> i));
> + }
> + }
> +
> /* Handle the XMM registers. */
> if ((tdep->xcr0 & X86_XSTATE_SSE))
> {
> @@ -1505,8 +1617,11 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
> avx512_xmm_avx512 = 0x100,
> pkeys = 0x200,
> apx = 0x400,
> + tilecfg = 0x800,
> + tmm_raw = 0x1000,
> all = x87 | sse | avxh | avx512_k | avx512_zmm0_h | avx512_zmm16_h
> - | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys | apx
> + | avx512_ymmh_avx512 | avx512_xmm_avx512 | pkeys | apx |
> tilecfg
> + | tmm_raw
> } regclass;
>
> gdb_assert (tdep->st0_regnum >= I386_ST0_REGNUM);
> @@ -1517,6 +1632,11 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
> else if (regnum >= I387_R16_REGNUM (tdep)
> && regnum < I387_APX_END_REGNUM (tdep))
> regclass = apx;
> + else if (regnum == I387_TILECFG_RAW_REGNUM (tdep))
> + regclass = tilecfg;
> + else if (regnum >= I387_TMM0_RAW_REGNUM (tdep)
> + && regnum < I387_TMMEND_RAW_REGNUM (tdep))
> + regclass = tmm_raw;
> else if (regnum >= I387_PKRU_REGNUM (tdep)
> && regnum < I387_PKEYSEND_REGNUM (tdep))
> regclass = pkeys;
> @@ -1589,6 +1709,19 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
> memset (XSAVE_APX_EGPR_ADDR (tdep, regs, i), 0, 8);
> }
>
> + if ((clear_bv & X86_XSTATE_TILECFG))
> + {
> + i = I387_TILECFG_RAW_REGNUM (tdep);
> + memset (XSAVE_TILECFG_RAW_ADDR (tdep, regs, i), 0, 64);
> + }
> +
> + if ((clear_bv & X86_XSTATE_TILEDATA))
> + {
> + i = I387_TMM0_RAW_REGNUM (tdep);
> + memset (XSAVE_TMM_RAW_ADDR (tdep, regs, i), 0,
> + X86_AMX_TILEDATA_SIZE);
> + }
> +
> if ((clear_bv & X86_XSTATE_PKRU))
> for (i = I387_PKRU_REGNUM (tdep);
> i < I387_PKEYSEND_REGNUM (tdep); i++)
> @@ -1672,6 +1805,33 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
> }
> }
>
> + /* Check if the tilecfg register is changed. */
> + if ((tdep->xcr0 & X86_XSTATE_TILECFG))
> + {
> + i = I387_TILECFG_RAW_REGNUM (tdep);
> + regcache->raw_collect (i, raw);
> + p = XSAVE_TILECFG_RAW_ADDR (tdep, regs, i);
> + if (memcmp (raw, p, 64) != 0)
> + {
> + xstate_bv |= X86_XSTATE_TILECFG;
> + memcpy (p, raw, 64);
> + }
> + }
> +
> + /* Check if any raw tile register is changed. */
> + if ((tdep->xcr0 & X86_XSTATE_TILEDATA))
> + for (i = I387_TMM0_RAW_REGNUM (tdep);
> + i < I387_TMMEND_RAW_REGNUM (tdep); i++)
> + {
> + regcache->raw_collect (i, raw);
> + p = XSAVE_TMM_RAW_ADDR (tdep, regs, i);
> + if (memcmp (raw, p, X86_AMX_TMM_SIZE) != 0)
> + {
> + xstate_bv |= X86_XSTATE_TILEDATA;
> + memcpy (p, raw, X86_AMX_TMM_SIZE);
> + }
> + }
> +
> /* Check if any PKEYS registers are changed. */
> if ((tdep->xcr0 & X86_XSTATE_PKRU))
> for (i = I387_PKRU_REGNUM (tdep);
> @@ -1814,6 +1974,16 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
> }
> }
> }
> + else if (regclass == tmm_raw)
> + {
> + regcache->raw_collect (regnum, raw);
> + p = XSAVE_TMM_RAW_ADDR (tdep, regs, regnum);
> + if (memcmp (raw, p, 1024) != 0)
> + {
> + xstate_bv |= X86_XSTATE_TILEDATA;
> + memcpy (p, raw, 1024);
> + }
> + }
> else
> {
> /* Check if REGNUM is changed. */
> @@ -1834,6 +2004,16 @@ i387_collect_xsave (const struct regcache
> *regcache, int regnum,
> }
> break;
>
> + case tilecfg:
> + /* This is a tilecfg register. */
> + p = XSAVE_TILECFG_RAW_ADDR (tdep, regs, regnum);
> + if (memcmp (raw, p, 64) != 0)
> + {
> + xstate_bv |= X86_XSTATE_TILECFG;
> + memcpy (p, raw, 64);
> + }
> + break;
> +
> case pkeys:
> /* This is a PKEYS register. */
> p = XSAVE_PKEYS_ADDR (tdep, regs, regnum);
> diff --git a/gdb/i387-tdep.h b/gdb/i387-tdep.h
> index f029c1e5119..6055b122cba 100644
> --- a/gdb/i387-tdep.h
> +++ b/gdb/i387-tdep.h
> @@ -43,14 +43,18 @@ struct x86_xsave_layout;
> /* Set of constants used for 32 and 64-bit. */
> #define I387_NUM_K_REGS 8
> #define I387_NUM_PKEYS_REGS 1
> +#define I387_NUM_TILECFG_REGS 1
>
> #define I387_PKRU_REGNUM(tdep) ((tdep)->pkru_regnum)
> #define I387_K0_REGNUM(tdep) ((tdep)->k0_regnum)
> #define I387_NUM_ZMMH_REGS(tdep) ((tdep)->num_zmm_regs)
> +#define I387_NUM_TMM_RAW_REGS(tdep) ((tdep)->num_tmm_raw_regs)
> #define I387_ZMM0H_REGNUM(tdep) ((tdep)->zmm0h_regnum)
> #define I387_ZMM16H_REGNUM(tdep) ((tdep)->zmm0h_regnum + 16)
> #define I387_NUM_YMM_AVX512_REGS(tdep) ((tdep)-
> >num_ymm_avx512_regs)
> #define I387_YMM16H_REGNUM(tdep) ((tdep)->ymm16h_regnum)
> +#define I387_TILECFG_RAW_REGNUM(tdep) ((tdep)->tilecfg_raw_regnum)
> +#define I387_TMM0_RAW_REGNUM(tdep) ((tdep)->tmm_raw_regnum)
>
> #define I387_FCTRL_REGNUM(tdep) (I387_ST0_REGNUM (tdep) + 8)
> #define I387_FSTAT_REGNUM(tdep) (I387_FCTRL_REGNUM (tdep) + 1)
> @@ -83,6 +87,8 @@ struct x86_xsave_layout;
>
> #define I387_PKEYSEND_REGNUM(tdep) \
> (I387_PKRU_REGNUM (tdep) + I387_NUM_PKEYS_REGS)
> +#define I387_TMMEND_RAW_REGNUM(tdep) \
> + (I387_TMM0_RAW_REGNUM (tdep) + I387_NUM_TMM_RAW_REGS (tdep))
>
> /* Print out the i387 floating point state. */
>
> diff --git a/gdb/nat/x86-xstate.c b/gdb/nat/x86-xstate.c
> index f0f0b00e859..75719b98746 100644
> --- a/gdb/nat/x86-xstate.c
> +++ b/gdb/nat/x86-xstate.c
> @@ -61,5 +61,7 @@ x86_fetch_xsave_layout (uint64_t xcr0, int len)
> layout.zmm_h_offset = xsave_feature_offset (xcr0, X86_XSTATE_ZMM_H_ID);
> layout.zmm_offset = xsave_feature_offset (xcr0, X86_XSTATE_ZMM_ID);
> layout.pkru_offset = xsave_feature_offset (xcr0, X86_XSTATE_PKRU_ID);
> + layout.tilecfg_offset = xsave_feature_offset (xcr0, X86_XSTATE_TILECFG_ID);
> + layout.tiledata_offset = xsave_feature_offset (xcr0,
> X86_XSTATE_TILEDATA_ID);
> return layout;
> }
> diff --git a/gdb/target-debug.h b/gdb/target-debug.h
> index 949847b181c..9e096a18b7b 100644
> --- a/gdb/target-debug.h
> +++ b/gdb/target-debug.h
> @@ -381,6 +381,8 @@ target_debug_print_x86_xsave_layout (const
> x86_xsave_layout &layout)
> POFFS(zmm);
> POFFS(pkru);
> POFFS(apx);
> + POFFS(tilecfg);
> + POFFS(tiledata);
>
> #undef POFFS
>
> diff --git a/gdb/testsuite/gdb.arch/amd64-amx.c
> b/gdb/testsuite/gdb.arch/amd64-amx.c
> new file mode 100644
> index 00000000000..5dca29ad183
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/amd64-amx.c
> @@ -0,0 +1,115 @@
> +/* Test program for Intel AMX registers.
> +
> + Copyright 2022-2026 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 <immintrin.h>
> +#include <stdint.h>
> +
> +#include "amd64-amx.h"
> +
> +#define TILE int
> +
> +#define N 2
> +#define K 3
> +#define M 4
> +
> +uint8_t memA[N][4 * K] = { { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2 },
> + { 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3 } };
> +
> +uint8_t memB[K][4 * M] = {
> + { 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 },
> +};
> +
> +uint32_t memC[N][M] = { 0 };
> +
> +/* Data for type testing. */
> +
> +int8_t int8_matrix[2][8] = { { -1, -1, -1, -1, 1, 1, 1, 1 },
> + { 1, 1, 1, 1, -5, -5, -5, -5 } };
> +
> +float fp32_matrix[2][2] = { { 1.0, 1.125 },
> + { 1.25, 1.375 } };
> +
> +
> +static void
> +tfmaps_calc (void)
> +{
> + const int strideA = 4 * K;
> + const int strideB = 4 * M;
> + const int strideC = 4 * M;
> +
> + /* Configure. */
> + struct tileconfig_t
> + {
> + uint8_t palette_id;
> + uint8_t startRow;
> + uint8_t reserved[14];
> + uint16_t cols[16];
> + uint8_t rows[16];
> + };
> +
> + struct tileconfig_t tc = { 1 };
> +
> + const TILE A = 0;
> + const TILE B = 1;
> + const TILE C = 2;
> +
> + tc.rows[A] = N;
> + tc.cols[A] = K * 4;
> + tc.rows[B] = K;
> + tc.cols[B] = M * 4;
> + tc.rows[C] = N;
> + tc.cols[C] = M * 4;
> +
> + /* Tiles for testing the remaining element types. */
> + tc.rows[4] = 2;
> + tc.cols[4] = 8;
> + tc.rows[5] = 2;
> + tc.cols[5] = 8;
> +
> + _tile_loadconfig (&tc);
> +
> + /* Load additional types for type testing. */
> + _tile_loadd (4, fp32_matrix, 2 * 4);
> + _tile_loadd (5, int8_matrix, 4 * 2);
> +
> + /* Computation. */
> + _tile_loadd (0, memA, strideA);
> + _tile_loadd (1, memB, strideB);
> + _tile_dpbuud (2, 0, 1);
> + _tile_stored (2, memC, strideC);
> +
> + /* Provoke a SIGSEGV while the tiles are still live, so that the OS
> + writes a core file containing them. */
> + *(volatile int *) 0; /* Crash. */
> +}
> +
> +
> +int
> +main (void)
> +{
> + /* Ask the OS to configure Intel AMX in xsave. */
> + if (amx_enable () != 0)
> + return -1;
> +
> + tfmaps_calc ();
> +
> + return 0;
> +}
> diff --git a/gdb/testsuite/gdb.arch/amd64-amx.exp
> b/gdb/testsuite/gdb.arch/amd64-amx.exp
> new file mode 100644
> index 00000000000..af92e2d37a0
> --- /dev/null
> +++ b/gdb/testsuite/gdb.arch/amd64-amx.exp
> @@ -0,0 +1,192 @@
> +# Copyright 2022-2026 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/>.
> +
> +# This file tests basic Intel AMX functionality. The raw tile registers
> +# always show a tile with its maximum dimensions, that is 16 rows of 64
> bytes.
> +# Only the elements configured in $tilecfg hold data.
> +
> +require allow_amx_tests
> +
> +standard_testfile
> +if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
> + {debug additional_flags=-mamx-tile additional_flags=-mamx-int8}]} {
> + return
> +}
> +
> +if {![runto_main]} {
> + return
> +}
> +
> +proc test_zeroed_tile {reg} {
> + gdb_test "print/d (uint8_t\[16\]\[64\]) $reg" \
> + "= \\{\\{0 <repeats 64 times>\\} <repeats 16 times>\\}"
> +}
> +
> +# Check the tile registers as loaded by the program at the "Crash" line.
> +
> +proc test_loaded_tiles {} {
> + gdb_test "print/x \$tilecfg_raw" \
> + [join {"= 0x20200020302000000000000000000000000000000000" \
> +
> "000000000080008000000100010000c000000000000000000000000000000
> 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}}"]
> +
> + gdb_test "print/d (uint8_t\[16\]\[64\]) \$tmm0_raw" \
> + [join {"= \\{\\{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_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>\\}" \
> + "\\{1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4,\
> + 0 <repeats 48 times>\\}" \
> + "\\{2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5,\
> + 0 <repeats 48 times>\\}" \
> + "\\{0 <repeats 64 times>\\} <repeats 13 times>\\}"} \
> + ", "]
> +
> + 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 (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/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} {
> + test_zeroed_tile "\$tmm${i}_raw"
> + }
> +}
> +
> +# Restart gdb, load the core file generated by gcore or the OS
> +# and check reading registers from the core file.
> +
> +proc test_corefile {core_filename} {
> + clean_restart $::testfile
> +
> + gdb_test "core $core_filename" "Core was generated by .*" \
> + "load core file"
> +
> + test_loaded_tiles
> +}
> +
> +# Registers should be displayed as zeroed before Intel AMX enablement.
> +with_test_prefix "before Intel AMX is enabled" {
> + gdb_test "print \$tilecfg_raw" "= 0"
> + for {set i 0} {$i < 8} {incr i} {
> + test_zeroed_tile "\$tmm${i}_raw"
> + }
> +}
> +
> +# Continue until the program provokes a SIGSEGV. This is required to test
> +# reading tile registers from the OS generated core file below.
> +set line [gdb_get_line_number "Crash"]
> +gdb_breakpoint $line
> +gdb_continue_to_breakpoint "tiles are loaded" ".*$srcfile:$line.*"
> +
> +with_test_prefix "read tiles" {
> + test_loaded_tiles
> +}
> +
> +# Write a core file before modifying the tile registers.
> +set gcorefile $binfile.gcore
> +set gcore_generated [gdb_gcore_cmd $gcorefile "save a core file"]
> +
> +# Test setting tiles.
> +with_test_prefix "setting tiles" {
> + 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>\\}"} \
> + ", "]
> +
> + 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>\\}"} \
> + ", "]
> +
> + 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_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"
> +}
> +
> +# Test generic setting.
> +with_test_prefix "set tilecfg raw" {
> + gdb_test_no_output "set \$tilecfg_raw = 0"
> + gdb_test_no_output "set \$tilecfg.palette = 1"
> +
> + gdb_test "print/x \$tilecfg_raw" "= 0x1"
> + gdb_test "print \$tilecfg" \
> + [string_to_regexp "= {palette = 1, start_row = 0,\
> + colsb = {0, 0, 0, 0, 0, 0, 0, 0}, rows = {0, 0, 0, 0, 0, 0, 0, 0}}"]
> +}
> +
> +with_test_prefix "set tilecfg" {
> + gdb_test_no_output "set \$tilecfg.palette = 0x2"
> + gdb_test_no_output "set \$tilecfg.start_row = 0x3"
> + gdb_test_no_output "set \$tilecfg.rows\[0\] = 0x4"
> +
> + gdb_test "print/x \$tilecfg_raw" \
> + [join {"= 0x40000000000000000000000000000000000000000000" \
> +
> "00000000000000000000000000000000000000000000000000302"} ""]
> + gdb_test "print \$tilecfg" \
> + [string_to_regexp "= {palette = 2, start_row = 3,\
> + colsb = {0, 0, 0, 0, 0, 0, 0, 0}, rows = {4, 0, 0, 0, 0, 0, 0, 0}}"]
> +}
> +
> +# 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} {
> + with_test_prefix "gcore core file" {
> + test_corefile $gcorefile
> + }
> +}
> +
> +# Like the above, but test the core file generated by the OS.
> +with_test_prefix "OS generated core file" {
> + # This test relies on reading address zero triggering a SIGSEGV.
> + # If address zero is readable skip this test.
> + if {[is_address_zero_readable]} {
> + unsupported "address zero is readable"
> + } else {
> + set corefile [core_find $binfile]
> + if {$corefile eq ""} {
> + unsupported "unable to generate core file"
> + } else {
> + test_corefile $corefile
> + }
> + }
> +}
> diff --git a/gdb/testsuite/lib/amd64-amx.h b/gdb/testsuite/lib/amd64-amx.h
> new file mode 100644
> index 00000000000..4b2d0b7ba71
> --- /dev/null
> +++ b/gdb/testsuite/lib/amd64-amx.h
> @@ -0,0 +1,41 @@
> +/* This testcase is part of GDB, the GNU debugger.
> +
> + Copyright 2026 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/>. */
> +
> +#ifndef AMD64_AMX_H
> +#define AMD64_AMX_H
> +
> +#include <asm/prctl.h>
> +#include <sys/syscall.h>
> +#include <unistd.h>
> +
> +/* Intel AMX requires Linux 5.16. ARCH_XCOMP_TILEDATA is added in Linux
> 6.4.
> + Add fallback for previous kernels. */
> +
> +#ifndef ARCH_XCOMP_TILEDATA
> +#define ARCH_XCOMP_TILEDATA 18
> +#endif
> +
> +/* Ask the OS to configure Intel AMX in xsave. Tile data registers are
> + only usable after this succeeded. Return zero on success. */
> +
> +static inline int
> +amx_enable (void)
> +{
> + return syscall (SYS_arch_prctl, ARCH_REQ_XCOMP_PERM,
> ARCH_XCOMP_TILEDATA);
> +}
> +
> +#endif /* AMD64_AMX_H */
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index bc6725b948f..c24cfd5dfbd 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -4635,6 +4635,81 @@ gdb_caching_proc allow_ssp_tests {} {
> return $allow_ssp_tests
> }
>
> +# Run a test on the target to see if it supports AMX. Return 1 if so,
> +# 0 if it does not.
> +
> +gdb_caching_proc allow_amx_tests {} {
> + global srcdir subdir gdb_prompt inferior_exited_re
> +
> + set me "allow_amx_tests"
> + if { ![istarget "x86_64-*-*"] } {
> + verbose "$me: target does not support AMX" 2
> + return 0
> + }
> +
> + # Compile a test program.
> + set src {
> + #include <stdint.h>
> + #include <immintrin.h>
> +
> + #include "amd64-amx.h"
> +
> + int
> + main ()
> + {
> + if (amx_enable () != 0)
> + return 1;
> +
> + struct tileconfig_t {
> + uint8_t palette_id;
> + uint8_t startRow;
> + uint8_t reserved[14];
> + uint16_t cols[16];
> + uint8_t rows[16];
> + };
> +
> + struct tileconfig_t tc = {1};
> + _tile_loadconfig (&tc);
> + _tile_release ();
> +
> + return 0;
> + }
> + }
> + set compile_flags "additional_flags=-mamx-tile"
> + if {![gdb_simple_compile $me $src executable $compile_flags]} {
> + return 0
> + }
> +
> + # 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
> + set allow_amx_tests 0
> + gdb_expect {
> + -re ".*Illegal instruction.*${gdb_prompt} $" {
> + verbose -log "$me: AMX hardware not detected."
> + }
> + -re ".*$inferior_exited_re with code.*${gdb_prompt} $" {
> + verbose -log "$me: AMX not enabled by the OS."
> + }
> + -re ".*$inferior_exited_re normally.*${gdb_prompt} $" {
> + verbose -log "$me: AMX hardware detected."
> + set allow_amx_tests 1
> + }
> + default {
> + warning "\n$me: default case taken."
> + }
> + }
> + gdb_exit
> + remote_file build delete $obj
> +
> + verbose "$me: returning $allow_amx_tests" 2
> + return $allow_amx_tests
> +}
> +
> # Run a test on the target to see if it supports avx512bf16. Return 1 if so,
> # 0 if it does not. Based on 'check_vmx_hw_available' from the GCC testsuite.
>
> diff --git a/gdbserver/i387-fp.cc b/gdbserver/i387-fp.cc
> index 90f146a74d2..7d195c554ce 100644
> --- a/gdbserver/i387-fp.cc
> +++ b/gdbserver/i387-fp.cc
> @@ -138,6 +138,14 @@ public:
> 32 bits. */
> unsigned char *pkru_space ()
> { return xsave () + xsave_layout.pkru_offset; }
> +
> + /* Memory address for the TILECFG register, which is 64 bytes. */
> + unsigned char *tilecfg_space ()
> + { return xsave () + xsave_layout.tilecfg_offset; }
> +
> + /* Memory address of the TILEDATA state component. */
> + unsigned char *tiledata_space ()
> + { return xsave () + xsave_layout.tiledata_offset; }
> };
>
> static_assert (sizeof(i387_xsave) == 576);
> @@ -260,7 +268,7 @@ i387_cache_to_xsave (struct regcache *regcache, void
> *buf)
> unsigned long val, val2;
> unsigned long long xstate_bv = 0;
> unsigned long long clear_bv = 0;
> - char raw[64];
> + char raw[1024];
> unsigned char *p;
>
> /* Amd64 has 16 xmm regs; I386 has 8 xmm regs. */
> @@ -321,6 +329,12 @@ i387_cache_to_xsave (struct regcache *regcache,
> void *buf)
> if (amd64 && (clear_bv & X86_XSTATE_APX_F) != 0)
> for (i = 0; i < num_apx_registers; i++)
> memset (fp->apx_space () + i * 8, 0, 8);
> +
> + if (amd64 && (clear_bv & X86_XSTATE_AMX) != 0)
> + {
> + memset (fp->tilecfg_space (), 0, X86_AMX_TILECFG_SIZE);
> + memset (fp->tiledata_space (), 0, X86_AMX_TILEDATA_SIZE);
> + }
> }
>
> /* Check if any x87 registers are changed. */
> @@ -462,6 +476,35 @@ i387_cache_to_xsave (struct regcache *regcache,
> void *buf)
> }
> }
>
> + /* Check if TILECFG register is changed (only for amd64). */
> + if (amd64 && ((x86_xstate_bv & X86_XSTATE_TILECFG) != 0))
> + {
> + collect_register_by_name (regcache, "tilecfg_raw", raw);
> + p = fp->tilecfg_space ();
> + if (memcmp (raw, p, X86_AMX_TILECFG_SIZE) != 0)
> + {
> + xstate_bv |= X86_XSTATE_TILECFG;
> + memcpy (p, raw, X86_AMX_TILECFG_SIZE);
> + }
> + }
> +
> + /* Check if any raw tile register is changed (only for amd64). */
> + if (amd64 && ((x86_xstate_bv & X86_XSTATE_TILEDATA) != 0))
> + {
> + int tmm0_raw_regnum = find_regno (regcache->tdesc, "tmm0_raw");
> +
> + for (i = 0; i < X86_AMX_NUM_TMM_REGISTERS; i++)
> + {
> + collect_register (regcache, tmm0_raw_regnum + i, raw);
> + p = fp->tiledata_space () + i * X86_AMX_TMM_SIZE;
> + if (memcmp (raw, p, X86_AMX_TMM_SIZE) != 0)
> + {
> + xstate_bv |= X86_XSTATE_TILEDATA;
> + memcpy (p, raw, X86_AMX_TMM_SIZE);
> + }
> + }
> + }
> +
> if ((x86_xstate_bv & X86_XSTATE_SSE) || (x86_xstate_bv &
> X86_XSTATE_AVX))
> {
> collect_register_by_name (regcache, "mxcsr", raw);
> @@ -833,6 +876,31 @@ i387_xsave_to_cache (struct regcache *regcache,
> const void *buf)
> }
> }
>
> + if (amd64 && (x86_xstate_bv & X86_XSTATE_AMX) != 0)
> + {
> + int tilecfg_regnum = find_regno (regcache->tdesc, "tilecfg_raw");
> + int tmm0_raw_regnum = find_regno (regcache->tdesc, "tmm0_raw");
> +
> + if ((clear_bv & X86_XSTATE_TILECFG) != 0)
> + supply_register_zeroed (regcache, tilecfg_regnum);
> + else
> + {
> + p = fp->tilecfg_space ();
> + supply_register (regcache, tilecfg_regnum, p);
> + }
> +
> + if ((clear_bv & X86_XSTATE_TILEDATA) != 0)
> + for (i = 0; i < X86_AMX_NUM_TMM_REGISTERS; i++)
> + supply_register_zeroed (regcache, tmm0_raw_regnum + i);
> + else
> + {
> + p = fp->tiledata_space ();
> + for (i = 0; i < X86_AMX_NUM_TMM_REGISTERS; i++)
> + supply_register (regcache, tmm0_raw_regnum + i,
> + p + i * X86_AMX_TMM_SIZE);
> + }
> + }
> +
> if ((clear_bv & (X86_XSTATE_SSE | X86_XSTATE_AVX))
> == (X86_XSTATE_SSE | X86_XSTATE_AVX))
> {
> diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc
> index f893821fa48..24473ae1916 100644
> --- a/gdbserver/linux-x86-low.cc
> +++ b/gdbserver/linux-x86-low.cc
> @@ -263,6 +263,8 @@ static const int x86_64_regmap[] =
> -1, /* CET user mode register PL3_SSP. */
> -1, -1, -1, -1, -1, -1, -1, -1, /* r16...r31 (APX). */
> -1, -1, -1, -1, -1, -1, -1, -1,
> + -1, /* AMX TILECFG register. */
> + -1, -1, -1, -1, -1, -1, -1, -1, /* AMX tmm0_raw ... tmm7_raw. */
> };
>
> #define X86_64_NUM_REGS (sizeof (x86_64_regmap) / sizeof
> (x86_64_regmap[0]))
> diff --git a/gdbsupport/x86-xstate.h b/gdbsupport/x86-xstate.h
> index 3cb75ccfed6..368c34426b1 100644
> --- a/gdbsupport/x86-xstate.h
> +++ b/gdbsupport/x86-xstate.h
> @@ -29,6 +29,8 @@
> #define X86_XSTATE_ZMM_ID 7
> #define X86_XSTATE_PKRU_ID 9
> #define X86_XSTATE_CET_U_ID 11
> +#define X86_XSTATE_TILECFG_ID 17
> +#define X86_XSTATE_TILEDATA_ID 18
> #define X86_XSTATE_APX_F_ID 19
>
> /* The extended state feature bits. */
> @@ -47,6 +49,11 @@
> #define X86_XSTATE_PKRU (1ULL << X86_XSTATE_PKRU_ID)
> #define X86_XSTATE_CET_U (1ULL << X86_XSTATE_CET_U_ID)
>
> +/* AMX adds two feature bits. Both must be enabled. */
> +#define X86_XSTATE_TILECFG (1ULL << X86_XSTATE_TILECFG_ID)
> +#define X86_XSTATE_TILEDATA (1ULL << X86_XSTATE_TILEDATA_ID)
> +#define X86_XSTATE_AMX (X86_XSTATE_TILECFG |
> X86_XSTATE_TILEDATA)
> +
> /* Total size of the XSAVE area extended region and offsets of
> register states within the region. Offsets are set to 0 to
> indicate the absence of the associated registers. */
> @@ -60,6 +67,8 @@ struct x86_xsave_layout
> int zmm_h_offset = 0;
> int zmm_offset = 0;
> int pkru_offset = 0;
> + int tilecfg_offset = 0;
> + int tiledata_offset = 0;
> };
>
> constexpr bool operator== (const x86_xsave_layout &lhs,
> @@ -71,7 +80,9 @@ constexpr bool operator== (const x86_xsave_layout &lhs,
> && lhs.k_offset == rhs.k_offset
> && lhs.zmm_h_offset == rhs.zmm_h_offset
> && lhs.zmm_offset == rhs.zmm_offset
> - && lhs.pkru_offset == rhs.pkru_offset;
> + && lhs.pkru_offset == rhs.pkru_offset
> + && lhs.tilecfg_offset == rhs.tilecfg_offset
> + && lhs.tiledata_offset == rhs.tiledata_offset;
> }
>
> constexpr bool operator!= (const x86_xsave_layout &lhs,
> @@ -90,21 +101,30 @@ constexpr bool operator!= (const x86_xsave_layout
> &lhs,
> | X86_XSTATE_AVX512 |
> X86_XSTATE_PKRU)
> #define X86_XSTATE_AVX_AVX512_PKU_APX_MASK\
> (X86_XSTATE_AVX_AVX512_PKU_MASK | X86_XSTATE_APX_F)
> +#define X86_XSTATE_AVX_AVX512_PKU_APX_AMX_MASK\
> + (X86_XSTATE_AVX_AVX512_PKU_APX_MASK | X86_XSTATE_AMX)
>
> /* Supported mask of state-component bitmap xstate_bv. The SDM defines
> xstate_bv as XCR0 | IA32_XSS. */
>
> -#define X86_XSTATE_ALL_MASK
> (X86_XSTATE_AVX_AVX512_PKU_APX_MASK\
> - | X86_XSTATE_CET_U)
> +#define X86_XSTATE_ALL_MASK\
> + (X86_XSTATE_AVX_AVX512_PKU_APX_AMX_MASK | X86_XSTATE_CET_U)
>
> #define X86_XSTATE_SSE_SIZE 576
> #define X86_XSTATE_AVX_SIZE 832
>
> +/* Size of the AMX TILECFG register and of the raw tile registers. */
> +
> +#define X86_AMX_TILECFG_SIZE 64
> +#define X86_AMX_TMM_SIZE 1024
> +#define X86_AMX_NUM_TMM_REGISTERS 8
> +#define X86_AMX_TILEDATA_SIZE (X86_AMX_NUM_TMM_REGISTERS *
> X86_AMX_TMM_SIZE)
>
> #define HAS_AVX(XCR0) (((XCR0) & X86_XSTATE_AVX) != 0)
> #define HAS_AVX512(XCR0) (((XCR0) & X86_XSTATE_AVX512) != 0)
> #define HAS_APX(XCR0) (((XCR0) & X86_XSTATE_APX_F) != 0)
> #define HAS_PKRU(XCR0) (((XCR0) & X86_XSTATE_PKRU) != 0)
> +#define HAS_AMX(XCR0) (((XCR0) & X86_XSTATE_AMX) != 0)
>
> /* Initial value for fctrl register, as defined in the X86 manual, and
> confirmed in the (Linux) kernel source. When the x87 floating point
> --
> 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.
I have 2 more comments for the test:
I think it be good if we test gdb_continue_to_end including a " _tile_release ();"
in the test source file like Felix initial version, to make sure we don't end with
an invalid state.
You can make the crash conditional, like the other x86 registers tests for OS core files.
Also, it would be nice if we ran an AMX operation based on data written by GDB.
It doesn't have to be as complex as the previous version of this test though.
Thanks,
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.
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH v2 5/5] gdb: add Intel AMX tile registers as user registers
2026-10-30 11:50 ` [PATCH v2 5/5] gdb: add Intel AMX tile registers as user registers Stephan Rohr
2026-10-30 12:50 ` Eli Zaretskii
@ 2026-11-03 15:19 ` Joos, Christina
2026-11-04 9:00 ` Joos, Christina
1 sibling, 1 reply; 15+ messages in thread
From: Joos, Christina @ 2026-11-03 15:19 UTC (permalink / raw)
To: Rohr, Stephan, gdb-patches; +Cc: pedro, eliz, jhb, luis.machado
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.
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH v2 5/5] gdb: add Intel AMX tile registers as user registers
2026-11-03 15:19 ` Joos, Christina
@ 2026-11-04 9:00 ` Joos, Christina
0 siblings, 0 replies; 15+ messages in thread
From: Joos, Christina @ 2026-11-04 9:00 UTC (permalink / raw)
To: Rohr, Stephan, gdb-patches; +Cc: pedro, eliz, jhb, luis.machado
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.
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2026-11-04 9:00 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30 11:50 [PATCH v2 0/5] Add Intel AMX support Stephan Rohr
2026-10-30 11:50 ` [PATCH v2 1/5] gdb: define additional integer built-in types Stephan Rohr
2026-10-30 12:45 ` Eli Zaretskii
2026-10-30 11:50 ` [PATCH v2 2/5] gdb, gdbserver: Add Intel AMX registers Stephan Rohr
2026-10-30 12:47 ` Eli Zaretskii
2026-11-03 10:44 ` Joos, Christina
2026-11-03 14:40 ` Joos, Christina
2026-10-30 11:50 ` [PATCH v2 3/5] gdb: support register groups for user registers Stephan Rohr
2026-10-30 12:48 ` Eli Zaretskii
2026-10-30 11:50 ` [PATCH v2 4/5] gdb: add a "matrix" register group Stephan Rohr
2026-10-30 12:49 ` Eli Zaretskii
2026-10-30 11:50 ` [PATCH v2 5/5] gdb: add Intel AMX tile registers as user registers Stephan Rohr
2026-10-30 12:50 ` Eli Zaretskii
2026-11-03 15:19 ` Joos, Christina
2026-11-04 9:00 ` Joos, Christina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox