diff options
author | Thomas Lively <tlively@google.com> | 2019-03-29 22:00:18 +0000 |
---|---|---|
committer | Thomas Lively <tlively@google.com> | 2019-03-29 22:00:18 +0000 |
commit | 5f0c4c67bbff5374b196578486a16147cb786548 (patch) | |
tree | e66d05e4810f760c273b7a4a3d477ceefd008103 /clang/lib/Basic/Targets/WebAssembly.cpp | |
parent | 32fd32bc6f6de46b96c9e09575694d34f248d6ee (diff) | |
download | bcm5719-llvm-5f0c4c67bbff5374b196578486a16147cb786548.tar.gz bcm5719-llvm-5f0c4c67bbff5374b196578486a16147cb786548.zip |
[WebAssembly] Add mutable globals feature
Summary:
This feature is not actually used for anything in the WebAssembly
backend, but adding it allows users to get it into the target features
sections of their objects, which makes these objects
future-compatible.
Reviewers: aheejin, dschuff
Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, jdoerfert, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D60013
llvm-svn: 357321
Diffstat (limited to 'clang/lib/Basic/Targets/WebAssembly.cpp')
-rw-r--r-- | clang/lib/Basic/Targets/WebAssembly.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp index 4e22abaaa8b..2fceed2ad1f 100644 --- a/clang/lib/Basic/Targets/WebAssembly.cpp +++ b/clang/lib/Basic/Targets/WebAssembly.cpp @@ -42,6 +42,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const { .Case("exception-handling", HasExceptionHandling) .Case("bulk-memory", HasBulkMemory) .Case("atomics", HasAtomics) + .Case("mutable-globals", HasMutableGlobals) .Default(false); } @@ -71,6 +72,8 @@ void WebAssemblyTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__wasm_bulk_memory__"); if (HasAtomics) Builder.defineMacro("__wasm_atomics__"); + if (HasMutableGlobals) + Builder.defineMacro("__wasm_mutable_globals__"); } void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features, @@ -94,6 +97,7 @@ bool WebAssemblyTargetInfo::initFeatureMap( Features["nontrapping-fptoint"] = true; Features["sign-ext"] = true; Features["atomics"] = true; + Features["mutable-globals"] = true; setSIMDLevel(Features, SIMD128); } // Other targets do not consider user-configured features here, but while we @@ -110,6 +114,8 @@ bool WebAssemblyTargetInfo::initFeatureMap( Features["bulk-memory"] = true; if (HasAtomics) Features["atomics"] = true; + if (HasMutableGlobals) + Features["mutable-globals"] = true; return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); } @@ -173,6 +179,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures( HasAtomics = false; continue; } + if (Feature == "+mutable-globals") { + HasMutableGlobals = true; + continue; + } + if (Feature == "-mutable-globals") { + HasMutableGlobals = false; + continue; + } Diags.Report(diag::err_opt_not_valid_with_opt) << Feature << "-target-feature"; |