From patchwork Tue Oct 25 07:25:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 10537 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp857420wru; Tue, 25 Oct 2022 00:26:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5DdL8Tf9cW2J9i5UxQSA6o8lgIACD3JvpUydK/9WaxtxAVFCKEuxIkfKXSGY+/yqPAHWXx X-Received: by 2002:a05:6402:24a0:b0:454:d197:6238 with SMTP id q32-20020a05640224a000b00454d1976238mr33655383eda.274.1666682771527; Tue, 25 Oct 2022 00:26:11 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id cs15-20020a170906dc8f00b0072b1964e54esi2490675ejc.1007.2022.10.25.00.26.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 00:26:11 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=B+WWsMk+; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c 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 57E77385800F for ; Tue, 25 Oct 2022 07:26:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57E77385800F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666682770; bh=/A7z/czPQF2P8ekzE6rBGvPzhXAM5rl91eSt0yQ++TY=; 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=B+WWsMk+tOUevSkizRK7Cklvmkzd7OMCoNb169ztf+vkowOEKj+vw6/6EdE61ZNTm K/KZ0TWiloHe14PuXnWzhZscClvKUx21jIZIFX4vdGGWqpK3mai5hLymC+PLLbPmjv 1zNgdOCNwzD3DLeam0dSuq+4kxqVraigJYrq3giU= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2071.outbound.protection.outlook.com [40.107.247.71]) by sourceware.org (Postfix) with ESMTPS id 660A938582AD for ; Tue, 25 Oct 2022 07:25:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 660A938582AD ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QOYLcJc1XxzPODqBXWr0d38oufMdsCp/RhwxxM7gK2JqTQc+jGU9xlqU2HPsP2mzE+ASTf0eH6+BfZ0+b2MMd07UtMwQK3Jb/yhIAnut4iwY1jl4hcxhivcVaYAMEhQ8+zybko8qZlhrrpGSpCTFlIssonkUbM79nLJiH5NN5efWE7vYCas/FRlsoXst9TnxplYhpmc/eftne487daT7SRKBvUrPb4WndmPFNAMRBaqon7kC6j1VuPu7DzWNOvTbWRy6GZ3bRXb9CIgGDuREkFDv1Qud8MPYwKJCrEU7yuieFwlJA/NAGOfIVGjdkiOkX1arNd977+ODRHUGP57Tfg== 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=/A7z/czPQF2P8ekzE6rBGvPzhXAM5rl91eSt0yQ++TY=; b=L4R76XmY0l+Ce4Txcr3UeHUOPs7CgSJv3izXLQD4wH8u/6UjyTJ9CtkOw2N8XYT/VqfZBtvTQWLAo3GkB7ceUZQFZBcu87PT92F8Z5drElTQRBZySJvI0FgTBLYcsFv7xl2NubjkZoS0IUUpQ02YlWjoi5dNOWaZnnGozh2iITZzzsNRglHTj2Rcj0NWTERsbkvjBALXNFb9gn3HkBhJ019uOxeob4UgLDoSv+AjPc2DPI22duV+9ewCzeHqhfSgKL2ZYVvCvv4ZTp6E4HZ622F1tAcPsP7k86L44N8F252F6GZYHhEoNM5+V3PuB3tzBARoZAkTNYrSL4eEmuC0ZA== 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 PA4PR04MB7933.eurprd04.prod.outlook.com (2603:10a6:102:b9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.21; Tue, 25 Oct 2022 07:25:27 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::4da2:ea8b:e71e:b8d8%4]) with mapi id 15.20.5746.021; Tue, 25 Oct 2022 07:25:27 +0000 Message-ID: Date: Tue, 25 Oct 2022 09:25:26 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: [PATCH v5 1/8] x86: introduce Pass2 insn attribute Content-Language: en-US To: Binutils References: In-Reply-To: X-ClientProxiedBy: FR3P281CA0170.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::18) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PA4PR04MB7933:EE_ X-MS-Office365-Filtering-Correlation-Id: 0219fffe-7bfd-4cd5-b9f7-08dab65a16ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VfSpW0wb2N5rkeH+cZGEAp1+8qNIuthuEd64e5wrJpDC6u81tGYq584V60Aa9lqXE/u7vC6J2d+vjNRbpG8aPGKsKCTMweLByOFLR28YyooPc/MRs8P+ssd3vLxuI4Ve30A0vcvMEUasdvtrdFbbMjGHqUFlzpGe65T5ILIdPqk+BwiJ+/Jw3qkdVfYCExhlEHHPPQLx/cE9TRvL91mlC6ysi/f2oYO5HBhxZzw30B32EPbrflPwE2J60AvLc5y3p0ypu/3ZK0/hSD21mAQwlGevVznF2UIZaGdhN9vRcOyB0xBB1yOaY9+5SOgC6Ec7rkjmRsrar2I/pVgT+KnGG5FT2vGpxmzkRIHakmEb7lqG3h6d27PoshgVUxqaCl0ZG+SqMkqYU00llI8quAuO0H3coAkRST1ts19blpLxHgOrXZvi3YDLmqMEPPxHqpfLZis82jaRJOKrxjWxmW1OpNIIWezCa5MNoYnIZVTpjh2LHSTDCx7x/KEHL1MCqwo7fFxJYgWt1K8/fQh0ylcTEcXep4NX+gEzRb7pDMVRnDuFjyX8FY+Sm09V9lMfC3Awiuf5yxYuX6hMGaqvtnIz7rCVOMLv7pH5mkxBGaUwB1tqo9HEQXC9pb8N2wEv3kFqTPS9h4Wz1d2Sj3Dn8QfjGXt/R27JoXSg+nq/0lX4gjrREo8B5y+jjvFJk/2fIrxKizshXAHxvp/au5UQUkvBCLZJb/x3I9Jo1vKEPOt7FfqRprFmQoH3y0GFElxGJhtIhQVFWrwjizjjo1baO9WkpNkg6OagDW8MBWxzgznMG/s= 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)(39860400002)(396003)(136003)(366004)(376002)(346002)(451199015)(86362001)(316002)(38100700002)(83380400001)(31696002)(6916009)(6512007)(66476007)(41300700001)(26005)(186003)(2616005)(8936002)(5660300002)(2906002)(8676002)(4326008)(66556008)(66946007)(6506007)(36756003)(6486002)(31686004)(478600001)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?3+nKQRJPkYcx96fsDCD1kPAzLjBv?= =?utf-8?q?ko+ROytVrD113PxxWXkUgc1A3DmYEz0ob9fT0EswP4ZljFmgYH9boI5M2DNVR/pZY?= =?utf-8?q?4LUYcGGQP/KdRbWoBKTOlGNizfsA2Lntxp4L3Sw9OGNRxqWMIWLyEwrE8tzL26B1k?= =?utf-8?q?3HKL/Zh32WMKrWOyl0/vWzB0i3l2mh/n88pdHyhl+UNryTWASerV7M0wvmtErxmvP?= =?utf-8?q?Z6yYgSfC2vCxqAitlC2Gb2sZ/3KwqCPuwpmee9XpN0vwgpDFJJapAyE4nHZi4i9tJ?= =?utf-8?q?9Vfwrk7qtUob7jn3p3CHgMBKK3GBlcr/FkGU7H8X2TFvqGRxnzR949N2PCvQZ1RSW?= =?utf-8?q?CyRK5TvZtpbvjc2NwfCxIKTXesD+EUzWuVOm6N4GLFjKirfEF+fEmY46vcjUAhngc?= =?utf-8?q?JWiAEeAfSA3B8AuK1CUTSSjQCGdd08PJrBOIMktoybZ3W1tpfp42sn/JjA+l0nXfl?= =?utf-8?q?g3gcjz84hXlrbChWqNFKVODqTU0OKWrHRn2YOq2EEf6qBLKGNWv7Ot+Ec63pZQRU7?= =?utf-8?q?iw7dO4Y2p3mU25p8RGvzm/yKEErkoWpjrDkLJsuHC/Cv8e+Elu5UQW5cWG8hw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?= =?utf-8?q?H5BQpeAM2DsJWTJtfoFRpRuGQSSIOunz7axLrSYSEmkFGg3xF6P4rC84AwZe+wDIx?= =?utf-8?q?QIQhEOX5fI0B?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0219fffe-7bfd-4cd5-b9f7-08dab65a16ec X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Oct 2022 07:25:27.5364 (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: 8ZMDbGjodUWH5x3PHyJbtsqlCd5t6sJN7ZQgIxE2DnNsfBk9bpEB16aSkPLc8C5c5x8camOnAcZo4c8YFm0eOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7933 X-Spam-Status: No, score=-3029.6 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?1747643554038627360?= X-GMAIL-MSGID: =?utf-8?q?1747643554038627360?= 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), @@ -800,7 +802,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; @@ -1168,7 +1170,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)); @@ -1191,8 +1194,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; @@ -1867,6 +1873,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) { @@ -1875,6 +1882,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 @@ -730,6 +733,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;