diff options
author | Jack Carter <jcarter@mips.com> | 2013-01-25 01:31:34 +0000 |
---|---|---|
committer | Jack Carter <jcarter@mips.com> | 2013-01-25 01:31:34 +0000 |
commit | 07c818d2da3bf98609cd171363c50b86553a856c (patch) | |
tree | 0c7ce43521829138ed325094acafb9b4b04f1f16 /llvm/lib | |
parent | a71919c9d6e989fb183f69729510da0152e1572b (diff) | |
download | bcm5719-llvm-07c818d2da3bf98609cd171363c50b86553a856c.tar.gz bcm5719-llvm-07c818d2da3bf98609cd171363c50b86553a856c.zip |
This patch implements parsing the .word
directive for the Mips assembler.
Contributer: Vladimir Medic
llvm-svn: 173407
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 49 |
1 files changed, 42 insertions, 7 deletions
diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index 39a53aeba72..1f143d10b50 100644 --- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -133,6 +133,8 @@ class MipsAsmParser : public MCTargetAsmParser { bool parseSetReorderDirective(); bool parseSetNoReorderDirective(); + bool parseDirectiveWord(unsigned Size, SMLoc L); + MCSymbolRefExpr::VariantKind getVariantKind(StringRef Symbol); bool isMips64() const { @@ -1451,51 +1453,84 @@ bool MipsAsmParser::parseDirectiveSet() { Parser.EatToEndOfStatement(); return false; } + return true; } +/// parseDirectiveWord +/// ::= .word [ expression (, expression)* ] +bool MipsAsmParser::parseDirectiveWord(unsigned Size, SMLoc L) { + if (getLexer().isNot(AsmToken::EndOfStatement)) { + for (;;) { + const MCExpr *Value; + if (getParser().ParseExpression(Value)) + return true; + + getParser().getStreamer().EmitValue(Value, Size); + + if (getLexer().is(AsmToken::EndOfStatement)) + break; + + // FIXME: Improve diagnostic. + if (getLexer().isNot(AsmToken::Comma)) + return Error(L, "unexpected token in directive"); + Parser.Lex(); + } + } + + Parser.Lex(); + return false; +} + bool MipsAsmParser::ParseDirective(AsmToken DirectiveID) { - if (DirectiveID.getString() == ".ent") { + StringRef IDVal = DirectiveID.getString(); + + if ( IDVal == ".ent") { // ignore this directive for now Parser.Lex(); return false; } - if (DirectiveID.getString() == ".end") { + if (IDVal == ".end") { // ignore this directive for now Parser.Lex(); return false; } - if (DirectiveID.getString() == ".frame") { + if (IDVal == ".frame") { // ignore this directive for now Parser.EatToEndOfStatement(); return false; } - if (DirectiveID.getString() == ".set") { + if (IDVal == ".set") { return parseDirectiveSet(); } - if (DirectiveID.getString() == ".fmask") { + if (IDVal == ".fmask") { // ignore this directive for now Parser.EatToEndOfStatement(); return false; } - if (DirectiveID.getString() == ".mask") { + if (IDVal == ".mask") { // ignore this directive for now Parser.EatToEndOfStatement(); return false; } - if (DirectiveID.getString() == ".gpword") { + if (IDVal == ".gpword") { // ignore this directive for now Parser.EatToEndOfStatement(); return false; } + if (IDVal == ".word") { + parseDirectiveWord(4, DirectiveID.getLoc()); + return false; + } + return true; } |