forked from OSchip/llvm-project
Fix AsmParser binary precedence for shift operators.
rdar://9976729 llvm-svn: 138208
This commit is contained in:
parent
3322f02a03
commit
bd16424f91
|
@ -740,9 +740,12 @@ AsmParser::ApplyModifierToExpr(const MCExpr *E,
|
|||
|
||||
/// ParseExpression - Parse an expression and return it.
|
||||
///
|
||||
/// expr ::= expr +,- expr -> lowest.
|
||||
/// expr ::= expr |,^,&,! expr -> middle.
|
||||
/// expr ::= expr *,/,%,<<,>> expr -> highest.
|
||||
/// expr ::= expr &&,|| expr -> lowest.
|
||||
/// expr ::= expr |,^,&,! expr
|
||||
/// expr ::= expr ==,!=,<>,<,<=,>,>= expr
|
||||
/// expr ::= expr <<,>> expr
|
||||
/// expr ::= expr +,- expr
|
||||
/// expr ::= expr *,/,% expr -> highest.
|
||||
/// expr ::= primaryexpr
|
||||
///
|
||||
bool AsmParser::ParseExpression(const MCExpr *&Res, SMLoc &EndLoc) {
|
||||
|
@ -809,7 +812,7 @@ static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
|
|||
default:
|
||||
return 0; // not a binop.
|
||||
|
||||
// Lowest Precedence: &&, ||, @
|
||||
// Lowest Precedence: &&, ||
|
||||
case AsmToken::AmpAmp:
|
||||
Kind = MCBinaryExpr::LAnd;
|
||||
return 1;
|
||||
|
@ -852,30 +855,32 @@ static unsigned getBinOpPrecedence(AsmToken::TokenKind K,
|
|||
Kind = MCBinaryExpr::GTE;
|
||||
return 3;
|
||||
|
||||
// Intermediate Precedence: <<, >>
|
||||
case AsmToken::LessLess:
|
||||
Kind = MCBinaryExpr::Shl;
|
||||
return 4;
|
||||
case AsmToken::GreaterGreater:
|
||||
Kind = MCBinaryExpr::Shr;
|
||||
return 4;
|
||||
|
||||
// High Intermediate Precedence: +, -
|
||||
case AsmToken::Plus:
|
||||
Kind = MCBinaryExpr::Add;
|
||||
return 4;
|
||||
return 5;
|
||||
case AsmToken::Minus:
|
||||
Kind = MCBinaryExpr::Sub;
|
||||
return 4;
|
||||
return 5;
|
||||
|
||||
// Highest Precedence: *, /, %, <<, >>
|
||||
// Highest Precedence: *, /, %
|
||||
case AsmToken::Star:
|
||||
Kind = MCBinaryExpr::Mul;
|
||||
return 5;
|
||||
return 6;
|
||||
case AsmToken::Slash:
|
||||
Kind = MCBinaryExpr::Div;
|
||||
return 5;
|
||||
return 6;
|
||||
case AsmToken::Percent:
|
||||
Kind = MCBinaryExpr::Mod;
|
||||
return 5;
|
||||
case AsmToken::LessLess:
|
||||
Kind = MCBinaryExpr::Shl;
|
||||
return 5;
|
||||
case AsmToken::GreaterGreater:
|
||||
Kind = MCBinaryExpr::Shr;
|
||||
return 5;
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ k:
|
|||
check_expr 0 || 1, 1
|
||||
check_expr 0 || 0, 0
|
||||
check_expr 1 + 2 < 3 + 4, 1
|
||||
check_expr 1 << 8 - 1, 128
|
||||
|
||||
.set c, 10
|
||||
check_expr c + 1, 11
|
||||
|
|
Loading…
Reference in New Issue