This is an archive of the discontinued LLVM Phabricator instance.

[LLVM][inline-asm] Altmacro absolute expression '%' feature
ClosedPublic

Authored by m_zuckerman on Apr 26 2017, 2:40 AM.

Details

Summary

In this patch, I introduce a new alt macro feature.
This feature adds meaning for the % when using it as a prefix to the calling macro arguments.

In the altmacro mode, the percent sign '%' before an absolute expression convert the expression first to a string.
As described in the https://sourceware.org/binutils/docs-2.27/as/Altmacro.html
"Expression results as strings
You can write `%expr' to evaluate the expression expr and use the result as a string."

expression assumptions:

  1. '%' can only evaluate an absolute expression.
  2. Altmacro '%' must be the first character of the evaluated expression.
  3. If no '%' is located before the expression, a regular module operation is expected.
  4. The result of Absolute Expressions can be only integer.

Diff Detail

Event Timeline

m_zuckerman edited the summary of this revision. (Show Details)Apr 26 2017, 2:42 AM
m_zuckerman added a subscriber: llvm-commits.
rengolin edited edge metadata.Apr 26 2017, 4:07 AM

I think this patch and D32523 are small and simple enough that it could be merged into one...

MC/MCParser/AsmParser.cpp
489

These functions seem redundant... You could have used getLexer() directly.

rengolin added inline comments.Apr 26 2017, 8:17 AM
MC/AsmParser/AltMacroExpression.s
65

Can you add .noaltmacro and have some cases where it breaks?

This could be a separate file, so that you can add // RUN: not instead.

Make sure you cover before .altmacro is set as well as after it's unset.

Can you merge D32523 with this one?

We don't usually add functionality without purpose/tests, and this is the functionality (and tests) D32523 needs. :)

Otherwise, looks good. Are you going to implement the remaining functionality?

Can you merge D32523 with this one?

We don't usually add functionality without purpose/tests, and this is the functionality (and tests) D32523 needs. :)

Otherwise, looks good. Are you going to implement the remaining functionality?

Yes,
Thanks, I will merge the two together.

m_zuckerman updated this revision to Diff 97277.May 1 2017, 3:28 AM

merge two reviews to one D32526 and D32523

If it's ok with you and you think the review is ready, please mark LGTM

rengolin accepted this revision.May 1 2017, 4:05 AM

Thanks! LGTM with the test change.

MC/AsmParser/negativ_altmacro_expression.s
12 ↗(On Diff #97277)

Better to move this test above .altmacro to make sure the default behaviour is .noaltmacro.

This revision is now accepted and ready to land.May 1 2017, 4:05 AM
This revision was automatically updated to reflect the committed changes.