[LLVM][inline-asm] Altmacro absolute expression '%' feature
authorMichael Zuckerman <Michael.zuckerman@intel.com>
Mon, 1 May 2017 13:20:12 +0000 (13:20 +0000)
committerMichael Zuckerman <Michael.zuckerman@intel.com>
Mon, 1 May 2017 13:20:12 +0000 (13:20 +0000)
commit56704618aa037fbaaa0e141f86b1c78be45569d4
tree49e7c2d494c8f0964bf18c74eb3d29c1327b64da
parent6c60ed5a45937d5644bafb2fa7272994c337e8d7
[LLVM][inline-asm] Altmacro absolute expression '%' feature

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.

Differential Revision: https://reviews.llvm.org/D32526

llvm-svn: 301797
llvm/include/llvm/MC/MCParser/MCAsmLexer.h
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCParser/MCAsmLexer.cpp
llvm/test/MC/AsmParser/altmacro_expression.s [new file with mode: 0644]
llvm/test/MC/AsmParser/negativ_altmacro_expression.s [new file with mode: 0644]