diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-08-31 08:07:22 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-31 08:07:22 +0000 |
commit | 9643ac55142d40da404caa8e5fedfef2cd7b4afc (patch) | |
tree | f925fcae59497a061b91541242aeb85adfcea514 /tools | |
parent | 869a5e7d66cdc756608190bff1e837fe5809d16e (diff) | |
download | external_llvm-9643ac55142d40da404caa8e5fedfef2cd7b4afc.zip external_llvm-9643ac55142d40da404caa8e5fedfef2cd7b4afc.tar.gz external_llvm-9643ac55142d40da404caa8e5fedfef2cd7b4afc.tar.bz2 |
llvm-mc: Switch MCExpr construction to using static member functions, and taking the MCContext (which now owns all MCExprs).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80569 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r-- | tools/llvm-mc/AsmParser.cpp | 30 | ||||
-rw-r--r-- | tools/llvm-mc/AsmParser.h | 8 |
2 files changed, 19 insertions, 19 deletions
diff --git a/tools/llvm-mc/AsmParser.cpp b/tools/llvm-mc/AsmParser.cpp index cb69bb1..6f002e1 100644 --- a/tools/llvm-mc/AsmParser.cpp +++ b/tools/llvm-mc/AsmParser.cpp @@ -173,7 +173,7 @@ void AsmParser::EatToEndOfStatement() { /// /// parenexpr ::= expr) /// -bool AsmParser::ParseParenExpr(MCExpr *&Res) { +bool AsmParser::ParseParenExpr(const 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(MCExpr *&Res) { +bool AsmParser::ParsePrimaryExpr(const MCExpr *&Res) { switch (Lexer.getKind()) { default: return TokError("unknown token in expression"); @@ -205,7 +205,7 @@ bool AsmParser::ParsePrimaryExpr(MCExpr *&Res) { Lexer.Lex(); // Eat the operator. if (ParsePrimaryExpr(Res)) return true; - Res = new MCUnaryExpr(MCUnaryExpr::LNot, Res); + Res = MCUnaryExpr::CreateLNot(Res, Ctx); return false; case AsmToken::String: case AsmToken::Identifier: { @@ -213,12 +213,12 @@ bool AsmParser::ParsePrimaryExpr(MCExpr *&Res) { // handle things like LFOO+4. MCSymbol *Sym = CreateSymbol(Lexer.getTok().getIdentifier()); - Res = new MCSymbolRefExpr(Sym); + Res = MCSymbolRefExpr::Create(Sym, Ctx); Lexer.Lex(); // Eat identifier. return false; } case AsmToken::Integer: - Res = new MCConstantExpr(Lexer.getTok().getIntVal()); + Res = MCConstantExpr::Create(Lexer.getTok().getIntVal(), Ctx); Lexer.Lex(); // Eat token. return false; case AsmToken::LParen: @@ -228,19 +228,19 @@ bool AsmParser::ParsePrimaryExpr(MCExpr *&Res) { Lexer.Lex(); // Eat the operator. if (ParsePrimaryExpr(Res)) return true; - Res = new MCUnaryExpr(MCUnaryExpr::Minus, Res); + Res = MCUnaryExpr::CreateMinus(Res, Ctx); return false; case AsmToken::Plus: Lexer.Lex(); // Eat the operator. if (ParsePrimaryExpr(Res)) return true; - Res = new MCUnaryExpr(MCUnaryExpr::Plus, Res); + Res = MCUnaryExpr::CreatePlus(Res, Ctx); return false; case AsmToken::Tilde: Lexer.Lex(); // Eat the operator. if (ParsePrimaryExpr(Res)) return true; - Res = new MCUnaryExpr(MCUnaryExpr::Not, Res); + Res = MCUnaryExpr::CreateNot(Res, Ctx); return false; } } @@ -252,14 +252,14 @@ bool AsmParser::ParsePrimaryExpr(MCExpr *&Res) { /// expr ::= expr *,/,%,<<,>> expr -> highest. /// expr ::= primaryexpr /// -bool AsmParser::ParseExpression(MCExpr *&Res) { +bool AsmParser::ParseExpression(const MCExpr *&Res) { Res = 0; return ParsePrimaryExpr(Res) || ParseBinOpRHS(1, Res); } bool AsmParser::ParseAbsoluteExpression(int64_t &Res) { - MCExpr *Expr; + const MCExpr *Expr; SMLoc StartLoc = Lexer.getLoc(); if (ParseExpression(Expr)) @@ -272,7 +272,7 @@ bool AsmParser::ParseAbsoluteExpression(int64_t &Res) { } bool AsmParser::ParseRelocatableExpression(MCValue &Res) { - MCExpr *Expr; + const MCExpr *Expr; SMLoc StartLoc = Lexer.getLoc(); if (ParseExpression(Expr)) @@ -285,7 +285,7 @@ bool AsmParser::ParseRelocatableExpression(MCValue &Res) { } bool AsmParser::ParseParenRelocatableExpression(MCValue &Res) { - MCExpr *Expr; + const MCExpr *Expr; SMLoc StartLoc = Lexer.getLoc(); if (ParseParenExpr(Expr)) @@ -372,7 +372,7 @@ 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, MCExpr *&Res) { +bool AsmParser::ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res) { while (1) { MCBinaryExpr::Opcode Kind = MCBinaryExpr::Add; unsigned TokPrec = getBinOpPrecedence(Lexer.getKind(), Kind); @@ -385,7 +385,7 @@ bool AsmParser::ParseBinOpRHS(unsigned Precedence, MCExpr *&Res) { Lexer.Lex(); // Eat the next primary expression. - MCExpr *RHS; + const MCExpr *RHS; if (ParsePrimaryExpr(RHS)) return true; // If BinOp binds less tightly with RHS than the operator after RHS, let @@ -397,7 +397,7 @@ bool AsmParser::ParseBinOpRHS(unsigned Precedence, MCExpr *&Res) { } // Merge LHS and RHS according to operator. - Res = new MCBinaryExpr(Kind, Res, RHS); + Res = MCBinaryExpr::Create(Kind, Res, RHS, Ctx); } } diff --git a/tools/llvm-mc/AsmParser.h b/tools/llvm-mc/AsmParser.h index 99e5bbe..c7b7316 100644 --- a/tools/llvm-mc/AsmParser.h +++ b/tools/llvm-mc/AsmParser.h @@ -66,7 +66,7 @@ public: virtual bool Error(SMLoc L, const Twine &Msg); - virtual bool ParseExpression(MCExpr *&Res); + virtual bool ParseExpression(const MCExpr *&Res); virtual bool ParseAbsoluteExpression(int64_t &Res); @@ -104,9 +104,9 @@ private: /// @see ParseRelocatableExpression, ParseParenExpr. bool ParseParenRelocatableExpression(MCValue &Res); - bool ParsePrimaryExpr(MCExpr *&Res); - bool ParseBinOpRHS(unsigned Precedence, MCExpr *&Res); - bool ParseParenExpr(MCExpr *&Res); + bool ParsePrimaryExpr(const MCExpr *&Res); + bool ParseBinOpRHS(unsigned Precedence, const MCExpr *&Res); + bool ParseParenExpr(const MCExpr *&Res); /// ParseIdentifier - Parse an identifier or string (as a quoted identifier) /// and set \arg Res to the identifier contents. |