From patchwork Fri Sep 15 08:59:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 76109 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AC1E13858436 for ; Fri, 15 Sep 2023 08:59:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AC1E13858436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1694768390; bh=mXDNbtIiIzUXa8Jg07xZ5S6BzYvlqco9KFBQ0+g5nNQ=; 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=oaWoIxORmFWEzOK724JWVlj9uY5y4eNBzLWWTaXxHZFsGb0g2fiODa0sP7Pq/H4RZ bWOFbh6ApOQzed50u5ZbfI7Hou3z0ojWJr8a+w71v0BW9+LQNMPRSRf+PmzEW+7jXw Lkm+TQBeFw3jcb74wY4ZPCoopXIYELfm7QtkooDk= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org 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 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 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> In-Reply-To: <8d21b532-7a4a-da25-3e95-d1aea76f75a3@suse.com> 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?q?a83EVS/G4SK0Bl+cya+mo8JBij2W?= =?utf-8?q?Jf+Gd6N7iWO4R5Eb9x67w0WkK0w/c0A4JENmv4sXnpQ02+3VNyl//evQEDv9WPC22?= =?utf-8?q?3xZjDnrz3HypwCNOQWpz0BUKvCkMpcNvtUyOJ57vXjaTawCF55/UxojwcuOp+OjqT?= =?utf-8?q?/4E/Tx1Ba2wuopaY5BoD/quz4fI3lb+dhwX0rwUW+9lbpDkWDZvIv+8dl9CuiHwVQ?= =?utf-8?q?oTcg5k17Q6OZt5Rad4cBFrPNKP69uM+7pl17+bASPtPDs8/Gz7/PPX3birfZpep/L?= =?utf-8?q?sX0BxhbUsXKirbtu8Vbi+n1pI7ShuupkoWfqyPdczCZQveu+eDbpDJHX6PMBo9NUS?= =?utf-8?q?FvYU0eGG6UBfZah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0jiPM0fvupJ243MH0yu2sYCNg5cCwrAoQ3RjyJNN0f0JAPls5?= =?utf-8?q?CFVbwHFo/T8Z0R/Rvt2nanwqXm2y7HuqIFuUN2YyJrSAgtIKSAKXIpiDl4X7+IYjE?= =?utf-8?q?Vp+09tCiiJp4U78jM5qd7nzDT3vw7xSnsmfefM7oGZLlCc+LIi+8BjAw8D1HKv2yX?= =?utf-8?q?//k3evul/iHJi1dyr0IbZphkJJ0Iqf2p7ppPZD/WKyLueHb2dWyRI0oNuOtjGnSum?= =?utf-8?q?YcS+doI4kK/jLLH4fp6zu4bUAClUT03++AcsKF3duZuBQSMmCUpfFXswfP+T+3KoE?= =?utf-8?q?KLDTA4R4RSzs?= 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 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+patchwork=sourceware.org@sourceware.org Sender: "Binutils" 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