[PATCH] D130311: [RISCV] Enable strict FP in clang as long as Zve* or V are not enabled.

Craig Topper via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 1 16:03:46 PDT 2022


craig.topper updated this revision to Diff 449150.
craig.topper added a comment.

Add hasVInstructions to RISCVISAInfo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130311

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/test/CodeGen/builtin_float_strictfp.c
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp


Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -929,6 +929,10 @@
     }
   }
 
+  // FIXME: Strict FP support is incomplete for vectors.
+  if (!Subtarget.hasVInstructions())
+    IsStrictFPEnabled = true;
+
   // Function alignments.
   const Align FunctionAlignment(Subtarget.hasStdExtC() ? 2 : 4);
   setMinFunctionAlignment(FunctionAlignment);
Index: llvm/lib/Support/RISCVISAInfo.cpp
===================================================================
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -228,6 +228,10 @@
          llvm::any_of(SupportedExperimentalExtensions, FindByNameAndVersion);
 }
 
+bool RISCVISAInfo::hasVInstructions() const {
+  return hasExtension("zve32x");
+}
+
 bool RISCVISAInfo::hasExtension(StringRef Ext) const {
   stripExperimentalPrefix(Ext);
 
@@ -702,7 +706,7 @@
   bool HasF = Exts.count("f") != 0;
   bool HasZfinx = Exts.count("zfinx") != 0;
   bool HasZdinx = Exts.count("zdinx") != 0;
-  bool HasVector = Exts.count("zve32x") != 0;
+  bool HasVector = hasVInstructions();
   bool HasZve32f = Exts.count("zve32f") != 0;
   bool HasZve64d = Exts.count("zve64d") != 0;
   bool HasZvl = MinVLen != 0;
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===================================================================
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -62,6 +62,7 @@
   unsigned getMinVLen() const { return MinVLen; }
   unsigned getMaxELen() const { return MaxELen; }
   unsigned getMaxELenFp() const { return MaxELenFp; }
+  bool hasVInstructions() const;
 
   bool hasExtension(StringRef Ext) const;
   std::string toString() const;
Index: clang/test/CodeGen/builtin_float_strictfp.c
===================================================================
--- clang/test/CodeGen/builtin_float_strictfp.c
+++ clang/test/CodeGen/builtin_float_strictfp.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple x86_64-windows-pc -ffp-exception-behavior=maytrap -o - %s | FileCheck %s --check-prefixes=CHECK,FP16
 // RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple ppc64-be -ffp-exception-behavior=maytrap -o - %s | FileCheck %s --check-prefixes=CHECK,NOFP16
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm -triple riscv64 -ffp-exception-behavior=maytrap -o - %s | FileCheck %s --check-prefixes=CHECK,FP16
 
 // test to ensure that these builtins don't do the variadic promotion of float->double.
 
Index: clang/lib/Basic/Targets/RISCV.h
===================================================================
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -41,6 +41,7 @@
     HasRISCVVTypes = true;
     MCountName = "_mcount";
     HasFloat16 = true;
+    HasStrictFP = true;
   }
 
   bool setCPU(const std::string &Name) override {
Index: clang/lib/Basic/Targets/RISCV.cpp
===================================================================
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -190,7 +190,7 @@
   if (ISAInfo->hasExtension("c"))
     Builder.defineMacro("__riscv_compressed");
 
-  if (ISAInfo->hasExtension("zve32x"))
+  if (ISAInfo->hasVInstructions())
     Builder.defineMacro("__riscv_vector");
 }
 
@@ -282,6 +282,10 @@
   if (ABI.empty())
     ABI = ISAInfo->computeDefaultABI().str();
 
+  // StrictFP support for vectors is incomplete.
+  if (ISAInfo->hasVInstructions())
+    HasStrictFP = false;
+
   return true;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130311.449150.patch
Type: text/x-patch
Size: 3626 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220801/e5677825/attachment.bin>


More information about the cfe-commits mailing list