[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 08:02:55 PST 2017
mstojanovic updated this revision to Diff 124384.
mstojanovic added a comment.
Fixed formatting.
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,44 @@
+; Check msa warnings.
+; RUN: llc -march=mips -mattr=+mips32r2 -mattr=+msa -mattr=+fp64 < %s 2>&1 | \
+; RUN: FileCheck %s -check-prefix=msa_32
+; RUN: llc -march=mips64 -mattr=+mips64r2 -mattr=+msa < %s 2>&1 | \
+; RUN: FileCheck %s -check-prefix=msa_64
+; RUN: llc -march=mips -mattr=+mips32r5 -mattr=+msa -mattr=+fp64 < %s 2>&1 | \
+; RUN: FileCheck %s -check-prefix=msa_32_no_warning
+; RUN: llc -march=mips64 -mattr=+mips64r5 -mattr=+msa < %s 2>&1 | \
+; RUN: FileCheck %s -check-prefix=msa_64_no_warning
+
+; Check dspr2 warnings.
+; RUN: llc -march=mips -mattr=+mips32 -mattr=+dspr2 < %s 2>&1| \
+; RUN: FileCheck %s -check-prefix=dspr2_32
+; RUN: llc -march=mips64 -mattr=+mips64 -mattr=+dspr2 < %s 2>&1 | \
+; RUN: FileCheck %s -check-prefix=dspr2_64
+; RUN: llc -march=mips64 -mattr=+mips64r3 -mattr=+dspr2 < %s 2>&1 | \
+; RUN: FileCheck %s -check-prefix=dspr2_64_no_warning
+; RUN: llc -march=mips -mattr=+mips32r2 -mattr=+dspr2 < %s 2>&1 | \
+; RUN: FileCheck %s -check-prefix=dspr2_32_no_warning
+
+; Check dsp warnings.
+; RUN: llc -march=mips -mattr=+mips32 -mattr=+dsp < %s 2>&1 | \
+; RUN: FileCheck %s -check-prefix=dsp_32
+; RUN: llc -march=mips64 -mattr=+mips64 -mattr=+dsp < %s 2>&1 | \
+; RUN: FileCheck %s -check-prefix=dsp_64
+; RUN: llc -march=mips -mattr=+mips32r5 -mattr=+dsp < %s 2>&1 | \
+; RUN: FileCheck %s -check-prefix=dsp_32_no_warning
+; RUN: llc -march=mips64 -mattr=+mips64r2 -mattr=+dsp < %s 2>&1 | \
+; RUN: 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
+; msa_32_no_warning-NOT: warning: the 'msa' extension requires MIPS32 revision 5 or greater
+; msa_64_no_warning-NOT: 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
+; 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: warning: the 'dsp' extension requires MIPS32 revision 2 or greater
+; dsp_64: warning: the 'dsp' 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.124384.patch
Type: text/x-patch
Size: 4573 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171127/47484e22/attachment.bin>
More information about the llvm-commits
mailing list