From: Dan Gohman Date: Fri, 19 Jan 2018 17:16:32 +0000 (+0000) Subject: [WebAssembly] Add target flags for sign-ext opcodes. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d91a0b81e57b81df9c049c2df0f298c39518ba0b;p=clang [WebAssembly] Add target flags for sign-ext opcodes. Add -msign-ext and -mno-sign-ext to control the new sign-ext target feature. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322967 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/ClangCommandLineReference.rst b/docs/ClangCommandLineReference.rst index 782d225dce..1cbb3b8dc6 100644 --- a/docs/ClangCommandLineReference.rst +++ b/docs/ClangCommandLineReference.rst @@ -2320,6 +2320,8 @@ WebAssembly ----------- .. option:: -mnontrapping-fptoint, -mno-nontrapping-fptoint +.. option:: -msign-ext, -mno-sign-ext + .. option:: -msimd128, -mno-simd128 X86 diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 821837d5e6..128960382e 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -1870,6 +1870,8 @@ 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 msign_ext : Flag<["-"], "msign-ext">, Group; +def mno_sign_ext : Flag<["-"], "mno-sign-ext">, 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 915aad4b56..ecccb58865 100644 --- a/lib/Basic/Targets/WebAssembly.cpp +++ b/lib/Basic/Targets/WebAssembly.cpp @@ -33,6 +33,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const { return llvm::StringSwitch(Feature) .Case("simd128", SIMDLevel >= SIMD128) .Case("nontrapping-fptoint", HasNontrappingFPToInt) + .Case("sign-ext", HasSignExt) .Default(false); } @@ -70,6 +71,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures( HasNontrappingFPToInt = false; continue; } + if (Feature == "+sign-ext") { + HasSignExt = true; + continue; + } + if (Feature == "-sign-ext") { + HasSignExt = 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 ee0073d081..b07e849949 100644 --- a/lib/Basic/Targets/WebAssembly.h +++ b/lib/Basic/Targets/WebAssembly.h @@ -31,10 +31,12 @@ class LLVM_LIBRARY_VISIBILITY WebAssemblyTargetInfo : public TargetInfo { } SIMDLevel; bool HasNontrappingFPToInt; + bool HasSignExt; public: explicit WebAssemblyTargetInfo(const llvm::Triple &T, const TargetOptions &) - : TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false) { + : TargetInfo(T), SIMDLevel(NoSIMD), HasNontrappingFPToInt(false), + HasSignExt(false) { NoAsmVariants = true; SuitableAlign = 128; LargeArrayMinWidth = 128; @@ -60,6 +62,7 @@ private: if (CPU == "bleeding-edge") { Features["simd128"] = true; Features["nontrapping-fptoint"] = true; + Features["sign-ext"] = true; } return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); }