[PATCH] D40490: [mips] Add warnings for using dsp and msa flags with inapropriate MIPS revisions
Miloš Stojanović via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 27 05:10:44 PST 2017
mstojanovic created this revision.
Herald added a subscriber: arichardson.
Dsp and dspr2 require MIPS revision 2, while msa requires revision 5. Adding warnings for cases when these flags are used with earlier revision.
https://reviews.llvm.org/D40490
Files:
lib/Target/Mips/MipsSubtarget.cpp
test/CodeGen/Mips/dsp_msa_warning.ll
Index: test/CodeGen/Mips/dsp_msa_warning.ll
===================================================================
--- /dev/null
+++ test/CodeGen/Mips/dsp_msa_warning.ll
@@ -0,0 +1,21 @@
+; RUN: llc -march=mips -mattr=+mips32r2 -mattr=+msa -mattr=+fp64 < %s 2>&1 | FileCheck %s -check-prefix=msa_32
+; RUN: llc -march=mips64 -mattr=+mips64r2 -mattr=+msa < %s 2>&1 | FileCheck %s -check-prefix=msa_64
+; RUN: llc -march=mips -mattr=+mips32 -mattr=+dspr2 < %s 2>&1| FileCheck %s -check-prefix=dspr2_32
+; RUN: llc -march=mips64 -mattr=+mips64 -mattr=+dspr2 < %s 2>&1 | FileCheck %s -check-prefix=dspr2_64
+; RUN: llc -march=mips -mattr=+mips32 -mattr=+dsp < %s 2>&1 | FileCheck %s -check-prefix=dsp_32
+; RUN: llc -march=mips64 -mattr=+mips64 -mattr=+dsp < %s 2>&1 | FileCheck %s -check-prefix=dsp_64
+; RUN: llc -march=mips -mattr=+mips32r2 -mattr=+dspr2 < %s 2>&1 | FileCheck %s -check-prefix=dspr2_32_no_warning
+; RUN: llc -march=mips64 -mattr=+mips64r3 -mattr=+dspr2 < %s 2>&1 | FileCheck %s -check-prefix=dspr2_64_no_warning
+; RUN: llc -march=mips -mattr=+mips32r5 -mattr=+dsp < %s 2>&1 | FileCheck %s -check-prefix=dsp_32_no_warning
+; RUN: llc -march=mips64 -mattr=+mips64r2 -mattr=+dsp < %s 2>&1 | FileCheck %s -check-prefix=dsp_64_no_warning
+
+; msa_32: warning: the 'msa' extension requires MIPS32 revision 5 or greater
+; msa_64: warning: the 'msa' extension requires MIPS64 revision 5 or greater
+; dspr2_32: warning: the 'dspr2' extension requires MIPS32 revision 2 or greater
+; dspr2_64: warning: the 'dspr2' extension requires MIPS64 revision 2 or greater
+; dsp_32: warning: the 'dsp' extension requires MIPS32 revision 2 or greater
+; dsp_64: warning: the 'dsp' extension requires MIPS64 revision 2 or greater
+; dspr2_32_no_warning-NOT: warning: the 'dspr2' extension requires MIPS32 revision 2 or greater
+; dspr2_64_no_warning-NOT: warning: the 'dspr2' extension requires MIPS64 revision 2 or greater
+; dsp_32_no_warning-NOT: warning: the 'dsp' extension requires MIPS32 revision 2 or greater
+; dsp_64_no_warning-NOT: warning: the 'dsp' extension requires MIPS64 revision 2 or greater
Index: lib/Target/Mips/MipsSubtarget.cpp
===================================================================
--- lib/Target/Mips/MipsSubtarget.cpp
+++ lib/Target/Mips/MipsSubtarget.cpp
@@ -126,6 +126,45 @@
<< "\n";
UseSmallSection = false;
}
+
+ // Used to avoid printing dsp warnings multiple times.
+ static bool DspWarningPrinted = false;
+
+ if(hasDSPR2() && !DspWarningPrinted) {
+ if(hasMips64() && !hasMips64r2()) {
+ errs() << "warning: the 'dspr2' extension requires MIPS64 revision 2 or "
+ << "greater\n";
+ DspWarningPrinted = true;
+ } else if(hasMips32() && !hasMips32r2()) {
+ errs() << "warning: the 'dspr2' extension requires MIPS32 revision 2 or "
+ << "greater\n";
+ DspWarningPrinted = true;
+ }
+ } else if(hasDSP() && !DspWarningPrinted) {
+ if(hasMips64() && !hasMips64r2()) {
+ errs() << "warning: the 'dsp' extension requires MIPS64 revision 2 or "
+ << "greater\n";
+ DspWarningPrinted = true;
+ } else if(hasMips32() && !hasMips32r2()) {
+ errs() << "warning: the 'dsp' extension requires MIPS32 revision 2 or "
+ << "greater\n";
+ DspWarningPrinted = true;
+ }
+ }
+
+ // Used to avoid printing msa warnings multiple times.
+ static bool MSAWarningPrinted = false;
+ if(hasMSA() && !MSAWarningPrinted) {
+ if(hasMips64() && !hasMips64r5()) {
+ errs() << "warning: the 'msa' extension requires MIPS64 revision 5 or "
+ << "greater\n";
+ MSAWarningPrinted = true;
+ } else if(hasMips32() && !hasMips32r5()) {
+ errs() << "warning: the 'msa' extension requires MIPS32 revision 5 or "
+ << "greater\n";
+ MSAWarningPrinted = true;
+ }
+ }
}
bool MipsSubtarget::isPositionIndependent() const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40490.124353.patch
Type: text/x-patch
Size: 3919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171127/c719aee9/attachment-0001.bin>
More information about the llvm-commits
mailing list