diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h --- a/clang/lib/Basic/Targets/RISCV.h +++ b/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 { diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp --- a/clang/lib/Basic/Targets/RISCV.cpp +++ b/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; } diff --git a/clang/test/CodeGen/builtin_float_strictfp.c b/clang/test/CodeGen/builtin_float_strictfp.c --- a/clang/test/CodeGen/builtin_float_strictfp.c +++ b/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. diff --git a/llvm/include/llvm/Support/RISCVISAInfo.h b/llvm/include/llvm/Support/RISCVISAInfo.h --- a/llvm/include/llvm/Support/RISCVISAInfo.h +++ b/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; diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp --- a/llvm/lib/Support/RISCVISAInfo.cpp +++ b/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; diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/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);