From patchwork Wed Oct 23 16:51:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guinevere Larsen X-Patchwork-Id: 99446 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BC07E3858408 for ; Wed, 23 Oct 2024 16:53:20 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 0A03C3858D3C for ; Wed, 23 Oct 2024 16:51:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0A03C3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0A03C3858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729702321; cv=none; b=a7HaTGz5GupjcSPOQwkrWmqh2ejCvQJ61pGorqGUr0VrXQuz1behdSEYWm8LYSEmAnRhOUNEw4dYbC4geXuEIn+9Edwg9yWnf7w4eMKZlzmUxqgjO+hRyEuQZURNJJCpE/lFoKhaGUZgA9zJJGmbzm6NvrPixHayBrCvEglueTc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1729702321; c=relaxed/simple; bh=4Plv3PLoVKIQB1+s1jE6tbc5/edWBX65F6VT/cpdZUA=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ce6HbLR1C8TkIBh4Nuhvsw+KlwP0zWPFpnUGBqyAV5S6lKkBniYTbwTybioKZiSXwrT0fzXW0Hvvs1GIKNtmNu0mDRmiVRt6qjx/yJnGJd7EDbXZyFEenzVHcX1XPJHXyb+IWRGYjbC42kEPh8zfhYsSgxcwkQcctn59pMYBgLk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729702316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1BDr812XFGfNpE6N/otEUIc/ypcuV2DzM03e68zpMi0=; b=BDaD2chzzeAehdmqcknVapmdZG71FRIAPBOBexiUS7sTjTI0GqK6q7tlBq2nh2YmsCoSLM BR7cgcBTDdbBIEsEw7tXL3XYPAnt78W2A4NMrofEv/AQAYcgkav95PgQO4GU7t+EPOdGF6 XZ14fgAKQcxPKgoGx5CE1eqCirQFcno= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-250-gyabx3oUP-SgpnQKFA32IA-1; Wed, 23 Oct 2024 12:51:55 -0400 X-MC-Unique: gyabx3oUP-SgpnQKFA32IA-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8A021195FE24 for ; Wed, 23 Oct 2024 16:51:54 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.96.134.67]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3A9AF300018D; Wed, 23 Oct 2024 16:51:52 +0000 (UTC) From: Guinevere Larsen To: gdb-patches@sourceware.org Cc: Guinevere Larsen Subject: [PATCH v5 5/7] gdb/record: Add recording support to vpbroadcast instructions Date: Wed, 23 Oct 2024 13:51:15 -0300 Message-ID: <20241023165117.4051131-6-guinevere@redhat.com> In-Reply-To: <20241023165117.4051131-1-guinevere@redhat.com> References: <20241023165117.4051131-1-guinevere@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org This commit adds recording support to all AVX and AVX2 instructions of the form vpbroadcast. GDB is not yet concerned about AVX512 in recording mode, so for now we only support the AVX2 registers and instructions. This commit also updates the gdb.reverse/i386-avx-reverse.exp to test broadcast instructions. --- gdb/i386-tdep.c | 13 +++++++++ gdb/testsuite/gdb.reverse/i386-avx-reverse.c | 29 +++++++++++++++++++ .../gdb.reverse/i386-avx-reverse.exp | 29 +++++++++++++++++++ 3 files changed, 71 insertions(+) diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index a0e0181a2c5..b9ac12edfa3 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -4902,6 +4902,19 @@ i386_record_vex (struct i386_record_s *ir, uint8_t vex_w, uint8_t vex_r, } break; + case 0x78: /* VPBROADCASTB */ + case 0x79: /* VPBROADCASTW */ + case 0x58: /* VPBROADCASTD */ + case 0x59: /* VPBROADCASTQ */ + { + i386_record_modrm (ir); + int reg_offset = ir->reg + vex_r * 8; + gdb_assert (tdep->num_ymm_regs > reg_offset); + record_full_arch_list_add_reg (ir->regcache, + tdep->ymm0_regnum + reg_offset); + } + break; + default: gdb_printf (gdb_stderr, _("Process record does not support VEX instruction 0x%02x " diff --git a/gdb/testsuite/gdb.reverse/i386-avx-reverse.c b/gdb/testsuite/gdb.reverse/i386-avx-reverse.c index c897436995e..16303a42248 100644 --- a/gdb/testsuite/gdb.reverse/i386-avx-reverse.c +++ b/gdb/testsuite/gdb.reverse/i386-avx-reverse.c @@ -130,6 +130,34 @@ vpunpck_test () return 0; /* end vpunpck_test */ } +/* Test if we can record vpbroadcast instructions. */ +int +vpbroadcast_test () +{ + /* Using GDB, load this value onto the register, for ease of testing. + xmm0.uint128 = 0x0 + xmm1.uint128 = 0x1f1e1d1c1b1a19181716151413121110 + xmm15.uint128 = 0x0 + this way it's easy to confirm we're undoing things correctly. */ + /* start vpbroadcast_test. */ + + asm volatile ("vpbroadcastb %xmm1, %xmm0"); + asm volatile ("vpbroadcastb %xmm1, %xmm15"); + + asm volatile ("vpbroadcastw %xmm1, %ymm0"); + asm volatile ("vpbroadcastw %xmm1, %ymm15"); + + asm volatile ("vpbroadcastd %xmm1, %xmm0"); + asm volatile ("vpbroadcastd %xmm1, %xmm15"); + + asm volatile ("vpbroadcastq %xmm1, %ymm0"); + asm volatile ("vpbroadcastq %xmm1, %ymm15"); + + /* We have a return statement to deal with + epilogue in different compilers. */ + return 0; /* end vpbroadcast_test */ +} + int main () { @@ -148,5 +176,6 @@ main () vmov_test (); vpunpck_test (); + vpbroadcast_test (); return 0; /* end of main */ } diff --git a/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp b/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp index 718dca3429a..75c313c2225 100644 --- a/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp +++ b/gdb/testsuite/gdb.reverse/i386-avx-reverse.exp @@ -237,3 +237,32 @@ if {[record_full_function "vpunpck"] == true} { 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 +gdb_test_no_output "set \$ymm0.v2_int128 = {0x0, 0x0}" "set xmm0 for vpbroadcast" +gdb_test_no_output "set \$xmm1.v2_int64 = {0x1716151413121110, 0x1f1e1d1c1b1a1918}" \ + "set xmm1 for vpbroadcast" +gdb_test_no_output "set \$ymm15.v2_int128 = {0x0, 0x0}" "set xmm15 for vpbroadcast" +if {[record_full_function "vpbroadcast"] == true} { + test_one_register "vpbroadcastq" "ymm15" "0x13121110131211101312111013121110, 0x0" + test_one_register "vpbroadcastq" "ymm0" "0x13121110131211101312111013121110, 0x0" + + test_one_register "vpbroadcastd" "ymm15" \ + "0x11101110111011101110111011101110, 0x11101110111011101110111011101110" + test_one_register "vpbroadcastd" "ymm0" \ + "0x11101110111011101110111011101110, 0x11101110111011101110111011101110" + + test_one_register "vpbroadcastw" "ymm15" "0x10101010101010101010101010101010, 0x0" + test_one_register "vpbroadcastw" "ymm0" "0x10101010101010101010101010101010, 0x0" + + test_one_register "vpbroadcastb" "ymm15" "0x0, 0x0" + test_one_register "vpbroadcastb" "ymm0" "0x0, 0x0" + + gdb_test "record stop" "Process record is stopped.*" \ + "delete history for vpbroadcast_test" +} else { + untested "couldn't run vpbroadcast tests" +} + +gdb_test "finish" "Run till exit from.*vpbroadcast_test.*" \ + "leaving vpbroadcast"