From patchwork Thu Oct 13 08:17:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 1977 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp152828wrs; Thu, 13 Oct 2022 01:17:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7HIHd1BQZhZpm0KudsD/n0r84t9ED5iMjZh4RxYM1ukZDmwPJL9Rm/ElzN/7o9FWEDY+7T X-Received: by 2002:a17:907:160c:b0:78d:b6f5:9f56 with SMTP id hb12-20020a170907160c00b0078db6f59f56mr14863336ejc.325.1665649079358; Thu, 13 Oct 2022 01:17:59 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id z18-20020a05640240d200b0045cf886717esi460454edb.18.2022.10.13.01.17.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 01:17:59 -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=wm9Kr9U8; 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 8987F385084C for ; Thu, 13 Oct 2022 08:17:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8987F385084C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665649052; 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=wm9Kr9U8bMs0GD8y/A3tzT9XneQyD8ZRz9WEJ0D6T6RQJa/KBkNgBlRD1IKJB73wd Q6bcQRjCo+XUjO9KgUGFsyHt261ofdBqkS0vUnENKCKTod3aA805VnHhwQ41aM2x34 +V2zK8OppYjygZyVaQKNNPdehEvbYuJLJQ1GEAw4= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80048.outbound.protection.outlook.com [40.107.8.48]) by sourceware.org (Postfix) with ESMTPS id BAC35385084E for ; Thu, 13 Oct 2022 08:17:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BAC35385084E ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TIVJQQjHIUgLrPuxxseCoiNi1BTimQkoGsnGZnHPu6eqf2ovkNgQM4cHTg/E+goGE0IEvshk5iwUUcdxRP63G8Bc5uNaOVpOt+yOjOh6OfuEP6gC9jhcRh6hFbOBFgs7yEHtpXPhxsruIT6/r44yZQBgy1CHridqjllzTlncG1gMNqPjsPqTvH37R4x6RvT7NVUKqnJVwcDPEUT5f+s6GO8QEYV48B0piS1HLEP6WdgxsFU5RaRx7oX6PpbWvMfQ89VwjWxAIiduInfhSE7kmtkQYF3IqPFZvifgUgmMcvvHW7nv+DD1RCTchdHD07g5+Sa/1eer6vGbG/YQwBQ9Ag== 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=MdU2X8CdNZOP0YOJrD/OKFMG7eE1g7Hxap9h0mIXXVJjYWcnAxuBHXC+1KX6TsiOeMw9pm07PQXjHHeO5y6x7giQw7N3u2ULtca+j0ImaLC3yRK+NgFyb44Xe/ocibdhAbHxxt4F8Z8GIE3ecSH12+cYz+4fAn1LY0dfdqq+AZ+nuQFMOjFNd7XVfhDhTAYSmvypVQuc7LayWD//qGSLZOo+hf2CgR0OM6ERTZV7YiI2fd036rAgSzg5i40ocv8xufbSHP4AMSyHrbBChAwzra4ar4QmFXETXQh2CiZkksxttB9BdatErBoMTbFsNjhnuzb/nLru+kvpYxRxkhviJA== 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 AS4PR04MB9650.eurprd04.prod.outlook.com (2603:10a6:20b:4cd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26; Thu, 13 Oct 2022 08:17:19 +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.5723.026; Thu, 13 Oct 2022 08:17:19 +0000 Message-ID: <11599bbe-c779-aa9f-4d5d-c2243f0e69dc@suse.com> Date: Thu, 13 Oct 2022 10:17:17 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: [PATCH v4 2/8] x86: introduce Pass2 insn attribute Content-Language: en-US To: Binutils References: <4aa2665c-535f-da2d-1edb-4eb1f4195c3e@suse.com> In-Reply-To: <4aa2665c-535f-da2d-1edb-4eb1f4195c3e@suse.com> X-ClientProxiedBy: FR3P281CA0135.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:94::19) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS4PR04MB9650:EE_ X-MS-Office365-Filtering-Correlation-Id: 9415114d-e5b3-44e4-3747-08daacf3588b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9eAeWBhHDwnMtbyYsb9Jo6YLD3VD0JEszcT16ZsWi/UXreOBuCgithi23b21qcKAg2nyIbzslNaEvc83fr/KMF8LJusWCcAQcpkitxeex5PsaswvwLnvqRvy5eELB9zedAwvUWrTkQcjC5jW1TQpYaiHpuL0AoetO1WW23cpadxoTbq+eu6Yw/kb+4iCHiKtcjzzkAGB4dszIUtuWL15a7Tbj/bAiR5uCKSa2rR/35cSkYZ7m24jqRq4q3r8nxtUegwUIQuWpUmTxN1CYSUpPipakXJJq5hvSUzXkJtnkZ7XjgqteJuDwby1/5J7tcQ+y3y8JXTz42KAC3eJJ8dWYU/uPDFFlb9R74CRjChr5S8kjZiW8QyOwSACCsAs+z6R40kmPaR2Q9LN6zLJJKuYMhruPdUALP20Xxh1w91tMTqObOvKtjC3RiCQuWvsIfwWRGSfijCUCin5449S39Bw+0Rhr/bAhSstlVltju+oh0gHjXSBQ78a8KTXPmyC2DCVNHARuPwDXqWlkDYyW5lzogh0VGc+NC1WjNPw8ToZn+SfJzpEBFF33xxhqA/kVOgtVtcZuoUc1iZsd/KIpKb8Gb5k47HTZA4VRpD+0DsJHGCB5HmFDVt2zTBBWCBeDVuXG5XSUCea67fCLH9Mudk+oyfrxisaQEmY0G8RgvAtFEXGxVcpa1ywlihHJbNkbKz/CWDy9CgHe78vIL7icQ2WZY6rowrcwBlpNkpwtcVpvcDaXDVY45dZZll7MBsiExxcmmvz+0yy169ZZ8aNJz4ULw31QBpqLZccz4KwkFHv5zA= 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)(346002)(376002)(136003)(366004)(39860400002)(396003)(451199015)(8676002)(36756003)(5660300002)(4326008)(186003)(83380400001)(478600001)(316002)(6486002)(31686004)(6916009)(66476007)(66946007)(66556008)(6512007)(86362001)(26005)(2616005)(38100700002)(41300700001)(2906002)(6506007)(31696002)(8936002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?n85S7vV48xP+Xq41ljnXq40arUIZ?= =?utf-8?q?JLl21ZDKUU0nrjuAwVoWPzCl1M2CqD3rA4DJ6unanmffEHKKYvFyODB399BTp3ce/?= =?utf-8?q?346nOFudjUx6inkRO6NH0yqyRbv5piMhuwDxVsDDIUSHfdHV4mlOq5T6paGDHo9UL?= =?utf-8?q?i1UmZUneuUPTUWZPz8ytNOuKGPLANT1rHJwpEJacOx/PxojR6DxBG3QCdTRhZxImA?= =?utf-8?q?ScQtPxGUF4wAFi3+IIxoy+dMYVE++pIyalny2RLWxvEQNwQhKY7m75l9t1I7NxXWN?= =?utf-8?q?5cllWGmChjwK9jEPL7TK4LNHE3HOKXmVehNGsjQ0ENzkToqXM72D18fpakq8HHPO/?= =?utf-8?q?fHjBTX/z/cW9UgIBkMEZmhFBUElLmVUMcYMjz7xdXNWlWZdaru23Hx5GVAHVTJk/c?= =?utf-8?q?oPl7Y8CfWAvO3/ZpLL3J3ftMSwsP/H60Pu+r7Zw8NZvTjMcAgHEDDE53//YBvnEJL?= =?utf-8?q?DFeCAY7LhnWx0se9zzZj25CHQZO8rg7uMoOclDMMomBl7gC519YDywxDuQC0xNgkt?= =?utf-8?q?IsAnyolOe1HKf0ijg4aFJ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hHXTSjTgk5CVs++c6up1AZsogSHtXuZHDHu6UTpMSu8LFTlL4D4fVAbNTdS?= =?utf-8?q?4XpQEc8CRGO2bz82INwBjNu0eN6/nGLLpX3y2K+YEjCPhyJOFX8fO7LYODILToOvO?= =?utf-8?q?fpPOLczBmv6o?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9415114d-e5b3-44e4-3747-08daacf3588b X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2022 08:17:18.9989 (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: A3TrJD+QMbukoVTNiP72bdNOT76IrQesP0QPOejwpjYYeulTFR4pfCJnLHnUzdAO0Gim3LaDAsk/uoMU1WUNVg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9650 X-Spam-Status: No, score=-3029.8 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?1746559649237070496?= X-GMAIL-MSGID: =?utf-8?q?1746559649237070496?= 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;