From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2070.outbound.protection.outlook.com [40.107.14.70]) by sourceware.org (Postfix) with ESMTPS id A99C13858C66 for ; Fri, 13 Jan 2023 11:06:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A99C13858C66 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NgAmSySpL6T8fpf6SrLP6x9gH5fdlbSlhhfWQzgLU0STLELGACcFMZIZZo/1DqcquR+FvXbc0zEIjsiyrdsJncThv051G5eaA1F2tr2f4iwdGRqDQPvl4L2fEKDJL0F5i8SniT7MKWabJ3y15+exqXD2xAItQE2fgtc2AaG1oz2b8u0MOldXi2beiFtvaCDfJM1a51vK7yy2HFl9pXPSk4YrqMn0q4TUy8VT0Voo80w7RsFaYjUBjgZ79YobMa/4dtxNaWpCIB4s0qw0DPZjOnk1M8o1NahwvwZympRf2p89txqa4fUp2rzBF/0SY4yso0SFJyVXKwZC8VOa4egvFQ== 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=OPcIcTmzAdUQRaz1KpVFrRS/XwtIv4adR7tGcWbrKO4=; b=F1EqP3TgKMFuGSjMe/Lcvq8rsO5Cm600iRGFT29GdP2f366V0fciWZYeutEplzhooMBWjWOmt4xFOmEfV+wBB49NGhDOcOR5AuP+JCaGXey7kNLvfokgOpVDJ1qhLcxNpfIRx6i8bNav4yySGTJf0jZHX+1BKUQWPvwVBkVOLpm7UvveggRHgeEGMUaEtIRh5qmRHM8eEu9gSoDPsIN5HlkDhqCapDP/nGqnnkFRZXugCzbpxlm1Sr/6vQpjG+9y2ef/0UMD0y41Cr0r4VC78cvoGKVLZKU8eRxxSdR3ikch3Re2lv8SnAvGhOsd0wXANJP5q/7AooXmTG6MpxYkXA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OPcIcTmzAdUQRaz1KpVFrRS/XwtIv4adR7tGcWbrKO4=; b=HE2aH1MYyd9MUtW8Dv62QpHGJlQmhvMFKW6rGHO9ehTBy/QnLyapEqzziH5GMHwIAXjV+pNUGJPLNene9GtnwFN0791DB0w3UX5U8OqCegyjajX8thX9kI1Cjdl4m1uTWtREnopjNe9OIplGt8jIMaRhacDSdB+8ZsKs7LJXRPCGX6oAwarmVFWifJUd5HWXKPTBkw094xNbQR3PMLA+emmkuio4O8Jk4lfAvq+6Ush1gIO/43HuWmXAGmi+S9sVPLDiMTK2i1e3pomX1xE3NZ1DsShG3eSjB4ErEnlzg1iE608fCaf+bJdXjWYpCSmKnEjxU+JYUyx3cnYuHO0jCw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AS8PR04MB8133.eurprd04.prod.outlook.com (2603:10a6:20b:3b1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Fri, 13 Jan 2023 11:06:34 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2991:58a4:e308:4389]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::2991:58a4:e308:4389%7]) with mapi id 15.20.6002.012; Fri, 13 Jan 2023 11:06:34 +0000 Message-ID: Date: Fri, 13 Jan 2023 12:06:32 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: [PATCH 1/8] x86: move insn mnemonics to a separate table Content-Language: en-US To: Binutils Cc: "H.J. Lu" References: From: Jan Beulich In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR3P281CA0176.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a0::11) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AS8PR04MB8133:EE_ X-MS-Office365-Filtering-Correlation-Id: 630a4ca0-bff4-4e97-4ea3-08daf5563b93 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G272GKC73jl+doXLam8pLfLd9XDyVprf+qkDZvc1NUiyIJqBcsGALvPbE6MZM8p5DFMEVQ2Hhez6pE/qreMmETV3G6U+YsmhaXLVPyJiVE/d/vdvBb6ot9P1laOF0cB1LeE1tb1nwEhxgWAAaGansnfajuWSrnmy1TI0Pwm4vXlKeNUxjZXyrZyy/Wzo8TmTR775A6wB0B+k4fAiE6FMom+c9N8fEE7WpF4Wl7wAKUBN3s8CMsaHMhyWx7COn3pKusyoLVrAlgfltSXXGTUkDEQ70PpROzd32+6OiFmug5IhcuYihT3I4HoMVNVoeDrqUbF2AjlQUvmX6oXKLXUAu+9ikmwNI4z2jNyJCS8wdkTTOERZiUapU/L0ir3aMulBrvsVsR7Kbs1qR2CmMjOAOEQ4Eqom0SlLv+pgXEZysuL5qXj7dPE6nx8DuYI8kyqRV8vAUJ/piPr6C+t6RNvxYhsSGGPZIUlHGU14qVDl9qUnHa/h3/Rn76lvT10bS9i6oFNSIoqdyypM2yCzp4VWN5p1PDaFajZKS6Wf7LSNoJ3ITpvPMnrCEYmFOFjU4RDd/7201qlfzrg0uHmBHsxj+OziOScqBD667OxTyzz+aBzHgDRWyRhZVqOYNJDDulVmmkI10WIRtcqAjt1Q3Slf4y+hemY+GkE6jmgy/e69VVFhPGE9tLkceSlSGCJdp9CrgFFw5mQ9CeFzGAhx103juC6lZCePYtBC0JAhdVQTPPk= 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)(39860400002)(136003)(366004)(346002)(396003)(451199015)(4326008)(41300700001)(6916009)(8936002)(5660300002)(2906002)(31686004)(8676002)(66476007)(66556008)(66946007)(478600001)(6486002)(26005)(186003)(6506007)(6512007)(2616005)(83380400001)(31696002)(38100700002)(36756003)(86362001)(316002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?RTh6eWhTTVd0cFFiQU95dy9RRjU4U0x3NEx3ditJWmhVZWFHZVRoY1duRk9F?= =?utf-8?B?RkhRQytPWTdRSzAyQzRVa1RTUDc0LzZVbnVJSVFvdkZoYUhEeFRkTnJra1VD?= =?utf-8?B?dnpsVEdac1ZXYmNtRU1lcmQ4WElwTVY2aExOUVAxaDRKM09Yc1dTdjBDNmJE?= =?utf-8?B?UFlXV0xSK3FwT0NZSUZOa2hjYlNoK042RkM4T3VJNDBlUzl6YU5pQVlDUE00?= =?utf-8?B?dmRSWUNhRlBuYU55bm41Ni9HQzdIcDZOL0NIRllXQU5WZUNvdldrajVMeSts?= =?utf-8?B?Nm1KdjEwMFdybzlEUndCUFQwODJpbmdXR2ljT0QzTzZFK1pwSnhSNTRVZWRV?= =?utf-8?B?cUxteVRON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Vn7?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 630a4ca0-bff4-4e97-4ea3-08daf5563b93 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2023 11:06:34.3723 (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: 0JrNUhSTt7fBRDme5Obc+TK+2KeUih3FVJ9SPNoMi99WG92xMf+126xIiCyEmSS/vvVniYN/pEl8kSwb0HQncw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8133 X-Spam-Status: No, score=-3028.7 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 List-Id: Using full pointers to reference the insn mnemonic strings is not very efficient. With overall string size presently just slightly over 20k, even a 16-bit value would suffice. Use "unsigned int" for now, as there's no good use we could presently make of the otherwise saved 16 bits. For 64-bit builds this reduces table size by 6.25% (prior to the recent ISA extension additions it would have been 12.5%), with a similar effect on cache occupation of table entries accessed. For PIE builds of gas this also reduces the number of base relocations quite a bit (obviously independent of bitness). --- An alternative to introducing i386-mnem.h would of course be to put the #define-s in i386-init.h. That would look like an abuse of the file to me, but I'd be okay switching to such an approach. As to further shrinking mnem_off (to 16 bits): I'm intending to drop i386_opcode_modifier as a separate struct, embedding the fields directly in insn_template. i386_opcode_modifier presently using only 6 bits from its 3rd word will allow to shrink insn_template by another word then. (This would also benefit readabilty of tc-i386*.c, as all the uses of "opcode_modifier." would go away. This would additionally reduce the apparent discrepancy between e.g. opcode_modifier.opcode_space and opcode_modifier.opcode_prefix vs base_opcode and extension_opcode.) --- a/gas/Makefile.am +++ b/gas/Makefile.am @@ -453,7 +453,7 @@ i386_tbl_deps = $(srcdir)/../opcodes/i38 $(srcdir)/../opcodes/i386-reg.tbl \ $(srcdir)/../opcodes/i386-gen.c $(srcdir)/../opcodes/i386-opc.h -$(srcdir)/../opcodes/i386%init.h $(srcdir)/../opcodes/i386%tbl.h: @MAINT@ $(i386_tbl_deps) +$(srcdir)/../opcodes/i386%init.h $(srcdir)/../opcodes/i386%tbl.h $(srcdir)/../opcodes/i386%mnem.h: @MAINT@ $(i386_tbl_deps) @echo '"$@" is outdated wrt "$?"' >&2 @echo 'Please rebuild from the top level or in $(CURDIR)/../opcodes/' >&2 @false --- a/gas/Makefile.in +++ b/gas/Makefile.in @@ -2070,7 +2070,7 @@ development.exp: $(BFDDIR)/development.s config/tc-i386.o: $(srcdir)/../opcodes/i386-init.h $(srcdir)/../opcodes/i386-tbl.h -$(srcdir)/../opcodes/i386%init.h $(srcdir)/../opcodes/i386%tbl.h: @MAINT@ $(i386_tbl_deps) +$(srcdir)/../opcodes/i386%init.h $(srcdir)/../opcodes/i386%tbl.h $(srcdir)/../opcodes/i386%mnem.h: @MAINT@ $(i386_tbl_deps) @echo '"$@" is outdated wrt "$?"' >&2 @echo 'Please rebuild from the top level or in $(CURDIR)/../opcodes/' >&2 @false --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -34,6 +34,7 @@ #include "sframe.h" #include "elf/x86-64.h" #include "opcodes/i386-init.h" +#include "opcodes/i386-mnem.h" #include #ifndef INFER_ADDR_PREFIX @@ -2428,7 +2429,7 @@ offset_in_range (offsetT val, int size) static INLINE const char *insn_name (const insn_template *t) { - return t->name; + return &i386_mnemonics[t->mnem_off]; } enum PREFIX_GROUP --- a/opcodes/Makefile.am +++ b/opcodes/Makefile.am @@ -523,7 +523,8 @@ MOSTLYCLEANFILES = aarch64-gen$(EXEEXT_F z8kgen$(EXEEXT_FOR_BUILD) opc2c$(EXEEXT_FOR_BUILD) MAINTAINERCLEANFILES = $(srcdir)/aarch64-asm-2.c $(srcdir)/aarch64-dis-2.c \ - $(srcdir)/aarch64-opc-2.c $(srcdir)/i386-tbl.h $(srcdir)/i386-init.h \ + $(srcdir)/aarch64-opc-2.c \ + $(srcdir)/i386-tbl.h $(srcdir)/i386-init.h $(srcdir)/i386-mnem.h \ $(srcdir)/ia64-asmtab.c $(srcdir)/z8k-opc.h \ $(srcdir)/msp430-decode.c \ $(srcdir)/rl78-decode.c \ @@ -552,16 +553,17 @@ i386-gen.o: i386-gen.c i386-opc.h $(srcd config.h sysdep.h $(COMPILE_FOR_BUILD) -c $(srcdir)/i386-gen.c -# i386-gen will generate both headers in one go. Use a pattern rule to properly +# i386-gen will generate all headers in one go. Use a pattern rule to properly # express this, with the inner dash ('-') arbitrarily chosen to be the stem. -$(srcdir)/i386%tbl.h $(srcdir)/i386%init.h: @MAINT@ i386-gen$(EXEEXT_FOR_BUILD) i386-opc.tbl i386-reg.tbl i386-opc.h +$(srcdir)/i386%tbl.h $(srcdir)/i386%init.h $(srcdir)/i386%mnem.h: \ + @MAINT@ i386-gen$(EXEEXT_FOR_BUILD) i386-opc.tbl i386-reg.tbl i386-opc.h $(AM_V_GEN)$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) - \ < $(srcdir)/i386-opc.tbl \ | ./i386-gen$(EXEEXT_FOR_BUILD) --srcdir $(srcdir) -# While not really dependencies, specify i386-{init,tbl}.h here as well to -# make sure they are re-generated as necessary. -i386-dis.lo: $(srcdir)/i386-tbl.h $(srcdir)/i386-init.h +# While not really dependencies, specify other generated i386-*.h here as well +# to make sure they are re-generated as necessary. +i386-dis.lo: $(srcdir)/i386-tbl.h $(srcdir)/i386-init.h $(srcdir)/i386-mnem.h ia64-gen$(EXEEXT_FOR_BUILD): ia64-gen.o $(BUILD_LIB_DEPS) $(AM_V_CCLD)$(LINK_FOR_BUILD) ia64-gen.o $(BUILD_LIBS) --- a/opcodes/Makefile.in +++ b/opcodes/Makefile.in @@ -758,7 +758,8 @@ MOSTLYCLEANFILES = aarch64-gen$(EXEEXT_F z8kgen$(EXEEXT_FOR_BUILD) opc2c$(EXEEXT_FOR_BUILD) MAINTAINERCLEANFILES = $(srcdir)/aarch64-asm-2.c $(srcdir)/aarch64-dis-2.c \ - $(srcdir)/aarch64-opc-2.c $(srcdir)/i386-tbl.h $(srcdir)/i386-init.h \ + $(srcdir)/aarch64-opc-2.c \ + $(srcdir)/i386-tbl.h $(srcdir)/i386-init.h $(srcdir)/i386-mnem.h \ $(srcdir)/ia64-asmtab.c $(srcdir)/z8k-opc.h \ $(srcdir)/msp430-decode.c \ $(srcdir)/rl78-decode.c \ @@ -1526,16 +1527,17 @@ i386-gen.o: i386-gen.c i386-opc.h $(srcd config.h sysdep.h $(COMPILE_FOR_BUILD) -c $(srcdir)/i386-gen.c -# i386-gen will generate both headers in one go. Use a pattern rule to properly +# i386-gen will generate all headers in one go. Use a pattern rule to properly # express this, with the inner dash ('-') arbitrarily chosen to be the stem. -$(srcdir)/i386%tbl.h $(srcdir)/i386%init.h: @MAINT@ i386-gen$(EXEEXT_FOR_BUILD) i386-opc.tbl i386-reg.tbl i386-opc.h +$(srcdir)/i386%tbl.h $(srcdir)/i386%init.h $(srcdir)/i386%mnem.h: \ + @MAINT@ i386-gen$(EXEEXT_FOR_BUILD) i386-opc.tbl i386-reg.tbl i386-opc.h $(AM_V_GEN)$(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) - \ < $(srcdir)/i386-opc.tbl \ | ./i386-gen$(EXEEXT_FOR_BUILD) --srcdir $(srcdir) -# While not really dependencies, specify i386-{init,tbl}.h here as well to -# make sure they are re-generated as necessary. -i386-dis.lo: $(srcdir)/i386-tbl.h $(srcdir)/i386-init.h +# While not really dependencies, specify other generated i386-*.h here as well +# to make sure they are re-generated as necessary. +i386-dis.lo: $(srcdir)/i386-tbl.h $(srcdir)/i386-init.h $(srcdir)/i386-mnem.h ia64-gen$(EXEEXT_FOR_BUILD): ia64-gen.o $(BUILD_LIB_DEPS) $(AM_V_CCLD)$(LINK_FOR_BUILD) ia64-gen.o $(BUILD_LIBS) --- a/opcodes/i386-gen.c +++ b/opcodes/i386-gen.c @@ -1146,12 +1146,26 @@ process_i386_operand_type (FILE *table, stage, indent); } +static char *mkident (const char *mnem) +{ + char *ident = xstrdup (mnem), *p = ident; + + do + { + if (!ISALNUM (*p)) + *p = '_'; + } + while (*++p); + + return ident; +} + static void output_i386_opcode (FILE *table, const char *name, char *str, char *last, int lineno) { unsigned int i, length, prefix = 0, space = 0; - char *base_opcode, *extension_opcode, *end; + char *base_opcode, *extension_opcode, *end, *ident; char *cpu_flags, *opcode_modifier, *operand_types [MAX_OPERANDS]; unsigned long long opcode; @@ -1245,9 +1259,11 @@ output_i386_opcode (FILE *table, const c fail (_("%s:%d: %s: residual opcode (0x%0*llx) too large\n"), filename, lineno, name, 2 * length, opcode); - fprintf (table, " { \"%s\", 0x%0*llx%s, %lu, %s,\n", - name, 2 * (int)length, opcode, end, i, + ident = mkident (name); + fprintf (table, " { MN_%s, 0x%0*llx%s, %lu, %s,\n", + ident, 2 * (int)length, opcode, end, i, extension_opcode ? extension_opcode : "None"); + free (ident); process_i386_opcode_modifier (table, opcode_modifier, space, prefix, operand_types, lineno); @@ -1565,7 +1581,7 @@ process_i386_opcodes (FILE *table) { FILE *fp; char buf[2048]; - unsigned int i, j, nr; + unsigned int i, j, nr, offs; char *str, *p, *last, *name; htab_t opcode_hash_table; struct opcode_hash_entry **opcode_array = NULL; @@ -1579,6 +1595,7 @@ process_i386_opcodes (FILE *table) opcode_hash_eq, NULL, xcalloc, free); + fprintf (table, "\n#include \"i386-mnem.h\"\n"); fprintf (table, "\n/* i386 opcode table. */\n\n"); fprintf (table, "static const insn_template i386_optab[] =\n{\n"); @@ -1701,6 +1718,32 @@ process_i386_opcodes (FILE *table) } fprintf (table, "};\n"); + + /* Emit mnemonics and associated #define-s. */ + fp = fopen ("i386-mnem.h", "w"); + if (fp == NULL) + fail (_("can't create i386-mnem.h, errno = %s\n"), + xstrerror (errno)); + + process_copyright (fp); + + fprintf (table, "\n/* i386 mnemonics table. */\n\n"); + fprintf (table, "const char i386_mnemonics[] =\n"); + fprintf (fp, "\nextern const char i386_mnemonics[];\n\n"); + + for (offs = j = 0; j < i; j++) + { + name = opcode_array[j]->name; + fprintf (table, " \"\\0\"\"%s\"\n", name); + str = mkident (name); + fprintf (fp, "#define MN_%s %#x\n", str, offs + 1); + free (str); + offs += strlen (name) + 1; + } + + fprintf (table, ";\n"); + + fclose (fp); } static void --- a/opcodes/i386-opc.h +++ b/opcodes/i386-opc.h @@ -918,7 +918,7 @@ typedef union i386_operand_type typedef struct insn_template { /* instruction name sans width suffix ("mov" for movl insns) */ - const char *name; + unsigned int mnem_off; /* Bitfield arrangement is such that individual fields can be easily extracted (in native builds at least) - either by at most a masking