public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: Dmytro Tarasiuk <tadmytro@gmail.com>
Cc: Binutils <binutils@sourceware.org>
Subject: Re: Paired Nested Macroses Support
Date: Fri, 17 Feb 2023 09:01:53 +0100	[thread overview]
Message-ID: <f47ba61c-b34b-32fb-34de-443f40acc109@suse.com> (raw)
In-Reply-To: <CAEk2QZPYg+Q=EXAcR98AUHsGOT8c4GSFpPndjsB+ZC7ukzkG0g@mail.gmail.com>

(re-sending again, since you _again_ dropped the list from your reply;
I'm not going to further reply to private mails you may send on
technical matters)

On 16.02.2023 23:28, Dmytro Tarasiuk wrote:
> On 16.02.2023 18:31 Jan Beulich <jbeulich@suse.com> wrote:
>> (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 <jbeulich@suse.com> 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.
>>
> 
> a:
> DO
>     [...]
>     b:
>     DO
>         [...]
>     DONE_WNEN
>     [...]
> DONE
> 
> Here is shown the pair (open/close) connected with one another macroses (DO
> ... DONE_WNEN) which are nested into another pair (open/close) connected
> with one another macroses (DO .. DONE). To work correctly there must be 2
> counters: one for the sequential pairs and one for the nested pairs in each
> sequential one. These counters allow generating unique labels in each pair.
> Current macro language including altmacro features looks weak to be happy
> with it. I have paid a lot of time to find a decision. Could you show me an
> example how it is possible to do without patching even if it looks ugly?.

I'm sorry, but no, I simply lack the time to invest into putting together
something I'm never going to use.

>> 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.
>>
> 
> There seems to be no new problem here. Macro conflicts can be resolved by
> scope area, etc.

How is

	.macro DO
	.endm

	.macro M pfx:req, sfx:req
\pfx\(DO)\sfx:
	.endm

suddenly changing behavior not a new problem? In what you propose
nothing in M identifies that \(DO) is meant to reference DO's local
counter. Right now the DO there is substituted in literally.

Jan

  parent reply	other threads:[~2023-02-17  8:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15 23:37 Dmytro Tarasiuk
2023-02-16  8:04 ` Jan Beulich
     [not found]   ` <CAEk2QZN7aQ26PANUY-ua3sBuGZhPL9fA9Q=k4V3mAsV2R+heGA@mail.gmail.com>
2023-02-16 16:31     ` Jan Beulich
     [not found]       ` <CAEk2QZPYg+Q=EXAcR98AUHsGOT8c4GSFpPndjsB+ZC7ukzkG0g@mail.gmail.com>
2023-02-17  8:01         ` Jan Beulich [this message]
2023-02-16  8:29 ` Ulf Samuelsson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f47ba61c-b34b-32fb-34de-443f40acc109@suse.com \
    --to=jbeulich@suse.com \
    --cc=binutils@sourceware.org \
    --cc=tadmytro@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).