From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2067.outbound.protection.outlook.com [40.107.105.67]) by sourceware.org (Postfix) with ESMTPS id 6DB583858C5F for ; Thu, 16 Feb 2023 16:31:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6DB583858C5F 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=fxLVuZw9LfUb2+K7kT1T8pc0Qdg6eqNijNiclzCQGH43mrsszNXO691KI8GWLS+e3USv+yC75X/yIAkFFp5FRoWSAnVkTJsmM3qxabemvyL/WQk/fR7fHLNq+jdhVmoFV9DNVek8ZuddTow1Ipg8Ke7Z3ZRCEXQqNRl7ME2OT5Sj2W7aC8H56rhNqImlzXiMe/pyN6OAq6+uaMie+iisY/FlTc0pHngRCIt3L+THF0wFUwreIrSOaBNU48C1N94hVshUEOlYgo0YxQ3I/nVAfxXXAVRJtJv0RNgDOlyHHQF9K6MAkKpNJJyiqwzrt+xdflm0c/x4NJfNBY9epFT6hw== 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=3wi3evT6bsGf0Im7aJ2QZiSEzpss98nH9tsFsXmyCjQ=; b=e/CGunAIfXNDAAUzH95goI1i86WetJT+1oCjyR3rYVZO8muCFAZjqsfPlHQWJYXXO2Ek9D32Qu2ypws/PWO972DKSwhZ2Hrle4HLSi0d63qFWNGzxrFW8OoPluilaErLTEh8QG5Lkt7tgmU4pr3lxiLVdb/3VJmm7ZPTG3JciLFITwAhhNREaF1DC0jiqr33Zt9Z3srrnD2JvwxLot1Ax2qGjDVRpkHTCkAjpdEoi+Qc0LElugzZKjkSkbYUzohYZD9VxopCAwP0L4Pd/a+M05gpmgWkPsSGn4rI52Pn4IzuHFvly+w7XuaqNnrUAmBC1Z4tUOQDPid+Z2XuGVPwwQ== 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=3wi3evT6bsGf0Im7aJ2QZiSEzpss98nH9tsFsXmyCjQ=; b=NCSrJiTiEoDdnrkRejo/VAFjCCitiM9E3fnZb9zrCyDtTI23UQliMZElXknMuaqEvH60VsnQmqn9/zcMXP7aJxnuN9dyHxSxduqcvA3kzPtN+edS7SsXwTH/oz4JlAcUHIwz4bb+jgaYt1+LpIY6hCFTR+qg5ZLNpqdbxuAH/rsBje0GwLdiq3reP2bCL9350Ct8YgHFQi7e6BZc0efV0JIOTU8r3zXCQHtT8lP+EZhEUloNAf7uR5TpTMiTgEz35MwgKBDa7onPm6PPOaqAQh4gEOvOjUvh/wfC8OgfY64TQrZ3or6rYFfXzTudejwIuM4chf2S2aHhgDBou+F9Ww== 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 DU0PR04MB9299.eurprd04.prod.outlook.com (2603:10a6:10:356::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.13; Thu, 16 Feb 2023 16:31:53 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::e138:4fc3:705c:d178]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::e138:4fc3:705c:d178%7]) with mapi id 15.20.6111.013; Thu, 16 Feb 2023 16:31:53 +0000 Message-ID: Date: Thu, 16 Feb 2023 17:31:50 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 From: Jan Beulich Subject: Re: Paired Nested Macroses Support To: Dmytro Tarasiuk References: <01350d86-628f-77c0-4fb2-dbffeaf8219d@suse.com> Content-Language: en-US Cc: Binutils In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: FR2P281CA0019.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::6) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|DU0PR04MB9299:EE_ X-MS-Office365-Filtering-Correlation-Id: 6c36820a-c218-443c-f7d7-08db103b4f9f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p4rQPQCVn2gCT02VV9lkX+p7K5GWt3Sonz21wa2HCa2gYVzotDCcFuJ0+jH9/zfNFfKKXV7pf57UG+DiP3Z5nQy5tjRHjXYZyP6xXKw99h3HeoaiamGvNjEmyXIvyxoyrARAkAtdpDbkHkSO2op8AirHdm9Yc4r1T5QqIrih+yJ1seCp/g03k9zSeqo4Fk8UxBIOFSU2COF4/iaSP1wLkmB/U5WDqNmeJXQFpU7sTCM9uyHnVOjKIKyBn++8zf3cizDxwv8RAm+wlCNNLO0kOhoMo5zhVdKwo/7aacqjVj4fnLa5vZrjDMrLEOIwKW2YFwt0oZYt6xySqLfByHgWsG9hoZbuW0dYSawT6UVXvnfbwA5Agt0A7kvbJjnPOdltsbHb69XT4Tm8XE7wXcKY0u17gMBtXRlMWlc6j3qLB+GoWoDOjNOH0XzI8VnUUOeer+puCjdQl++DR8KfpFEy4yg6BJdUiLRoSQUQDfrpk59L/xZpeiBS5V8PA9kAb9upPpBERbomrTIN6QCI5q0MTiXjzJtKJwRvEuXTBq/jUCeUBTZQi8FG3Qx1LJhgQi64LXsruebO9LzLayr+R9q5cJ0vlhS1hnvbDB7hNapqoGgk0D3BWA8HLqAnXHyjIVBHhXdAb/p8OtHVG90MURk90ugIgnChlKyxVOjqbYM2UBX6kV6p+VUH8xklrq0OKnsafkZm9+xh6mlITfdFaxPMaFB4eW/vzKZdfrIqzEXoM6o= 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:(13230025)(39860400002)(376002)(346002)(136003)(396003)(366004)(451199018)(31686004)(6916009)(41300700001)(4326008)(66476007)(66556008)(36756003)(66946007)(8676002)(86362001)(31696002)(478600001)(8936002)(5660300002)(316002)(6512007)(38100700002)(3480700007)(2616005)(53546011)(26005)(186003)(6506007)(2906002)(6486002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?MGhwOGFLK2NrMCt6SkRrQW1pYWpBcC9DV3AzQUUxUFFQZUlJeHhpeUJmYWUv?= =?utf-8?B?MjA1dHVwVFVjQmk3bWoyTDFRSGRmNGc1WFRxVkVqWFM5YVVHZzRhTWxyVVRN?= =?utf-8?B?MVVpd1k4U2UrT1VyZWR2Q1ZHNHBZbmhZcXgwNElURWRTa2pZV3ZqVEl5Tk5W?= =?utf-8?B?SE1zTGpUZVoweXdEQ2IyR3F6NW1iRkl5emU5Nm1wRmR6eUpUbndNNWxFK2d2?= =?utf-8?B?aWlDQ0NGWHU2NTh4U0g4bituWEw4V1FhVHBzcW1PbUVSb1QwZENEbDBFVHI4?= =?utf-8?B?ZzJwb2VTL2pEclMxMXMrdj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=?utf-8?Q?h1kYqgMG0FcGp6t8/TfN4ntLe?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c36820a-c218-443c-f7d7-08db103b4f9f X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Feb 2023 16:31:52.9618 (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: qRw+gBYnbHnrAzaSIqLnsutgh9QAyGqekA4WiNOC8bmGOlt35FHRF0VTq9rnoBoAp/c162M3nGHAgNBj7cZVnw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR04MB9299 X-Spam-Status: No, score=-3028.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,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: (re-sending with the list added back - please don't drop the list when replying to earlier list communication, unless there's a very specific reason to do so) On 16.02.2023 16:06, Dmytro Tarasiuk wrote: > on, 16.02.2023 10:04 Jan Beulich wrote: >> On 16.02.2023 00:37, Dmytro Tarasiuk via Binutils wrote: >>> Writing paired nested macros is not possible in the gas macro assembler. >>> For example, BEGIN/WHILE macros for loops, etc. This is important to me >>> for writing portable pseudocode between different architectures that >>> supports gas. >> >> Without explaining (perhaps by way of providing an example) it's unclear >> what you mean here. >> > > Excuse me. Here is an example of the macroses for nested cycles: Thanks for the example. My first conclusion is - there's no nesting of macros here. Instead you want multiple macros to interact with one another in a certain way. I think this can be achieved without patching the assembler, using alternative macro mode (.altmacro) and the special unary % operator that this mode supports. That may require helper macros, yes, so the set of macros overall may end up bigger (and uglier), but that's still not necessarily a reason to extend gas. Furthermore ... > .macro DO > LABEL_DO\(++DO)_start: ... while this syntax may indeed have a low chance of colliding with anything people already use (simply because it is pretty unlikely for anyone to use two + in a row), ... > .endm > > .macro DO_WHILE cond > j\cond LABEL_DO_WHILE\@continue > jmp LABEL_DONE\(DO)_end ... this is a problem: There's nothing wrong with somebody having a construct like this in an existing macro, while at the same time also having a macro somewhere with the name DO. If you wanted to extend the language, you would need to make sure that this cannot break existing code. Irrespective of the ++ being not as much of a problem syntax-wise, I hope you're aware that without further changes elsewhere \(+ +DO) may end up being seen as \(++DO) by the time the (scrubbed) input reaches the parsing logic here. That's because unlike in C ++ (and -- as well) do not form a "token"; they're always two separate +, and hence whitespace between them may be dropped by the scrubber. > LABEL_DO_WHILE\@continue: > .endm > > .macro DONE_WHEN cond > j\cond LABEL_DONE\(DO)_end > jmp LABEL_DO\(DO)_start > LABEL_DONE\(DO--)_end: > .endm > > .macro DONE > jmp LABEL_DO\(DO)_start > LABEL_DONE\(DO--)_end: > .endm > > Using macroses above (which is not translated without patching) I able to > write program like below: > > DO > xor %rax, %rax > mov counter, %eax Just as an aside: The "xor" here is pointless. Jan