[llvm] r217946 - [mips] Add assembler support for the .set nodsp directive.
Toma Tabacu
toma.tabacu at imgtec.com
Wed Sep 17 02:01:54 PDT 2014
Author: tomatabacu
Date: Wed Sep 17 04:01:54 2014
New Revision: 217946
URL: http://llvm.org/viewvc/llvm-project?rev=217946&view=rev
Log:
[mips] Add assembler support for the .set nodsp directive.
Summary: This directive is used to tell the assembler to reject DSP-specific instructions.
Reviewers: dsanders
Reviewed By: dsanders
Differential Revision: http://reviews.llvm.org/D5142
Added:
llvm/trunk/test/MC/Mips/set-nodsp.s
Modified:
llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h
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=217946&r1=217945&r2=217946&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Wed Sep 17 04:01:54 2014
@@ -192,6 +192,7 @@ class MipsAsmParser : public MCTargetAsm
bool parseSetNoMacroDirective();
bool parseSetMsaDirective();
bool parseSetNoMsaDirective();
+ bool parseSetNoDspDirective();
bool parseSetReorderDirective();
bool parseSetNoReorderDirective();
bool parseSetNoMips16Directive();
@@ -2654,6 +2655,20 @@ bool MipsAsmParser::parseSetNoMsaDirecti
return false;
}
+bool MipsAsmParser::parseSetNoDspDirective() {
+ Parser.Lex(); // Eat "nodsp".
+
+ // If this is not the end of the statement, report an error.
+ if (getLexer().isNot(AsmToken::EndOfStatement)) {
+ reportParseError("unexpected token, expected end of statement");
+ return false;
+ }
+
+ clearFeatureBits(Mips::FeatureDSP, "dsp");
+ getTargetStreamer().emitDirectiveSetNoDsp();
+ return false;
+}
+
bool MipsAsmParser::parseSetNoMips16Directive() {
Parser.Lex();
// If this is not the end of the statement, report an error.
@@ -3037,6 +3052,8 @@ bool MipsAsmParser::parseDirectiveSet()
return parseSetFeature(Mips::FeatureMips64r6);
} else if (Tok.getString() == "dsp") {
return parseSetFeature(Mips::FeatureDSP);
+ } else if (Tok.getString() == "nodsp") {
+ return parseSetNoDspDirective();
} else if (Tok.getString() == "msa") {
return parseSetMsaDirective();
} else if (Tok.getString() == "nomsa") {
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp?rev=217946&r1=217945&r2=217946&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp Wed Sep 17 04:01:54 2014
@@ -74,6 +74,7 @@ void MipsTargetStreamer::emitDirectiveSe
void MipsTargetStreamer::emitDirectiveSetPop() {}
void MipsTargetStreamer::emitDirectiveSetPush() {}
void MipsTargetStreamer::emitDirectiveSetDsp() { forbidModuleDirective(); }
+void MipsTargetStreamer::emitDirectiveSetNoDsp() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveCpload(unsigned RegNo) {}
void MipsTargetStreamer::emitDirectiveCpsetup(unsigned RegNo, int RegOrOffset,
const MCSymbol &Sym, bool IsReg) {
@@ -247,6 +248,11 @@ void MipsTargetAsmStreamer::emitDirectiv
MipsTargetStreamer::emitDirectiveSetDsp();
}
+void MipsTargetAsmStreamer::emitDirectiveSetNoDsp() {
+ OS << "\t.set\tnodsp\n";
+ MipsTargetStreamer::emitDirectiveSetNoDsp();
+}
+
void MipsTargetAsmStreamer::emitDirectiveSetPop() { OS << "\t.set\tpop\n"; }
void MipsTargetAsmStreamer::emitDirectiveSetPush() { OS << "\t.set\tpush\n"; }
Modified: llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h?rev=217946&r1=217945&r2=217946&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h Wed Sep 17 04:01:54 2014
@@ -62,6 +62,7 @@ public:
virtual void emitDirectiveSetMips64R2();
virtual void emitDirectiveSetMips64R6();
virtual void emitDirectiveSetDsp();
+ virtual void emitDirectiveSetNoDsp();
virtual void emitDirectiveSetPop();
virtual void emitDirectiveSetPush();
@@ -165,6 +166,7 @@ public:
void emitDirectiveSetMips64R2() override;
void emitDirectiveSetMips64R6() override;
void emitDirectiveSetDsp() override;
+ void emitDirectiveSetNoDsp() override;
void emitDirectiveSetPop() override;
void emitDirectiveSetPush() override;
Added: llvm/trunk/test/MC/Mips/set-nodsp.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/set-nodsp.s?rev=217946&view=auto
==============================================================================
--- llvm/trunk/test/MC/Mips/set-nodsp.s (added)
+++ llvm/trunk/test/MC/Mips/set-nodsp.s Wed Sep 17 04:01:54 2014
@@ -0,0 +1,12 @@
+# RUN: not llvm-mc %s -mcpu=mips32 -mattr=+dsp -triple mips-unknown-linux 2>%t1
+# RUN: FileCheck %s < %t1
+
+ lbux $7, $10($11)
+
+ .set nodsp
+ lbux $6, $10($11)
+ # CHECK: error: instruction requires a CPU feature not currently enabled
+
+ .set dsp
+ lbux $5, $10($11)
+ # CHECK-NOT: error: instruction requires a CPU feature not currently enabled
More information about the llvm-commits
mailing list