This is an archive of the discontinued LLVM Phabricator instance.

[MC] [IAS] Add support for the \@ .macro pseudo-variable.
ClosedPublic

Authored by tomatabacu on Apr 22 2015, 8:42 AM.

Details

Summary

When used, it is substituted with the number of .macro instantiations we've done up to that point in time.
So if this is the 1st time we've instantiated a .macro (any .macro, regardless of name), \@ will instantiate to 0, if it's the 2nd .macro instantiation, it will instantiate to 1 etc.

It can only be used inside a .macro definition, an .irp definition or an .irpc definition (those last 2 uses are undocumented).

Diff Detail

Event Timeline

tomatabacu updated this revision to Diff 24231.Apr 22 2015, 8:42 AM
tomatabacu retitled this revision from to [MC] [IAS] Add support for the \@ .macro pseudo-variable..
tomatabacu updated this object.
tomatabacu edited the test plan for this revision. (Show Details)
tomatabacu added reviewers: rafael, echristo.
tomatabacu added subscribers: Unknown Object (MLST), dsanders.
rafael edited edge metadata.Apr 22 2015, 2:22 PM

The documentation in gas says @ is " how many macros it has executed ". Is the documentation wrong?

Expand the test a bit. In particular, can you test for a macro being undefined and the number going down? Also, you check for \@ in two locations (two ifs use EnableAtPseudoVariable), but the test only covers one of them, no?

tomatabacu updated this revision to Diff 24287.Apr 23 2015, 5:08 AM
tomatabacu edited edge metadata.

Fixed wrong implementation.
Updated tests.

tomatabacu updated this object.Apr 23 2015, 5:11 AM

The documentation in gas says @ is " how many macros it has executed ". Is the documentation wrong?

No, the documentation is right, I just got too focused on an ambiguous test-case. Sorry about that!
I think it's supposed to track the number of .macro instantiations we've made up to that point.

In particular, can you test for a macro being undefined and the number going down?

I don't think this applies anymore, as the number of instantiations can't go down.

Also, you check for \@ in two locations (two ifs use EnableAtPseudoVariable), but the test only covers one of them, no?

That second check is redundant AFAICT, as Argument can only be "@" if the first check succeeds, so I removed it.

Please a test with rep showing that it increments (or doesn't) the counter for @.

lib/MC/MCParser/AsmParser.cpp
2153

rep will increment this, no? Should it?

tomatabacu updated this revision to Diff 24371.Apr 24 2015, 3:15 AM

Added test case which checks that .irp(c) and .rep(t) do not increase \@.

Replied to inline comment.

lib/MC/MCParser/AsmParser.cpp
2153

It turns out that .rep(t) don't increment \@ and shouldn't. The same goes for irp(c).

rafael accepted this revision.Apr 24 2015, 5:45 AM
rafael edited edge metadata.

LGTM

This revision is now accepted and ready to land.Apr 24 2015, 5:45 AM
tomatabacu closed this revision.Apr 27 2015, 3:53 AM