[llvm] r323131 - [mips] add warnings for using dsp and msa flags with inappropriate revisions

Petar Jovanovic via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 08:43:30 PST 2018


Author: petarj
Date: Mon Jan 22 08:43:30 2018
New Revision: 323131

URL: http://llvm.org/viewvc/llvm-project?rev=323131&view=rev
Log:
[mips] add warnings for using dsp and msa flags with inappropriate revisions

Dsp and dspr2 require MIPS revision 2, while msa requires revision 5. Adding
warnings for cases when these flags are used with earlier revision.

Patch by Milos Stojanovic.

Differential Revision: https://reviews.llvm.org/D40490

Added:
    llvm/trunk/test/CodeGen/Mips/dsp_msa_warning.ll
Modified:
    llvm/trunk/lib/Target/Mips/MipsSubtarget.cpp
    llvm/trunk/lib/Target/Mips/MipsSubtarget.h

Modified: llvm/trunk/lib/Target/Mips/MipsSubtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsSubtarget.cpp?rev=323131&r1=323130&r2=323131&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsSubtarget.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsSubtarget.cpp Mon Jan 22 08:43:30 2018
@@ -57,6 +57,10 @@ static cl::opt<bool>
     GPOpt("mgpopt", cl::Hidden,
           cl::desc("Enable gp-relative addressing of mips small data items"));
 
+bool MipsSubtarget::DspWarningPrinted = false;
+
+bool MipsSubtarget::MSAWarningPrinted = false;
+
 void MipsSubtarget::anchor() {}
 
 MipsSubtarget::MipsSubtarget(const Triple &TT, StringRef CPU, StringRef FS,
@@ -129,6 +133,40 @@ MipsSubtarget::MipsSubtarget(const Tripl
            << "\n";
     UseSmallSection = false;
   }
+
+  if (hasDSPR2() && !DspWarningPrinted) {
+    if (hasMips64() && !hasMips64r2()) {
+      errs() << "warning: the 'dspr2' ASE requires MIPS64 revision 2 or "
+             << "greater\n";
+      DspWarningPrinted = true;
+    } else if (hasMips32() && !hasMips32r2()) {
+      errs() << "warning: the 'dspr2' ASE requires MIPS32 revision 2 or "
+             << "greater\n";
+      DspWarningPrinted = true;
+    }
+  } else if (hasDSP() && !DspWarningPrinted) {
+    if (hasMips64() && !hasMips64r2()) {
+      errs() << "warning: the 'dsp' ASE requires MIPS64 revision 2 or "
+             << "greater\n";
+      DspWarningPrinted = true;
+    } else if (hasMips32() && !hasMips32r2()) {
+      errs() << "warning: the 'dsp' ASE requires MIPS32 revision 2 or "
+             << "greater\n";
+      DspWarningPrinted = true;
+    }
+  }
+
+  if (hasMSA() && !MSAWarningPrinted) {
+    if (hasMips64() && !hasMips64r5()) {
+      errs() << "warning: the 'msa' ASE requires MIPS64 revision 5 or "
+             << "greater\n";
+      MSAWarningPrinted = true;
+    } else if (hasMips32() && !hasMips32r5()) {
+      errs() << "warning: the 'msa' ASE requires MIPS32 revision 5 or "
+             << "greater\n";
+      MSAWarningPrinted = true;
+    }
+  }
 }
 
 bool MipsSubtarget::isPositionIndependent() const {

Modified: llvm/trunk/lib/Target/Mips/MipsSubtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsSubtarget.h?rev=323131&r1=323130&r2=323131&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsSubtarget.h (original)
+++ llvm/trunk/lib/Target/Mips/MipsSubtarget.h Mon Jan 22 08:43:30 2018
@@ -44,6 +44,12 @@ class MipsSubtarget : public MipsGenSubt
 
   enum class CPU { P5600 };
 
+  // Used to avoid printing dsp warnings multiple times.
+  static bool DspWarningPrinted;
+
+  // Used to avoid printing msa warnings multiple times.
+  static bool MSAWarningPrinted;
+
   // Mips architecture version
   MipsArchEnum MipsArchVersion;
 

Added: llvm/trunk/test/CodeGen/Mips/dsp_msa_warning.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/dsp_msa_warning.ll?rev=323131&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/dsp_msa_warning.ll (added)
+++ llvm/trunk/test/CodeGen/Mips/dsp_msa_warning.ll Mon Jan 22 08:43:30 2018
@@ -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' ASE requires MIPS32 revision 5 or greater
+; MSA_64: warning: the 'msa' ASE requires MIPS64 revision 5 or greater
+; MSA_32_NO_WARNING-NOT: warning: the 'msa' ASE requires MIPS32 revision 5 or greater
+; MSA_64_NO_WARNING-NOT: warning: the 'msa' ASE requires MIPS64 revision 5 or greater
+
+; DSPR2_32: warning: the 'dspr2' ASE requires MIPS32 revision 2 or greater
+; DSPR2_64: warning: the 'dspr2' ASE requires MIPS64 revision 2 or greater
+; DSPR2_32_NO_WARNING-NOT: warning: the 'dspr2' ASE requires MIPS32 revision 2 or greater
+; DSPR2_64_NO_WARNING-NOT: warning: the 'dspr2' ASE requires MIPS64 revision 2 or greater
+
+; DSP_32: warning: the 'dsp' ASE requires MIPS32 revision 2 or greater
+; DSP_64: warning: the 'dsp' ASE requires MIPS64 revision 2 or greater
+; DSP_32_NO_WARNING-NOT: warning: the 'dsp' ASE requires MIPS32 revision 2 or greater
+; DSP_64_NO_WARNING-NOT: warning: the 'dsp' ASE requires MIPS64 revision 2 or greater




More information about the llvm-commits mailing list