[llvm] r314994 - [mips] implement .set dspr2 directive
Petar Jovanovic via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 5 10:40:33 PDT 2017
Author: petarj
Date: Thu Oct 5 10:40:32 2017
New Revision: 314994
URL: http://llvm.org/viewvc/llvm-project?rev=314994&view=rev
Log:
[mips] implement .set dspr2 directive
Implement .set dspr2 directive with appropriate feature bits. This
directive is a counterpart of -mattr=dspr2 command line option with the
exception that it does not influence elf header flags.
Patch by Milos Stojanovic.
Differential Revision: https://reviews.llvm.org/D38537
Modified:
llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h
llvm/trunk/test/MC/Mips/mips_directives.s
llvm/trunk/test/MC/Mips/module-directive-bad.s
llvm/trunk/test/MC/Mips/set-nodsp.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=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Thu Oct 5 10:40:32 2017
@@ -6584,6 +6584,10 @@ bool MipsAsmParser::parseSetFeature(uint
setFeatureBits(Mips::FeatureDSP, "dsp");
getTargetStreamer().emitDirectiveSetDsp();
break;
+ case Mips::FeatureDSPR2:
+ setFeatureBits(Mips::FeatureDSPR2, "dspr2");
+ getTargetStreamer().emitDirectiveSetDspr2();
+ break;
case Mips::FeatureMicroMips:
setFeatureBits(Mips::FeatureMicroMips, "micromips");
getTargetStreamer().emitDirectiveSetMicroMips();
@@ -6928,6 +6932,8 @@ bool MipsAsmParser::parseDirectiveSet()
return parseSetFeature(Mips::FeatureMips64r6);
} else if (Tok.getString() == "dsp") {
return parseSetFeature(Mips::FeatureDSP);
+ } else if (Tok.getString() == "dspr2") {
+ return parseSetFeature(Mips::FeatureDSPR2);
} else if (Tok.getString() == "nodsp") {
return parseSetNoDspDirective();
} else if (Tok.getString() == "msa") {
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=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp Thu Oct 5 10:40:32 2017
@@ -98,6 +98,7 @@ void MipsTargetStreamer::emitDirectiveSe
forbidModuleDirective();
}
void MipsTargetStreamer::emitDirectiveSetDsp() { forbidModuleDirective(); }
+void MipsTargetStreamer::emitDirectiveSetDspr2() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveSetNoDsp() { forbidModuleDirective(); }
void MipsTargetStreamer::emitDirectiveCpLoad(unsigned RegNo) {}
bool MipsTargetStreamer::emitDirectiveCpRestore(
@@ -547,6 +548,11 @@ void MipsTargetAsmStreamer::emitDirectiv
MipsTargetStreamer::emitDirectiveSetDsp();
}
+void MipsTargetAsmStreamer::emitDirectiveSetDspr2() {
+ OS << "\t.set\tdspr2\n";
+ MipsTargetStreamer::emitDirectiveSetDspr2();
+}
+
void MipsTargetAsmStreamer::emitDirectiveSetNoDsp() {
OS << "\t.set\tnodsp\n";
MipsTargetStreamer::emitDirectiveSetNoDsp();
Modified: llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h?rev=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h (original)
+++ llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h Thu Oct 5 10:40:32 2017
@@ -77,6 +77,7 @@ public:
virtual void emitDirectiveSetMips64R5();
virtual void emitDirectiveSetMips64R6();
virtual void emitDirectiveSetDsp();
+ virtual void emitDirectiveSetDspr2();
virtual void emitDirectiveSetNoDsp();
virtual void emitDirectiveSetPop();
virtual void emitDirectiveSetPush();
@@ -244,6 +245,7 @@ public:
void emitDirectiveSetMips64R5() override;
void emitDirectiveSetMips64R6() override;
void emitDirectiveSetDsp() override;
+ void emitDirectiveSetDspr2() override;
void emitDirectiveSetNoDsp() override;
void emitDirectiveSetPop() override;
void emitDirectiveSetPush() override;
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=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/mips_directives.s (original)
+++ llvm/trunk/test/MC/Mips/mips_directives.s Thu Oct 5 10:40:32 2017
@@ -83,3 +83,10 @@ $BB0_4:
.set dsp
lbux $7, $10($11)
lhx $5, $6($7)
+
+# CHECK: .set dspr2
+# CHECK: append $7, $10, 2 # encoding: [0x7d,0x47,0x10,0x31]
+# CHECK: balign $5, $6, 3 # encoding: [0x7c,0xc5,0x1c,0x31]
+ .set dspr2
+ append $7, $10, 2
+ balign $5, $6, 3
\ No newline at end of file
Modified: llvm/trunk/test/MC/Mips/module-directive-bad.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/module-directive-bad.s?rev=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/module-directive-bad.s (original)
+++ llvm/trunk/test/MC/Mips/module-directive-bad.s Thu Oct 5 10:40:32 2017
@@ -157,6 +157,10 @@
.module fp=64
# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+ .set dspr2
+ .module fp=64
+# CHECK: :[[@LINE-1]]:13: error: .module directive must appear before any code
+
.llvm_internal_mips_reallow_module_directive
.module fp=32
# CHECK-NOT: :[[@LINE-1]]:13: error: .module directive must appear before any code
Modified: llvm/trunk/test/MC/Mips/set-nodsp.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/set-nodsp.s?rev=314994&r1=314993&r2=314994&view=diff
==============================================================================
--- llvm/trunk/test/MC/Mips/set-nodsp.s (original)
+++ llvm/trunk/test/MC/Mips/set-nodsp.s Thu Oct 5 10:40:32 2017
@@ -1,7 +1,8 @@
-# RUN: not llvm-mc %s -mcpu=mips32 -mattr=+dsp -triple mips-unknown-linux 2>%t1
+# RUN: not llvm-mc %s -mcpu=mips32 -mattr=+dspr2 -triple mips-unknown-linux 2>%t1
# RUN: FileCheck %s < %t1
lbux $7, $10($11)
+ append $4, $10, 2
.set nodsp
lbux $6, $10($11)
@@ -10,3 +11,11 @@
.set dsp
lbux $5, $10($11)
# CHECK-NOT: error: instruction requires a CPU feature not currently enabled
+
+ .set nodsp
+ append $3, $10, 2
+ # CHECK: error: instruction requires a CPU feature not currently enabled
+
+ .set dspr2
+ append $2, $10, 2
+ # CHECK-NOT: error: instruction requires a CPU feature not currently enabled
More information about the llvm-commits
mailing list