* [PATCH v4 2/5] gdb, gdbserver: Add Intel AMX registers.
2026-11-10 15:57 [PATCH v4 0/5] Add Intel AMX support Stephan Rohr
2026-11-10 15:57 ` [PATCH v4 1/5] gdb: define additional integer built-in types Stephan Rohr
@ 2026-11-10 15:57 ` Stephan Rohr
2026-11-10 15:57 ` [PATCH v4 3/5] gdb: support register groups for user registers Stephan Rohr
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Stephan Rohr @ 2026-11-10 15:57 UTC (permalink / raw)
To: gdb-patches; +Cc: pedro, jhb, luis.machado, christina.joos
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.
To hide the raw registers, they are added to the "save" and "restore"
register groups only. The $tilecfg pseudo register is part of the "all"
register group. 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>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Approved-By: Christina Joos <christina.joos@intel.com>
---
gdb/NEWS | 5 +
gdb/amd64-linux-tdep.c | 2 +
gdb/amd64-tdep.c | 66 ++++++-
gdb/amd64-tdep.h | 3 +
gdb/arch/amd64.c | 4 +
gdb/arch/x86-linux-tdesc-features.c | 5 +-
gdb/doc/gdb.texinfo | 39 ++++
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 | 24 ++-
gdb/i387-tdep.c | 197 +++++++++++++++++++-
gdb/i387-tdep.h | 5 +
gdb/nat/x86-xstate.c | 2 +
gdb/target-debug.h | 2 +
gdb/testsuite/gdb.arch/amd64-amx.c | 133 +++++++++++++
gdb/testsuite/gdb.arch/amd64-amx.exp | 268 +++++++++++++++++++++++++++
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, 1133 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 db3fa820df1..1d635d743a0 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..0b3985eb156 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 * const amd64_tilecfg_raw_names[] = {
+ "tilecfg_raw"
+};
+
+/* Register names for the raw AMX tile registers. */
+
+static const char * const 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 * const 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,18 @@ 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->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 +3921,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 +3929,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 2f8869a174c..97ec5ab25ff 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27448,6 +27448,40 @@ 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.
+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
@@ -50890,6 +50924,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 e2333d10ca9..5e8ed11d1d3 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..4b37b8204dd 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -225,6 +225,25 @@ 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 *tmm_raw_register_names = nullptr;
+
/* Register number for %fsbase. If supported, set this to a value
>= 0. */
int fsbase_regnum = -1;
@@ -265,6 +284,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 +399,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 +416,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..080a1b43877 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,20 @@ 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,
+ X86_AMX_TILECFG_SIZE);
+ }
+
+ 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 +1806,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, 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. */
+ 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 +1975,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, X86_AMX_TMM_SIZE) != 0)
+ {
+ xstate_bv |= X86_XSTATE_TILEDATA;
+ memcpy (p, raw, X86_AMX_TMM_SIZE);
+ }
+ }
else
{
/* Check if REGNUM is changed. */
@@ -1834,6 +2005,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, X86_AMX_TILECFG_SIZE) != 0)
+ {
+ xstate_bv |= X86_XSTATE_TILECFG;
+ memcpy (p, raw, X86_AMX_TILECFG_SIZE);
+ }
+ 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..65dd334d3bf 100644
--- a/gdb/i387-tdep.h
+++ b/gdb/i387-tdep.h
@@ -47,10 +47,13 @@ struct x86_xsave_layout;
#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 +86,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..5ca779565b4
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-amx.c
@@ -0,0 +1,133 @@
+/* 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 };
+
+volatile int should_dump_core_p = 1;
+
+/* 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);
+
+ /* Modify the tiles and continue to the crash line. The modified registers
+ must be written back to the target. */
+ asm volatile ("nop"); /* Tiles loaded. */
+
+ /* The test stops at the "nop" above and modifies the Intel AMX registers.
+ Compute again to test the values are written. If the write fails, this
+ computes the same result as above. */
+ _tile_zero (2);
+ _tile_dpbuud (2, 0, 1);
+ _tile_stored (2, memC, strideC);
+
+ /* Crash for OS core file. */
+ if (should_dump_core_p)
+ {
+ /* Generate SIGSEGV to crash. */
+ *(volatile int *) 0;
+ }
+
+ _tile_release ();
+}
+
+
+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..94dfa441daf
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/amd64-amx.exp
@@ -0,0 +1,268 @@
+# 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.
+
+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
+}
+
+gdb_test_no_output "set should_dump_core_p=0"
+
+proc test_zeroed_tile {reg} {
+ gdb_test "print/d (uint8_t\[16\]\[64\]) $reg" \
+ "= \\{\\{0 <repeats 64 times>\\} <repeats 16 times>\\}"
+}
+
+proc test_tiles {} {
+ gdb_test "print/x \$tilecfg_raw" \
+ [join {"= 0x20200020302000000000000000000000000000000000" \
+ "000000000080008000000100010000c" \
+ "00000000000000000000000000000001"} ""]
+
+ 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_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 tiles are loaded.
+set line [gdb_get_line_number "Tiles loaded"]
+gdb_breakpoint $line
+gdb_continue_to_breakpoint "tiles are loaded" ".*$srcfile:$line.*"
+
+with_test_prefix "read tiles" {
+ test_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 that the modified tiles are written back to the target. Some targets,
+# e.g., gdbserver, write the modified registers only when the target is
+# resumed.
+with_test_prefix "after resume" {
+ gdb_test_no_output \
+ "set ((uint8_t\[16\]\[64\]) \$tmm0_raw)\[0\] = {2, 2, 2, 2}"
+ gdb_test_no_output "set ((uint8_t\[16\]\[64\]) \$tmm0_raw)\[1\] = {0}"
+
+ set regs {tilecfg_raw tmm0_raw tmm1_raw}
+ set values {}
+ foreach reg $regs {
+ lappend values [get_valueof "/x" "\$$reg" "" "get $reg before resume"]
+ }
+
+ set line [gdb_get_line_number "if (should_dump_core_p)"]
+ gdb_breakpoint $line
+ gdb_continue_to_breakpoint "resume to the crash" ".*$srcfile:$line.*"
+
+ foreach reg $regs value $values {
+ gdb_test "print/x \$$reg" " = [string_to_regexp $value]" \
+ "$reg after resume"
+ }
+
+ # The test calculated tmm2 = tmm0 * tmm1 again, but this time with the
+ # modified Intel AMX registers. This covers the write path, if the write
+ # fails, we see unexpected output here.
+ gdb_test "print (int\[16\]\[16\]) \$tmm2_raw" \
+ [string_to_regexp "= {{0, 8, 16, 24, 0 <repeats 12 times>},\
+ {0 <repeats 16 times>} <repeats 15 times>}"] \
+ "tmm2_raw computed from the modified tiles"
+ gdb_test "print memC" \
+ [string_to_regexp "= {{0, 8, 16, 24}, {0, 0, 0, 0}}"] \
+ "memC computed from the modified tiles"
+}
+
+# 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}}"]
+}
+
+# Return the Intel AMX registers listed in the output of COMMAND.
+
+proc amx_regs_in_output {command} {
+ set output [capture_command_output $command ""]
+ set re {^(tilecfg(?:_raw)?|tmm[0-7](?:_raw)?)[ \t]}
+ set regs {}
+ foreach {-> reg} [regexp -all -inline -line $re $output] {
+ lappend regs $reg
+ }
+ verbose -log "Intel AMX registers in \"$command\": $regs"
+ return $regs
+}
+
+# The tilecfg pseudo register is in the "all" register group. The raw
+# registers are only in the "save" and "restore" register groups.
+with_test_prefix "register groups" {
+ set raw_regs {tilecfg_raw}
+ for {set i 0} {$i < 8} {incr i} {
+ lappend raw_regs tmm${i}_raw
+ }
+
+ foreach {command expected} [list \
+ "info registers" {} \
+ "info all-registers" {tilecfg} \
+ "info registers general" {} \
+ "info registers all" {tilecfg} \
+ "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
+ }
+}
+
+# Run the program to the end, which releases the tiles. This also checks
+# that the program can continue after the tile configurations written above.
+gdb_continue_to_end
+
+# 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 950bfbcae73..266ecd3e84c 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 ada68211596..50957aa9658 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_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.
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH v4 5/5] gdb: add Intel AMX tile registers as user registers
2026-11-10 15:57 [PATCH v4 0/5] Add Intel AMX support Stephan Rohr
` (3 preceding siblings ...)
2026-11-10 15:57 ` [PATCH v4 4/5] gdb: add a "matrix" register group Stephan Rohr
@ 2026-11-10 15:57 ` Stephan Rohr
2026-11-24 14:01 ` [PING][PATCH v4 0/5] Add Intel AMX support Rohr, Stephan
5 siblings, 0 replies; 7+ messages in thread
From: Stephan Rohr @ 2026-11-10 15:57 UTC (permalink / raw)
To: gdb-patches; +Cc: pedro, jhb, luis.machado, christina.joos
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 implement a union with the following
types:
- int8
- uint8
- int32
- bfloat16
- float
Intel AMX instructions operate on dwords. A row of a tile holds
colsb / 4 dwords, each of which holds four 1-byte elements, two 2-byte
elements or one 4-byte element.
A user register is void if the tile configuration is not valid. That
is, if
- a palette other than palette 1 is selected,
- the number of rows is either zero or exceeds the maximum number of
rows,
- the number of bytes per row (colsb) is zero or exceeds the maximum
number of bytes per row,
- colsb is not a multiple of 4.
Intel AMX instructions cannot operate on a tile with such a
configuration. The raw tile register still shows the contents of the
tile.
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.
Reviewed-By: Christina Joos <christina.joos@intel.com>
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
---
gdb/NEWS | 2 +
gdb/amd64-tdep.c | 68 ++++++++
gdb/doc/gdb.texinfo | 25 ++-
gdb/i386-tdep.c | 104 ++++++++++++
gdb/i386-tdep.h | 96 +++++++++++
gdb/testsuite/gdb.arch/amd64-amx.c | 9 +
gdb/testsuite/gdb.arch/amd64-amx.exp | 239 +++++++++++++++++++++++++--
7 files changed, 526 insertions(+), 17 deletions(-)
diff --git a/gdb/NEWS b/gdb/NEWS
index 0a0d3edc624..afe51616b60 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 0b3985eb156..83ca4be933d 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,24 @@ static const char * const amd64_tmm_raw_names[] = {
"tmm4_raw", "tmm5_raw", "tmm6_raw", "tmm7_raw"
};
+/* Register names for the tmm user registers. */
+
+static const char * const 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 +652,48 @@ amd64_ax_pseudo_register_collect (struct gdbarch *gdbarch,
\f
+/* Return the tile dimensions configured in TILECFG for NEXT_FRAME. */
+
+static tile_dimensions
+amd64_read_tile_dimensions (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 tile_dimensions (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. */
+ tile_dimensions dims = amd64_read_tile_dimensions (next_frame);
+
+ /* Return void if the configuration is not valid, see i386-tdep.h. */
+ if (!dims.is_valid (tmmnum))
+ return value::allocate (builtin_type (gdbarch)->builtin_void);
+
+ uint8_t rows = dims.rows (tmmnum);
+ uint16_t colsb = dims.bytes_per_row (tmmnum);
+
+ /* "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
@@ -3862,6 +3924,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 7f0c8d24c42..6849d990af6 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -27465,7 +27465,11 @@ 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.
-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
@@ -27481,8 +27485,27 @@ $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}).
+
+A user register is @code{void} if its tile is not configured, or if the
+tile configuration is not valid, that is, if:
+
+@itemize @bullet
+@item @code{rows} is zero or exceeds the maximum number of rows.
+@item @code{colsb} is zero or exceeds the maximum number of bytes per row.
+@item @code{colsb} is not a multiple of four, as Intel @acronym{AMX}
+instructions operate on doublewords.
+@end itemize
+
+The raw tile register still shows the contents of the tile.
+
@node Alpha
@subsection Alpha
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 5e8ed11d1d3..2cc91048a64 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,26 @@ i386_pseudo_register_name (struct gdbarch *gdbarch, int regnum)
internal_error (_("invalid regnum"));
}
+/* See i386-tdep.h. */
+
+tile_dimensions::tile_dimensions (gdb::array_view<const gdb_byte> raw_tilecfg)
+{
+ gdb_assert (raw_tilecfg.size () == X86_AMX_TILECFG_SIZE);
+
+ /* Only palette 1 is supported. */
+ if (raw_tilecfg[PALETTE_OFFSET] != 1)
+ return;
+
+ /* 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 +3271,86 @@ 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 TILE_DIMENSIONS::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 (tile_dimensions::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 <= tile_dimensions::MAX_ROWS);
+ gdb_assert (colsb > 0 && colsb <= tile_dimensions::MAX_BYTES_PER_ROW
+ && colsb % 4 == 0);
+
+ /* 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 +4473,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 4b37b8204dd..124b1de77fc 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;
@@ -286,6 +287,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. */
@@ -436,6 +440,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. */
@@ -535,4 +545,90 @@ 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 tile dimensions configured in TILECFG. */
+
+class tile_dimensions
+{
+public:
+ /* Construct it from raw tilecfg data. Only palette 1 is supported.
+ With any other palette, no tile is configured. */
+ explicit tile_dimensions (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;
+ }
+
+ /* Return true if the configuration of tile P is valid. A configuration
+ is invalid if:
+
+ - rows is zero or exceeds MAX_ROWS.
+ - colsb is zero or exceeds MAX_BYTES_PER_ROW.
+ - colsb is not a multiple of 4, as Intel AMX instructions operate
+ on dwords. */
+ inline bool
+ is_valid (uint8_t p) const
+ {
+ gdb_assert (p < NUM_TILES);
+ const tile &t = m_tiles[p];
+ return (t.rows > 0 && t.rows <= MAX_ROWS
+ && t.colsb > 0 && t.colsb <= MAX_BYTES_PER_ROW
+ && t.colsb % 4 == 0);
+ }
+
+ /* 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 palette and of the colsb and rows arrays. */
+ static const uint16_t PALETTE_OFFSET = 0;
+ 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;
+ };
+
+ /* 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 5ca779565b4..0100baf701f 100644
--- a/gdb/testsuite/gdb.arch/amd64-amx.c
+++ b/gdb/testsuite/gdb.arch/amd64-amx.c
@@ -49,6 +49,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)
@@ -81,6 +87,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;
@@ -89,6 +97,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 94dfa441daf..4dfad4a0e25 100644
--- a/gdb/testsuite/gdb.arch/amd64-amx.exp
+++ b/gdb/testsuite/gdb.arch/amd64-amx.exp
@@ -37,14 +37,14 @@ proc test_zeroed_tile {reg} {
proc test_tiles {} {
gdb_test "print/x \$tilecfg_raw" \
- [join {"= 0x20200020302000000000000000000000000000000000" \
- "000000000080008000000100010000c" \
+ [join {"= 0x20202020302000000000000000000000000000000000" \
+ "000000000080008000800100010000c" \
"00000000000000000000000000000001"} ""]
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,\
@@ -53,6 +53,11 @@ proc test_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>\\}" \
@@ -63,26 +68,48 @@ proc test_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"
+ gdb_test "print \$tmm${i}" "= void"
}
}
@@ -119,28 +146,130 @@ 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"
+
+ # Restore the configuration of tmm0. The program computes with it
+ # below.
+ gdb_test_no_output "set \$tilecfg.colsb\[0\] = 12"
}
# Test that the modified tiles are written back to the target. Some targets,
@@ -194,16 +323,90 @@ 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_no_output "set \$tilecfg.colsb\[0\] = 0x4"
gdb_test "print/x \$tilecfg_raw" \
[join {"= 0x40000000000000000000000000000000000000000000" \
- "00000000000000000000000000000000000000000000000000302"} ""]
+ "00000000000000000000400000000000000000000000000000302"} ""]
gdb_test "print \$tilecfg" \
[string_to_regexp "= {palette = 2, start_row = 3,\
- colsb = {0, 0, 0, 0, 0, 0, 0, 0},\
+ colsb = {4, 0, 0, 0, 0, 0, 0, 0},\
rows = {4, 0, 0, 0, 0, 0, 0, 0}}"]
}
+# Test that the user registers are "void" for an invalid configuration.
+with_test_prefix "tile validity" {
+ gdb_test_no_output "set \$tilecfg.palette = 1"
+ gdb_test_no_output "set \$tilecfg.rows\[0\] = 2"
+ gdb_test_no_output "set \$tilecfg.colsb\[0\] = 8"
+
+ gdb_test "print \$tmm0" "= \\{m_int8 = .*\\}" "valid configuration"
+
+ foreach {setting valid invalid} {
+ palette 1 2
+ rows[0] 2 0
+ colsb[0] 8 0
+ colsb[0] 8 6
+ } {
+ with_test_prefix "$setting = $invalid" {
+ gdb_test_no_output "set \$tilecfg.$setting = $invalid"
+ gdb_test "print \$tmm0" "= void"
+ gdb_test_no_output "set \$tilecfg.$setting = $valid"
+ }
+ }
+}
+
+# Test tile dimensions.
+with_test_prefix "tile dimensions" {
+ gdb_test "print \$tmm6" "= void" "print unconfigured tmm6"
+
+ set tile_1x4 [string_to_regexp "= {{0, 0, 0, 0}}"]
+ set type_1x4 [string_to_regexp \
+ "type = uint8_t __attribute__ ((vector_size(1)))\
+ __attribute__ ((vector_size(4)))"]
+ set tile_16x64 \
+ [string_to_regexp "= {{0 <repeats 64 times>} <repeats 16 times>}"]
+ set type_16x64 [string_to_regexp \
+ "type = uint8_t __attribute__ ((vector_size(16)))\
+ __attribute__ ((vector_size(64)))"]
+
+ foreach {rows colsb expected expected_type name} [list \
+ 1 4 $tile_1x4 $type_1x4 "1 row of 4 bytes" \
+ 16 64 $tile_16x64 $type_16x64 "maximum dimensions"] {
+ with_test_prefix $name {
+ gdb_test_no_output "set \$tilecfg.rows\[6\] = $rows"
+ gdb_test_no_output "set \$tilecfg.colsb\[6\] = $colsb"
+ gdb_test "print \$tmm6.m_uint8" $expected
+ gdb_test "ptype \$tmm6.m_uint8" $expected_type
+ }
+ }
+
+ foreach {rows colsb name} {
+ 2 0 "0 bytes per row"
+ 0 8 "0 rows"
+ 2 65 "65 bytes per row"
+ 17 8 "17 rows"
+ 2 2 "2 bytes per row"
+ 2 6 "6 bytes per row"
+ } {
+ with_test_prefix $name {
+ gdb_test_no_output "set \$tilecfg.rows\[6\] = $rows"
+ gdb_test_no_output "set \$tilecfg.colsb\[6\] = $colsb"
+ gdb_test "print \$tmm6" "= void"
+ }
+ }
+
+ foreach palette {0 2} {
+ with_test_prefix "palette $palette" {
+ gdb_test_no_output "set \$tilecfg.rows\[6\] = 2"
+ gdb_test_no_output "set \$tilecfg.colsb\[6\] = 8"
+ gdb_test_no_output "set \$tilecfg.palette = $palette"
+ gdb_test "print \$tmm6" "= void"
+ gdb_test "ptype \$tmm6" "type = void"
+ }
+ }
+}
+
# Return the Intel AMX registers listed in the output of COMMAND.
proc amx_regs_in_output {command} {
@@ -217,19 +420,23 @@ proc amx_regs_in_output {command} {
return $regs
}
-# The tilecfg pseudo register is in the "all" register group. The raw
-# registers are only in the "save" and "restore" register groups.
+# 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" {tilecfg} \
+ "info all-registers" $matrix_regs \
"info registers general" {} \
- "info registers all" {tilecfg} \
+ "info registers all" $matrix_regs \
+ "info registers matrix" $matrix_regs \
"info registers vector" {} \
"info registers float" {} \
"info registers system" {} \
--
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] 7+ messages in thread