Chris Lattner | 27aa7d2 | 2009-06-21 20:16:42 +0000 | [diff] [blame] | 1 | //===- AsmParser.cpp - Parser for Assembly Files --------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This class implements the parser for assembly files. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "AsmParser.h" |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 15 | |
| 16 | #include "AsmExpr.h" |
Daniel Dunbar | f9507ff | 2009-07-27 23:20:52 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/Twine.h" |
Daniel Dunbar | ecc63f8 | 2009-06-23 22:01:43 +0000 | [diff] [blame] | 18 | #include "llvm/MC/MCContext.h" |
Chris Lattner | 29dfe7c | 2009-06-23 18:41:30 +0000 | [diff] [blame] | 19 | #include "llvm/MC/MCInst.h" |
Chris Lattner | 56594f9 | 2009-07-31 17:47:16 +0000 | [diff] [blame] | 20 | #include "llvm/MC/MCSection.h" |
Daniel Dunbar | ecc63f8 | 2009-06-23 22:01:43 +0000 | [diff] [blame] | 21 | #include "llvm/MC/MCStreamer.h" |
Daniel Dunbar | dce0f3c | 2009-06-29 23:43:14 +0000 | [diff] [blame] | 22 | #include "llvm/MC/MCSymbol.h" |
Chris Lattner | b0789ed | 2009-06-21 20:54:55 +0000 | [diff] [blame] | 23 | #include "llvm/Support/SourceMgr.h" |
| 24 | #include "llvm/Support/raw_ostream.h" |
Daniel Dunbar | a3af370 | 2009-07-20 18:55:04 +0000 | [diff] [blame] | 25 | #include "llvm/Target/TargetAsmParser.h" |
Chris Lattner | 27aa7d2 | 2009-06-21 20:16:42 +0000 | [diff] [blame] | 26 | using namespace llvm; |
| 27 | |
Daniel Dunbar | f9507ff | 2009-07-27 23:20:52 +0000 | [diff] [blame] | 28 | void AsmParser::Warning(SMLoc L, const Twine &Msg) { |
| 29 | Lexer.PrintMessage(L, Msg.str(), "warning"); |
Daniel Dunbar | 3fb7683 | 2009-06-30 00:49:23 +0000 | [diff] [blame] | 30 | } |
| 31 | |
Daniel Dunbar | f9507ff | 2009-07-27 23:20:52 +0000 | [diff] [blame] | 32 | bool AsmParser::Error(SMLoc L, const Twine &Msg) { |
| 33 | Lexer.PrintMessage(L, Msg.str(), "error"); |
Chris Lattner | 14ee48a | 2009-06-21 21:22:11 +0000 | [diff] [blame] | 34 | return true; |
| 35 | } |
| 36 | |
| 37 | bool AsmParser::TokError(const char *Msg) { |
Daniel Dunbar | 3fb7683 | 2009-06-30 00:49:23 +0000 | [diff] [blame] | 38 | Lexer.PrintMessage(Lexer.getLoc(), Msg, "error"); |
Chris Lattner | 14ee48a | 2009-06-21 21:22:11 +0000 | [diff] [blame] | 39 | return true; |
| 40 | } |
| 41 | |
Chris Lattner | 27aa7d2 | 2009-06-21 20:16:42 +0000 | [diff] [blame] | 42 | bool AsmParser::Run() { |
Chris Lattner | b0789ed | 2009-06-21 20:54:55 +0000 | [diff] [blame] | 43 | // Prime the lexer. |
| 44 | Lexer.Lex(); |
| 45 | |
Chris Lattner | b717fb0 | 2009-07-02 21:53:43 +0000 | [diff] [blame] | 46 | bool HadError = false; |
Chris Lattner | b0789ed | 2009-06-21 20:54:55 +0000 | [diff] [blame] | 47 | |
Chris Lattner | b717fb0 | 2009-07-02 21:53:43 +0000 | [diff] [blame] | 48 | // While we have input, parse each statement. |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 49 | while (Lexer.isNot(AsmToken::Eof)) { |
Chris Lattner | b717fb0 | 2009-07-02 21:53:43 +0000 | [diff] [blame] | 50 | if (!ParseStatement()) continue; |
| 51 | |
| 52 | // If we had an error, remember it and recover by skipping to the next line. |
| 53 | HadError = true; |
| 54 | EatToEndOfStatement(); |
| 55 | } |
| 56 | |
| 57 | return HadError; |
Chris Lattner | b0789ed | 2009-06-21 20:54:55 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Chris Lattner | 2cf5f14 | 2009-06-22 01:29:09 +0000 | [diff] [blame] | 60 | /// EatToEndOfStatement - Throw away the rest of the line for testing purposes. |
| 61 | void AsmParser::EatToEndOfStatement() { |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 62 | while (Lexer.isNot(AsmToken::EndOfStatement) && |
| 63 | Lexer.isNot(AsmToken::Eof)) |
Chris Lattner | 2cf5f14 | 2009-06-22 01:29:09 +0000 | [diff] [blame] | 64 | Lexer.Lex(); |
| 65 | |
| 66 | // Eat EOL. |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 67 | if (Lexer.is(AsmToken::EndOfStatement)) |
Chris Lattner | 2cf5f14 | 2009-06-22 01:29:09 +0000 | [diff] [blame] | 68 | Lexer.Lex(); |
| 69 | } |
| 70 | |
Chris Lattner | c419383 | 2009-06-22 05:51:26 +0000 | [diff] [blame] | 71 | |
Chris Lattner | 74ec1a3 | 2009-06-22 06:32:03 +0000 | [diff] [blame] | 72 | /// ParseParenExpr - Parse a paren expression and return it. |
| 73 | /// NOTE: This assumes the leading '(' has already been consumed. |
| 74 | /// |
| 75 | /// parenexpr ::= expr) |
| 76 | /// |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 77 | bool AsmParser::ParseParenExpr(AsmExpr *&Res) { |
Chris Lattner | 74ec1a3 | 2009-06-22 06:32:03 +0000 | [diff] [blame] | 78 | if (ParseExpression(Res)) return true; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 79 | if (Lexer.isNot(AsmToken::RParen)) |
Chris Lattner | 74ec1a3 | 2009-06-22 06:32:03 +0000 | [diff] [blame] | 80 | return TokError("expected ')' in parentheses expression"); |
| 81 | Lexer.Lex(); |
| 82 | return false; |
| 83 | } |
Chris Lattner | c419383 | 2009-06-22 05:51:26 +0000 | [diff] [blame] | 84 | |
Chris Lattner | 74ec1a3 | 2009-06-22 06:32:03 +0000 | [diff] [blame] | 85 | /// ParsePrimaryExpr - Parse a primary expression and return it. |
| 86 | /// primaryexpr ::= (parenexpr |
| 87 | /// primaryexpr ::= symbol |
| 88 | /// primaryexpr ::= number |
| 89 | /// primaryexpr ::= ~,+,- primaryexpr |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 90 | bool AsmParser::ParsePrimaryExpr(AsmExpr *&Res) { |
Chris Lattner | c419383 | 2009-06-22 05:51:26 +0000 | [diff] [blame] | 91 | switch (Lexer.getKind()) { |
| 92 | default: |
| 93 | return TokError("unknown token in expression"); |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 94 | case AsmToken::Exclaim: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 95 | Lexer.Lex(); // Eat the operator. |
| 96 | if (ParsePrimaryExpr(Res)) |
| 97 | return true; |
| 98 | Res = new AsmUnaryExpr(AsmUnaryExpr::LNot, Res); |
| 99 | return false; |
Daniel Dunbar | 76c4d76 | 2009-07-31 21:55:09 +0000 | [diff] [blame] | 100 | case AsmToken::String: |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 101 | case AsmToken::Identifier: { |
Chris Lattner | c419383 | 2009-06-22 05:51:26 +0000 | [diff] [blame] | 102 | // This is a label, this should be parsed as part of an expression, to |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 103 | // handle things like LFOO+4. |
Daniel Dunbar | 76c4d76 | 2009-07-31 21:55:09 +0000 | [diff] [blame] | 104 | MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getTok().getIdentifier()); |
Daniel Dunbar | dce0f3c | 2009-06-29 23:43:14 +0000 | [diff] [blame] | 105 | |
| 106 | // If this is use of an undefined symbol then mark it external. |
| 107 | if (!Sym->getSection() && !Ctx.GetSymbolValue(Sym)) |
| 108 | Sym->setExternal(true); |
| 109 | |
| 110 | Res = new AsmSymbolRefExpr(Sym); |
Chris Lattner | c419383 | 2009-06-22 05:51:26 +0000 | [diff] [blame] | 111 | Lexer.Lex(); // Eat identifier. |
| 112 | return false; |
Daniel Dunbar | dce0f3c | 2009-06-29 23:43:14 +0000 | [diff] [blame] | 113 | } |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 114 | case AsmToken::Integer: |
Daniel Dunbar | 419aded | 2009-07-28 16:38:40 +0000 | [diff] [blame] | 115 | Res = new AsmConstantExpr(Lexer.getTok().getIntVal()); |
Daniel Dunbar | 76c4d76 | 2009-07-31 21:55:09 +0000 | [diff] [blame] | 116 | Lexer.Lex(); // Eat token. |
Chris Lattner | c419383 | 2009-06-22 05:51:26 +0000 | [diff] [blame] | 117 | return false; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 118 | case AsmToken::LParen: |
Chris Lattner | 74ec1a3 | 2009-06-22 06:32:03 +0000 | [diff] [blame] | 119 | Lexer.Lex(); // Eat the '('. |
| 120 | return ParseParenExpr(Res); |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 121 | case AsmToken::Minus: |
Chris Lattner | 74ec1a3 | 2009-06-22 06:32:03 +0000 | [diff] [blame] | 122 | Lexer.Lex(); // Eat the operator. |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 123 | if (ParsePrimaryExpr(Res)) |
| 124 | return true; |
| 125 | Res = new AsmUnaryExpr(AsmUnaryExpr::Minus, Res); |
| 126 | return false; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 127 | case AsmToken::Plus: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 128 | Lexer.Lex(); // Eat the operator. |
| 129 | if (ParsePrimaryExpr(Res)) |
| 130 | return true; |
| 131 | Res = new AsmUnaryExpr(AsmUnaryExpr::Plus, Res); |
| 132 | return false; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 133 | case AsmToken::Tilde: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 134 | Lexer.Lex(); // Eat the operator. |
| 135 | if (ParsePrimaryExpr(Res)) |
| 136 | return true; |
| 137 | Res = new AsmUnaryExpr(AsmUnaryExpr::Not, Res); |
| 138 | return false; |
Chris Lattner | c419383 | 2009-06-22 05:51:26 +0000 | [diff] [blame] | 139 | } |
| 140 | } |
Chris Lattner | 74ec1a3 | 2009-06-22 06:32:03 +0000 | [diff] [blame] | 141 | |
| 142 | /// ParseExpression - Parse an expression and return it. |
| 143 | /// |
| 144 | /// expr ::= expr +,- expr -> lowest. |
| 145 | /// expr ::= expr |,^,&,! expr -> middle. |
| 146 | /// expr ::= expr *,/,%,<<,>> expr -> highest. |
| 147 | /// expr ::= primaryexpr |
| 148 | /// |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 149 | bool AsmParser::ParseExpression(AsmExpr *&Res) { |
| 150 | Res = 0; |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 151 | return ParsePrimaryExpr(Res) || |
| 152 | ParseBinOpRHS(1, Res); |
Chris Lattner | 74ec1a3 | 2009-06-22 06:32:03 +0000 | [diff] [blame] | 153 | } |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 154 | |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 155 | bool AsmParser::ParseAbsoluteExpression(int64_t &Res) { |
| 156 | AsmExpr *Expr; |
| 157 | |
Daniel Dunbar | f4b830f | 2009-06-30 02:10:03 +0000 | [diff] [blame] | 158 | SMLoc StartLoc = Lexer.getLoc(); |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 159 | if (ParseExpression(Expr)) |
| 160 | return true; |
| 161 | |
| 162 | if (!Expr->EvaluateAsAbsolute(Ctx, Res)) |
Daniel Dunbar | f4b830f | 2009-06-30 02:10:03 +0000 | [diff] [blame] | 163 | return Error(StartLoc, "expected absolute expression"); |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 164 | |
| 165 | return false; |
| 166 | } |
| 167 | |
Daniel Dunbar | 15d1707 | 2009-06-30 01:49:52 +0000 | [diff] [blame] | 168 | bool AsmParser::ParseRelocatableExpression(MCValue &Res) { |
| 169 | AsmExpr *Expr; |
| 170 | |
Daniel Dunbar | f4b830f | 2009-06-30 02:10:03 +0000 | [diff] [blame] | 171 | SMLoc StartLoc = Lexer.getLoc(); |
Daniel Dunbar | 15d1707 | 2009-06-30 01:49:52 +0000 | [diff] [blame] | 172 | if (ParseExpression(Expr)) |
| 173 | return true; |
| 174 | |
| 175 | if (!Expr->EvaluateAsRelocatable(Ctx, Res)) |
Daniel Dunbar | f4b830f | 2009-06-30 02:10:03 +0000 | [diff] [blame] | 176 | return Error(StartLoc, "expected relocatable expression"); |
Daniel Dunbar | 15d1707 | 2009-06-30 01:49:52 +0000 | [diff] [blame] | 177 | |
| 178 | return false; |
| 179 | } |
| 180 | |
Daniel Dunbar | 2c3f00c | 2009-07-02 02:09:07 +0000 | [diff] [blame] | 181 | bool AsmParser::ParseParenRelocatableExpression(MCValue &Res) { |
| 182 | AsmExpr *Expr; |
| 183 | |
| 184 | SMLoc StartLoc = Lexer.getLoc(); |
| 185 | if (ParseParenExpr(Expr)) |
| 186 | return true; |
| 187 | |
| 188 | if (!Expr->EvaluateAsRelocatable(Ctx, Res)) |
| 189 | return Error(StartLoc, "expected relocatable expression"); |
| 190 | |
| 191 | return false; |
| 192 | } |
| 193 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 194 | static unsigned getBinOpPrecedence(AsmToken::TokenKind K, |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 195 | AsmBinaryExpr::Opcode &Kind) { |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 196 | switch (K) { |
| 197 | default: return 0; // not a binop. |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 198 | |
| 199 | // Lowest Precedence: &&, || |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 200 | case AsmToken::AmpAmp: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 201 | Kind = AsmBinaryExpr::LAnd; |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 202 | return 1; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 203 | case AsmToken::PipePipe: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 204 | Kind = AsmBinaryExpr::LOr; |
| 205 | return 1; |
| 206 | |
| 207 | // Low Precedence: +, -, ==, !=, <>, <, <=, >, >= |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 208 | case AsmToken::Plus: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 209 | Kind = AsmBinaryExpr::Add; |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 210 | return 2; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 211 | case AsmToken::Minus: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 212 | Kind = AsmBinaryExpr::Sub; |
| 213 | return 2; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 214 | case AsmToken::EqualEqual: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 215 | Kind = AsmBinaryExpr::EQ; |
| 216 | return 2; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 217 | case AsmToken::ExclaimEqual: |
| 218 | case AsmToken::LessGreater: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 219 | Kind = AsmBinaryExpr::NE; |
| 220 | return 2; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 221 | case AsmToken::Less: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 222 | Kind = AsmBinaryExpr::LT; |
| 223 | return 2; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 224 | case AsmToken::LessEqual: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 225 | Kind = AsmBinaryExpr::LTE; |
| 226 | return 2; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 227 | case AsmToken::Greater: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 228 | Kind = AsmBinaryExpr::GT; |
| 229 | return 2; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 230 | case AsmToken::GreaterEqual: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 231 | Kind = AsmBinaryExpr::GTE; |
| 232 | return 2; |
| 233 | |
| 234 | // Intermediate Precedence: |, &, ^ |
| 235 | // |
| 236 | // FIXME: gas seems to support '!' as an infix operator? |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 237 | case AsmToken::Pipe: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 238 | Kind = AsmBinaryExpr::Or; |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 239 | return 3; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 240 | case AsmToken::Caret: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 241 | Kind = AsmBinaryExpr::Xor; |
| 242 | return 3; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 243 | case AsmToken::Amp: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 244 | Kind = AsmBinaryExpr::And; |
| 245 | return 3; |
| 246 | |
| 247 | // Highest Precedence: *, /, %, <<, >> |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 248 | case AsmToken::Star: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 249 | Kind = AsmBinaryExpr::Mul; |
| 250 | return 4; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 251 | case AsmToken::Slash: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 252 | Kind = AsmBinaryExpr::Div; |
| 253 | return 4; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 254 | case AsmToken::Percent: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 255 | Kind = AsmBinaryExpr::Mod; |
| 256 | return 4; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 257 | case AsmToken::LessLess: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 258 | Kind = AsmBinaryExpr::Shl; |
| 259 | return 4; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 260 | case AsmToken::GreaterGreater: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 261 | Kind = AsmBinaryExpr::Shr; |
| 262 | return 4; |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 263 | } |
| 264 | } |
| 265 | |
| 266 | |
| 267 | /// ParseBinOpRHS - Parse all binary operators with precedence >= 'Precedence'. |
| 268 | /// Res contains the LHS of the expression on input. |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 269 | bool AsmParser::ParseBinOpRHS(unsigned Precedence, AsmExpr *&Res) { |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 270 | while (1) { |
Daniel Dunbar | 5133063 | 2009-06-29 21:14:21 +0000 | [diff] [blame] | 271 | AsmBinaryExpr::Opcode Kind = AsmBinaryExpr::Add; |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 272 | unsigned TokPrec = getBinOpPrecedence(Lexer.getKind(), Kind); |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 273 | |
| 274 | // If the next token is lower precedence than we are allowed to eat, return |
| 275 | // successfully with what we ate already. |
| 276 | if (TokPrec < Precedence) |
| 277 | return false; |
| 278 | |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 279 | Lexer.Lex(); |
| 280 | |
| 281 | // Eat the next primary expression. |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 282 | AsmExpr *RHS; |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 283 | if (ParsePrimaryExpr(RHS)) return true; |
| 284 | |
| 285 | // If BinOp binds less tightly with RHS than the operator after RHS, let |
| 286 | // the pending operator take RHS as its LHS. |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 287 | AsmBinaryExpr::Opcode Dummy; |
| 288 | unsigned NextTokPrec = getBinOpPrecedence(Lexer.getKind(), Dummy); |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 289 | if (TokPrec < NextTokPrec) { |
| 290 | if (ParseBinOpRHS(Precedence+1, RHS)) return true; |
| 291 | } |
| 292 | |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 293 | // Merge LHS and RHS according to operator. |
| 294 | Res = new AsmBinaryExpr(Kind, Res, RHS); |
Chris Lattner | 8dfbe6c | 2009-06-23 05:57:07 +0000 | [diff] [blame] | 295 | } |
| 296 | } |
| 297 | |
Chris Lattner | c419383 | 2009-06-22 05:51:26 +0000 | [diff] [blame] | 298 | |
| 299 | |
| 300 | |
Chris Lattner | b0789ed | 2009-06-21 20:54:55 +0000 | [diff] [blame] | 301 | /// ParseStatement: |
| 302 | /// ::= EndOfStatement |
Chris Lattner | 2cf5f14 | 2009-06-22 01:29:09 +0000 | [diff] [blame] | 303 | /// ::= Label* Directive ...Operands... EndOfStatement |
| 304 | /// ::= Label* Identifier OperandList* EndOfStatement |
Chris Lattner | b0789ed | 2009-06-21 20:54:55 +0000 | [diff] [blame] | 305 | bool AsmParser::ParseStatement() { |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 306 | if (Lexer.is(AsmToken::EndOfStatement)) { |
Chris Lattner | b0789ed | 2009-06-21 20:54:55 +0000 | [diff] [blame] | 307 | Lexer.Lex(); |
| 308 | return false; |
Chris Lattner | b0789ed | 2009-06-21 20:54:55 +0000 | [diff] [blame] | 309 | } |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 310 | |
| 311 | // Statements always start with an identifier. |
Daniel Dunbar | 419aded | 2009-07-28 16:38:40 +0000 | [diff] [blame] | 312 | AsmToken ID = Lexer.getTok(); |
| 313 | SMLoc IDLoc = ID.getLoc(); |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 314 | StringRef IDVal; |
| 315 | if (ParseIdentifier(IDVal)) |
| 316 | return TokError("unexpected token at start of statement"); |
| 317 | |
| 318 | // FIXME: Recurse on local labels? |
| 319 | |
| 320 | // See what kind of statement we have. |
| 321 | switch (Lexer.getKind()) { |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 322 | case AsmToken::Colon: { |
Chris Lattner | b0789ed | 2009-06-21 20:54:55 +0000 | [diff] [blame] | 323 | // identifier ':' -> Label. |
| 324 | Lexer.Lex(); |
Daniel Dunbar | dce0f3c | 2009-06-29 23:43:14 +0000 | [diff] [blame] | 325 | |
| 326 | // Diagnose attempt to use a variable as a label. |
| 327 | // |
| 328 | // FIXME: Diagnostics. Note the location of the definition as a label. |
| 329 | // FIXME: This doesn't diagnose assignment to a symbol which has been |
| 330 | // implicitly marked as external. |
| 331 | MCSymbol *Sym = Ctx.GetOrCreateSymbol(IDVal); |
| 332 | if (Sym->getSection()) |
| 333 | return Error(IDLoc, "invalid symbol redefinition"); |
| 334 | if (Ctx.GetSymbolValue(Sym)) |
| 335 | return Error(IDLoc, "symbol already used as assembler variable"); |
Chris Lattner | c69485e | 2009-06-24 04:31:49 +0000 | [diff] [blame] | 336 | |
| 337 | // Since we saw a label, create a symbol and emit it. |
| 338 | // FIXME: If the label starts with L it is an assembler temporary label. |
| 339 | // Why does the client of this api need to know this? |
Daniel Dunbar | dce0f3c | 2009-06-29 23:43:14 +0000 | [diff] [blame] | 340 | Out.EmitLabel(Sym); |
| 341 | |
Chris Lattner | b0789ed | 2009-06-21 20:54:55 +0000 | [diff] [blame] | 342 | return ParseStatement(); |
Daniel Dunbar | dce0f3c | 2009-06-29 23:43:14 +0000 | [diff] [blame] | 343 | } |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 344 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 345 | case AsmToken::Equal: |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 346 | // identifier '=' ... -> assignment statement |
| 347 | Lexer.Lex(); |
| 348 | |
| 349 | return ParseAssignment(IDVal, false); |
| 350 | |
| 351 | default: // Normal instruction or directive. |
| 352 | break; |
Chris Lattner | b0789ed | 2009-06-21 20:54:55 +0000 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | // Otherwise, we have a normal instruction or directive. |
Chris Lattner | 2cf5f14 | 2009-06-22 01:29:09 +0000 | [diff] [blame] | 356 | if (IDVal[0] == '.') { |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 357 | // FIXME: This should be driven based on a hash lookup and callback. |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 358 | if (IDVal == ".section") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 359 | return ParseDirectiveDarwinSection(); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 360 | if (IDVal == ".text") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 361 | // FIXME: This changes behavior based on the -static flag to the |
| 362 | // assembler. |
| 363 | return ParseDirectiveSectionSwitch("__TEXT,__text", |
| 364 | "regular,pure_instructions"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 365 | if (IDVal == ".const") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 366 | return ParseDirectiveSectionSwitch("__TEXT,__const"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 367 | if (IDVal == ".static_const") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 368 | return ParseDirectiveSectionSwitch("__TEXT,__static_const"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 369 | if (IDVal == ".cstring") |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 370 | return ParseDirectiveSectionSwitch("__TEXT,__cstring", |
| 371 | "cstring_literals"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 372 | if (IDVal == ".literal4") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 373 | return ParseDirectiveSectionSwitch("__TEXT,__literal4", "4byte_literals"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 374 | if (IDVal == ".literal8") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 375 | return ParseDirectiveSectionSwitch("__TEXT,__literal8", "8byte_literals"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 376 | if (IDVal == ".literal16") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 377 | return ParseDirectiveSectionSwitch("__TEXT,__literal16", |
| 378 | "16byte_literals"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 379 | if (IDVal == ".constructor") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 380 | return ParseDirectiveSectionSwitch("__TEXT,__constructor"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 381 | if (IDVal == ".destructor") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 382 | return ParseDirectiveSectionSwitch("__TEXT,__destructor"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 383 | if (IDVal == ".fvmlib_init0") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 384 | return ParseDirectiveSectionSwitch("__TEXT,__fvmlib_init0"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 385 | if (IDVal == ".fvmlib_init1") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 386 | return ParseDirectiveSectionSwitch("__TEXT,__fvmlib_init1"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 387 | if (IDVal == ".symbol_stub") // FIXME: Different on PPC. |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 388 | return ParseDirectiveSectionSwitch("__IMPORT,__jump_table,symbol_stubs", |
| 389 | "self_modifying_code+pure_instructions,5"); |
| 390 | // FIXME: .picsymbol_stub on PPC. |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 391 | if (IDVal == ".data") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 392 | return ParseDirectiveSectionSwitch("__DATA,__data"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 393 | if (IDVal == ".static_data") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 394 | return ParseDirectiveSectionSwitch("__DATA,__static_data"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 395 | if (IDVal == ".non_lazy_symbol_pointer") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 396 | return ParseDirectiveSectionSwitch("__DATA,__nl_symbol_pointer", |
| 397 | "non_lazy_symbol_pointers"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 398 | if (IDVal == ".lazy_symbol_pointer") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 399 | return ParseDirectiveSectionSwitch("__DATA,__la_symbol_pointer", |
| 400 | "lazy_symbol_pointers"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 401 | if (IDVal == ".dyld") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 402 | return ParseDirectiveSectionSwitch("__DATA,__dyld"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 403 | if (IDVal == ".mod_init_func") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 404 | return ParseDirectiveSectionSwitch("__DATA,__mod_init_func", |
| 405 | "mod_init_funcs"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 406 | if (IDVal == ".mod_term_func") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 407 | return ParseDirectiveSectionSwitch("__DATA,__mod_term_func", |
| 408 | "mod_term_funcs"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 409 | if (IDVal == ".const_data") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 410 | return ParseDirectiveSectionSwitch("__DATA,__const", "regular"); |
| 411 | |
| 412 | |
| 413 | // FIXME: Verify attributes on sections. |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 414 | if (IDVal == ".objc_class") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 415 | return ParseDirectiveSectionSwitch("__OBJC,__class"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 416 | if (IDVal == ".objc_meta_class") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 417 | return ParseDirectiveSectionSwitch("__OBJC,__meta_class"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 418 | if (IDVal == ".objc_cat_cls_meth") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 419 | return ParseDirectiveSectionSwitch("__OBJC,__cat_cls_meth"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 420 | if (IDVal == ".objc_cat_inst_meth") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 421 | return ParseDirectiveSectionSwitch("__OBJC,__cat_inst_meth"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 422 | if (IDVal == ".objc_protocol") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 423 | return ParseDirectiveSectionSwitch("__OBJC,__protocol"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 424 | if (IDVal == ".objc_string_object") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 425 | return ParseDirectiveSectionSwitch("__OBJC,__string_object"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 426 | if (IDVal == ".objc_cls_meth") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 427 | return ParseDirectiveSectionSwitch("__OBJC,__cls_meth"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 428 | if (IDVal == ".objc_inst_meth") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 429 | return ParseDirectiveSectionSwitch("__OBJC,__inst_meth"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 430 | if (IDVal == ".objc_cls_refs") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 431 | return ParseDirectiveSectionSwitch("__OBJC,__cls_refs"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 432 | if (IDVal == ".objc_message_refs") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 433 | return ParseDirectiveSectionSwitch("__OBJC,__message_refs"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 434 | if (IDVal == ".objc_symbols") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 435 | return ParseDirectiveSectionSwitch("__OBJC,__symbols"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 436 | if (IDVal == ".objc_category") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 437 | return ParseDirectiveSectionSwitch("__OBJC,__category"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 438 | if (IDVal == ".objc_class_vars") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 439 | return ParseDirectiveSectionSwitch("__OBJC,__class_vars"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 440 | if (IDVal == ".objc_instance_vars") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 441 | return ParseDirectiveSectionSwitch("__OBJC,__instance_vars"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 442 | if (IDVal == ".objc_module_info") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 443 | return ParseDirectiveSectionSwitch("__OBJC,__module_info"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 444 | if (IDVal == ".objc_class_names") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 445 | return ParseDirectiveSectionSwitch("__TEXT,__cstring","cstring_literals"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 446 | if (IDVal == ".objc_meth_var_types") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 447 | return ParseDirectiveSectionSwitch("__TEXT,__cstring","cstring_literals"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 448 | if (IDVal == ".objc_meth_var_names") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 449 | return ParseDirectiveSectionSwitch("__TEXT,__cstring","cstring_literals"); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 450 | if (IDVal == ".objc_selector_strs") |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 451 | return ParseDirectiveSectionSwitch("__OBJC,__selector_strs"); |
Chris Lattner | 9a023f7 | 2009-06-24 04:43:34 +0000 | [diff] [blame] | 452 | |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 453 | // Assembler features |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 454 | if (IDVal == ".set") |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 455 | return ParseDirectiveSet(); |
| 456 | |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 457 | // Data directives |
| 458 | |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 459 | if (IDVal == ".ascii") |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 460 | return ParseDirectiveAscii(false); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 461 | if (IDVal == ".asciz") |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 462 | return ParseDirectiveAscii(true); |
| 463 | |
| 464 | // FIXME: Target hooks for size? Also for "word", "hword". |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 465 | if (IDVal == ".byte") |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 466 | return ParseDirectiveValue(1); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 467 | if (IDVal == ".short") |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 468 | return ParseDirectiveValue(2); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 469 | if (IDVal == ".long") |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 470 | return ParseDirectiveValue(4); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 471 | if (IDVal == ".quad") |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 472 | return ParseDirectiveValue(8); |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 473 | |
| 474 | // FIXME: Target hooks for IsPow2. |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 475 | if (IDVal == ".align") |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 476 | return ParseDirectiveAlign(/*IsPow2=*/true, /*ExprSize=*/1); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 477 | if (IDVal == ".align32") |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 478 | return ParseDirectiveAlign(/*IsPow2=*/true, /*ExprSize=*/4); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 479 | if (IDVal == ".balign") |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 480 | return ParseDirectiveAlign(/*IsPow2=*/false, /*ExprSize=*/1); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 481 | if (IDVal == ".balignw") |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 482 | return ParseDirectiveAlign(/*IsPow2=*/false, /*ExprSize=*/2); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 483 | if (IDVal == ".balignl") |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 484 | return ParseDirectiveAlign(/*IsPow2=*/false, /*ExprSize=*/4); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 485 | if (IDVal == ".p2align") |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 486 | return ParseDirectiveAlign(/*IsPow2=*/true, /*ExprSize=*/1); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 487 | if (IDVal == ".p2alignw") |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 488 | return ParseDirectiveAlign(/*IsPow2=*/true, /*ExprSize=*/2); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 489 | if (IDVal == ".p2alignl") |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 490 | return ParseDirectiveAlign(/*IsPow2=*/true, /*ExprSize=*/4); |
| 491 | |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 492 | if (IDVal == ".org") |
Daniel Dunbar | c238b58 | 2009-06-25 22:44:51 +0000 | [diff] [blame] | 493 | return ParseDirectiveOrg(); |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 494 | |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 495 | if (IDVal == ".fill") |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 496 | return ParseDirectiveFill(); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 497 | if (IDVal == ".space") |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 498 | return ParseDirectiveSpace(); |
| 499 | |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 500 | // Symbol attribute directives |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 501 | if (IDVal == ".globl" || IDVal == ".global") |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 502 | return ParseDirectiveSymbolAttribute(MCStreamer::Global); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 503 | if (IDVal == ".hidden") |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 504 | return ParseDirectiveSymbolAttribute(MCStreamer::Hidden); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 505 | if (IDVal == ".indirect_symbol") |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 506 | return ParseDirectiveSymbolAttribute(MCStreamer::IndirectSymbol); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 507 | if (IDVal == ".internal") |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 508 | return ParseDirectiveSymbolAttribute(MCStreamer::Internal); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 509 | if (IDVal == ".lazy_reference") |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 510 | return ParseDirectiveSymbolAttribute(MCStreamer::LazyReference); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 511 | if (IDVal == ".no_dead_strip") |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 512 | return ParseDirectiveSymbolAttribute(MCStreamer::NoDeadStrip); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 513 | if (IDVal == ".private_extern") |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 514 | return ParseDirectiveSymbolAttribute(MCStreamer::PrivateExtern); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 515 | if (IDVal == ".protected") |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 516 | return ParseDirectiveSymbolAttribute(MCStreamer::Protected); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 517 | if (IDVal == ".reference") |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 518 | return ParseDirectiveSymbolAttribute(MCStreamer::Reference); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 519 | if (IDVal == ".weak") |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 520 | return ParseDirectiveSymbolAttribute(MCStreamer::Weak); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 521 | if (IDVal == ".weak_definition") |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 522 | return ParseDirectiveSymbolAttribute(MCStreamer::WeakDefinition); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 523 | if (IDVal == ".weak_reference") |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 524 | return ParseDirectiveSymbolAttribute(MCStreamer::WeakReference); |
| 525 | |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 526 | if (IDVal == ".comm") |
Chris Lattner | 1fc3d75 | 2009-07-09 17:25:12 +0000 | [diff] [blame] | 527 | return ParseDirectiveComm(/*IsLocal=*/false); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 528 | if (IDVal == ".lcomm") |
Chris Lattner | 1fc3d75 | 2009-07-09 17:25:12 +0000 | [diff] [blame] | 529 | return ParseDirectiveComm(/*IsLocal=*/true); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 530 | if (IDVal == ".zerofill") |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 531 | return ParseDirectiveDarwinZerofill(); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 532 | if (IDVal == ".desc") |
Kevin Enderby | 95cf30c | 2009-07-14 18:17:10 +0000 | [diff] [blame] | 533 | return ParseDirectiveDarwinSymbolDesc(); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 534 | if (IDVal == ".lsym") |
Kevin Enderby | 7114824 | 2009-07-14 21:35:03 +0000 | [diff] [blame] | 535 | return ParseDirectiveDarwinLsym(); |
Chris Lattner | 4e4db7a | 2009-07-07 20:30:46 +0000 | [diff] [blame] | 536 | |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 537 | if (IDVal == ".subsections_via_symbols") |
Kevin Enderby | a5c7832 | 2009-07-13 21:03:15 +0000 | [diff] [blame] | 538 | return ParseDirectiveDarwinSubsectionsViaSymbols(); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 539 | if (IDVal == ".abort") |
Kevin Enderby | 5f1f0b8 | 2009-07-13 23:15:14 +0000 | [diff] [blame] | 540 | return ParseDirectiveAbort(); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 541 | if (IDVal == ".include") |
Kevin Enderby | 1f049b2 | 2009-07-14 23:21:55 +0000 | [diff] [blame] | 542 | return ParseDirectiveInclude(); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 543 | if (IDVal == ".dump") |
Kevin Enderby | 5026ae4 | 2009-07-20 20:25:37 +0000 | [diff] [blame] | 544 | return ParseDirectiveDarwinDumpOrLoad(IDLoc, /*IsDump=*/true); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 545 | if (IDVal == ".load") |
Kevin Enderby | 5026ae4 | 2009-07-20 20:25:37 +0000 | [diff] [blame] | 546 | return ParseDirectiveDarwinDumpOrLoad(IDLoc, /*IsLoad=*/false); |
Kevin Enderby | a5c7832 | 2009-07-13 21:03:15 +0000 | [diff] [blame] | 547 | |
Daniel Dunbar | 3fb7683 | 2009-06-30 00:49:23 +0000 | [diff] [blame] | 548 | Warning(IDLoc, "ignoring directive for now"); |
Chris Lattner | 2cf5f14 | 2009-06-22 01:29:09 +0000 | [diff] [blame] | 549 | EatToEndOfStatement(); |
| 550 | return false; |
| 551 | } |
Chris Lattner | b0789ed | 2009-06-21 20:54:55 +0000 | [diff] [blame] | 552 | |
Chris Lattner | 29dfe7c | 2009-06-23 18:41:30 +0000 | [diff] [blame] | 553 | MCInst Inst; |
Daniel Dunbar | 16cdcb3 | 2009-07-28 22:40:46 +0000 | [diff] [blame] | 554 | if (getTargetParser().ParseInstruction(IDVal, Inst)) |
Chris Lattner | 29dfe7c | 2009-06-23 18:41:30 +0000 | [diff] [blame] | 555 | return true; |
Chris Lattner | 2cf5f14 | 2009-06-22 01:29:09 +0000 | [diff] [blame] | 556 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 557 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Chris Lattner | 9a023f7 | 2009-06-24 04:43:34 +0000 | [diff] [blame] | 558 | return TokError("unexpected token in argument list"); |
Chris Lattner | 2cf5f14 | 2009-06-22 01:29:09 +0000 | [diff] [blame] | 559 | |
| 560 | // Eat the end of statement marker. |
| 561 | Lexer.Lex(); |
| 562 | |
| 563 | // Instruction is good, process it. |
Daniel Dunbar | 0eebb05 | 2009-07-01 06:35:48 +0000 | [diff] [blame] | 564 | Out.EmitInstruction(Inst); |
Chris Lattner | 2cf5f14 | 2009-06-22 01:29:09 +0000 | [diff] [blame] | 565 | |
| 566 | // Skip to end of line for now. |
Chris Lattner | 27aa7d2 | 2009-06-21 20:16:42 +0000 | [diff] [blame] | 567 | return false; |
| 568 | } |
Chris Lattner | 9a023f7 | 2009-06-24 04:43:34 +0000 | [diff] [blame] | 569 | |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 570 | bool AsmParser::ParseAssignment(const StringRef &Name, bool IsDotSet) { |
Daniel Dunbar | dce0f3c | 2009-06-29 23:43:14 +0000 | [diff] [blame] | 571 | // FIXME: Use better location, we should use proper tokens. |
| 572 | SMLoc EqualLoc = Lexer.getLoc(); |
| 573 | |
Daniel Dunbar | f4b830f | 2009-06-30 02:10:03 +0000 | [diff] [blame] | 574 | MCValue Value; |
| 575 | if (ParseRelocatableExpression(Value)) |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 576 | return true; |
| 577 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 578 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 579 | return TokError("unexpected token in assignment"); |
| 580 | |
| 581 | // Eat the end of statement marker. |
| 582 | Lexer.Lex(); |
| 583 | |
Daniel Dunbar | dce0f3c | 2009-06-29 23:43:14 +0000 | [diff] [blame] | 584 | // Diagnose assignment to a label. |
| 585 | // |
| 586 | // FIXME: Diagnostics. Note the location of the definition as a label. |
| 587 | // FIXME: This doesn't diagnose assignment to a symbol which has been |
| 588 | // implicitly marked as external. |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 589 | // FIXME: Handle '.'. |
Daniel Dunbar | dce0f3c | 2009-06-29 23:43:14 +0000 | [diff] [blame] | 590 | // FIXME: Diagnose assignment to protected identifier (e.g., register name). |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 591 | MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name); |
Daniel Dunbar | dce0f3c | 2009-06-29 23:43:14 +0000 | [diff] [blame] | 592 | if (Sym->getSection()) |
| 593 | return Error(EqualLoc, "invalid assignment to symbol emitted as a label"); |
| 594 | if (Sym->isExternal()) |
| 595 | return Error(EqualLoc, "invalid assignment to external symbol"); |
| 596 | |
| 597 | // Do the assignment. |
Daniel Dunbar | f4b830f | 2009-06-30 02:10:03 +0000 | [diff] [blame] | 598 | Out.EmitAssignment(Sym, Value, IsDotSet); |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 599 | |
| 600 | return false; |
| 601 | } |
| 602 | |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 603 | /// ParseIdentifier: |
| 604 | /// ::= identifier |
| 605 | /// ::= string |
| 606 | bool AsmParser::ParseIdentifier(StringRef &Res) { |
| 607 | if (Lexer.isNot(AsmToken::Identifier) && |
| 608 | Lexer.isNot(AsmToken::String)) |
| 609 | return true; |
| 610 | |
| 611 | Res = Lexer.getTok().getIdentifier(); |
| 612 | |
| 613 | Lexer.Lex(); // Consume the identifier token. |
| 614 | |
| 615 | return false; |
| 616 | } |
| 617 | |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 618 | /// ParseDirectiveSet: |
| 619 | /// ::= .set identifier ',' expression |
| 620 | bool AsmParser::ParseDirectiveSet() { |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 621 | StringRef Name; |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 622 | |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 623 | if (ParseIdentifier(Name)) |
| 624 | return TokError("expected identifier after '.set' directive"); |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 625 | |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 626 | if (Lexer.isNot(AsmToken::Comma)) |
Daniel Dunbar | 8f780cd | 2009-06-25 21:56:11 +0000 | [diff] [blame] | 627 | return TokError("unexpected token in '.set'"); |
| 628 | Lexer.Lex(); |
| 629 | |
| 630 | return ParseAssignment(Name, true); |
| 631 | } |
| 632 | |
Chris Lattner | 9a023f7 | 2009-06-24 04:43:34 +0000 | [diff] [blame] | 633 | /// ParseDirectiveSection: |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 634 | /// ::= .section identifier (',' identifier)* |
| 635 | /// FIXME: This should actually parse out the segment, section, attributes and |
| 636 | /// sizeof_stub fields. |
| 637 | bool AsmParser::ParseDirectiveDarwinSection() { |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 638 | StringRef SectionName; |
| 639 | |
| 640 | if (ParseIdentifier(SectionName)) |
Chris Lattner | 9a023f7 | 2009-06-24 04:43:34 +0000 | [diff] [blame] | 641 | return TokError("expected identifier after '.section' directive"); |
| 642 | |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 643 | std::string Section = SectionName; |
| 644 | |
| 645 | // FIXME: This doesn't work, we lose quoting on things |
| 646 | |
Chris Lattner | 9a023f7 | 2009-06-24 04:43:34 +0000 | [diff] [blame] | 647 | // Accept a comma separated list of modifiers. |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 648 | while (Lexer.is(AsmToken::Comma)) { |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 649 | Lexer.Lex(); // Consume the comma. |
| 650 | |
| 651 | StringRef ModifierName; |
| 652 | if (ParseIdentifier(ModifierName)) |
Chris Lattner | 9a023f7 | 2009-06-24 04:43:34 +0000 | [diff] [blame] | 653 | return TokError("expected identifier in '.section' directive"); |
| 654 | Section += ','; |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 655 | Section += ModifierName; |
Chris Lattner | 9a023f7 | 2009-06-24 04:43:34 +0000 | [diff] [blame] | 656 | } |
| 657 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 658 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Chris Lattner | 9a023f7 | 2009-06-24 04:43:34 +0000 | [diff] [blame] | 659 | return TokError("unexpected token in '.section' directive"); |
| 660 | Lexer.Lex(); |
| 661 | |
Chris Lattner | 56594f9 | 2009-07-31 17:47:16 +0000 | [diff] [blame] | 662 | // FIXME: Arch specific. |
| 663 | MCSection *S = Ctx.GetSection(Section); |
| 664 | if (S == 0) |
Chris Lattner | 4a7bc1e | 2009-08-01 18:25:49 +0000 | [diff] [blame] | 665 | S = MCSection::Create(Section, SectionKind(), Ctx); |
Chris Lattner | 56594f9 | 2009-07-31 17:47:16 +0000 | [diff] [blame] | 666 | |
| 667 | Out.SwitchSection(S); |
Chris Lattner | 9a023f7 | 2009-06-24 04:43:34 +0000 | [diff] [blame] | 668 | return false; |
| 669 | } |
| 670 | |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 671 | bool AsmParser::ParseDirectiveSectionSwitch(const char *Section, |
| 672 | const char *Directives) { |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 673 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 674 | return TokError("unexpected token in section switching directive"); |
| 675 | Lexer.Lex(); |
| 676 | |
| 677 | std::string SectionStr = Section; |
| 678 | if (Directives && Directives[0]) { |
| 679 | SectionStr += ","; |
| 680 | SectionStr += Directives; |
| 681 | } |
| 682 | |
Chris Lattner | 56594f9 | 2009-07-31 17:47:16 +0000 | [diff] [blame] | 683 | // FIXME: Arch specific. |
| 684 | MCSection *S = Ctx.GetSection(Section); |
| 685 | if (S == 0) |
Chris Lattner | 4a7bc1e | 2009-08-01 18:25:49 +0000 | [diff] [blame] | 686 | S = MCSection::Create(Section, SectionKind(), Ctx); |
Chris Lattner | 56594f9 | 2009-07-31 17:47:16 +0000 | [diff] [blame] | 687 | |
| 688 | Out.SwitchSection(S); |
Chris Lattner | 529fb54 | 2009-06-24 05:13:15 +0000 | [diff] [blame] | 689 | return false; |
| 690 | } |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 691 | |
| 692 | /// ParseDirectiveAscii: |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 693 | /// ::= ( .ascii | .asciz ) [ "string" ( , "string" )* ] |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 694 | bool AsmParser::ParseDirectiveAscii(bool ZeroTerminated) { |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 695 | if (Lexer.isNot(AsmToken::EndOfStatement)) { |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 696 | for (;;) { |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 697 | if (Lexer.isNot(AsmToken::String)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 698 | return TokError("expected string in '.ascii' or '.asciz' directive"); |
| 699 | |
| 700 | // FIXME: This shouldn't use a const char* + strlen, the string could have |
| 701 | // embedded nulls. |
| 702 | // FIXME: Should have accessor for getting string contents. |
Daniel Dunbar | 419aded | 2009-07-28 16:38:40 +0000 | [diff] [blame] | 703 | StringRef Str = Lexer.getTok().getString(); |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 704 | Out.EmitBytes(Str.substr(1, Str.size() - 2)); |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 705 | if (ZeroTerminated) |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 706 | Out.EmitBytes(StringRef("\0", 1)); |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 707 | |
| 708 | Lexer.Lex(); |
| 709 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 710 | if (Lexer.is(AsmToken::EndOfStatement)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 711 | break; |
| 712 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 713 | if (Lexer.isNot(AsmToken::Comma)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 714 | return TokError("unexpected token in '.ascii' or '.asciz' directive"); |
| 715 | Lexer.Lex(); |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | Lexer.Lex(); |
| 720 | return false; |
| 721 | } |
| 722 | |
| 723 | /// ParseDirectiveValue |
| 724 | /// ::= (.byte | .short | ... ) [ expression (, expression)* ] |
| 725 | bool AsmParser::ParseDirectiveValue(unsigned Size) { |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 726 | if (Lexer.isNot(AsmToken::EndOfStatement)) { |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 727 | for (;;) { |
Daniel Dunbar | f4b830f | 2009-06-30 02:10:03 +0000 | [diff] [blame] | 728 | MCValue Expr; |
| 729 | if (ParseRelocatableExpression(Expr)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 730 | return true; |
| 731 | |
Daniel Dunbar | f4b830f | 2009-06-30 02:10:03 +0000 | [diff] [blame] | 732 | Out.EmitValue(Expr, Size); |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 733 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 734 | if (Lexer.is(AsmToken::EndOfStatement)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 735 | break; |
| 736 | |
| 737 | // FIXME: Improve diagnostic. |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 738 | if (Lexer.isNot(AsmToken::Comma)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 739 | return TokError("unexpected token in directive"); |
| 740 | Lexer.Lex(); |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | Lexer.Lex(); |
| 745 | return false; |
| 746 | } |
| 747 | |
| 748 | /// ParseDirectiveSpace |
| 749 | /// ::= .space expression [ , expression ] |
| 750 | bool AsmParser::ParseDirectiveSpace() { |
| 751 | int64_t NumBytes; |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 752 | if (ParseAbsoluteExpression(NumBytes)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 753 | return true; |
| 754 | |
| 755 | int64_t FillExpr = 0; |
| 756 | bool HasFillExpr = false; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 757 | if (Lexer.isNot(AsmToken::EndOfStatement)) { |
| 758 | if (Lexer.isNot(AsmToken::Comma)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 759 | return TokError("unexpected token in '.space' directive"); |
| 760 | Lexer.Lex(); |
| 761 | |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 762 | if (ParseAbsoluteExpression(FillExpr)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 763 | return true; |
| 764 | |
| 765 | HasFillExpr = true; |
| 766 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 767 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 768 | return TokError("unexpected token in '.space' directive"); |
| 769 | } |
| 770 | |
| 771 | Lexer.Lex(); |
| 772 | |
| 773 | if (NumBytes <= 0) |
| 774 | return TokError("invalid number of bytes in '.space' directive"); |
| 775 | |
| 776 | // FIXME: Sometimes the fill expr is 'nop' if it isn't supplied, instead of 0. |
| 777 | for (uint64_t i = 0, e = NumBytes; i != e; ++i) |
| 778 | Out.EmitValue(MCValue::get(FillExpr), 1); |
| 779 | |
| 780 | return false; |
| 781 | } |
| 782 | |
| 783 | /// ParseDirectiveFill |
| 784 | /// ::= .fill expression , expression , expression |
| 785 | bool AsmParser::ParseDirectiveFill() { |
| 786 | int64_t NumValues; |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 787 | if (ParseAbsoluteExpression(NumValues)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 788 | return true; |
| 789 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 790 | if (Lexer.isNot(AsmToken::Comma)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 791 | return TokError("unexpected token in '.fill' directive"); |
| 792 | Lexer.Lex(); |
| 793 | |
| 794 | int64_t FillSize; |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 795 | if (ParseAbsoluteExpression(FillSize)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 796 | return true; |
| 797 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 798 | if (Lexer.isNot(AsmToken::Comma)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 799 | return TokError("unexpected token in '.fill' directive"); |
| 800 | Lexer.Lex(); |
| 801 | |
| 802 | int64_t FillExpr; |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 803 | if (ParseAbsoluteExpression(FillExpr)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 804 | return true; |
| 805 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 806 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Daniel Dunbar | a0d1426 | 2009-06-24 23:30:00 +0000 | [diff] [blame] | 807 | return TokError("unexpected token in '.fill' directive"); |
| 808 | |
| 809 | Lexer.Lex(); |
| 810 | |
| 811 | if (FillSize != 1 && FillSize != 2 && FillSize != 4) |
| 812 | return TokError("invalid '.fill' size, expected 1, 2, or 4"); |
| 813 | |
| 814 | for (uint64_t i = 0, e = NumValues; i != e; ++i) |
| 815 | Out.EmitValue(MCValue::get(FillExpr), FillSize); |
| 816 | |
| 817 | return false; |
| 818 | } |
Daniel Dunbar | c238b58 | 2009-06-25 22:44:51 +0000 | [diff] [blame] | 819 | |
| 820 | /// ParseDirectiveOrg |
| 821 | /// ::= .org expression [ , expression ] |
| 822 | bool AsmParser::ParseDirectiveOrg() { |
Daniel Dunbar | f4b830f | 2009-06-30 02:10:03 +0000 | [diff] [blame] | 823 | MCValue Offset; |
| 824 | if (ParseRelocatableExpression(Offset)) |
Daniel Dunbar | c238b58 | 2009-06-25 22:44:51 +0000 | [diff] [blame] | 825 | return true; |
| 826 | |
| 827 | // Parse optional fill expression. |
| 828 | int64_t FillExpr = 0; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 829 | if (Lexer.isNot(AsmToken::EndOfStatement)) { |
| 830 | if (Lexer.isNot(AsmToken::Comma)) |
Daniel Dunbar | c238b58 | 2009-06-25 22:44:51 +0000 | [diff] [blame] | 831 | return TokError("unexpected token in '.org' directive"); |
| 832 | Lexer.Lex(); |
| 833 | |
Daniel Dunbar | 475839e | 2009-06-29 20:37:27 +0000 | [diff] [blame] | 834 | if (ParseAbsoluteExpression(FillExpr)) |
Daniel Dunbar | c238b58 | 2009-06-25 22:44:51 +0000 | [diff] [blame] | 835 | return true; |
| 836 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 837 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Daniel Dunbar | c238b58 | 2009-06-25 22:44:51 +0000 | [diff] [blame] | 838 | return TokError("unexpected token in '.org' directive"); |
| 839 | } |
| 840 | |
| 841 | Lexer.Lex(); |
Daniel Dunbar | f4b830f | 2009-06-30 02:10:03 +0000 | [diff] [blame] | 842 | |
| 843 | // FIXME: Only limited forms of relocatable expressions are accepted here, it |
| 844 | // has to be relative to the current section. |
| 845 | Out.EmitValueToOffset(Offset, FillExpr); |
Daniel Dunbar | c238b58 | 2009-06-25 22:44:51 +0000 | [diff] [blame] | 846 | |
| 847 | return false; |
| 848 | } |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 849 | |
| 850 | /// ParseDirectiveAlign |
| 851 | /// ::= {.align, ...} expression [ , expression [ , expression ]] |
| 852 | bool AsmParser::ParseDirectiveAlign(bool IsPow2, unsigned ValueSize) { |
| 853 | int64_t Alignment; |
| 854 | if (ParseAbsoluteExpression(Alignment)) |
| 855 | return true; |
| 856 | |
| 857 | SMLoc MaxBytesLoc; |
| 858 | bool HasFillExpr = false; |
| 859 | int64_t FillExpr = 0; |
| 860 | int64_t MaxBytesToFill = 0; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 861 | if (Lexer.isNot(AsmToken::EndOfStatement)) { |
| 862 | if (Lexer.isNot(AsmToken::Comma)) |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 863 | return TokError("unexpected token in directive"); |
| 864 | Lexer.Lex(); |
| 865 | |
| 866 | // The fill expression can be omitted while specifying a maximum number of |
| 867 | // alignment bytes, e.g: |
| 868 | // .align 3,,4 |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 869 | if (Lexer.isNot(AsmToken::Comma)) { |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 870 | HasFillExpr = true; |
| 871 | if (ParseAbsoluteExpression(FillExpr)) |
| 872 | return true; |
| 873 | } |
| 874 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 875 | if (Lexer.isNot(AsmToken::EndOfStatement)) { |
| 876 | if (Lexer.isNot(AsmToken::Comma)) |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 877 | return TokError("unexpected token in directive"); |
| 878 | Lexer.Lex(); |
| 879 | |
| 880 | MaxBytesLoc = Lexer.getLoc(); |
| 881 | if (ParseAbsoluteExpression(MaxBytesToFill)) |
| 882 | return true; |
| 883 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 884 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 885 | return TokError("unexpected token in directive"); |
| 886 | } |
| 887 | } |
| 888 | |
| 889 | Lexer.Lex(); |
| 890 | |
| 891 | if (!HasFillExpr) { |
| 892 | // FIXME: Sometimes fill with nop. |
| 893 | FillExpr = 0; |
| 894 | } |
| 895 | |
| 896 | // Compute alignment in bytes. |
| 897 | if (IsPow2) { |
| 898 | // FIXME: Diagnose overflow. |
Chris Lattner | 3975025 | 2009-07-11 22:32:37 +0000 | [diff] [blame] | 899 | Alignment = 1LL << Alignment; |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | // Diagnose non-sensical max bytes to fill. |
| 903 | if (MaxBytesLoc.isValid()) { |
| 904 | if (MaxBytesToFill < 1) { |
Daniel Dunbar | 3fb7683 | 2009-06-30 00:49:23 +0000 | [diff] [blame] | 905 | Warning(MaxBytesLoc, "alignment directive can never be satisfied in this " |
| 906 | "many bytes, ignoring"); |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 907 | return false; |
| 908 | } |
| 909 | |
| 910 | if (MaxBytesToFill >= Alignment) { |
Daniel Dunbar | 3fb7683 | 2009-06-30 00:49:23 +0000 | [diff] [blame] | 911 | Warning(MaxBytesLoc, "maximum bytes expression exceeds alignment and " |
| 912 | "has no effect"); |
Daniel Dunbar | c29dfa7 | 2009-06-29 23:46:59 +0000 | [diff] [blame] | 913 | MaxBytesToFill = 0; |
| 914 | } |
| 915 | } |
| 916 | |
| 917 | // FIXME: Target specific behavior about how the "extra" bytes are filled. |
| 918 | Out.EmitValueToAlignment(Alignment, FillExpr, ValueSize, MaxBytesToFill); |
| 919 | |
| 920 | return false; |
| 921 | } |
| 922 | |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 923 | /// ParseDirectiveSymbolAttribute |
| 924 | /// ::= { ".globl", ".weak", ... } [ identifier ( , identifier )* ] |
| 925 | bool AsmParser::ParseDirectiveSymbolAttribute(MCStreamer::SymbolAttr Attr) { |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 926 | if (Lexer.isNot(AsmToken::EndOfStatement)) { |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 927 | for (;;) { |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 928 | StringRef Name; |
| 929 | |
| 930 | if (ParseIdentifier(Name)) |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 931 | return TokError("expected identifier in directive"); |
| 932 | |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 933 | MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name); |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 934 | |
| 935 | // If this is use of an undefined symbol then mark it external. |
| 936 | if (!Sym->getSection() && !Ctx.GetSymbolValue(Sym)) |
| 937 | Sym->setExternal(true); |
| 938 | |
| 939 | Out.EmitSymbolAttribute(Sym, Attr); |
| 940 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 941 | if (Lexer.is(AsmToken::EndOfStatement)) |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 942 | break; |
| 943 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 944 | if (Lexer.isNot(AsmToken::Comma)) |
Daniel Dunbar | d7b267b | 2009-06-30 00:33:19 +0000 | [diff] [blame] | 945 | return TokError("unexpected token in directive"); |
| 946 | Lexer.Lex(); |
| 947 | } |
| 948 | } |
| 949 | |
| 950 | Lexer.Lex(); |
| 951 | return false; |
| 952 | } |
Chris Lattner | 4e4db7a | 2009-07-07 20:30:46 +0000 | [diff] [blame] | 953 | |
Kevin Enderby | 95cf30c | 2009-07-14 18:17:10 +0000 | [diff] [blame] | 954 | /// ParseDirectiveDarwinSymbolDesc |
| 955 | /// ::= .desc identifier , expression |
| 956 | bool AsmParser::ParseDirectiveDarwinSymbolDesc() { |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 957 | StringRef Name; |
| 958 | if (ParseIdentifier(Name)) |
Kevin Enderby | 95cf30c | 2009-07-14 18:17:10 +0000 | [diff] [blame] | 959 | return TokError("expected identifier in directive"); |
| 960 | |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 961 | // Handle the identifier as the key symbol. |
| 962 | MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name); |
Kevin Enderby | 95cf30c | 2009-07-14 18:17:10 +0000 | [diff] [blame] | 963 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 964 | if (Lexer.isNot(AsmToken::Comma)) |
Kevin Enderby | 95cf30c | 2009-07-14 18:17:10 +0000 | [diff] [blame] | 965 | return TokError("unexpected token in '.desc' directive"); |
| 966 | Lexer.Lex(); |
| 967 | |
| 968 | SMLoc DescLoc = Lexer.getLoc(); |
| 969 | int64_t DescValue; |
| 970 | if (ParseAbsoluteExpression(DescValue)) |
| 971 | return true; |
| 972 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 973 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Kevin Enderby | 95cf30c | 2009-07-14 18:17:10 +0000 | [diff] [blame] | 974 | return TokError("unexpected token in '.desc' directive"); |
| 975 | |
| 976 | Lexer.Lex(); |
| 977 | |
| 978 | // Set the n_desc field of this Symbol to this DescValue |
| 979 | Out.EmitSymbolDesc(Sym, DescValue); |
| 980 | |
| 981 | return false; |
| 982 | } |
| 983 | |
Chris Lattner | 4e4db7a | 2009-07-07 20:30:46 +0000 | [diff] [blame] | 984 | /// ParseDirectiveComm |
Chris Lattner | 1fc3d75 | 2009-07-09 17:25:12 +0000 | [diff] [blame] | 985 | /// ::= ( .comm | .lcomm ) identifier , size_expression [ , align_expression ] |
| 986 | bool AsmParser::ParseDirectiveComm(bool IsLocal) { |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 987 | SMLoc IDLoc = Lexer.getLoc(); |
| 988 | StringRef Name; |
| 989 | if (ParseIdentifier(Name)) |
Chris Lattner | 4e4db7a | 2009-07-07 20:30:46 +0000 | [diff] [blame] | 990 | return TokError("expected identifier in directive"); |
| 991 | |
Daniel Dunbar | 76c4d76 | 2009-07-31 21:55:09 +0000 | [diff] [blame] | 992 | // Handle the identifier as the key symbol. |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 993 | MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name); |
Chris Lattner | 4e4db7a | 2009-07-07 20:30:46 +0000 | [diff] [blame] | 994 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 995 | if (Lexer.isNot(AsmToken::Comma)) |
Chris Lattner | 4e4db7a | 2009-07-07 20:30:46 +0000 | [diff] [blame] | 996 | return TokError("unexpected token in directive"); |
| 997 | Lexer.Lex(); |
| 998 | |
| 999 | int64_t Size; |
| 1000 | SMLoc SizeLoc = Lexer.getLoc(); |
| 1001 | if (ParseAbsoluteExpression(Size)) |
| 1002 | return true; |
| 1003 | |
| 1004 | int64_t Pow2Alignment = 0; |
| 1005 | SMLoc Pow2AlignmentLoc; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1006 | if (Lexer.is(AsmToken::Comma)) { |
Chris Lattner | 4e4db7a | 2009-07-07 20:30:46 +0000 | [diff] [blame] | 1007 | Lexer.Lex(); |
| 1008 | Pow2AlignmentLoc = Lexer.getLoc(); |
| 1009 | if (ParseAbsoluteExpression(Pow2Alignment)) |
| 1010 | return true; |
| 1011 | } |
| 1012 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1013 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Chris Lattner | 1fc3d75 | 2009-07-09 17:25:12 +0000 | [diff] [blame] | 1014 | return TokError("unexpected token in '.comm' or '.lcomm' directive"); |
Chris Lattner | 4e4db7a | 2009-07-07 20:30:46 +0000 | [diff] [blame] | 1015 | |
| 1016 | Lexer.Lex(); |
| 1017 | |
Chris Lattner | 1fc3d75 | 2009-07-09 17:25:12 +0000 | [diff] [blame] | 1018 | // NOTE: a size of zero for a .comm should create a undefined symbol |
| 1019 | // but a size of .lcomm creates a bss symbol of size zero. |
Chris Lattner | 4e4db7a | 2009-07-07 20:30:46 +0000 | [diff] [blame] | 1020 | if (Size < 0) |
Chris Lattner | 1fc3d75 | 2009-07-09 17:25:12 +0000 | [diff] [blame] | 1021 | return Error(SizeLoc, "invalid '.comm' or '.lcomm' directive size, can't " |
| 1022 | "be less than zero"); |
Chris Lattner | 4e4db7a | 2009-07-07 20:30:46 +0000 | [diff] [blame] | 1023 | |
| 1024 | // NOTE: The alignment in the directive is a power of 2 value, the assember |
| 1025 | // may internally end up wanting an alignment in bytes. |
| 1026 | // FIXME: Diagnose overflow. |
| 1027 | if (Pow2Alignment < 0) |
Chris Lattner | 1fc3d75 | 2009-07-09 17:25:12 +0000 | [diff] [blame] | 1028 | return Error(Pow2AlignmentLoc, "invalid '.comm' or '.lcomm' directive " |
| 1029 | "alignment, can't be less than zero"); |
Chris Lattner | 4e4db7a | 2009-07-07 20:30:46 +0000 | [diff] [blame] | 1030 | |
| 1031 | // TODO: Symbol must be undefined or it is a error to re-defined the symbol |
| 1032 | if (Sym->getSection() || Ctx.GetSymbolValue(Sym)) |
| 1033 | return Error(IDLoc, "invalid symbol redefinition"); |
| 1034 | |
Chris Lattner | 1fc3d75 | 2009-07-09 17:25:12 +0000 | [diff] [blame] | 1035 | // Create the Symbol as a common or local common with Size and Pow2Alignment |
| 1036 | Out.EmitCommonSymbol(Sym, Size, Pow2Alignment, IsLocal); |
Chris Lattner | 4e4db7a | 2009-07-07 20:30:46 +0000 | [diff] [blame] | 1037 | |
| 1038 | return false; |
| 1039 | } |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1040 | |
| 1041 | /// ParseDirectiveDarwinZerofill |
| 1042 | /// ::= .zerofill segname , sectname [, identifier , size_expression [ |
| 1043 | /// , align_expression ]] |
| 1044 | bool AsmParser::ParseDirectiveDarwinZerofill() { |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 1045 | // FIXME: Handle quoted names here. |
| 1046 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1047 | if (Lexer.isNot(AsmToken::Identifier)) |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1048 | return TokError("expected segment name after '.zerofill' directive"); |
Daniel Dunbar | 419aded | 2009-07-28 16:38:40 +0000 | [diff] [blame] | 1049 | std::string Section = Lexer.getTok().getString(); |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1050 | Lexer.Lex(); |
| 1051 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1052 | if (Lexer.isNot(AsmToken::Comma)) |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1053 | return TokError("unexpected token in directive"); |
| 1054 | Section += ','; |
| 1055 | Lexer.Lex(); |
| 1056 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1057 | if (Lexer.isNot(AsmToken::Identifier)) |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1058 | return TokError("expected section name after comma in '.zerofill' " |
| 1059 | "directive"); |
Daniel Dunbar | 419aded | 2009-07-28 16:38:40 +0000 | [diff] [blame] | 1060 | Section += Lexer.getTok().getString().str(); |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1061 | Lexer.Lex(); |
| 1062 | |
| 1063 | // FIXME: we will need to tell GetSection() that this is to be created with or |
| 1064 | // must have the Mach-O section type of S_ZEROFILL. Something like the code |
| 1065 | // below could be done but for now it is not as EmitZerofill() does not know |
| 1066 | // how to deal with a section type in the section name like |
| 1067 | // ParseDirectiveDarwinSection() allows. |
| 1068 | // Section += ','; |
| 1069 | // Section += "zerofill"; |
| 1070 | |
| 1071 | // If this is the end of the line all that was wanted was to create the |
| 1072 | // the section but with no symbol. |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1073 | if (Lexer.is(AsmToken::EndOfStatement)) { |
Chris Lattner | 6bdd74c | 2009-07-31 18:27:48 +0000 | [diff] [blame] | 1074 | // FIXME: Arch specific. |
| 1075 | MCSection *S = Ctx.GetSection(Section); |
| 1076 | if (S == 0) |
Chris Lattner | 4a7bc1e | 2009-08-01 18:25:49 +0000 | [diff] [blame] | 1077 | S = MCSection::Create(Section, SectionKind(), Ctx); |
Chris Lattner | 6bdd74c | 2009-07-31 18:27:48 +0000 | [diff] [blame] | 1078 | |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1079 | // Create the zerofill section but no symbol |
Chris Lattner | 6bdd74c | 2009-07-31 18:27:48 +0000 | [diff] [blame] | 1080 | Out.EmitZerofill(S); |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1081 | return false; |
| 1082 | } |
| 1083 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1084 | if (Lexer.isNot(AsmToken::Comma)) |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1085 | return TokError("unexpected token in directive"); |
| 1086 | Lexer.Lex(); |
| 1087 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1088 | if (Lexer.isNot(AsmToken::Identifier)) |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1089 | return TokError("expected identifier in directive"); |
| 1090 | |
| 1091 | // handle the identifier as the key symbol. |
| 1092 | SMLoc IDLoc = Lexer.getLoc(); |
Daniel Dunbar | 419aded | 2009-07-28 16:38:40 +0000 | [diff] [blame] | 1093 | MCSymbol *Sym = Ctx.GetOrCreateSymbol(Lexer.getTok().getString()); |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1094 | Lexer.Lex(); |
| 1095 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1096 | if (Lexer.isNot(AsmToken::Comma)) |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1097 | return TokError("unexpected token in directive"); |
| 1098 | Lexer.Lex(); |
| 1099 | |
| 1100 | int64_t Size; |
| 1101 | SMLoc SizeLoc = Lexer.getLoc(); |
| 1102 | if (ParseAbsoluteExpression(Size)) |
| 1103 | return true; |
| 1104 | |
| 1105 | int64_t Pow2Alignment = 0; |
| 1106 | SMLoc Pow2AlignmentLoc; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1107 | if (Lexer.is(AsmToken::Comma)) { |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1108 | Lexer.Lex(); |
| 1109 | Pow2AlignmentLoc = Lexer.getLoc(); |
| 1110 | if (ParseAbsoluteExpression(Pow2Alignment)) |
| 1111 | return true; |
| 1112 | } |
| 1113 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1114 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1115 | return TokError("unexpected token in '.zerofill' directive"); |
| 1116 | |
| 1117 | Lexer.Lex(); |
| 1118 | |
| 1119 | if (Size < 0) |
| 1120 | return Error(SizeLoc, "invalid '.zerofill' directive size, can't be less " |
| 1121 | "than zero"); |
| 1122 | |
| 1123 | // NOTE: The alignment in the directive is a power of 2 value, the assember |
| 1124 | // may internally end up wanting an alignment in bytes. |
| 1125 | // FIXME: Diagnose overflow. |
| 1126 | if (Pow2Alignment < 0) |
| 1127 | return Error(Pow2AlignmentLoc, "invalid '.zerofill' directive alignment, " |
| 1128 | "can't be less than zero"); |
| 1129 | |
| 1130 | // TODO: Symbol must be undefined or it is a error to re-defined the symbol |
| 1131 | if (Sym->getSection() || Ctx.GetSymbolValue(Sym)) |
| 1132 | return Error(IDLoc, "invalid symbol redefinition"); |
| 1133 | |
Chris Lattner | 6bdd74c | 2009-07-31 18:27:48 +0000 | [diff] [blame] | 1134 | // FIXME: Arch specific. |
| 1135 | MCSection *S = Ctx.GetSection(Section); |
| 1136 | if (S == 0) |
Chris Lattner | 4a7bc1e | 2009-08-01 18:25:49 +0000 | [diff] [blame] | 1137 | S = MCSection::Create(Section, SectionKind(), Ctx); |
Chris Lattner | 6bdd74c | 2009-07-31 18:27:48 +0000 | [diff] [blame] | 1138 | |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1139 | // Create the zerofill Symbol with Size and Pow2Alignment |
Chris Lattner | 6bdd74c | 2009-07-31 18:27:48 +0000 | [diff] [blame] | 1140 | Out.EmitZerofill(S, Sym, Size, Pow2Alignment); |
Chris Lattner | 9be3fee | 2009-07-10 22:20:30 +0000 | [diff] [blame] | 1141 | |
| 1142 | return false; |
| 1143 | } |
Kevin Enderby | a5c7832 | 2009-07-13 21:03:15 +0000 | [diff] [blame] | 1144 | |
| 1145 | /// ParseDirectiveDarwinSubsectionsViaSymbols |
| 1146 | /// ::= .subsections_via_symbols |
| 1147 | bool AsmParser::ParseDirectiveDarwinSubsectionsViaSymbols() { |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1148 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Kevin Enderby | a5c7832 | 2009-07-13 21:03:15 +0000 | [diff] [blame] | 1149 | return TokError("unexpected token in '.subsections_via_symbols' directive"); |
| 1150 | |
| 1151 | Lexer.Lex(); |
| 1152 | |
Kevin Enderby | f96db46 | 2009-07-16 17:56:39 +0000 | [diff] [blame] | 1153 | Out.EmitAssemblerFlag(MCStreamer::SubsectionsViaSymbols); |
Kevin Enderby | a5c7832 | 2009-07-13 21:03:15 +0000 | [diff] [blame] | 1154 | |
| 1155 | return false; |
| 1156 | } |
Kevin Enderby | 5f1f0b8 | 2009-07-13 23:15:14 +0000 | [diff] [blame] | 1157 | |
| 1158 | /// ParseDirectiveAbort |
| 1159 | /// ::= .abort [ "abort_string" ] |
| 1160 | bool AsmParser::ParseDirectiveAbort() { |
Daniel Dunbar | f9507ff | 2009-07-27 23:20:52 +0000 | [diff] [blame] | 1161 | // FIXME: Use loc from directive. |
| 1162 | SMLoc Loc = Lexer.getLoc(); |
| 1163 | |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 1164 | StringRef Str = ""; |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1165 | if (Lexer.isNot(AsmToken::EndOfStatement)) { |
| 1166 | if (Lexer.isNot(AsmToken::String)) |
Kevin Enderby | 5f1f0b8 | 2009-07-13 23:15:14 +0000 | [diff] [blame] | 1167 | return TokError("expected string in '.abort' directive"); |
| 1168 | |
Daniel Dunbar | 419aded | 2009-07-28 16:38:40 +0000 | [diff] [blame] | 1169 | Str = Lexer.getTok().getString(); |
Kevin Enderby | 5f1f0b8 | 2009-07-13 23:15:14 +0000 | [diff] [blame] | 1170 | |
| 1171 | Lexer.Lex(); |
| 1172 | } |
| 1173 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1174 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Kevin Enderby | 5f1f0b8 | 2009-07-13 23:15:14 +0000 | [diff] [blame] | 1175 | return TokError("unexpected token in '.abort' directive"); |
| 1176 | |
| 1177 | Lexer.Lex(); |
| 1178 | |
Daniel Dunbar | 9a7e2cc | 2009-07-27 21:49:56 +0000 | [diff] [blame] | 1179 | // FIXME: Handle here. |
Daniel Dunbar | f9507ff | 2009-07-27 23:20:52 +0000 | [diff] [blame] | 1180 | if (Str.empty()) |
| 1181 | Error(Loc, ".abort detected. Assembly stopping."); |
| 1182 | else |
| 1183 | Error(Loc, ".abort '" + Str + "' detected. Assembly stopping."); |
Kevin Enderby | 5f1f0b8 | 2009-07-13 23:15:14 +0000 | [diff] [blame] | 1184 | |
| 1185 | return false; |
| 1186 | } |
Kevin Enderby | 7114824 | 2009-07-14 21:35:03 +0000 | [diff] [blame] | 1187 | |
| 1188 | /// ParseDirectiveLsym |
| 1189 | /// ::= .lsym identifier , expression |
| 1190 | bool AsmParser::ParseDirectiveDarwinLsym() { |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 1191 | StringRef Name; |
| 1192 | if (ParseIdentifier(Name)) |
Kevin Enderby | 7114824 | 2009-07-14 21:35:03 +0000 | [diff] [blame] | 1193 | return TokError("expected identifier in directive"); |
| 1194 | |
Daniel Dunbar | 76c4d76 | 2009-07-31 21:55:09 +0000 | [diff] [blame] | 1195 | // Handle the identifier as the key symbol. |
Daniel Dunbar | a6b3c5d | 2009-08-01 00:48:30 +0000 | [diff] [blame] | 1196 | MCSymbol *Sym = Ctx.GetOrCreateSymbol(Name); |
Kevin Enderby | 7114824 | 2009-07-14 21:35:03 +0000 | [diff] [blame] | 1197 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1198 | if (Lexer.isNot(AsmToken::Comma)) |
Kevin Enderby | 7114824 | 2009-07-14 21:35:03 +0000 | [diff] [blame] | 1199 | return TokError("unexpected token in '.lsym' directive"); |
| 1200 | Lexer.Lex(); |
| 1201 | |
| 1202 | MCValue Expr; |
| 1203 | if (ParseRelocatableExpression(Expr)) |
| 1204 | return true; |
| 1205 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1206 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Kevin Enderby | 7114824 | 2009-07-14 21:35:03 +0000 | [diff] [blame] | 1207 | return TokError("unexpected token in '.lsym' directive"); |
| 1208 | |
| 1209 | Lexer.Lex(); |
| 1210 | |
| 1211 | // Create the Sym with the value of the Expr |
| 1212 | Out.EmitLocalSymbol(Sym, Expr); |
| 1213 | |
| 1214 | return false; |
| 1215 | } |
Kevin Enderby | 1f049b2 | 2009-07-14 23:21:55 +0000 | [diff] [blame] | 1216 | |
| 1217 | /// ParseDirectiveInclude |
| 1218 | /// ::= .include "filename" |
| 1219 | bool AsmParser::ParseDirectiveInclude() { |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1220 | if (Lexer.isNot(AsmToken::String)) |
Kevin Enderby | 1f049b2 | 2009-07-14 23:21:55 +0000 | [diff] [blame] | 1221 | return TokError("expected string in '.include' directive"); |
| 1222 | |
Daniel Dunbar | 419aded | 2009-07-28 16:38:40 +0000 | [diff] [blame] | 1223 | std::string Filename = Lexer.getTok().getString(); |
Chris Lattner | 8e25e2d | 2009-07-16 06:14:39 +0000 | [diff] [blame] | 1224 | SMLoc IncludeLoc = Lexer.getLoc(); |
Kevin Enderby | 1f049b2 | 2009-07-14 23:21:55 +0000 | [diff] [blame] | 1225 | Lexer.Lex(); |
| 1226 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1227 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Kevin Enderby | 1f049b2 | 2009-07-14 23:21:55 +0000 | [diff] [blame] | 1228 | return TokError("unexpected token in '.include' directive"); |
| 1229 | |
Chris Lattner | 8e25e2d | 2009-07-16 06:14:39 +0000 | [diff] [blame] | 1230 | // Strip the quotes. |
| 1231 | Filename = Filename.substr(1, Filename.size()-2); |
| 1232 | |
| 1233 | // Attempt to switch the lexer to the included file before consuming the end |
| 1234 | // of statement to avoid losing it when we switch. |
| 1235 | if (Lexer.EnterIncludeFile(Filename)) { |
| 1236 | Lexer.PrintMessage(IncludeLoc, |
| 1237 | "Could not find include file '" + Filename + "'", |
| 1238 | "error"); |
| 1239 | return true; |
| 1240 | } |
Kevin Enderby | 1f049b2 | 2009-07-14 23:21:55 +0000 | [diff] [blame] | 1241 | |
| 1242 | return false; |
| 1243 | } |
Kevin Enderby | 6e68cd9 | 2009-07-15 15:30:11 +0000 | [diff] [blame] | 1244 | |
| 1245 | /// ParseDirectiveDarwinDumpOrLoad |
| 1246 | /// ::= ( .dump | .load ) "filename" |
Kevin Enderby | 5026ae4 | 2009-07-20 20:25:37 +0000 | [diff] [blame] | 1247 | bool AsmParser::ParseDirectiveDarwinDumpOrLoad(SMLoc IDLoc, bool IsDump) { |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1248 | if (Lexer.isNot(AsmToken::String)) |
Kevin Enderby | 6e68cd9 | 2009-07-15 15:30:11 +0000 | [diff] [blame] | 1249 | return TokError("expected string in '.dump' or '.load' directive"); |
| 1250 | |
Kevin Enderby | 6e68cd9 | 2009-07-15 15:30:11 +0000 | [diff] [blame] | 1251 | Lexer.Lex(); |
| 1252 | |
Daniel Dunbar | 3f87233 | 2009-07-28 16:08:33 +0000 | [diff] [blame] | 1253 | if (Lexer.isNot(AsmToken::EndOfStatement)) |
Kevin Enderby | 6e68cd9 | 2009-07-15 15:30:11 +0000 | [diff] [blame] | 1254 | return TokError("unexpected token in '.dump' or '.load' directive"); |
| 1255 | |
| 1256 | Lexer.Lex(); |
| 1257 | |
Kevin Enderby | 5026ae4 | 2009-07-20 20:25:37 +0000 | [diff] [blame] | 1258 | // FIXME: If/when .dump and .load are implemented they will be done in the |
| 1259 | // the assembly parser and not have any need for an MCStreamer API. |
Kevin Enderby | 6e68cd9 | 2009-07-15 15:30:11 +0000 | [diff] [blame] | 1260 | if (IsDump) |
Kevin Enderby | 5026ae4 | 2009-07-20 20:25:37 +0000 | [diff] [blame] | 1261 | Warning(IDLoc, "ignoring directive .dump for now"); |
Kevin Enderby | 6e68cd9 | 2009-07-15 15:30:11 +0000 | [diff] [blame] | 1262 | else |
Kevin Enderby | 5026ae4 | 2009-07-20 20:25:37 +0000 | [diff] [blame] | 1263 | Warning(IDLoc, "ignoring directive .load for now"); |
Kevin Enderby | 6e68cd9 | 2009-07-15 15:30:11 +0000 | [diff] [blame] | 1264 | |
| 1265 | return false; |
| 1266 | } |