[WebAssembly] Add bulk memory target feature
Summary: Also clean up some preexisting target feature code.
Reviewers: aheejin
Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, jfb
Differential Revision: https://reviews.llvm.org/D57495
llvm-svn: 352793
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp
index 7e6a113..48edade 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -40,6 +40,7 @@
.Case("nontrapping-fptoint", HasNontrappingFPToInt)
.Case("sign-ext", HasSignExt)
.Case("exception-handling", HasExceptionHandling)
+ .Case("bulk-memory", HasBulkMemory)
.Default(false);
}
@@ -59,6 +60,14 @@
Builder.defineMacro("__wasm_simd128__");
if (SIMDLevel >= UnimplementedSIMD128)
Builder.defineMacro("__wasm_unimplemented_simd128__");
+ if (HasNontrappingFPToInt)
+ Builder.defineMacro("__wasm_nontrapping_fptoint__");
+ if (HasSignExt)
+ Builder.defineMacro("__wasm_sign_ext__");
+ if (HasExceptionHandling)
+ Builder.defineMacro("__wasm_exception_handling__");
+ if (HasBulkMemory)
+ Builder.defineMacro("__wasm_bulk_memory__");
}
void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features,
@@ -93,6 +102,8 @@
Features["sign-ext"] = true;
if (HasExceptionHandling)
Features["exception-handling"] = true;
+ if (HasBulkMemory)
+ Features["bulk-memory"] = true;
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
}
@@ -140,6 +151,14 @@
HasExceptionHandling = false;
continue;
}
+ if (Feature == "+bulk-memory") {
+ HasBulkMemory = true;
+ continue;
+ }
+ if (Feature == "-bulk-memory") {
+ HasBulkMemory = false;
+ continue;
+ }
Diags.Report(diag::err_opt_not_valid_with_opt)
<< Feature << "-target-feature";