aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/Targets/WebAssembly.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Basic/Targets/WebAssembly.cpp')
-rw-r--r--clang/lib/Basic/Targets/WebAssembly.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp
index 0b380bd..d9d01bc 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -47,6 +47,8 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
return llvm::StringSwitch<bool>(Feature)
.Case("atomics", HasAtomics)
.Case("bulk-memory", HasBulkMemory)
+ .Case("bulk-memory-opt", HasBulkMemoryOpt)
+ .Case("call-indirect-overlong", HasCallIndirectOverlong)
.Case("exception-handling", HasExceptionHandling)
.Case("extended-const", HasExtendedConst)
.Case("fp16", HasFP16)
@@ -79,6 +81,8 @@ void WebAssemblyTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__wasm_atomics__");
if (HasBulkMemory)
Builder.defineMacro("__wasm_bulk_memory__");
+ if (HasBulkMemoryOpt)
+ Builder.defineMacro("__wasm_bulk_memory_opt__");
if (HasExceptionHandling)
Builder.defineMacro("__wasm_exception_handling__");
if (HasExtendedConst)
@@ -155,6 +159,8 @@ bool WebAssemblyTargetInfo::initFeatureMap(
const std::vector<std::string> &FeaturesVec) const {
auto addGenericFeatures = [&]() {
Features["bulk-memory"] = true;
+ Features["bulk-memory-opt"] = true;
+ Features["call-indirect-overlong"] = true;
Features["multivalue"] = true;
Features["mutable-globals"] = true;
Features["nontrapping-fptoint"] = true;
@@ -200,6 +206,22 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
HasBulkMemory = false;
continue;
}
+ if (Feature == "+bulk-memory-opt") {
+ HasBulkMemoryOpt = true;
+ continue;
+ }
+ if (Feature == "-bulk-memory-opt") {
+ HasBulkMemoryOpt = false;
+ continue;
+ }
+ if (Feature == "+call-indirect-overlong") {
+ HasCallIndirectOverlong = true;
+ continue;
+ }
+ if (Feature == "-call-indirect-overlong") {
+ HasCallIndirectOverlong = false;
+ continue;
+ }
if (Feature == "+exception-handling") {
HasExceptionHandling = true;
continue;
@@ -310,6 +332,18 @@ bool WebAssemblyTargetInfo::handleTargetFeatures(
<< Feature << "-target-feature";
return false;
}
+
+ // bulk-memory-opt is a subset of bulk-memory.
+ if (HasBulkMemory) {
+ HasBulkMemoryOpt = true;
+ }
+
+ // The reference-types feature included the change to `call_indirect`
+ // encodings to support overlong immediates.
+ if (HasReferenceTypes) {
+ HasCallIndirectOverlong = true;
+ }
+
return true;
}