llvm.org GIT mirror llvm / d4727e3
[ms-inline asm] Use parsePrimaryExpr in lieu of parseExpression if we need to parse an identifier. Otherwise, parseExpression may parse multiple tokens, which makes it impossible to properly compute an immediate displacement. An example of such a case is the source operand (i.e., [Symbol + ImmDisp]) in the below example: __asm mov eax, [Symbol + ImmDisp] The existing test cases exercise this patch. rdar://13611297 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179115 91177308-0d34-0410-b5e6-96231b3b80d8 Chad Rosier 7 years ago
3 changed file(s) with 17 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
150150 virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
151151 bool parseExpression(const MCExpr *&Res);
152152
153 /// parsePrimaryExpr - Parse a primary expression.
154 ///
155 /// @param Res - The value of the expression. The result is undefined
156 /// on error.
157 /// @result - False on success.
158 virtual bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) = 0;
159
153160 /// parseParenExpression - Parse an arbitrary expression, assuming that an
154161 /// initial '(' has already been consumed.
155162 ///
220220
221221 bool parseExpression(const MCExpr *&Res);
222222 virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc);
223 virtual bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc);
223224 virtual bool parseParenExpression(const MCExpr *&Res, SMLoc &EndLoc);
224225 virtual bool parseAbsoluteExpression(int64_t &Res);
225226
866867 bool AsmParser::parseExpression(const MCExpr *&Res) {
867868 SMLoc EndLoc;
868869 return parseExpression(Res, EndLoc);
870 }
871
872 bool AsmParser::parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) {
873 return ParsePrimaryExpr(Res, EndLoc);
869874 }
870875
871876 const MCExpr *
11291129 if (ParseRegister(TmpReg, Start, End)) {
11301130 const MCExpr *Disp;
11311131 SMLoc IdentStart = Tok.getLoc();
1132 if (getParser().parseExpression(Disp, End))
1132 if (getParser().parsePrimaryExpr(Disp, End))
11331133 return 0;
11341134
11351135 if (X86Operand *Err = ParseIntelVarWithQualifier(Disp, IdentStart))
11811181 SM.onRegister(TmpReg);
11821182 UpdateLocLex = false;
11831183 break;
1184 } else if (!getParser().parseExpression(Disp, End)) {
1184 } else if (!getParser().parsePrimaryExpr(Disp, End)) {
11851185 SM.onDispExpr();
11861186 UpdateLocLex = false;
11871187 break;
13231323
13241324 const MCExpr *Disp = 0;
13251325 SMLoc IdentStart = Tok.getLoc();
1326 if (getParser().parseExpression(Disp, End))
1326 if (getParser().parsePrimaryExpr(Disp, End))
13271327 return 0;
13281328
13291329 if (!isParsingInlineAsm())
14001400
14011401 SMLoc End;
14021402 const MCExpr *Val;
1403 if (getParser().parseExpression(Val, End))
1403 if (getParser().parsePrimaryExpr(Val, End))
14041404 return ErrorOperand(Start, "Unable to parse expression!");
14051405
14061406 // Don't emit the offset operator.
14361436
14371437 SMLoc End;
14381438 const MCExpr *Val;
1439 if (getParser().parseExpression(Val, End))
1439 if (getParser().parsePrimaryExpr(Val, End))
14401440 return 0;
14411441
14421442 unsigned Length = 0, Size = 0, Type = 0;