From: Dan Gohman Date: Tue, 28 Nov 2017 01:13:45 +0000 (+0000) Subject: [WebAssembly] Add options for using the nontrapping-fptoint feature. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=449f42c6c827e83778a0b018683755d72dfc76ef;p=clang [WebAssembly] Add options for using the nontrapping-fptoint feature. This adds ways to control use of WebAssembly's new nontrapping-fptoint feature. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319129 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 15a752b354..9f8684ddee 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -1837,6 +1837,8 @@ def ffixed_x18 : Flag<["-"], "ffixed-x18">, Group, def msimd128 : Flag<["-"], "msimd128">, Group; def mno_simd128 : Flag<["-"], "mno-simd128">, Group; +def mnontrapping_fptoint : Flag<["-"], "mnontrapping-fptoint">, Group; +def mno_nontrapping_fptoint : Flag<["-"], "mno-nontrapping-fptoint">, Group; def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">, Flags<[HelpHidden]>, diff --git a/lib/Basic/Targets/WebAssembly.cpp b/lib/Basic/Targets/WebAssembly.cpp index 9eaaf8d4fd..915aad4b56 100644 --- a/lib/Basic/Targets/WebAssembly.cpp +++ b/lib/Basic/Targets/WebAssembly.cpp @@ -32,6 +32,7 @@ const Builtin::Info WebAssemblyTargetInfo::BuiltinInfo[] = { bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const { return llvm::StringSwitch(Feature) .Case("simd128", SIMDLevel >= SIMD128) + .Case("nontrapping-fptoint", HasNontrappingFPToInt) .Default(false); } @@ -61,6 +62,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures( SIMDLevel = std::min(SIMDLevel, SIMDEnum(SIMD128 - 1)); continue; } + if (Feature == "+nontrapping-fptoint") { + HasNontrappingFPToInt = true; + continue; + } + if (Feature == "-nontrapping-fptoint") { + HasNontrappingFPToInt = false; + continue; + } Diags.Report(diag::err_opt_not_valid_with_opt) << Feature << "-target-feature"; diff --git a/lib/Basic/Targets/WebAssembly.h b/lib/Basic/Targets/WebAssembly.h index 20f57506d9..ee0073d081 100644 --- a/lib/Basic/Targets/WebAssembly.h +++ b/lib/Basic/Targets/WebAssembly.h @@ -30,9 +30,11 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo { SIMD128, } SIMDLevel; + bool HasNontrappingFPToInt; + public: explicit WebAssemblyTargetInfo(const llvm::Triple &T, const TargetOptions &) - : TargetInfo(T), SIMDLevel(NoSIMD) { + : TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false) { NoAsmVariants = true; SuitableAlign = 128; LargeArrayMinWidth = 128; @@ -55,8 +57,10 @@ private: initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector &FeaturesVec) const override { - if (CPU == "bleeding-edge") + if (CPU == "bleeding-edge") { Features["simd128"] = true; + Features["nontrapping-fptoint"] = true; + } return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); }