Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: <Ezra.Sitorus@arm.com>
To: <gdb-patches@sourceware.org>
Cc: <eliz@gnu.org>, <luis.machado.foss@gmail.com>,
	Ezra Sitorus <ezra.sitorus@arm.com>
Subject: [PATCH 4/4] gdb/aarch64: Tests for verifying fp8 register formats
Date: Thu, 25 Sep 2025 22:18:04 +0100	[thread overview]
Message-ID: <20250925211804.21967-5-Ezra.Sitorus@arm.com> (raw)
In-Reply-To: <20250925211804.21967-1-Ezra.Sitorus@arm.com>

From: Ezra Sitorus <ezra.sitorus@arm.com>

The non-SVE version tests the V + B registers. The SVE version tests the
Z, V and B registers.
---
 gdb/testsuite/gdb.arch/aarch64-fp8-reg.c   | 49 ++++++++++++++++++++++
 gdb/testsuite/gdb.arch/aarch64-fp8-reg.exp | 42 +++++++++++++++++++
 gdb/testsuite/gdb.arch/aarch64-fp8-sve.c   | 49 ++++++++++++++++++++++
 gdb/testsuite/gdb.arch/aarch64-fp8-sve.exp | 45 ++++++++++++++++++++
 4 files changed, 185 insertions(+)
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-fp8-reg.c
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-fp8-reg.exp
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-fp8-sve.c
 create mode 100644 gdb/testsuite/gdb.arch/aarch64-fp8-sve.exp

diff --git a/gdb/testsuite/gdb.arch/aarch64-fp8-reg.c b/gdb/testsuite/gdb.arch/aarch64-fp8-reg.c
new file mode 100644
index 00000000000..cd85138c176
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-fp8-reg.c
@@ -0,0 +1,49 @@
+/* This test program is part of GDB, the GNU debugger.
+
+   Copyright 2024-2025 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/>.  */
+
+int
+main (void)
+{
+  char e4m3[] = { 0b00000001, 0b00000000, 0b10000000, 0b01111010,
+		  0b01111011, 0b01111100, 0b01111101, 0b01111110,
+		  0b01111111, 0b00001000, 0b01110000, 0b01111111,
+		  0b11111111, 0b01111110, 0b11111110, 0b0 };
+
+  char e5m2[] = { 0b00000001, 0b00000011, 0b00000100, 0b01110000,
+		  0b01111100, 0b01111101, 0b01111110, 0b11111111,
+		  0b11111100, 0b11111101, 0b11111110, 0b11111111,
+		  0b0,	0b10000000, 0b0,	0b0 };
+
+  long val;
+  void *addr = &e4m3[0];
+  __asm __volatile ("ldr %x0, [%1]\n\t"
+		    "ldr q0, [%x0]"
+		    : "=r"(val)
+		    : "r"(&addr)
+		    : "q0");
+  /* CHECK_E4M3  */
+
+  addr = &e5m2[0];
+  __asm __volatile ("ldr %x0, [%1]\n\t"
+		    "ldr q0, [%x0]"
+		    : "=r"(val)
+		    : "r"(&addr)
+		    : "q0");
+
+  /* CHECK_E5M2  */
+  return 1;
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-fp8-reg.exp b/gdb/testsuite/gdb.arch/aarch64-fp8-reg.exp
new file mode 100644
index 00000000000..41f4dcf38ea
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-fp8-reg.exp
@@ -0,0 +1,42 @@
+# Copyright 2025 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 test checks that GDB correctly displays FP8 formats in AArch64
+# vector registers.
+
+require is_aarch64_target
+
+standard_testfile
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+    return -1
+}
+
+if ![runto_main] {
+    return -1
+}
+
+set e4m3_breakpoint "CHECK_E4M3"
+gdb_breakpoint [gdb_get_line_number $e4m3_breakpoint]
+gdb_continue_to_breakpoint "Continue until E4M3 check"
+
+gdb_test "p \$v0.b.e4m3" "v0.b.e4m3.* = \{ ?0.00195, ?0, ?-0, ?320, ?352, ?384, ?416, ?448, ?nan\\(0x7\\), ?0.0156, ?128, ?nan\\(0x7\\), ?-nan\\(0x7\\), ?448, ?-448, ?0\}" "e4m3 register check"
+gdb_test "p \$b0.e4m3" "b0.e4m3.* = 0.00195" "e4m3 b pseudo-register check"
+
+set e5m2_breakpoint "CHECK_E5M2"
+gdb_breakpoint [gdb_get_line_number $e5m2_breakpoint]
+gdb_continue_to_breakpoint "Continue until E5M2 check"
+
+gdb_test "p \$v0.b.e5m2" "v0.b.e5m2.* = \{ ?1.5e-05, ?4.6e-05, ?6.1e-05, ?8.2e\\+03, ?inf, ?nan\\(0x1\\), ?nan\\(0x2\\), ?-nan\\(0x3\\), ?-inf, ?-nan\\(0x1\\), ?-nan\\(0x2\\), ?-nan\\(0x3\\), ?0, ?-0, ?0, ?0\}" "e5m2 register check"
+gdb_test "p \$b0.e5m2" "b0.e5m2.* = 1.5e-05" "e5m2 b pseudo-register check"
diff --git a/gdb/testsuite/gdb.arch/aarch64-fp8-sve.c b/gdb/testsuite/gdb.arch/aarch64-fp8-sve.c
new file mode 100644
index 00000000000..cd85138c176
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-fp8-sve.c
@@ -0,0 +1,49 @@
+/* This test program is part of GDB, the GNU debugger.
+
+   Copyright 2024-2025 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/>.  */
+
+int
+main (void)
+{
+  char e4m3[] = { 0b00000001, 0b00000000, 0b10000000, 0b01111010,
+		  0b01111011, 0b01111100, 0b01111101, 0b01111110,
+		  0b01111111, 0b00001000, 0b01110000, 0b01111111,
+		  0b11111111, 0b01111110, 0b11111110, 0b0 };
+
+  char e5m2[] = { 0b00000001, 0b00000011, 0b00000100, 0b01110000,
+		  0b01111100, 0b01111101, 0b01111110, 0b11111111,
+		  0b11111100, 0b11111101, 0b11111110, 0b11111111,
+		  0b0,	0b10000000, 0b0,	0b0 };
+
+  long val;
+  void *addr = &e4m3[0];
+  __asm __volatile ("ldr %x0, [%1]\n\t"
+		    "ldr q0, [%x0]"
+		    : "=r"(val)
+		    : "r"(&addr)
+		    : "q0");
+  /* CHECK_E4M3  */
+
+  addr = &e5m2[0];
+  __asm __volatile ("ldr %x0, [%1]\n\t"
+		    "ldr q0, [%x0]"
+		    : "=r"(val)
+		    : "r"(&addr)
+		    : "q0");
+
+  /* CHECK_E5M2  */
+  return 1;
+}
diff --git a/gdb/testsuite/gdb.arch/aarch64-fp8-sve.exp b/gdb/testsuite/gdb.arch/aarch64-fp8-sve.exp
new file mode 100644
index 00000000000..ef79f0fd036
--- /dev/null
+++ b/gdb/testsuite/gdb.arch/aarch64-fp8-sve.exp
@@ -0,0 +1,45 @@
+# Copyright 2025 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 test checks that GDB correctly displays FP8 formats in AArch64
+# vector registers.
+
+require is_aarch64_target
+require allow_aarch64_sve_tests
+
+standard_testfile
+if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
+    return -1
+}
+
+if ![runto_main] {
+    return -1
+}
+
+set e4m3_breakpoint "CHECK_E4M3"
+gdb_breakpoint [gdb_get_line_number $e4m3_breakpoint]
+gdb_continue_to_breakpoint "Continue until E4M3 check"
+
+gdb_test "p \$z0.b.e4m3" "z0.b.e4m3.* = \{ ?0.00195, ?0, ?-0, ?320, ?352, ?384, ?416, ?448, ?nan\\(0x7\\), ?0.0156, ?128, ?nan\\(0x7\\), ?-nan\\(0x7\\), ?448, ?-448, ?0.*\}" "e4m3 z register check"
+gdb_test "p \$v0.b.e4m3" "v0.b.e4m3.* = \{ ?0.00195, ?0, ?-0, ?320, ?352, ?384, ?416, ?448, ?nan\\(0x7\\), ?0.0156, ?128, ?nan\\(0x7\\), ?-nan\\(0x7\\), ?448, ?-448, ?0\}" "e4m3 v pseudo register check"
+gdb_test "p \$b0.e4m3" "b0.e4m3.* = 0.00195" "e4m3 b pseudo-register check"
+
+set e5m2_breakpoint "CHECK_E5M2"
+gdb_breakpoint [gdb_get_line_number $e5m2_breakpoint]
+gdb_continue_to_breakpoint "Continue until E5M2 check"
+
+gdb_test "p \$z0.b.e5m2" "z0.b.e5m2.* = \{ ?1.5e-05, ?4.6e-05, ?6.1e-05, ?8.2e\\+03, ?inf, ?nan\\(0x1\\), ?nan\\(0x2\\), ?-nan\\(0x3\\), ?-inf, ?-nan\\(0x1\\), ?-nan\\(0x2\\), ?-nan\\(0x3\\), ?0, ?-0, ?0.*\}" "e5m2 z register check"
+gdb_test "p \$v0.b.e5m2" "v0.b.e5m2.* = \{ ?1.5e-05, ?4.6e-05, ?6.1e-05, ?8.2e\\+03, ?inf, ?nan\\(0x1\\), ?nan\\(0x2\\), ?-nan\\(0x3\\), ?-inf, ?-nan\\(0x1\\), ?-nan\\(0x2\\), ?-nan\\(0x3\\), ?0, ?-0, ?0, ?0\}" "e5m2 v pseudo register check"
+gdb_test "p \$b0.e5m2" "b0.e5m2.* = 1.5e-05" "e5m2 b pseudo-register check"
-- 
2.45.2


  parent reply	other threads:[~2025-09-25 21:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-25 21:18 [PATCH 0/4] gdb: Display fp8 format for AArch64 registers Ezra.Sitorus
2025-09-25 21:18 ` [PATCH 1/4] libiberty: Add fp8 float formats Ezra.Sitorus
2025-09-25 21:18 ` [PATCH] gdb: Add support for fp8 formats Ezra.Sitorus
2025-09-25 21:18 ` [PATCH 3/4] gdb/aarch64: Display fp8 formats in registers Ezra.Sitorus
2025-10-11 13:10   ` Luis
2025-10-14  0:56     ` Ezra Sitorus
2025-10-17 10:20       ` Luis
2025-09-25 21:18 ` Ezra.Sitorus [this message]
2025-09-29 17:55 ` [PATCH 0/4] gdb: Display fp8 format for AArch64 registers Pedro Alves

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250925211804.21967-5-Ezra.Sitorus@arm.com \
    --to=ezra.sitorus@arm.com \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=luis.machado.foss@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox