From patchwork Fri Nov 18 09:14:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 22218 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp80210wrr; Fri, 18 Nov 2022 01:14:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf4m01c9xmMMi0jv9yB/b9K/GtN3ZNnDVqT2rf/K94NpwPbZKyO0rsL6pX2DfYNWt4v73/le X-Received: by 2002:a17:907:6e12:b0:730:631c:40b7 with SMTP id sd18-20020a1709076e1200b00730631c40b7mr5199126ejc.336.1668762898126; Fri, 18 Nov 2022 01:14:58 -0800 (PST) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id tb26-20020a1709078b9a00b00741a16e8562si2406330ejc.826.2022.11.18.01.14.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Nov 2022 01:14:58 -0800 (PST) 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=WvcrtVBb; 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 281043839F71 for ; Fri, 18 Nov 2022 09:14:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 281043839F71 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668762876; bh=o9B8ohx8JZ1kX4Oa16fVe5cglMOstwygd5/FedkPTS8=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=WvcrtVBbiJ+eypVJGAljHnDTA96byXVux/H/QAu4NKCO+Gs6WL9yvJV60y1ofZJkW LNNi8bWjeJn6mgUk0ogW+mrITryyjRxBpH8PsCa3bINW34MDs6io583hRxs1RJks/7 jnZGicQtPB6+MW3wx0Yv/vdSLbJB6+QG+cBjsZOY= 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 33BC23860744 for ; Fri, 18 Nov 2022 09:14:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 33BC23860744 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jWCzaUcpV8ygf4HRvo67AmCDgKeMLkiOz6XVA8LP9enDFzy61synNF1l18xepN+njuR6eGZ6hUcoaAB4RTtP9nGi2DCaMZ7wVHZkfP1kKD8eqyOyzxTNDY5/chuegtY/BT6bx+1kBdg5YhKejzLJyUhllQGHlXNizaKCMKYRwm3VUd8twfIoudk4RCxFFhDu4tflKshcTzvOlfY+bxd6WZPX3l47B2fhagBn2Hi7jm6TqcHNF+nrmHv3o/jhJqf9JG3vxfUj45RsRugxu4tiU1aRX09hEw0tWG1oiwIkhKx5cciPuIg4hTUwQEJnT+ha9PYhxdA42fj4B9WPRH9ySw== 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=o9B8ohx8JZ1kX4Oa16fVe5cglMOstwygd5/FedkPTS8=; b=ShJq11FZyVoL3fSVHMKOJyKczGhiwe3GirWc2KKBzSTM4FM0pGephsmM4Kc2O5gLs/2t4TuORtkxNuBUtjSha9J1PbHXqrAQYfXR1DfyicC0Pr8sGBeOKgUxENM2IGHmrFFkwN/X5EuXm+pwZFc63JsCkAhqUfOGHs4AlvObDDGg/n3Uy+GBtQ3pwCst6Q7zxVKx8Xmc0Bc87rZ4nqf79JN3PsEyp6CNw0JNKV04rB01FEDpvUg+pJPMc3W4aQqqnlupn6u/mgCz5K0/xS5oDRPq3cfKc0Nue9t5kQ2zHYILOmfarhPR06y6Ems4nJUyj7r6f4UbDxIv5AUfbgMNzA== 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 AS8PR04MB9094.eurprd04.prod.outlook.com (2603:10a6:20b:445::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.9; Fri, 18 Nov 2022 09:14:06 +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.5813.018; Fri, 18 Nov 2022 09:14:06 +0000 Message-ID: Date: Fri, 18 Nov 2022 10:14:05 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: [PATCH v2 4/4] x86: drop sentinel from i386_optab[] Content-Language: en-US To: Binutils Cc: "H.J. Lu" References: <7a1ee76a-5b54-32a6-6301-a1741b5c1883@suse.com> In-Reply-To: <7a1ee76a-5b54-32a6-6301-a1741b5c1883@suse.com> X-ClientProxiedBy: FR3P281CA0149.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:95::20) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB9094:EE_ X-MS-Office365-Filtering-Correlation-Id: 72a928b4-a2fd-4fc1-c34b-08dac9453e48 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LL0ZSqsG1bTJfi0wlxzmN/XsJ7TnurbJPYzYu7a+1PdQ4ujMuf6VXqlKS45p8QVu/S1aE/na6MrxneAnCaKhabwWX3LKs70ouJscy7M+XyqItn1iPY1xP08xhrQtkfxria22YE3qfE8mdDoWA1gQpuRi0B9c36pIJ/tAYVeWT6b0pCBFtTYqtNBlyL8yh2h+jZNCe8mbZ6RbxaNfBRvNXKX4Ah4wCigTIXL2+67wJqsmFBvQW7rZEX7iI368d71rJ9eedV74OxrRg1kFwnJK/HFgGg+fl8lT6lbW1yMfW2aw1Ng+kRe2cWe2pWKYWwwp/ctVjdVMcbnf0upPvYF0rePwuMnF74WIPxOsZebz6kSRkoVDV8jChVqEbe5DTg89BCKNkA7tiQTMgJM+DW0olgGAHsdtA3M/0TAZBAkfIuXuev0fbjAjqIvi57pE6fw0BBSSOOhuxyVhnHw20Pdirz7REb5xxcRVd9qzRk6wi8J6QfxqPMDe9mgpSVMA5r5sZFQchd5UaLyh9C/cmpvyPxxmLhgutzXa74pOw5jK0/fjl4e5aAW6e0grHdjHrAh3y8Murk0Cm8aOIGXfPk2Vn4+OGMY8EhNWmmOmwgTVW68HIAj1+zcg/cor/vAbbVcS0rcGa/sb0l1S3UaiOMlwQZ4WMeN4w9rlKDQOOMjiXjlFyC7YgLmj1CLWJfMa+joJyhhAQPJ5Vjyr3VsEhkNrklPxec9nQss+dwZi3QbbYKU= 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)(136003)(366004)(39860400002)(376002)(346002)(396003)(451199015)(316002)(6916009)(31696002)(6512007)(26005)(8676002)(38100700002)(4326008)(66476007)(86362001)(66556008)(66946007)(83380400001)(2906002)(36756003)(2616005)(41300700001)(5660300002)(186003)(8936002)(31686004)(478600001)(6486002)(6506007)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?6VnkuIVba9Gc0yR96dFoAr25SdnU?= =?utf-8?q?heiMpxwlgSt8E8cZ3J+BYVXmvvPtPvQLKGhOc46Ds5Lbi/KByy3hbB5ReQR9MMPI5?= =?utf-8?q?jmmnNMKqXLWrD7vioVF4QF8fGlRBADFeSfJ04ThIqeEaJ/RjyPuV0GudzISVY2xVp?= =?utf-8?q?kWfjGUXf6AeAg6Tl2tudn4qL9TQi9EJ91tLnGAzAOzKF27DQyaUwZMVSkIUYYyUm/?= =?utf-8?q?iFKzMf0o5J3gmQ1RkIZCEbiznju/Q7Jr1J7nQPR5bQOIh5yx9zddfT4fbUMdyie65?= =?utf-8?q?vIZ/3E5mKr3+uBuqQ0yjmS7T/qrB5BBLE4TqaWAlYmkktRdua6wO1wfrRZffRHvTF?= =?utf-8?q?0PkygE1n5cPhTiFs+zSUx/yHVJ65P2PAhnczGRzVzw8BYK3/RgBmQwycdX643+PEw?= =?utf-8?q?SREy4/zoKDidi1B1p9PtqWjn8mKTKJe2xTJu1EU6VnuGTSUJ1KjhPYp1CGsxD9TwM?= =?utf-8?q?ZA0+A+NRkYw1ItxmLx8bye6VxfzWB1TAETNN5wqBd/Pi8AKtut+8m6dY3ybPmS9gR?= =?utf-8?q?phZqjwEvmH55RXJeWDXjiuRc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/rYU4+i6VPpNVixdiNu40ZveL0amjM5?= =?utf-8?q?IFhdRut9NrdQTj7eX2s4HPDuxR2PpiAM0D7EyHQ9QRZD15Ond+6tQVClZqEFQw9u9?= =?utf-8?q?2W70gbCWhilm?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72a928b4-a2fd-4fc1-c34b-08dac9453e48 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Nov 2022 09:14:06.2322 (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: fHskb09o+niBxrVa8w4L9N8401dbTmc7II/vbSpJTRuUDXDFSydrKs5FQzIZb0H9Ksxr+2LrJCVzcdtf5B/pRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB9094 X-Spam-Status: No, score=-3029.3 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?1749824724848717466?= X-GMAIL-MSGID: =?utf-8?q?1749824724848717466?= Now that the table is local to gas, ARRAY_SIZE() can be used to determine the end of the table. Re-arrange the processing loop in md_begin() accordingly, at the same time folding the two calls to notes_alloc() into just one. --- v2: New. --- We may want to consider having i386-gen also produce a table of type "templates[]", which we could then iterate through without needing to do any allocations (and with fewer overall iterations). --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -2981,31 +2981,20 @@ md_begin (void) op_hash = str_htab_create (); { - const insn_template *optab; - templates *core_optab; + const insn_template *optab = i386_optab; + const insn_template *end = optab + ARRAY_SIZE (i386_optab); - /* Setup for loop. */ - optab = i386_optab; - core_optab = notes_alloc (sizeof (*core_optab)); - core_optab->start = optab; - - while (1) + while (optab < end) { - ++optab; - if (optab->name == NULL - || strcmp (optab->name, (optab - 1)->name) != 0) - { - /* different name --> ship out current template list; - add to hash table; & begin anew. */ - core_optab->end = optab; - if (str_hash_insert (op_hash, (optab - 1)->name, core_optab, 0)) - as_fatal (_("duplicate %s"), (optab - 1)->name); + templates *core_optab = notes_alloc (sizeof (*core_optab)); - if (optab->name == NULL) - break; - core_optab = notes_alloc (sizeof (*core_optab)); - core_optab->start = optab; - } + core_optab->start = optab; + while (++optab < end) + if (strcmp (optab->name, optab[-1].name) != 0) + break; + core_optab->end = optab; + if (str_hash_insert (op_hash, optab[-1].name, core_optab, 0)) + as_fatal (_("duplicate %s"), optab[-1].name); } } --- a/opcodes/i386-gen.c +++ b/opcodes/i386-gen.c @@ -1916,16 +1916,6 @@ process_i386_opcodes (FILE *table) fclose (fp); - fprintf (table, " { NULL, 0, 0, 0,\n"); - - process_i386_opcode_modifier (table, "0", 0, 0, NULL, -1); - - process_i386_cpu_flag (table, "0", 0, ",", " ", -1); - - fprintf (table, " { "); - process_i386_operand_type (table, "0", stage_opcodes, "\t ", -1); - fprintf (table, " } }\n"); - fprintf (table, "};\n"); }