inline assembly supports %= syntax

it outputs a number that is unique to each instance of the asm
statement in the entire compilation.

useful when creating local labels and referring to them multiple
times in a single template that generates multiple
assembler instructions
This commit is contained in:
Andrew Kelley
2017-02-04 22:33:58 -05:00
parent b840184bb0
commit 64a0510205
3 changed files with 18 additions and 3 deletions

View File

@@ -136,6 +136,10 @@ static void parse_asm_template(ParseContext *pc, AstNode *node) {
} else if (c == '[') {
cur_tok->id = AsmTokenIdVar;
state = StateVar;
} else if (c == '=') {
cur_tok->id = AsmTokenIdUniqueId;
cur_tok->end = i;
state = StateStart;
} else {
ast_asm_error(pc, node, i, "expected a '%%' or '['");
}