[llvm-commits] [llvm] r108612 - /llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
Eli Friedman
eli.friedman at gmail.com
Fri Jul 16 23:27:28 PDT 2010
Author: efriedma
Date: Sat Jul 17 01:27:28 2010
New Revision: 108612
URL: http://llvm.org/viewvc/llvm-project?rev=108612&view=rev
Log:
Start of .sleb128/.uleb128 parsing support.
Modified:
llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
Modified: llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp?rev=108612&r1=108611&r2=108612&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/ELFAsmParser.cpp Sat Jul 17 01:27:28 2010
@@ -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 @@
&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 @@
MCSectionELF::SHF_EXECINSTR |
MCSectionELF::SHF_ALLOC, SectionKind::getText());
}
+ bool ParseDirectiveLEB128(StringRef, SMLoc);
bool ParseDirectiveSection(StringRef, SMLoc);
bool ParseDirectiveSize(StringRef, SMLoc);
};
@@ -191,6 +197,26 @@
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() {
More information about the llvm-commits
mailing list