diff options
Diffstat (limited to 'tools/llvm-mc/AsmParser.cpp')
-rw-r--r-- | tools/llvm-mc/AsmParser.cpp | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp index 032b25e..cb69bb1 100644 --- a/tools/llvm-mc/AsmParser.cpp +++ b/tools/llvm-mc/AsmParser.cpp @@ -13,10 +13,10 @@ #include "AsmParser.h" -#include "AsmExpr.h" #include "llvm/ADT/SmallString.h" #include "llvm/ADT/Twine.h" #include "llvm/MC/MCContext.h" +#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCStreamer.h" @@ -173,7 +173,7 @@ void AsmParser::EatToEndOfStatement() { /// /// parenexpr ::= expr) /// -bool AsmParser::ParseParenExpr(AsmExpr *&Res) { +bool AsmParser::ParseParenExpr(MCExpr *&Res) { if (ParseExpression(Res)) return true; if (Lexer.isNot(AsmToken::RParen)) return TokError("expected ')' in parentheses expression"); @@ -197,7 +197,7 @@ MCSymbol *AsmParser::CreateSymbol(StringRef Name) { /// primaryexpr ::= symbol /// primaryexpr ::= number /// primaryexpr ::= ~,+,- primaryexpr -bool AsmParser::ParsePrimaryExpr(AsmExpr *&Res) { +bool AsmParser::ParsePrimaryExpr(MCExpr *&Res) { switch (Lexer.getKind()) { default: return TokError("unknown token in expression"); @@ -205,7 +205,7 @@ bool AsmParser::ParsePrimaryExpr(AsmExpr *&Res) { Lexer.Lex(); // Eat the operator. if (ParsePrimaryExpr(Res)) return true; - Res = new AsmUnaryExpr(AsmUnaryExpr::LNot, Res); + Res = new MCUnaryExpr(MCUnaryExpr::LNot, Res); return false; case AsmToken::String: case AsmToken::Identifier: { @@ -213,12 +213,12 @@ bool AsmParser::ParsePrimaryExpr(AsmExpr *&Res) { // handle things like LFOO+4. MCSymbol *Sym = CreateSymbol(Lexer.getTok().getIdentifier()); - Res = new AsmSymbolRefExpr(Sym); + Res = new MCSymbolRefExpr(Sym); Lexer.Lex(); // Eat identifier. return false; } case AsmToken::Integer: - Res = new AsmConstantExpr(Lexer.getTok().getIntVal()); + Res = new MCConstantExpr(Lexer.getTok().getIntVal()); Lexer.Lex(); // Eat token. return false; case AsmToken::LParen: @@ -228,19 +228,19 @@ bool AsmParser::ParsePrimaryExpr(AsmExpr *&Res) { Lexer.Lex(); // Eat the operator. if (ParsePrimaryExpr(Res)) return true; - Res = new AsmUnaryExpr(AsmUnaryExpr::Minus, Res); + Res = new MCUnaryExpr(MCUnaryExpr::Minus, Res); return false; case AsmToken::Plus: Lexer.Lex(); // Eat the operator. if (ParsePrimaryExpr(Res)) return true; - Res = new AsmUnaryExpr(AsmUnaryExpr::Plus, Res); + Res = new MCUnaryExpr(MCUnaryExpr::Plus, Res); return false; case AsmToken::Tilde: Lexer.Lex(); // Eat the operator. if (ParsePrimaryExpr(Res)) return true; - Res = new AsmUnaryExpr(AsmUnaryExpr::Not, Res); + Res = new MCUnaryExpr(MCUnaryExpr::Not, Res); return false; } } @@ -252,14 +252,14 @@ bool AsmParser::ParsePrimaryExpr(AsmExpr *&Res) { /// expr ::= expr *,/,%,<<,>> expr -> highest. /// expr ::= primaryexpr /// -bool AsmParser::ParseExpression(AsmExpr *&Res) { +bool AsmParser::ParseExpression(MCExpr *&Res) { Res = 0; return ParsePrimaryExpr(Res) || ParseBinOpRHS(1, Res); } bool AsmParser::ParseAbsoluteExpression(int64_t &Res) { - AsmExpr *Expr; + MCExpr *Expr; SMLoc StartLoc = Lexer.getLoc(); if (ParseExpression(Expr)) @@ -272,7 +272,7 @@ bool AsmParser::ParseAbsoluteExpression(int64_t &Res) { } bool AsmParser::ParseRelocatableExpression(MCValue &Res) { - AsmExpr *Expr; + MCExpr *Expr; SMLoc StartLoc = Lexer.getLoc(); if (ParseExpression(Expr)) @@ -285,7 +285,7 @@ bool AsmParser::ParseRelocatableExpression(MCValue &Res) { } bool AsmParser::ParseParenRelocatableExpression(MCValue &Res) { - AsmExpr *Expr; + MCExpr *Expr; SMLoc StartLoc = Lexer.getLoc(); if (ParseParenExpr(Expr)) @@ -298,73 +298,73 @@ bool AsmParser::ParseParenRelocatableExpression(MCValue &Res) { } static unsigned getBinOpPrecedence(AsmToken::TokenKind K, - AsmBinaryExpr::Opcode &Kind) { + MCBinaryExpr::Opcode &Kind) { switch (K) { default: return 0; // not a binop. // Lowest Precedence: &&, || case AsmToken::AmpAmp: - Kind = AsmBinaryExpr::LAnd; + Kind = MCBinaryExpr::LAnd; return 1; case AsmToken::PipePipe: - Kind = AsmBinaryExpr::LOr; + Kind = MCBinaryExpr::LOr; return 1; // Low Precedence: +, -, ==, !=, <>, <, <=, >, >= case AsmToken::Plus: - Kind = AsmBinaryExpr::Add; + Kind = MCBinaryExpr::Add; return 2; case AsmToken::Minus: - Kind = AsmBinaryExpr::Sub; + Kind = MCBinaryExpr::Sub; return 2; case AsmToken::EqualEqual: - Kind = AsmBinaryExpr::EQ; + Kind = MCBinaryExpr::EQ; return 2; case AsmToken::ExclaimEqual: case AsmToken::LessGreater: - Kind = AsmBinaryExpr::NE; + Kind = MCBinaryExpr::NE; return 2; case AsmToken::Less: - Kind = AsmBinaryExpr::LT; + Kind = MCBinaryExpr::LT; return 2; case AsmToken::LessEqual: - Kind = AsmBinaryExpr::LTE; + Kind = MCBinaryExpr::LTE; return 2; case AsmToken::Greater: - Kind = AsmBinaryExpr::GT; + Kind = MCBinaryExpr::GT; return 2; case AsmToken::GreaterEqual: - Kind = AsmBinaryExpr::GTE; + Kind = MCBinaryExpr::GTE; return 2; // Intermediate Precedence: |, &, ^ // // FIXME: gas seems to support '!' as an infix operator? case AsmToken::Pipe: - Kind = AsmBinaryExpr::Or; + Kind = MCBinaryExpr::Or; return 3; case AsmToken::Caret: - Kind = AsmBinaryExpr::Xor; + Kind = MCBinaryExpr::Xor; return 3; case AsmToken::Amp: - Kind = AsmBinaryExpr::And; + Kind = MCBinaryExpr::And; return 3; // Highest Precedence: *, /, %, <<, >> case AsmToken::Star: - Kind = AsmBinaryExpr::Mul; + Kind = MCBinaryExpr::Mul; return 4; case AsmToken::Slash: - Kind = AsmBinaryExpr::Div; + Kind = MCBinaryExpr::Div; return 4; case AsmToken::Percent: - Kind = AsmBinaryExpr::Mod; + Kind = MCBinaryExpr::Mod; return 4; case AsmToken::LessLess: - Kind = AsmBinaryExpr::Shl; + Kind = MCBinaryExpr::Shl; return 4; case AsmToken::GreaterGreater: - Kind = AsmBinaryExpr::Shr; + Kind = MCBinaryExpr::Shr; return 4; } } @@ -372,9 +372,9 @@ static unsigned getBinOpPrecedence(AsmToken::TokenKind K, /// ParseBinOpRHS - Parse all binary operators with precedence >= 'Precedence'. /// Res contains the LHS of the expression on input. -bool AsmParser::ParseBinOpRHS(unsigned Precedence, AsmExpr *&Res) { +bool AsmParser::ParseBinOpRHS(unsigned Precedence, MCExpr *&Res) { while (1) { - AsmBinaryExpr::Opcode Kind = AsmBinaryExpr::Add; + MCBinaryExpr::Opcode Kind = MCBinaryExpr::Add; unsigned TokPrec = getBinOpPrecedence(Lexer.getKind(), Kind); // If the next token is lower precedence than we are allowed to eat, return @@ -385,19 +385,19 @@ bool AsmParser::ParseBinOpRHS(unsigned Precedence, AsmExpr *&Res) { Lexer.Lex(); // Eat the next primary expression. - AsmExpr *RHS; + MCExpr *RHS; if (ParsePrimaryExpr(RHS)) return true; // If BinOp binds less tightly with RHS than the operator after RHS, let // the pending operator take RHS as its LHS. - AsmBinaryExpr::Opcode Dummy; + MCBinaryExpr::Opcode Dummy; unsigned NextTokPrec = getBinOpPrecedence(Lexer.getKind(), Dummy); if (TokPrec < NextTokPrec) { if (ParseBinOpRHS(Precedence+1, RHS)) return true; } // Merge LHS and RHS according to operator. - Res = new AsmBinaryExpr(Kind, Res, RHS); + Res = new MCBinaryExpr(Kind, Res, RHS); } } |