diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2010-07-17 06:27:28 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2010-07-17 06:27:28 +0000 |
commit | 9de5967244a57beee5e0531c4b75ce38976da39f (patch) | |
tree | 737888a9352c4dd4f61c3dd0ec4dc1ba0dacba19 | |
parent | 3c93d12916bba7380f316de7665acb898f6f1c0c (diff) | |
download | bcm5719-llvm-9de5967244a57beee5e0531c4b75ce38976da39f.tar.gz bcm5719-llvm-9de5967244a57beee5e0531c4b75ce38976da39f.zip |
Start of .sleb128/.uleb128 parsing support.
llvm-svn: 108612
-rw-r--r-- | llvm/lib/MC/MCParser/ELFAsmParser.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCParser/ELFAsmParser.cpp b/llvm/lib/MC/MCParser/ELFAsmParser.cpp index 340af23cf9b..8bbc8b37cbf 100644 --- a/llvm/lib/MC/MCParser/ELFAsmParser.cpp +++ b/llvm/lib/MC/MCParser/ELFAsmParser.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "llvm/MC/MCParser/MCAsmParserExtension.h" +#include "llvm/ADT/Twine.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" #include "llvm/MC/MCParser/MCAsmLexer.h" @@ -36,6 +37,10 @@ public: &ELFAsmParser::ParseDirectiveSection)); Parser.AddDirectiveHandler(this, ".size", MCAsmParser::DirectiveHandler( &ELFAsmParser::ParseDirectiveSize)); + Parser.AddDirectiveHandler(this, ".sleb128", MCAsmParser::DirectiveHandler( + &ELFAsmParser::ParseDirectiveLEB128)); + Parser.AddDirectiveHandler(this, ".uleb128", MCAsmParser::DirectiveHandler( + &ELFAsmParser::ParseDirectiveLEB128)); } bool ParseSectionDirectiveData(StringRef, SMLoc) { @@ -48,6 +53,7 @@ public: MCSectionELF::SHF_EXECINSTR | MCSectionELF::SHF_ALLOC, SectionKind::getText()); } + bool ParseDirectiveLEB128(StringRef, SMLoc); bool ParseDirectiveSection(StringRef, SMLoc); bool ParseDirectiveSize(StringRef, SMLoc); }; @@ -191,6 +197,26 @@ bool ELFAsmParser::ParseDirectiveSection(StringRef, SMLoc) { return false; } +bool ELFAsmParser::ParseDirectiveLEB128(StringRef DirName, SMLoc) { + int64_t Value; + if (getParser().ParseAbsoluteExpression(Value)) + return true; + + if (getLexer().isNot(AsmToken::EndOfStatement)) + return TokError("unexpected token in directive"); + + // FIXME: Add proper MC support. + if (getContext().getAsmInfo().hasLEB128()) { + if (DirName[1] == 's') + getStreamer().EmitRawText("\t.sleb128\t" + Twine(Value)); + else + getStreamer().EmitRawText("\t.uleb128\t" + Twine(Value)); + return false; + } + // FIXME: This shouldn't be an error! + return TokError("LEB128 not supported yet"); +} + namespace llvm { MCAsmParserExtension *createELFAsmParser() { |