diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-08-11 04:24:50 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-08-11 04:24:50 +0000 |
| commit | a4b069ce002a0978b0c9f8f206d730752ba4e137 (patch) | |
| tree | d05c1bac02c756733435cbc945dcca9a0a55b60f /llvm/tools/llvm-mc/AsmParser.cpp | |
| parent | 78696a70bfd3adf7ca191a3315fee648c27b6b77 (diff) | |
| download | bcm5719-llvm-a4b069ce002a0978b0c9f8f206d730752ba4e137.tar.gz bcm5719-llvm-a4b069ce002a0978b0c9f8f206d730752ba4e137.zip | |
llvm-mc: Sketch parsing for .file, .line, and .loc. No streamer hooks for these
yet (I'm not even sure what they do).
llvm-svn: 78639
Diffstat (limited to 'llvm/tools/llvm-mc/AsmParser.cpp')
| -rw-r--r-- | llvm/tools/llvm-mc/AsmParser.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/llvm/tools/llvm-mc/AsmParser.cpp b/llvm/tools/llvm-mc/AsmParser.cpp index b4fdd83f7bb..b766830bf14 100644 --- a/llvm/tools/llvm-mc/AsmParser.cpp +++ b/llvm/tools/llvm-mc/AsmParser.cpp @@ -551,6 +551,7 @@ bool AsmParser::ParseStatement() { return ParseDirectiveSpace(); // Symbol attribute directives + if (IDVal == ".globl" || IDVal == ".global") return ParseDirectiveSymbolAttribute(MCStreamer::Global); if (IDVal == ".hidden") @@ -598,6 +599,15 @@ bool AsmParser::ParseStatement() { if (IDVal == ".load") return ParseDirectiveDarwinDumpOrLoad(IDLoc, /*IsLoad=*/false); + // Debugging directives + + if (IDVal == ".file") + return ParseDirectiveFile(IDLoc); + if (IDVal == ".line") + return ParseDirectiveLine(IDLoc); + if (IDVal == ".loc") + return ParseDirectiveLoc(IDLoc); + Warning(IDLoc, "ignoring directive for now"); EatToEndOfStatement(); return false; @@ -1439,3 +1449,90 @@ bool AsmParser::ParseDirectiveEndIf(SMLoc DirectiveLoc) { return false; } + +/// ParseDirectiveFile +/// ::= .file [number] string +bool AsmParser::ParseDirectiveFile(SMLoc DirectiveLoc) { + // FIXME: I'm not sure what this is. + int64_t FileNumber = -1; + if (Lexer.is(AsmToken::Integer)) { + FileNumber = Lexer.getTok().getIntVal(); + Lexer.Lex(); + + if (FileNumber < 1) + return TokError("file number less than one"); + } + + if (Lexer.isNot(AsmToken::String)) + return TokError("unexpected token in '.file' directive"); + + StringRef FileName = Lexer.getTok().getString(); + Lexer.Lex(); + + if (Lexer.isNot(AsmToken::EndOfStatement)) + return TokError("unexpected token in '.file' directive"); + + // FIXME: Do something with the .file. + + return false; +} + +/// ParseDirectiveLine +/// ::= .line [number] +bool AsmParser::ParseDirectiveLine(SMLoc DirectiveLoc) { + if (Lexer.isNot(AsmToken::EndOfStatement)) { + if (Lexer.isNot(AsmToken::Integer)) + return TokError("unexpected token in '.line' directive"); + + int64_t LineNumber = Lexer.getTok().getIntVal(); + (void) LineNumber; + Lexer.Lex(); + + // FIXME: Do something with the .line. + } + + if (Lexer.isNot(AsmToken::EndOfStatement)) + return TokError("unexpected token in '.file' directive"); + + return false; +} + + +/// ParseDirectiveLoc +/// ::= .loc number [number [number]] +bool AsmParser::ParseDirectiveLoc(SMLoc DirectiveLoc) { + if (Lexer.isNot(AsmToken::Integer)) + return TokError("unexpected token in '.loc' directive"); + + // FIXME: What are these fields? + int64_t FileNumber = Lexer.getTok().getIntVal(); + (void) FileNumber; + // FIXME: Validate file. + + Lexer.Lex(); + if (Lexer.isNot(AsmToken::EndOfStatement)) { + if (Lexer.isNot(AsmToken::Integer)) + return TokError("unexpected token in '.loc' directive"); + + int64_t Param2 = Lexer.getTok().getIntVal(); + (void) Param2; + Lexer.Lex(); + + if (Lexer.isNot(AsmToken::EndOfStatement)) { + if (Lexer.isNot(AsmToken::Integer)) + return TokError("unexpected token in '.loc' directive"); + + int64_t Param3 = Lexer.getTok().getIntVal(); + (void) Param3; + Lexer.Lex(); + + // FIXME: Do something with the .loc. + } + } + + if (Lexer.isNot(AsmToken::EndOfStatement)) + return TokError("unexpected token in '.file' directive"); + + return false; +} + |

