From patchwork Sun Jan 7 20:07:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 83485 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 43544385841D for ; Sun, 7 Jan 2024 20:08:06 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by sourceware.org (Postfix) with ESMTPS id D46243858CD1 for ; Sun, 7 Jan 2024 20:07:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D46243858CD1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D46243858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::102e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704658060; cv=none; b=o8aAgD6lAwwIot9TDFaKB3HyquAoVohgKKl8HSoYhdUGHibp5A4UDfmIUD7EhBa/tyhQPwd/S4aCZHyTIj4oeNULe3MPK0vss4Xl2UXIieYuM4awiu0m0Yl8D86iYHE9SyzVwBOa6I6PebpwMaIYWCG4FS3s/CBtGGQ6+WE/vlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704658060; c=relaxed/simple; bh=unnK/xAOBWyW5DMkqHw5/6m/dI+hRaxIVx1TBk403ZM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=EbeKS2AWCpUCqFVLDEtwcJKwaTyV12B8JQbHRPua+Ky4xZIUAMiKiIcfe3HhwS34RnI5HdcBp7sMJlrlIc61ztjkzWiOA/Oxyd1YWHH+KQ5Kd7HAkzIxNro5IuzIMXgkaf+7SUWA1ONSKmVDWFVXrhHIUEk22m5Mo0s8FckcZ7g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-28d2be70358so241550a91.0 for ; Sun, 07 Jan 2024 12:07:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704658057; x=1705262857; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=KprYdSWRR+ckAo+uvjNLH5tg61NNCCqNlDLB0+TvU8E=; b=J7Uwa+Os8GZgG8AQW1K8RL5MEWPnNi3yhBs3ei91WI+PENz+f5l9umBKt/b2eVQ0re Yoh+VMWHFgzs7yPAZCjo8qL+7xz+jYunOq8UR8EK5zUF/Ng6mRi+GY8ZTmj8hflcUA7F n2ig5v85CG14beLN7DS8v4/4dH4xmr25ochi7qiAMSXWw7mV05VBWDH7/tqzhkq7f8zn bK0IMjOi/7rHuzf3tElj4/R7RTm3JEos99odWi+cQ0slDGEi7KpRChsRh7RaYdofodml JTySLl2tuU0VyuXjngEWeWoYXPcl8gLrmLG7UZFr1DUMGv/TTpmXoP0xznQ9hBJ1HyLD fJ+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704658057; x=1705262857; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KprYdSWRR+ckAo+uvjNLH5tg61NNCCqNlDLB0+TvU8E=; b=AvGsC43GvKoUPmSQDjc+mQloSFjMmAc94jsq+x5WwIbyuyRFc91QB/7Gn543fMGC5R ZFUDz1zun3q9pZCjBENdoKwNrhX8KMrR4I3eAeZR1p4kNiWk/wX6qu1KuZKL2Z5VkEKk yv8jIF1jSE1J3ah31W3gruNyz+LHKDMRJxq1OjS50Xag3AP9VcaX1pWNN+XYQfTy9oGv BkKlRAx2NFJsdWobmN980l8Hx95zhFwIgJe5vvPQ3FMowyKe2NNdwGb1oaCi3PeRs5yv JzRQJVKWBwDOlKwmbDZl3yI8d+Vxx/saxmrkc2HTVdJNjK25eXLLGz7g++Bh8QTnXGYC YYyQ== X-Gm-Message-State: AOJu0Yxc7yZZ0w/8e0fLXPCBh1BQ+Tl+IeJMyspQx3JJpMyV6/aFsIdn q3IPeYnrvDjjlN2lPwCakR8wrPNGAAU= X-Google-Smtp-Source: AGHT+IFZjSNY/J3ZvbpcPx1d0qKGykBYO+LNnFpfR0enrEBqtSl+iWv6cdP8R8vuZK/GVG4mVrf1VA== X-Received: by 2002:a05:6a00:2d1f:b0:6d9:b4e6:12c5 with SMTP id fa31-20020a056a002d1f00b006d9b4e612c5mr891192pfb.0.1704658057256; Sun, 07 Jan 2024 12:07:37 -0800 (PST) Received: from gnu-cfl-3.localdomain ([172.56.169.119]) by smtp.gmail.com with ESMTPSA id p28-20020a056a000a1c00b006d9b30b33b0sm4618561pfh.196.2024.01.07.12.07.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jan 2024 12:07:36 -0800 (PST) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id EE3E27401CA for ; Sun, 7 Jan 2024 12:07:34 -0800 (PST) From: "H.J. Lu" To: binutils@sourceware.org Subject: [PATCH] i386: Correct adcx suffix in disassembler Date: Sun, 7 Jan 2024 12:07:34 -0800 Message-ID: <20240107200734.209130-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-3021.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org Since 0x66 is the opcode prefix for adcx, it is wrong to use the 'S' prefix: 'S' => print 'w', 'l' or 'q' if suffix_always is true on adcx. Add 'L' => print 'l' or 'q' if suffix_always is true replace S with L on adcx and adox. gas/ PR binutils/31219 * testsuite/gas/i386/suffix.d: Updated. * testsuite/gas/i386/x86-64-suffix.d: Likewise. * testsuite/gas/i386/suffix.s: Add tests for adcx and adox. * testsuite/gas/i386/x86-64-suffix.s: Likewise. opcodes/ PR binutils/31219 * i386-dis.c: Add the 'L' suffix. (prefix_table): Replace S with L on adcx and adox. (putop): Handle the 'L' suffix. --- gas/testsuite/gas/i386/suffix.d | 2 ++ gas/testsuite/gas/i386/suffix.s | 4 ++++ gas/testsuite/gas/i386/x86-64-suffix.d | 4 ++++ gas/testsuite/gas/i386/x86-64-suffix.s | 6 ++++++ opcodes/i386-dis.c | 17 +++++++++++++---- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/gas/testsuite/gas/i386/suffix.d b/gas/testsuite/gas/i386/suffix.d index d76dca3decd..3d0282ada68 100644 --- a/gas/testsuite/gas/i386/suffix.d +++ b/gas/testsuite/gas/i386/suffix.d @@ -22,4 +22,6 @@ Disassembly of section .text: [ ]*[a-f0-9]+: cf iretl [ ]*[a-f0-9]+: 0f 07 sysretl [ ]*[a-f0-9]+: 0f 07 sysretl +[ ]*[a-f0-9]+: 66 0f 38 f6 d1 adcxl %ecx,%edx +[ ]*[a-f0-9]+: f3 0f 38 f6 d1 adoxl %ecx,%edx #pass diff --git a/gas/testsuite/gas/i386/suffix.s b/gas/testsuite/gas/i386/suffix.s index 7f2864d8ed4..4cd85d5274e 100644 --- a/gas/testsuite/gas/i386/suffix.s +++ b/gas/testsuite/gas/i386/suffix.s @@ -22,3 +22,7 @@ foo: iret sysretd sysret + + .att_syntax prefix + adcxl %ecx, %edx + adoxl %ecx, %edx diff --git a/gas/testsuite/gas/i386/x86-64-suffix.d b/gas/testsuite/gas/i386/x86-64-suffix.d index e8edfa47bec..928f4bc35ad 100644 --- a/gas/testsuite/gas/i386/x86-64-suffix.d +++ b/gas/testsuite/gas/i386/x86-64-suffix.d @@ -26,4 +26,8 @@ Disassembly of section .text: [ ]*[a-f0-9]+: 0f 07 sysretl [ ]*[a-f0-9]+: 48 89 e5 movq %rsp,%rbp [ ]*[a-f0-9]+: 48 0f 07 sysretq +[ ]*[a-f0-9]+: 66 0f 38 f6 d1 adcxl %ecx,%edx +[ ]*[a-f0-9]+: f3 0f 38 f6 d1 adoxl %ecx,%edx +[ ]*[a-f0-9]+: 66 48 0f 38 f6 d1 adcxq %rcx,%rdx +[ ]*[a-f0-9]+: f3 48 0f 38 f6 d1 adoxq %rcx,%rdx #pass diff --git a/gas/testsuite/gas/i386/x86-64-suffix.s b/gas/testsuite/gas/i386/x86-64-suffix.s index a226836215c..1f40cd63f5d 100644 --- a/gas/testsuite/gas/i386/x86-64-suffix.s +++ b/gas/testsuite/gas/i386/x86-64-suffix.s @@ -25,3 +25,9 @@ foo: sysretd mov rbp,rsp sysretq + + .att_syntax prefix + adcxl %ecx, %edx + adoxl %ecx, %edx + adcxq %rcx, %rdx + adoxq %rcx, %rdx diff --git a/opcodes/i386-dis.c b/opcodes/i386-dis.c index 51bf7922694..7edae20c323 100644 --- a/opcodes/i386-dis.c +++ b/opcodes/i386-dis.c @@ -1778,7 +1778,7 @@ struct dis386 { 'I' unused. 'J' unused. 'K' => print 'd' or 'q' if rex prefix is present. - 'L' unused. + 'L' => print 'l' or 'q' if suffix_always is true 'M' => print 'r' if intel_mnemonic is false. 'N' => print 'n' if instruction has no wait "prefix" 'O' => print 'd' or 'o' (or 'q' in Intel mode) @@ -3654,8 +3654,8 @@ static const struct dis386 prefix_table[][4] = { /* PREFIX_0F38F6 */ { { "wrssK", { M, Gdq }, 0 }, - { "adoxS", { VexGdq, Gdq, Edq}, 0 }, - { "adcxS", { VexGdq, Gdq, Edq}, 0 }, + { "adoxL", { VexGdq, Gdq, Edq }, 0 }, + { "adcxL", { VexGdq, Gdq, Edq }, 0 }, { Bad_Opcode }, }, @@ -10602,7 +10602,16 @@ putop (instr_info *ins, const char *in_template, int sizeflag) *ins->obufp++ = 'd'; break; case 'L': - abort (); + if (ins->intel_syntax) + break; + if (sizeflag & SUFFIX_ALWAYS) + { + if (ins->rex & REX_W) + *ins->obufp++ = 'q'; + else + *ins->obufp++ = 'l'; + } + break; case 'M': if (ins->intel_mnemonic != cond) *ins->obufp++ = 'r';