]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/record: add support for floating point vunpck instructions
authorGuinevere Larsen <guinevere@redhat.com>
Wed, 8 Jan 2025 12:37:47 +0000 (09:37 -0300)
committerGuinevere Larsen <guinevere@redhat.com>
Tue, 14 Jan 2025 17:47:56 +0000 (14:47 -0300)
This commit adds support for the AVX instructions vunpck[l|h][ps|pd]
instructions, which was pretty straightforward.

This commit also fixes a mistake in the test, where "record stop" was
used after the recording was already stopped, if it failed during
vpunpck_test recording. It also improved the documentation at the start
of the relevant .c function.

Approved-By: Guinevere Larsen <guinevere@redhat.com>
gdb/i386-tdep.c
gdb/testsuite/gdb.reverse/i386-avx-reverse.c
gdb/testsuite/gdb.reverse/i386-avx-reverse.exp

index 61dc45688b5583ed4af68bb37cf4b68cd8505db0..44123979186a49d9a9654e2aea5af4a933759544 100644 (file)
@@ -4849,6 +4849,12 @@ i386_record_vex (struct i386_record_s *ir, uint8_t vex_w, uint8_t vex_r,
          i386_record_lea_modrm (ir);
        }
       break;
+    case 0x14: /* VUNPCKL[PS|PD].  */
+    case 0x15: /* VUNPCKH [PS|PD].  */
+      i386_record_modrm (ir);
+      record_full_arch_list_add_reg (ir->regcache,
+                                    tdep->ymm0_regnum + ir->reg + vex_r * 8);
+      break;
     case 0x6e: /* VMOVD XMM, reg/mem  */
       /* This is moving from a regular register or memory region into an
         XMM register. */
index 9d82bb0bc5136e7ed77343ac3c08e9e2a6c47ba6..f41c7ff2933e0959cfca0fa01503902835e30dd9 100644 (file)
@@ -182,6 +182,7 @@ vpunpck_test  ()
   /* Using GDB, load these values onto registers, for ease of testing.
      ymm0.v2_int128  = {0x1f1e1d1c1b1a19181716151413121110, 0x2f2e2d2c2b2a29282726252423222120}
      ymm1.v2_int128  = {0x4f4e4d4c4b4a49484746454443424140, 0x3f3e3d3c3b3a39383736353433323130}
+     ymm2.v2_int128 = {0x0, 0x0}
      ymm15.v2_int128 = {0xdead, 0xbeef}
      so that's easy to confirm that the unpacking went as expected.  */
 
@@ -220,6 +221,25 @@ vpunpck_test  ()
   asm volatile ("vpunpckhdq  %ymm0, %ymm1,  %ymm15");
   /* 17 16 15 14 13 12 11 10 ...*/
   asm volatile ("vpunpckhqdq %ymm0, %ymm1, %ymm15");
+
+  /* Test some of the floating point unpack instructions.  */
+  /* 17 27 16 26 15 25 14 24 ...*/
+  asm volatile ("vunpcklps  %xmm0, %xmm1, %xmm15");
+  /* 17 16 27 26 15 14 25 24 ...*/
+  asm volatile ("vunpcklps  %ymm0, %ymm1, %ymm2");
+  /* 17 16 15 14 27 26 25 24 ...*/
+  asm volatile ("vunpcklpd  %xmm0, %xmm1,  %xmm2");
+  /* 17 16 15 14 13 12 11 10 ...*/
+  asm volatile ("vunpcklpd %ymm0, %ymm1, %ymm15");
+  /* 17 27 16 26 15 25 14 24 ...*/
+  asm volatile ("vunpckhps  %xmm0, %xmm1, %xmm15");
+  /* 17 16 27 26 15 14 25 24 ...*/
+  asm volatile ("vunpckhps  %ymm0, %ymm1, %ymm2");
+  /* 17 16 15 14 27 26 25 24 ...*/
+  asm volatile ("vunpckhpd  %xmm0, %xmm1,  %xmm2");
+  /* 17 16 15 14 13 12 11 10 ...*/
+  asm volatile ("vunpckhpd %ymm0, %ymm1, %ymm15");
+
   /* We have a return statement to deal with
      epilogue in different compilers.  */
   return 0; /* end vpunpck_test */
index 45d89840f81c91065f5dccccc006e016146ff370..e3d1bbb3faa737105a3d78a799fe1a466bb4b8f1 100644 (file)
@@ -298,6 +298,25 @@ gdb_test_no_output \
 gdb_test_no_output "set \$ymm2.v2_int128 = {0x0, 0x0}"
 gdb_test_no_output "set \$ymm15.v2_int128 = {0xdead, 0xbeef}"
 if {[record_full_function "vpunpck"] == true} {
+    # Floating point unpack instructions.
+    test_one_register "vunpckhpd" "ymm15" \
+       "0x1f1e1d1c3f3e3d3c1b1a19183b3a3938, 0x0"
+    test_one_register "vunpckhpd" "ymm2" \
+       "0x1f1e1d1c3f3e3d3c1b1a19183b3a3938, 0x2f2e2d2c4f4e4d4c2b2a29284b4a4948"
+    test_one_register "vunpckhps" "ymm2" \
+       "0x17161514131211103736353433323130, 0x0"
+    test_one_register "vunpckhps" "ymm15" \
+       "0x17161514131211103736353433323130, 0x27262524232221204746454443424140"
+    test_one_register "vunpcklpd" "ymm15" \
+       "0x17161514373635341312111033323130, 0x0"
+    test_one_register "vunpcklpd" "ymm2" \
+       "0x17161514373635341312111033323130, 0x27262524474645442322212043424140"
+    test_one_register "vunpcklps" "ymm2" \
+       "0x1f1e1d1c1b1a19183f3e3d3c3b3a3938, 0x0"
+    test_one_register "vunpcklps" "ymm15" \
+       "0x1f1e1d1c1b1a19183f3e3d3c3b3a3938, 0x2f2e2d2c2b2a29284f4e4d4c4b4a4948"
+
+
     test_one_register "vpunpckhqdq" "ymm15" \
        "0x1f1e1d1c3f3e3d3c1b1a19183b3a3938, 0x2f2e2d2c4f4e4d4c2b2a29284b4a4948" \
        "ymm: "
@@ -325,14 +344,15 @@ if {[record_full_function "vpunpck"] == true} {
     test_one_register "vpunpcklwd" "ymm15" \
        "0x17371636153514341333123211311030, 0x0"
     test_one_register "vpunpcklbw" "ymm15" "0xdead, 0xbeef"
+
+    # Move to the end of vmov_test to set up next.
+    # Stop recording in case of recording errors.
+    gdb_test "record stop" "Process record is stopped.*" \
+       "delete history for vpunpck_test"
 } else {
     untested "couldn't test vpunpck tests"
 }
 
-# Move to the end of vmov_test to set up next.
-# Stop recording in case of recording errors.
-gdb_test "record stop" "Process record is stopped.*" \
-    "delete history for vpunpck_test"
 gdb_test "finish" "Run till exit from.*vpunpck_test.*" "leaving vpunpck_test"
 
 # Start vpbroadcast tests