[PATCH] D83778: MIPS: add build time option to disable madd.fmt

YunQiang Su via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 09:03:30 PDT 2020


wzssyqa updated this revision to Diff 277857.
wzssyqa added a comment.

No need to block list r6 since the maddf.fmt has 3 reg operand.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83778/new/

https://reviews.llvm.org/D83778

Files:
  clang/lib/Basic/Targets/Mips.h
  llvm/CMakeLists.txt
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/lib/Target/Mips/MipsSubtarget.cpp


Index: llvm/lib/Target/Mips/MipsSubtarget.cpp
===================================================================
--- llvm/lib/Target/Mips/MipsSubtarget.cpp
+++ llvm/lib/Target/Mips/MipsSubtarget.cpp
@@ -238,6 +238,7 @@
 MipsSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS,
                                                const TargetMachine &TM) {
   StringRef CPUName = MIPS_MC::selectMipsCPU(TM.getTargetTriple(), CPU);
+  SubtargetFeatures Features(FS);
 
   // Parse features string.
   ParseSubtargetFeatures(CPUName, FS);
@@ -260,6 +261,16 @@
     report_fatal_error("64-bit code requested on a subtarget that doesn't "
                        "support it!");
 
+#if LLVM_DISABLE_MIPS_MADD4
+  DisableMadd4 = true;
+#endif
+  for (const std::string &Feature : Features.getFeatures()) {
+    if (Feature == "+nomadd4")
+      DisableMadd4 = true;
+    else if (Feature == "-nomadd4")
+      DisableMadd4 = false;
+  }
+
   return *this;
 }
 
Index: llvm/include/llvm/Config/llvm-config.h.cmake
===================================================================
--- llvm/include/llvm/Config/llvm-config.h.cmake
+++ llvm/include/llvm/Config/llvm-config.h.cmake
@@ -56,6 +56,9 @@
 /* Define if we have the Intel JIT API runtime support library */
 #cmakedefine01 LLVM_USE_INTEL_JITEVENTS
 
+/* Define if wish disable MIPS madd.fmt/msub.fmt instructions by default. */
+#cmakedefine01 LLVM_DISABLE_MIPS_MADD4
+
 /* Define if we have the oprofile JIT-support library */
 #cmakedefine01 LLVM_USE_OPROFILE
 
Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -462,6 +462,12 @@
   endif()
 endif( LLVM_USE_INTEL_JITEVENTS )
 
+# Loongson has bug on madd.fmt/msub.fmt instructions. gcc has a buildtime option: --without-madd4/--with-madd4
+# Users can still enable/disable madd.fmt/msub.fmt when runtime with option: -mmadd4/-mno-madd4
+option(LLVM_DISABLE_MIPS_MADD4
+	"Disable MIPS madd.fmt/msub.fmt instructions by default."
+  OFF)
+
 option(LLVM_USE_OPROFILE
   "Use opagent JIT interface to inform OProfile about JIT code" OFF)
 
Index: clang/lib/Basic/Targets/Mips.h
===================================================================
--- clang/lib/Basic/Targets/Mips.h
+++ clang/lib/Basic/Targets/Mips.h
@@ -79,6 +79,9 @@
 
     CanUseBSDABICalls = Triple.isOSFreeBSD() ||
                         Triple.isOSOpenBSD();
+#if LLVM_DISABLE_MIPS_MADD4
+    DisableMadd4 = true;
+#endif
   }
 
   bool isIEEE754_2008Default() const {
@@ -332,6 +335,8 @@
         HasMSA = true;
       else if (Feature == "+nomadd4")
         DisableMadd4 = true;
+      else if (Feature == "-nomadd4")
+        DisableMadd4 = false;
       else if (Feature == "+fp64")
         FPMode = FP64;
       else if (Feature == "-fp64")


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83778.277857.patch
Type: text/x-patch
Size: 2833 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200714/8cd94e1c/attachment.bin>


More information about the llvm-commits mailing list