From patchwork Wed Oct 5 07:22:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 1713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp474177wrs; Wed, 5 Oct 2022 00:22:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7p2MlP2OJOk7vH8D3acXE73t9PKUxRyov9uiyXx/GDlNgCitggelgqXjYcDCYicYZhwvhW X-Received: by 2002:a05:6402:4444:b0:458:f355:ce04 with SMTP id o4-20020a056402444400b00458f355ce04mr13951640edb.422.1664954569848; Wed, 05 Oct 2022 00:22:49 -0700 (PDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ne35-20020a1709077ba300b0078116be1dcdsi14062762ejc.340.2022.10.05.00.22.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 00:22:49 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="pYkl/Ra3"; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 34816385828D for ; Wed, 5 Oct 2022 07:22:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34816385828D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664954568; bh=kYqcHG1dEDgRBH5nFSNg/W8o6s/kNFqWsPWYl7CGkow=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=pYkl/Ra35GIRK6Wyzwsn0nQD5q8+vwAqkTEo0B36VjobxwkZAy1a+ZyzjQqp8k8xL fNSqWDGnlOCF4SSv0ekSTQfPAK7qq7EZrnSoliw1z7WHBKJPwFXE1i/qR0X2pkfh/R 1gaxp8DOCzFr9BGPx6UNGmy7yK4zLqSghtjPNw7o= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60053.outbound.protection.outlook.com [40.107.6.53]) by sourceware.org (Postfix) with ESMTPS id C02D8385828E for ; Wed, 5 Oct 2022 07:22:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C02D8385828E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=c92kFaC0h6YpM2+f2ZhpWbfJtNLLlkkJ18BfIhfB3+C3CIbf6xyhtWzHzZmDmQyHh1TK3ACyaBbtdBN6M0iKU2p8Zf616mHbRGA/N3OsC5foedPlQjXxETJ3JiG+0m0quUnjqEhK8AbrwTAfWtuLkXaKbPfgs83+IchVb2ICFGufLiobHz5HiVbL88GLb9R/OogILHode5FO/I8oa1gN3XddBVayX0zfWCjyNwgXWGCXT8P1VLwodB/udbgLwCeOCg27at0ulYzAccpgFArP2jP4GcMggyPsbfQMvCUiDEJg9fu83S8e+AAUA5sUcDJJjX86WAAGFnM6StXS+792kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kYqcHG1dEDgRBH5nFSNg/W8o6s/kNFqWsPWYl7CGkow=; b=Cl9j/k92lxcrciN+r72yUtW1yHMnD81eliJwH+bYeARC6/WryVBBEPtNbc/cU5y6f44WP0FLkA6TwNBzOWnqaaGyNinNw+mIGFvUPDIl+qm4ZJtaiwddWzEXXEHoq/5sHtxPPrwph5k+JKGzfogto+5dzOrHSEwNFucFXUeoOZTr1lZhLTqRvOactQyKtIkb+Y/2g9e5IYaLKJTS8S66E67xBjLfzBe6uI9UO/mpC2VreUhqZLTsOenlBUc3IGrR8UhSYFYSN8OqyZQL28Ni8kuOUJTqehJvFz+CjT6jYG3/wlY0uwHP80Ka5hSYm1+gM7TXRVNL70AfIDkNsGezqQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB7751.eurprd04.prod.outlook.com (2603:10a6:20b:2a2::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.32; Wed, 5 Oct 2022 07:22:23 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2459:15ae:e6cb:218a]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2459:15ae:e6cb:218a%7]) with mapi id 15.20.5676.031; Wed, 5 Oct 2022 07:22:21 +0000 Message-ID: <925cb740-4e1b-abc4-8526-aaab6faae5e1@suse.com> Date: Wed, 5 Oct 2022 09:22:19 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 Subject: [PATCH v3 2/7] x86: introduce Pass2 insn attribute Content-Language: en-US To: Binutils References: <20e2773a-2e47-869b-1900-709f8ad4cd6b@suse.com> In-Reply-To: <20e2773a-2e47-869b-1900-709f8ad4cd6b@suse.com> X-ClientProxiedBy: AS9PR04CA0062.eurprd04.prod.outlook.com (2603:10a6:20b:48b::12) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB7751:EE_ X-MS-Office365-Filtering-Correlation-Id: 892d5112-207e-4381-fb9b-08daa6a257ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OVNKTv9KqN6OozdEWMs7bEb+yqjFKPE4nafhuc5Od1gzHi5AdCaKQWjSWu8yr3ttAKxq+e0FsRUEI0u7N2ffuyo/iNqcdkRnvIbyoT+pQHBZ4szC9cO1utyzUahdSo7sG+JqpXF1cfe16TrKWSIe+TKnZAdtENLp2703RIxCBB7yNSHAdS6TV6prs8h2DDpDEja2bUVENyT6BTKZe++DhN2K0LW1QgQShJQVMl25V65S4hMgtkSJQ+Ev9igNWihYxsRsYnI+9bWIHYPOJ8hoctkTwBBP/1UgKmTokCVq8QOsNmqJjSlLudh/mCxVybcHKPhiE9X2gWTTEuG2uXMZ6mnRy5Q9J/aQOowYaax0Ysqb4GPOph4QK0swGC7MRkgG2/+QHOenObnWbbwX54FBWFsLIdh/XyiykzRR3YV0hZGS0SWuQ7gpWE1UvM5SSnrO1HeBKTVxhmWP64OukoyoCheZAaT3AxFRASaW+fgOegunUpbcAx6tqACKwfFpwp7mVOkZZr8g1Vohs9jZK6dIJb4EShOz9voBaAo1H6AJsJTaTtejxDgOqN+wSBGC9xKcWSxPYGm4HYjnAAYhfqhGsfX9GHzzvIp+nnsfblhgcQGAsMPAWZnDFvU7wzhZ+Zr7vZrHsxLLuhwduwg3cqTtCZ5Yx6A3qFUaew55t6nFy+doMYtpopDTUR1D5RtRnDxueSOQZd4Yr6OwpZsBH6t6bKD9WDnxREWXm2GGFAw2RznKQU8vOLdBbaI5xB3f3y/EEXBUArTIlwQStqSeOg3AaFnTnoG7dr06inrPOrZ4278= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6560.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(376002)(136003)(346002)(366004)(396003)(39860400002)(451199015)(31686004)(36756003)(31696002)(2906002)(5660300002)(2616005)(83380400001)(38100700002)(186003)(6506007)(6512007)(6486002)(478600001)(26005)(66946007)(66476007)(4326008)(316002)(86362001)(8676002)(66556008)(41300700001)(8936002)(6916009)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?zXSY7r04mpwf+pxN2dDlpIL15tbX?= =?utf-8?q?v3gMVGT/wPxqKBB5EVEmkHGur+0sID9plNNt9l00MPLBRCQdx2+oxhmoBUBupp7Jc?= =?utf-8?q?Zy7NRpr3fzDVin9rarhO7WUmDpwESxpw7jjfRCiOmF/j7VdryXVVyB07SgpLWbh7V?= =?utf-8?q?o1PkxqCqbGqNM/OGsXvne+oovDrsX1P3MMMBPi5V4XG6kjbZp2hyxNsqu5F0qunyo?= =?utf-8?q?GgtATdPs7edEyt93i5R7RkyhQ4Pe9rH394ckdpcoMVsEToGWZndqsPaQRGiXAleU2?= =?utf-8?q?3IwzfyTHs5LgQ0dONP0BrX3Fz8sWNkUKl8qt3X7aBlynp2NfJjY1gjCBE4NIRWpvn?= =?utf-8?q?DbtJL+mNW0Tq7XzzRmNc+7UZgOWpmLGrqkJTY0edDUjakynI9VJqWW1ZbcvSsiDXm?= =?utf-8?q?Bp14oDrcrEfzSpGTsWnNu03AOTtigBLf2Eys9y6kiRylk4SKsOvuQiGCdF2+Ov4Iz?= =?utf-8?q?xBVPTC1hPJ9ltHiemLQhV+n/86Qvfm7xUKdgs8Bdxnynk55++6I2dHAD0GX76282e?= =?utf-8?q?gbe/wfXzqM3xV0FrVjlc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yPicpzkQED3mLlJnqcYoktWm8K2tOK+1n8JHQ/zP/1?= =?utf-8?q?WIL6tlp+v/TEpoHQcnbnrLvjZjMbtr9jz8/xNugYyahf1nlWbmQ9qqdtkFq2JciP7?= =?utf-8?q?sFNfYTTM8Dnv?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 892d5112-207e-4381-fb9b-08daa6a257ae X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2022 07:22:21.4219 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fk8gdnzYrNZZzNuTEMdRbPfYMOEDHl/lGb/bFX68+qHstHCz7mrDvNphhgAtnjXEEDQZBCGcthUwr2J6K7LSDg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7751 X-Spam-Status: No, score=-3029.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, 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: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745831403250962406?= X-GMAIL-MSGID: =?utf-8?q?1745831403250962406?= Subsequently we will want to mark templates for mnemonics which, due to their last character also possibly being a suffix, are "shadowing" other templates (and hence may require a second parsing pass). Introduce this attribute in a standalone patch, largely to ease looking at the actual later change. To simplify logic the later change is going to look for the new attribute only on the first template of a group. Make i386-gen warn about misplaced Pass2 (redundant ones are okay). While there convert "active_isstring" to bool, matching the new static variable. --- As to redundant attributes: An open question is whether - to avoid surprises when e.g. templates are re-ordered - it wouldn't be desirable to add Pass2 on all templates of a group. --- v3: New. --- a/opcodes/i386-gen.c +++ b/opcodes/i386-gen.c @@ -18,6 +18,7 @@ MA 02110-1301, USA. */ #include "sysdep.h" +#include #include #include #include "getopt.h" @@ -702,6 +703,7 @@ static bitfield opcode_modifiers[] = BITFIELD (FWait), BITFIELD (IsString), BITFIELD (RegMem), + BITFIELD (Pass2), BITFIELD (BNDPrefixOk), BITFIELD (RegKludge), BITFIELD (Implicit1stXmm0), @@ -801,7 +803,7 @@ static bitfield operand_types[] = static const char *filename; static i386_cpu_flags active_cpu_flags; -static int active_isstring; +static bool active_isstring, active_pass2; struct template_arg { const struct template_arg *next; @@ -1169,7 +1171,8 @@ process_i386_opcode_modifier (FILE *tabl char *str, *next, *last; bitfield modifiers [ARRAY_SIZE (opcode_modifiers)]; - active_isstring = 0; + active_isstring = false; + active_pass2 = false; /* Copy the default opcode modifier. */ memcpy (modifiers, opcode_modifiers, sizeof (modifiers)); @@ -1192,8 +1195,11 @@ process_i386_opcode_modifier (FILE *tabl set_bitfield (str, modifiers, val, ARRAY_SIZE (modifiers), lineno); + if (strcasecmp(str, "IsString") == 0) - active_isstring = 1; + active_isstring = true; + if (strcasecmp(str, "Pass2") == 0) + active_pass2 = true; if (strcasecmp(str, "W") == 0) have_w = 1; @@ -1868,6 +1874,7 @@ process_i386_opcodes (FILE *table) for (j = 0; j < i; j++) { struct opcode_hash_entry *next; + bool first_pass2 = false; for (next = opcode_array[j]; next; next = next->next) { @@ -1876,6 +1883,14 @@ process_i386_opcodes (FILE *table) lineno = next->lineno; last = str + strlen (str); output_i386_opcode (table, name, str, last, lineno); + + if (next == opcode_array[j]) + first_pass2 = active_pass2; + else if (!first_pass2 && active_pass2) + fprintf (stderr, + "Warning: %s:%d: %s: " + "'Pass2' is recognized only on the first template in a group\n", + filename, lineno, name); } } --- a/opcodes/i386-opc.h +++ b/opcodes/i386-opc.h @@ -504,6 +504,9 @@ enum Normally, it will be encoded in the reg field. We add a RegMem flag to indicate that it should be encoded in the regmem field. */ RegMem, + /* The (unsuffixed) mnemonic represents itself the suffixed form of another + mnemonic, potentially requiring a second parsing pass. */ + Pass2, /* quick test if branch instruction is MPX supported */ BNDPrefixOk, /* fake an extra reg operand for clr, imul and special register @@ -732,6 +735,7 @@ typedef struct i386_opcode_modifier unsigned int fwait:1; unsigned int isstring:2; unsigned int regmem:1; + unsigned int pass2:1; unsigned int bndprefixok:1; unsigned int regkludge:1; unsigned int implicit1stxmm0:1;