diff options
author | Fangrui Song <i@maskray.me> | 2024-07-05 14:00:26 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2024-07-05 14:00:26 -0700 |
commit | 812f9e81d2f75c874301a8f5df25d3de7616a9c5 (patch) | |
tree | e9d14557a96b811bcc036b9b81b5fe01d48eed97 | |
parent | ac03ae30cf2b6465ea8f117dfa74ba6f670f6258 (diff) | |
download | llvm-812f9e81d2f75c874301a8f5df25d3de7616a9c5.zip llvm-812f9e81d2f75c874301a8f5df25d3de7616a9c5.tar.gz llvm-812f9e81d2f75c874301a8f5df25d3de7616a9c5.tar.bz2 |
[MCParser] .altmacro: ignore & after a token
-rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 2 | ||||
-rw-r--r-- | llvm/test/MC/AsmParser/altmacro_expression.s | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 4b7c7f0..bf3061a 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -2528,6 +2528,8 @@ bool AsmParser::expandMacro(raw_svector_ostream &OS, MCAsmMacro &Macro, while (I != End && isIdentifierChar(Body[I])) ++I; StringRef Argument(Body.data() + Pos, I - Pos); + if (AltMacroMode && I != End && Body[I] == '&') + ++I; unsigned Index = 0; for (; Index < NParameters; ++Index) if (Parameters[Index].Name == Argument) diff --git a/llvm/test/MC/AsmParser/altmacro_expression.s b/llvm/test/MC/AsmParser/altmacro_expression.s index 58d8b48..cee0a68 100644 --- a/llvm/test/MC/AsmParser/altmacro_expression.s +++ b/llvm/test/MC/AsmParser/altmacro_expression.s @@ -3,10 +3,12 @@ # Checking that the '%' was evaluated as a string first # In a fail scenario: The asmprint will print: addl $%(1+4), %eax -# CHECK: addl $5, %eax +# CHECK: addl $5, %eax +# CHECK-NEXT: addl $5, %eax .altmacro .macro percent_expr arg addl $\arg, %eax + addl $\arg&, %eax .endm percent_expr %(1+4) |