From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2058.outbound.protection.outlook.com [40.107.105.58]) by sourceware.org (Postfix) with ESMTPS id 410D83858419 for ; Fri, 15 Sep 2023 08:59:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 410D83858419 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=DeqypHnuZl7ZktAPdngbZ+WB6Rmxz1q7MQjCZibdgoOnb8IQm5rY3dh8VqBV8b7crQTmtZmdO1S9Wp45lpulm9o9Mf+AnbjNenDIJGot/YlG2aJH50Cs9kmTVKJvNFAk5V+DvmPCqaL0zMpGyIxrUQcMtiRE17BA/QT65IXOx7Tw+0QzdCqK49XG0Q989cNOiOeNdVuB8Sfw4bj4isxuEW5CyS0JGl4MBVu+5WTdloVMMza6fr/H836/QbgpfBrJiqR7cqL0GnlOVyZQqmwoKqj8jN5f5EHaiQ76o3ivEd8gjw2n+/KTqGEsbMhxNrjuvCGoGzrH9V2L0JU5heiKsA== 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=mXDNbtIiIzUXa8Jg07xZ5S6BzYvlqco9KFBQ0+g5nNQ=; b=CJXZ3sonRJifNHvghI/NDx5s4QLL9I7zsumuWjqY8GROEl+sK0KAII0mzxMMDsEq0N4t4g1EnJkmVEV7tL8iZtcEHcwooYmnC8p+3/xV0G3Nwd01lmNPE1xa4nwwHXf8Q926++4w1qgj2zwj9yZuXa4l83sCFNFmU4VzBSNMW0feVJkGVIyn7GwdTN/zGl40a4QTBCEi/XZ1jd/il5YMI0X0Z7iTnUma+lLtlWeAsTBkLMx/C/mUai5jc0GekSFdRNVJ8TeBDbtr9Ilu2TLLJcTXWfFvOpHgxSaeezsskoyH14aEJzVLg+v+xHAPWharMJue0HGBsjhRsHyg/0+eGA== 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=mXDNbtIiIzUXa8Jg07xZ5S6BzYvlqco9KFBQ0+g5nNQ=; b=WpmYxmcw9a2YArp9ryEGeJfJg+Ik4HNR/5b7lwbLpShj5nESbnixOvabi815nMbLuT4N9Z6JtpOfyV/u1Dnc6u5emE5gldfZmNMxUP7zJLO8W0O7P3wQcGUiB3vPIZ8TTmIiYpwMjZqhbL6utCwkFLzbjh+j2ykTHFi1LmDk2eXv13ai/ivnqL4/bNVhjU+CJIV5R2bZzbt7lUeMry28RRnjfOUgV6aDDUcdDlpKuqCik8bpNxX0/MOpBw3BmQwu4iFcUOs+bXtnxdih2Gq/saMlwl8MQdi7/VQLTRzVwJ3dFWXQq5+4BI0m9su8feXQxaVrhuTmnRNUQW6Nfi+IQA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) by PA4PR04MB7886.eurprd04.prod.outlook.com (2603:10a6:102:c1::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.21; Fri, 15 Sep 2023 08:59:17 +0000 Received: from DU2PR04MB8790.eurprd04.prod.outlook.com ([fe80::f749:b27f:2187:6654]) by DU2PR04MB8790.eurprd04.prod.outlook.com ([fe80::f749:b27f:2187:6654%6]) with mapi id 15.20.6792.020; Fri, 15 Sep 2023 08:59:17 +0000 Message-ID: Date: Fri, 15 Sep 2023 10:59:15 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: [PATCH 1/3] x86: correct cpu_arch_isa_flags maintenance Content-Language: en-US To: Binutils Cc: "H.J. Lu" References: <8d21b532-7a4a-da25-3e95-d1aea76f75a3@suse.com> From: Jan Beulich In-Reply-To: <8d21b532-7a4a-da25-3e95-d1aea76f75a3@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR3P281CA0086.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::13) To DU2PR04MB8790.eurprd04.prod.outlook.com (2603:10a6:10:2e1::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8790:EE_|PA4PR04MB7886:EE_ X-MS-Office365-Filtering-Correlation-Id: 45e73b0f-a007-4121-9c2b-08dbb5ca0aae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fpn5v4ReutIjNOd2nTMw8s1/RP+sGtAUHUVhqJd4HWe9BJUpc5HqTsTLp5CQcalsgKBFEiXkT8Ox9NZOnu+qE4E+oz9tCgWmzEH46S8Dziop+k6ERjqaQTuBFug7fwcrVoPB81d2ZgbV29Wgopi2t7qOBG765h0P1KUIxLc+yFllWpDYLyprIPC6wbx7BkgQshOATH4/N0Kn1MgmnxW4Hr0zuwg4QRITYm+sr2iPY76BRKbEeKLz91jpRDVk2C5kLSX2ahJAeqm8Ng5hxS24iyyKzgeWfpuXUL6Whq3H6A315CQwnXY6kJAis3PkZLY+rbvO0M3eph1XUKjJmjkBTABNCEiJ0o+c6PLMn9HkprSGdtGJIl+iqL5oMtSsa+8YoByP5ZR1NMmWhjkhsZVW5chS58ntWNk0O4v/o2e6YmQuWer1FTn68E1vmaQQznmih4bJaZ10RqYh2ifjM5J7zk9Zs21XFLnTTZNL2SiVfJwQq+7RRryLy8RFHYHje3hI2wxeS0aOBErzRXTQCtLwJsHIDJVvkuj2cjFHrTkWiGHOwaVxd0PczWNpXhAgq0MnE47AiYt8U48y/ui8OrNfmPRkZL17LqrklzBz99R+LbmAz53XtMKmd7Wtn/qco6J81isluluwvfWVazaYqMdfDw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB8790.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(346002)(136003)(396003)(376002)(366004)(39860400002)(186009)(1800799009)(451199024)(5660300002)(26005)(8936002)(4326008)(8676002)(2616005)(2906002)(86362001)(31696002)(38100700002)(83380400001)(36756003)(6486002)(6506007)(66946007)(66476007)(66556008)(478600001)(31686004)(41300700001)(316002)(6916009)(6512007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YTgzRVZTL0c0U0swQmwrY3lhK21vOEpCaWoyV0pmK0dkNk43aVdPNFI1RWI5?= =?utf-8?B?eDY3dzBXa0swdy9jMEE0SkVObXY0c1hucFEwMiszVk55bC8vZXZRRUR2OVdQ?= =?utf-8?B?QzIyM3haakRucnozSHlwd0NOT1FXcHowQlVLdkNrTXBjTnZ0VXlPSjU3dlhq?= =?utf-8?B?YVRhd0NGNTUvVXhvandjdU9wK09qcVQvNEUvVHgxQmEyd3VvcGFZNUJvRC9x?= =?utf-8?B?dXo0ZkkzbGIrZGh3WDByd1VXKzlsYnBEa1dEWnZJdis4ZGw5Q3VpSHdWUW9U?= =?utf-8?B?Y2c1azE3UTZPWnQ1UmFkNGNCRnJQTktQNjl1TSs3cGwxNytiQVNQdFBE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EKLDTA4R4RSzs?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 45e73b0f-a007-4121-9c2b-08dbb5ca0aae X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8790.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Sep 2023 08:59:17.1681 (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: rJpWisdcVMqyRM+tP/WN0BEPDTHbtmsq7YMjgxdsQP96K4K2OKQ1NDUMEmt/VURdsIBRoWvHGrrS27Ei3YMcpg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7886 X-Spam-Status: No, score=-3026.9 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: These may not be set from a value derived from cpu_arch_flags: That starts with (almost) all functionality enabled, while cpu_arch_isa_flags is supposed to track features that were explicitly enabled (and perhaps later disabled) by the user. To avoid needing to do any such adjustment in two places (each), introduce helper functions used by both command line handling and directive processing. --- While setting of vector_size could be moved into isa_disable() (further reducing code duplication), the same isn't true for isa_enable(). Because of the asymmetry I didn't do so. Thoughts / opinions? --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -2804,13 +2804,41 @@ check_cpu_arch_compatible (const char *n } static void -extend_cpu_sub_arch_name (const char *name) +extend_cpu_sub_arch_name (const char *pfx, const char *name) { if (cpu_sub_arch_name) cpu_sub_arch_name = reconcat (cpu_sub_arch_name, cpu_sub_arch_name, - ".", name, (const char *) NULL); + pfx, name, (const char *) NULL); else - cpu_sub_arch_name = concat (".", name, (const char *) NULL); + cpu_sub_arch_name = concat (pfx, name, (const char *) NULL); +} + +static void isa_enable (unsigned int idx) +{ + i386_cpu_flags flags = cpu_flags_or (cpu_arch_flags, cpu_arch[idx].enable); + + if (!cpu_flags_equal (&flags, &cpu_arch_flags)) + { + extend_cpu_sub_arch_name (".", cpu_arch[idx].name); + cpu_arch_flags = flags; + } + + cpu_arch_isa_flags = cpu_flags_or (cpu_arch_isa_flags, cpu_arch[idx].enable); +} + +static void isa_disable (unsigned int idx) +{ + i386_cpu_flags flags + = cpu_flags_and_not (cpu_arch_flags, cpu_arch[idx].disable); + + if (!cpu_flags_equal (&flags, &cpu_arch_flags)) + { + extend_cpu_sub_arch_name (".no", cpu_arch[idx].name); + cpu_arch_flags = flags; + } + + cpu_arch_isa_flags + = cpu_flags_and_not (cpu_arch_isa_flags, cpu_arch[idx].disable); } static void @@ -2834,7 +2862,6 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED int e; const char *string; unsigned int j = 0; - i386_cpu_flags flags; SKIP_WHITESPACE (); @@ -2987,17 +3014,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED if (cpu_flags_all_zero (&cpu_arch[j].enable)) continue; - flags = cpu_flags_or (cpu_arch_flags, cpu_arch[j].enable); - - if (!cpu_flags_equal (&flags, &cpu_arch_flags)) - { - extend_cpu_sub_arch_name (string + 1); - cpu_arch_flags = flags; - cpu_arch_isa_flags = flags; - } - else - cpu_arch_isa_flags - = cpu_flags_or (cpu_arch_isa_flags, cpu_arch[j].enable); + isa_enable (j); (void) restore_line_pointer (e); @@ -3044,13 +3061,7 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED if (cpu_arch[j].type == PROCESSOR_NONE && strcmp (string + 3, cpu_arch[j].name) == 0) { - flags = cpu_flags_and_not (cpu_arch_flags, cpu_arch[j].disable); - if (!cpu_flags_equal (&flags, &cpu_arch_flags)) - { - extend_cpu_sub_arch_name (string + 1); - cpu_arch_flags = flags; - cpu_arch_isa_flags = flags; - } + isa_disable (j); if (cpu_arch[j].vsz == vsz_set) vector_size = VSZ_DEFAULT; @@ -14598,21 +14609,7 @@ md_parse_option (int c, const char *arg) && !cpu_flags_all_zero (&cpu_arch[j].enable)) { /* ISA extension. */ - i386_cpu_flags flags; - - flags = cpu_flags_or (cpu_arch_flags, - cpu_arch[j].enable); - - if (!cpu_flags_equal (&flags, &cpu_arch_flags)) - { - extend_cpu_sub_arch_name (arch); - cpu_arch_flags = flags; - cpu_arch_isa_flags = flags; - } - else - cpu_arch_isa_flags - = cpu_flags_or (cpu_arch_isa_flags, - cpu_arch[j].enable); + isa_enable (j); switch (cpu_arch[j].vsz) { @@ -14655,16 +14652,7 @@ md_parse_option (int c, const char *arg) if (cpu_arch[j].type == PROCESSOR_NONE && strcmp (arch + 2, cpu_arch[j].name) == 0) { - i386_cpu_flags flags; - - flags = cpu_flags_and_not (cpu_arch_flags, - cpu_arch[j].disable); - if (!cpu_flags_equal (&flags, &cpu_arch_flags)) - { - extend_cpu_sub_arch_name (arch); - cpu_arch_flags = flags; - cpu_arch_isa_flags = flags; - } + isa_disable (j); if (cpu_arch[j].vsz == vsz_set) vector_size = VSZ_DEFAULT; break; --- a/gas/testsuite/gas/i386/i386.exp +++ b/gas/testsuite/gas/i386/i386.exp @@ -147,6 +147,7 @@ if [gas_32_check] then { run_dump_test "nops-6" run_dump_test "nops-7" run_dump_test "nops-8" + run_dump_test "nops-9" run_dump_test "noreg16" run_list_test "noreg16" run_dump_test "noreg16-data32" --- /dev/null +++ b/gas/testsuite/gas/i386/nops-9.d @@ -0,0 +1,28 @@ +#objdump: -drw +#name: i386 nops 9 + +.*: +file format .* + +Disassembly of section .text: + +0+ : +[ ]*[a-f0-9]+: 0f be f0 movsbl %al,%esi +[ ]*[a-f0-9]+: 8d b4 26 00 00 00 00 lea 0x0\(%esi,%eiz,1\),%esi +[ ]*[a-f0-9]+: 8d b6 00 00 00 00 lea 0x0\(%esi\),%esi + +0+10 : +[ ]*[a-f0-9]+: 0f be f0 movsbl %al,%esi +[ ]*[a-f0-9]+: 8d b4 26 00 00 00 00 lea 0x0\(%esi,%eiz,1\),%esi +[ ]*[a-f0-9]+: 8d b6 00 00 00 00 lea 0x0\(%esi\),%esi + +0+20 : +[ ]*[a-f0-9]+: f3 0f b8 f0 popcnt %eax,%esi +[ ]*[a-f0-9]+: 8d b4 26 00 00 00 00 lea 0x0\(%esi,%eiz,1\),%esi +[ ]*[a-f0-9]+: 8d 74 26 00 lea 0x0\(%esi,%eiz,1\),%esi +[ ]*[a-f0-9]+: 90 nop + +0+30 : +[ ]*[a-f0-9]+: 0f be f0 movsbl %al,%esi +[ ]*[a-f0-9]+: 66 66 2e 0f 1f 84 00 00 00 00 00 data16 nopw %cs:0x0\(%eax,%eax,1\) +[ ]*[a-f0-9]+: 66 90 xchg %ax,%ax +#pass --- /dev/null +++ b/gas/testsuite/gas/i386/nops-9.s @@ -0,0 +1,19 @@ + .text +default: + movsbl %al,%esi + .p2align 4 + + .arch .nopopcnt +nopopcnt: + movsbl %al,%esi + .p2align 4 + + .arch .popcnt +popcnt: + popcnt %eax,%esi + .p2align 4 + + .arch .nop +nop: + movsbl %al,%esi + .p2align 4