Index: lib/MC/MCParser/AsmParser.cpp =================================================================== --- lib/MC/MCParser/AsmParser.cpp +++ lib/MC/MCParser/AsmParser.cpp @@ -2039,7 +2039,6 @@ case AsmToken::AmpAmp: case AsmToken::Exclaim: case AsmToken::ExclaimEqual: - case AsmToken::Percent: case AsmToken::Less: case AsmToken::LessEqual: case AsmToken::LessLess: @@ -2083,15 +2082,22 @@ // Darwin doesn't use spaces to delmit arguments. AsmLexerSkipSpaceRAII ScopedSkipSpace(Lexer, IsDarwin); + bool SpaceEaten; + for (;;) { + SpaceEaten = false; if (Lexer.is(AsmToken::Eof) || Lexer.is(AsmToken::Equal)) return TokError("unexpected token in macro instantiation"); - if (ParenLevel == 0 && Lexer.is(AsmToken::Comma)) - break; + if (ParenLevel == 0) { + + if (Lexer.is(AsmToken::Comma)) + break; - if (Lexer.is(AsmToken::Space)) { - Lex(); // Eat spaces + if (Lexer.is(AsmToken::Space)) { + SpaceEaten = true; + Lex(); // Eat spaces + } // Spaces can delimit parameters, but could also be part an expression. // If the token after a space is an operator, add the token and the next @@ -2101,14 +2107,12 @@ // Check to see whether the token is used as an operator, // or part of an identifier const char *NextChar = getTok().getEndLoc().getPointer(); - if (*NextChar == ' ') + if (*NextChar == ' ' || isdigit(*NextChar)) AddTokens = 2; } - - if (!AddTokens && ParenLevel == 0) { - break; - } } + if (AddTokens == 0 && SpaceEaten) + break; } // handleMacroEntry relies on not advancing the lexer here Index: test/MC/AsmParser/macros-gas.s =================================================================== --- test/MC/AsmParser/macros-gas.s +++ test/MC/AsmParser/macros-gas.s @@ -39,10 +39,10 @@ .ascii "\_a \_b \_c" .endm -// CHECK: .ascii "1 (23) " +// CHECK: .ascii "1 (2 3) " test3_prime 1, (2 3) -// CHECK: .ascii "1 (23) " +// CHECK: .ascii "1 (2 3) " test3_prime 1 (2 3) // CHECK: .ascii "1 2 " Index: test/MC/Mips/macro-sdc1.s =================================================================== --- /dev/null +++ test/MC/Mips/macro-sdc1.s @@ -0,0 +1,22 @@ +# RUN: llvm-mc %s -triple=mipsel-unknown-linux -show-encoding -mcpu=mips32r2 | \ +# RUN: FileCheck %s +# RUN: llvm-mc %s -triple=mips-unknown-linux -show-encoding -mcpu=mips32r2 | \ +# RUN: FileCheck %s + +# Check that the IAS expands macro instructions in the same way as GAS. + + .macro EX insn, reg, src +.ex\@: \insn \reg, \src + .endm + + EX sdc1 $f0, 272+8($a0) +# CHECK: sdc1 $f0, 280($4) + + EX sdc1 $f0, 272 +8($a0) +# CHECK: sdc1 $f0, 280($4) + + EX sdc1 $f0, 272+ 8($a0) +# CHECK: sdc1 $f0, 280($4) + + EX sdc1 $f0, 272 + 8($a0) +# CHECK: sdc1 $f0, 280($4)