summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2017-11-28 01:13:45 +0000
committerDan Gohman <dan433584@gmail.com>2017-11-28 01:13:45 +0000
commit0811cd1d158ee9f43948d2897ff02bcb34bc0a44 (patch)
treebb837e7e8faea7e472c5a07046358021b01e71e1 /clang
parentcdd48b8a6b08a1feb6acbc407b5735ed7e7dfead (diff)
downloadbcm5719-llvm-0811cd1d158ee9f43948d2897ff02bcb34bc0a44.tar.gz
bcm5719-llvm-0811cd1d158ee9f43948d2897ff02bcb34bc0a44.zip
[WebAssembly] Add options for using the nontrapping-fptoint feature.
This adds ways to control use of WebAssembly's new nontrapping-fptoint feature. llvm-svn: 319129
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/Driver/Options.td2
-rw-r--r--clang/lib/Basic/Targets/WebAssembly.cpp9
-rw-r--r--clang/lib/Basic/Targets/WebAssembly.h8
3 files changed, 17 insertions, 2 deletions
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 15a752b354a..9f8684ddee8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1837,6 +1837,8 @@ def ffixed_x18 : Flag<["-"], "ffixed-x18">, Group<m_aarch64_Features_Group>,
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]>,
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp
index 9eaaf8d4fdc..915aad4b563 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -32,6 +32,7 @@ const Builtin::Info WebAssemblyTargetInfo::BuiltinInfo[] = {
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::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/clang/lib/Basic/Targets/WebAssembly.h b/clang/lib/Basic/Targets/WebAssembly.h
index 20f57506d9f..ee0073d081e 100644
--- a/clang/lib/Basic/Targets/WebAssembly.h
+++ b/clang/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<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);
}
OpenPOWER on IntegriCloud