Author: djg Date: Mon Nov 27 17:13:45 2017 New Revision: 319129 URL: http://llvm.org/viewvc/llvm-project?rev=319129&view=rev Log: [WebAssembly] Add options for using the nontrapping-fptoint feature.
This adds ways to control use of WebAssembly's new nontrapping-fptoint feature. Modified: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Basic/Targets/WebAssembly.cpp cfe/trunk/lib/Basic/Targets/WebAssembly.h Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=319129&r1=319128&r2=319129&view=diff ============================================================================== --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Mon Nov 27 17:13:45 2017 @@ -1837,6 +1837,8 @@ def ffixed_x18 : Flag<["-"], "ffixed-x18 def msimd128 : Flag<["-"], "msimd128">, Group<m_wasm_Features_Group>; def mno_simd128 : Flag<["-"], "mno-simd128">, Group<m_wasm_Features_Group>; +def mnontrapping_fptoint : Flag<["-"], "mnontrapping-fptoint">, Group<m_wasm_Features_Group>; +def mno_nontrapping_fptoint : Flag<["-"], "mno-nontrapping-fptoint">, Group<m_wasm_Features_Group>; def mamdgpu_debugger_abi : Joined<["-"], "mamdgpu-debugger-abi=">, Flags<[HelpHidden]>, Modified: cfe/trunk/lib/Basic/Targets/WebAssembly.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/WebAssembly.cpp?rev=319129&r1=319128&r2=319129&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/WebAssembly.cpp (original) +++ cfe/trunk/lib/Basic/Targets/WebAssembly.cpp Mon Nov 27 17:13:45 2017 @@ -32,6 +32,7 @@ const Builtin::Info WebAssemblyTargetInf bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const { return llvm::StringSwitch<bool>(Feature) .Case("simd128", SIMDLevel >= SIMD128) + .Case("nontrapping-fptoint", HasNontrappingFPToInt) .Default(false); } @@ -61,6 +62,14 @@ bool WebAssemblyTargetInfo::handleTarget 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"; Modified: cfe/trunk/lib/Basic/Targets/WebAssembly.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/WebAssembly.h?rev=319129&r1=319128&r2=319129&view=diff ============================================================================== --- cfe/trunk/lib/Basic/Targets/WebAssembly.h (original) +++ cfe/trunk/lib/Basic/Targets/WebAssembly.h Mon Nov 27 17:13:45 2017 @@ -30,9 +30,11 @@ class LLVM_LIBRARY_VISIBILITY WebAssembl 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<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector<std::string> &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); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits