[llvm-commits] [llvm] r173407 - in /llvm/trunk: lib/Target/Mips/AsmParser/MipsAsmParser.cpp test/MC/Mips/mips_directives.s
Jack Carter
jcarter at mips.com
Thu Jan 24 17:31:34 PST 2013
Author: jacksprat
Date: Thu Jan 24 19:31:34 2013
New Revision: 173407
URL: http://llvm.org/viewvc/llvm-project?rev=173407&view=rev
Log:
This patch implements parsing the .word
directive for the Mips assembler.
Contributer: Vladimir Medic
Modified:
llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
llvm/trunk/test/MC/Mips/mips_directives.s
Modified: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp?rev=173407&r1=173406&r2=173407&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Thu Jan 24 19:31:34 2013
@@ -133,6 +133,8 @@
bool parseSetReorderDirective();
bool parseSetNoReorderDirective();
+ bool parseDirectiveWord(unsigned Size, SMLoc L);
+
MCSymbolRefExpr::VariantKind getVariantKind(StringRef Symbol);
bool isMips64() const {
@@ -1451,51 +1453,84 @@
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;
}
Modified: llvm/trunk/test/MC/Mips/mips_directives.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/mips_directives.s?rev=173407&r1=173406&r2=173407&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/mips_directives.s (original)
+++ llvm/trunk/test/MC/Mips/mips_directives.s Thu Jan 24 19:31:34 2013
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -triple mips-unknown-unknown %s
+# RUN: llvm-mc -triple mips-unknown-unknown %s | FileCheck %s
#this test produces no output so there isS no FileCheck call
$BB0_2:
.ent directives_test
@@ -10,6 +10,9 @@
.set noat
$JTI0_0:
.gpword ($BB0_2)
+ .word 0x77fffffc
+# CHECK: $JTI0_0:
+# CHECK-NEXT: .4byte 2013265916
.set at=$12
.set macro
.set reorder
More information about the llvm-commits
mailing list