From patchwork Mon Nov 28 11:30:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 26634 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5593148wrr; Mon, 28 Nov 2022 03:31:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf64iNVT46Fnwedwdm5dycz18uii5SddvwkYPNgIwM8LXSFVNG0iJqaGZsZLbWJEKy/70T6j X-Received: by 2002:a17:906:8922:b0:7bd:3aaa:466d with SMTP id fr34-20020a170906892200b007bd3aaa466dmr11398309ejc.1.1669635065591; Mon, 28 Nov 2022 03:31:05 -0800 (PST) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ec40-20020a0564020d6800b00461c314f79fsi9115378edb.284.2022.11.28.03.31.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Nov 2022 03:31:05 -0800 (PST) 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=Z6HiOyAk; 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 22009385B53E for ; Mon, 28 Nov 2022 11:30:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22009385B53E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1669635058; bh=l1TKD7P+srXb/v9W1xJZcGBYvtrePe0cmhVYGqKQh2U=; 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=Z6HiOyAk0niTjdFSmRsNSxwe+bLTHAZ0SiYOwdseX/IHVq+QZ4oQ6F+p7c9KhGcVU 52MHSY0bhdsLLoAxPMMvuh6UFaujDKxwOngmuZsvfUpcFS9+UW/xO7BtaFtFxJTsZY 29PdqKoskSt+qO0JeocgD/x1BJR/DSm7Jz8JQdEY= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02on2058.outbound.protection.outlook.com [40.107.249.58]) by sourceware.org (Postfix) with ESMTPS id 8E3473858D3C for ; Mon, 28 Nov 2022 11:30:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8E3473858D3C ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DVYfM1joKsPuwprcIoXhiDeNzP9cXh+gkKaTKfIrMeOGQ3I7dOhB1ZqemxN0yMnmKNXV1yf2cwLCB4GVaRbplsSB3I09REA2QMPPcSdu+2Nw3Z1fT6YQxU6otJIyBk+sCpX2qtvqKBcJAyRmllmo64ACoPyom0QB2qGEo56d343WMOaZijr3QnG2NetRNdS/iCQXXa1dyyptlMFPlmsPVbbVRbarwQ2DYK4W7VrL9ysuR0Zg9wVQ/YOdG77ReBuEShOfrHbAjVeizu7LKsKFsjNfeDeb89LSS/erCPHXt7TvMt+5JO8/6f+1oZFD4YQPUXGcIa5FYNcXkPc08JOibg== 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=l1TKD7P+srXb/v9W1xJZcGBYvtrePe0cmhVYGqKQh2U=; b=It+UTohIIIqBPBqSe/1qCtKdYmLkJ7cvffajj4Ztft2PqxRtp7nlU1FWh6yaCd+XQVOd2Fjz+HOlPe8OCO7V9S9xiWlNvr+towVElFvyH6bZM6QrrgQBK7LsinZiDPTU4gVHEy2Anc3yhMTHL8YG4Qzz6yNI3OInj2MipGoy/TL3nZOxuYecO6IHz8RHJ0WexNKHD9BLnX8p9uMcsTQU4bSEjF+nkQ3NaHBHMzC2UygYUV1fW0ilTHve2YVEnQI/krzaRPGFrbfmKla68Q3RJxp1YEEEYizzsYH2F6ENuf2pCJSXaqgHikxPiFwZRlrzKrErXmCpEPrCNpEiXutAeA== 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 PAXPR04MB8543.eurprd04.prod.outlook.com (2603:10a6:102:216::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.20; Mon, 28 Nov 2022 11:30:47 +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.5857.023; Mon, 28 Nov 2022 11:30:47 +0000 Message-ID: Date: Mon, 28 Nov 2022 12:30:46 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0 Subject: [PATCH v3 1/6] x86: instantiate i386_{op, reg}tab[] in gas instead of in libopcodes Content-Language: en-US To: Binutils Cc: "H.J. Lu" References: <8f385c36-cfe5-1b0a-45b6-ea6c008b20c8@suse.com> In-Reply-To: <8f385c36-cfe5-1b0a-45b6-ea6c008b20c8@suse.com> X-ClientProxiedBy: FR2P281CA0105.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:9c::17) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PAXPR04MB8543:EE_ X-MS-Office365-Filtering-Correlation-Id: c4468240-047b-4b02-8c9b-08dad133fedd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bo3dZx3UXIwRf2H9cTgB2LfILLqNpUOCirriO4SAISGJ62D73H+LD1B79AYJdwQHyfH4YolSfUQmy4nQomnrkTmzyKXr6IygVvlIl+mllmRcpfPceFFRqlBca9qvRog4dvSFwx0mdS+W17BVC1aTxTK+ZnithnOignNXKJDRvKOZcbgtq8th6VqScVU/J65M/a1CixRILrMwu2QHRnQoyoIbIxS1hn3C3xkn9pFWgzfmoWvZ1RPr7LMmxEmzAzyaP5KjPKr9pl3SQgMyLjccsKWTytRYxMgoFn2TbC8FtK3gY89gTxt/6WE80OAjNt22K3qzK6i1vnqE1y25jEp5ZFGC+Xcf9J/tNSHXlix5BfurBd9dDKG282yRzgMg5yOp2ja7+nzsv6LxwgZIE9RrcYugLZQIVXTtVwLJFcRbfSQcL7ywWOpiXbBXU+RX1r3xEphbKthiOsBXT36cYzfzhX3PWN1eREQn2x1mMN45i5/22fRQsuvfij17P6VZS43mz+ztLHI1X1BNbFsCWIBNKggZNbP5dh7CzdBym9TSF4vdomauVqBjaltvai8oSAcl8+HYO9yzyRhEClIQEKi4aKjKph+UNb+5W7eLAfSKs14UHOs703Pl/XA4O/1RryCSFEZ7HAnKDF5hdx2rWRNjFof7SqOSwnqYMyaSPWMx1bzwBvy4pF4C5WoyvkWaE0yuHwWcz/v8wn/iz+Pe0a353j3z5nyW4ViGdQdGTGK3efY= 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)(366004)(396003)(136003)(376002)(346002)(39860400002)(451199015)(2616005)(31686004)(2906002)(83380400001)(6512007)(6506007)(38100700002)(66946007)(66476007)(41300700001)(66556008)(8676002)(6486002)(36756003)(26005)(478600001)(186003)(5660300002)(8936002)(4326008)(86362001)(31696002)(316002)(6916009)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?dkKhYKJ17zYDoOdRUJMpjHNlqcQj?= =?utf-8?q?xhBNGNa2mGWn7tP6sZcevcRTGsDN3VyGPqKp+3HPmdBRfrYr2Tse1StP20bZ03ESt?= =?utf-8?q?sZVUYaMrUTSQttUtYVNQoy6riSmri7kAtpWNQLd6xghScvPUWBj6ui+q7p/wysTI0?= =?utf-8?q?eghH5AR7h0CTGKpsu9o/+r6oshfFJIHTEBKwnwyQRVrGfbLM26UzrQ3NeI2BJjGt/?= =?utf-8?q?+O1blhviVZYX0q9B94odvPj5R/5tawrD9QwU96y3su7iW/SxCoF1DPtEpntgDZT7m?= =?utf-8?q?LKpdBnr4MeXMqOm7I1m3hWwvch0BR0V4QqVR6shviMz/aYwygjkRT8SlthZK80ksM?= =?utf-8?q?DbGEMxaXywk+4ZHE26jdK1de3zvLZ9GBUGHufg0j98OSHfPrJ7hd0r8jnwRPxqQZH?= =?utf-8?q?0Ks9+oyg3we5FTPTYEjh3cPvDRUIqogavGst40Df6ooLbhUol9EuSeHTPLTEal31b?= =?utf-8?q?+S0lTdVLrXivrW7XgUQ+zpFLVQ6aNG48H9IgvDMVli2JyH422km9UUiK5VcjYmDd5?= =?utf-8?q?RK7pFdseTB39gT9CmdiaT/vlUZ+VI+gTkO/7kTr+hiR4LU1Wilk4zX1jWOXmKkbT8?= =?utf-8?q?J6q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?jdR8pX8mX/5/aZQjDNjgLuv+8B94QhM/OoHhELeR0RaVLv0q9JnW2lZwBxyNihhXP?= =?utf-8?q?hB2R11l5P5LT?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4468240-047b-4b02-8c9b-08dad133fedd X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Nov 2022 11:30:47.7066 (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: X2LBFhyORx1dQvpXO9Ln3D4s/DtaKQBn6CcsfMEmNS3J/IEWOztfIbUNvSC+t0vUUAhRbFnatKhwJz2AlwT3yA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8543 X-Spam-Status: No, score=-3029.2 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?1750739258528220583?= X-GMAIL-MSGID: =?utf-8?q?1750739258528220583?= Unlike many other architectures, x86 does not share an opcode table between assembly and disassembly. Any consumer of libopcodes would only ever access one of the two. Since gas is the only consumer of the assembly data, move it there. While doing so mark respective entities "static" in i386-gen (we may want to do away with i386_regtab_size altogether). This also shrinks the number of relocations to be processed for libopcodes.so by about 30%. --- v2: Re-base over the (premature) moving of i386_seg_prefixes[]. Move inclusion point of opcodes/i386-tbl.h. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -2965,6 +2965,8 @@ i386_mach (void) as_fatal (_("unknown architecture")); } +#include "opcodes/i386-tbl.h" + void md_begin (void) { --- a/opcodes/i386-gen.c +++ b/opcodes/i386-gen.c @@ -1815,7 +1815,7 @@ process_i386_opcodes (FILE *table) xcalloc, free); fprintf (table, "\n/* i386 opcode table. */\n\n"); - fprintf (table, "const insn_template i386_optab[] =\n{\n"); + fprintf (table, "static const insn_template i386_optab[] =\n{\n"); /* Put everything on opcode array. */ while (!feof (fp)) @@ -1945,7 +1945,7 @@ process_i386_registers (FILE *table) xstrerror (errno)); fprintf (table, "\n/* i386 register table. */\n\n"); - fprintf (table, "const reg_entry i386_regtab[] =\n{\n"); + fprintf (table, "static const reg_entry i386_regtab[] =\n{\n"); while (!feof (fp)) { @@ -2008,7 +2008,7 @@ process_i386_registers (FILE *table) fprintf (table, "};\n"); - fprintf (table, "\nconst unsigned int i386_regtab_size = ARRAY_SIZE (i386_regtab);\n"); + fprintf (table, "\nstatic const unsigned int i386_regtab_size = ARRAY_SIZE (i386_regtab);\n"); } static void --- a/opcodes/i386-opc.c +++ b/opcodes/i386-opc.c @@ -21,4 +21,3 @@ #include "sysdep.h" #include "libiberty.h" #include "i386-opc.h" -#include "i386-tbl.h" --- a/opcodes/i386-opc.h +++ b/opcodes/i386-opc.h @@ -921,7 +921,7 @@ typedef union i386_operand_type typedef struct insn_template { /* instruction name sans width suffix ("mov" for movl insns) */ - char *name; + const char *name; /* Bitfield arrangement is such that individual fields can be easily extracted (in native builds at least) - either by at most a masking @@ -987,8 +987,6 @@ typedef struct insn_template } insn_template; -extern const insn_template i386_optab[]; - /* these are for register name --> number & type hash lookup */ typedef struct { @@ -1008,6 +1006,3 @@ typedef struct #define Dw2Inval (-1) } reg_entry; - -extern const reg_entry i386_regtab[]; -extern const unsigned int i386_regtab_size;