OSDN Git Service

[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)
commit079b067df74b010544d2187e0385b396950169c4
treefc67a821bf73d3697a8c4ee0ed8bce32b2bde267
parent02f82baedd269eebb269f3aa4664a26aaa6a90a5
[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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301797 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/MC/MCParser/MCAsmLexer.h
lib/MC/MCParser/AsmParser.cpp
lib/MC/MCParser/MCAsmLexer.cpp
test/MC/AsmParser/altmacro_expression.s [new file with mode: 0644]
test/MC/AsmParser/negativ_altmacro_expression.s [new file with mode: 0644]