Index: llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp +++ llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp @@ -344,9 +344,7 @@ Parser.Lex(); } - bool parseOperandStartingWithInteger(bool IsNegative, OperandVector &Operands, - StringRef InstName) { - parseSingleInteger(IsNegative, Operands); + bool checkForP2AlignIfLoadStore(OperandVector &Operands, StringRef InstName) { // FIXME: there is probably a cleaner way to do this. auto IsLoadStore = InstName.find(".load") != StringRef::npos || InstName.find(".store") != StringRef::npos; @@ -471,11 +469,13 @@ // Assume this identifier is a label. const MCExpr *Val; SMLoc End; - if (Parser.parsePrimaryExpr(Val, End)) + if (Parser.parseExpression(Val, End)) return error("Cannot parse symbol: ", Lexer.getTok()); Operands.push_back(make_unique( WebAssemblyOperand::Symbol, Id.getLoc(), Id.getEndLoc(), WebAssemblyOperand::SymOp{Val})); + if (checkForP2AlignIfLoadStore(Operands, Name)) + return true; } break; } @@ -483,11 +483,13 @@ Parser.Lex(); if (Lexer.isNot(AsmToken::Integer)) return error("Expected integer instead got: ", Lexer.getTok()); - if (parseOperandStartingWithInteger(true, Operands, Name)) + parseSingleInteger(true, Operands); + if (checkForP2AlignIfLoadStore(Operands, Name)) return true; break; case AsmToken::Integer: - if (parseOperandStartingWithInteger(false, Operands, Name)) + parseSingleInteger(false, Operands); + if (checkForP2AlignIfLoadStore(Operands, Name)) return true; break; case AsmToken::Real: { Index: llvm/trunk/test/MC/WebAssembly/basic-assembly.s =================================================================== --- llvm/trunk/test/MC/WebAssembly/basic-assembly.s +++ llvm/trunk/test/MC/WebAssembly/basic-assembly.s @@ -81,6 +81,8 @@ end_block end_try i32.const .L.str + i32.load8_u .L.str+2 + i32.load16_u .L.str:p2align=0 throw 0 .LBB0_5: #i32.trunc_sat_f32_s @@ -170,6 +172,8 @@ # CHECK-NEXT: end_block # CHECK-NEXT: end_try # CHECK-NEXT: i32.const .L.str +# CHECK-NEXT: i32.load8_u .L.str+2 +# CHECK-NEXT: i32.load16_u .L.str:p2align=0 # CHECK-NEXT: throw 0 # CHECK-NEXT: .LBB0_5: # CHECK-NEXT: global.get __stack_pointer