public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@novell.com>
To: <binutils@sources.redhat.com>
Subject: Re: macro behavior
Date: Wed, 20 Apr 2005 09:20:00 -0000	[thread overview]
Message-ID: <s2662ccc.060@emea1-mh.id2.novell.com> (raw)

>>> Zack Weinberg <zack@codesourcery.com> 14.04.05 19:25:51 >>>
>"Jan Beulich" <JBeulich@novell.com> writes:
>
>> I'm having two issue with dealing with macro parameters:
>>
>> (1) If I want to append a constant suffix to the expanded string, I
>> see no way to do so in default mode; in .altmacro mode I am able to do
>> so using the & macro operator:
>[...]
>
>I just tripped over this myself.  I would suggest the following
>shell-like notation in default mode:
>
>        .macro m sym
>        .equiv \{sym}_, 1
>        .endm
>
>This can't break anything else, because "{" is not currently an
>acceptable name for a macro parameter.  I don't currently have time to
>implement it though.

Unfortunately this isn't true: On PPC, all of '{', '}', '[', and ']' are valid symbol name characters. I could see using

        .macro m sym
        .equiv \<sym>_, 1
        .endm

as an alternative there or in general, or maybe make-like

        .macro m sym
        .equiv \(sym)_, 1
        .endm

An additional question would then be whether we'd want to at least reserve the meaning of further shell-/make-like functionality, and hence initially forbid anything inside the braces/brackets/parentheses that isn't either itself an expansion or a symbol name, thus reserving the meaning of any non-symbol characters as potential future operators.

And there's actually another new piece of functionality I'd like to add - allowing for variable number of parameters, so that extending the functionality of things like .global becomes possible (pseudo-code for an ELF target):

	.macro gproc name, ...
	.global \name
	.type \name, @proc
	.ifnes "", "&..."
	gproc \...
	.endif
	.endm

Of course, I don't want to make ... a special identifier here, so I'd rather like to go the MASM route and allow qualifiers on parameters (and at once introduce their .ifb/.ifnb pseudo-ops to not require use of the undocumented use of & in the .ifnes above):

	.macro gproc name:req, more:vararg
	.global \name
	.type \name, @proc
	.ifnb \more
	gproc \more
	.endif
	.endm

These qualifiers mean

req	argument value required
vararg	parameter covers all remaining arguments, if any

while by default specifying an argument value would remain optional (including the use of =<value> to specify a default value). Of course, the use of : here again may present some issues, since MMIX allows : in symbol names, but other than above I think this could be tolerated, just requiring to use white space around the colon to disambiguate things.


Jan

             reply	other threads:[~2005-04-20  9:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-20  9:20 Jan Beulich [this message]
2005-04-20  9:34 ` Hans-Peter Nilsson
     [not found] <s25f7070.029@emea1-mh.id2.novell.com>
2005-04-15  8:32 ` Erik Christiansen
  -- strict thread matches above, loose matches on Subject: below --
2005-04-15  6:42 Jan Beulich
2005-04-14 14:43 Jan Beulich
2005-04-14 17:25 ` Zack Weinberg
2005-04-15  2:49 ` Erik Christiansen

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=s2662ccc.060@emea1-mh.id2.novell.com \
    --to=jbeulich@novell.com \
    --cc=binutils@sources.redhat.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).