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.cpp60
1 files changed, 31 insertions, 29 deletions
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp
index 6746768090f5..dcb3d8fd7790 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -96,19 +96,43 @@ void WebAssemblyTargetInfo::getTargetDefines(const LangOptions &Opts,
}
void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features,
- SIMDEnum Level) {
+ SIMDEnum Level, bool Enabled) {
+ if (Enabled) {
+ switch (Level) {
+ case UnimplementedSIMD128:
+ Features["unimplemented-simd128"] = true;
+ LLVM_FALLTHROUGH;
+ case SIMD128:
+ Features["simd128"] = true;
+ LLVM_FALLTHROUGH;
+ case NoSIMD:
+ break;
+ }
+ return;
+ }
+
switch (Level) {
- case UnimplementedSIMD128:
- Features["unimplemented-simd128"] = true;
- LLVM_FALLTHROUGH;
+ case NoSIMD:
case SIMD128:
- Features["simd128"] = true;
+ Features["simd128"] = false;
LLVM_FALLTHROUGH;
- case NoSIMD:
+ case UnimplementedSIMD128:
+ Features["unimplemented-simd128"] = false;
break;
}
}
+void WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
+ StringRef Name,
+ bool Enabled) const {
+ if (Name == "simd128")
+ setSIMDLevel(Features, SIMD128, Enabled);
+ else if (Name == "unimplemented-simd128")
+ setSIMDLevel(Features, UnimplementedSIMD128, Enabled);
+ else
+ Features[Name] = Enabled;
+}
+
bool WebAssemblyTargetInfo::initFeatureMap(
llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
const std::vector<std::string> &FeaturesVec) const {
@@ -119,30 +143,8 @@ bool WebAssemblyTargetInfo::initFeatureMap(
Features["atomics"] = true;
Features["mutable-globals"] = true;
Features["tail-call"] = true;
- setSIMDLevel(Features, SIMD128);
+ setSIMDLevel(Features, SIMD128, true);
}
- // Other targets do not consider user-configured features here, but while we
- // are actively developing new features it is useful to let user-configured
- // features control availability of builtins
- setSIMDLevel(Features, SIMDLevel);
- if (HasNontrappingFPToInt)
- Features["nontrapping-fptoint"] = true;
- if (HasSignExt)
- Features["sign-ext"] = true;
- if (HasExceptionHandling)
- Features["exception-handling"] = true;
- if (HasBulkMemory)
- Features["bulk-memory"] = true;
- if (HasAtomics)
- Features["atomics"] = true;
- if (HasMutableGlobals)
- Features["mutable-globals"] = true;
- if (HasMultivalue)
- Features["multivalue"] = true;
- if (HasTailCall)
- Features["tail-call"] = true;
- if (HasReferenceTypes)
- Features["reference-types"] = true;
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
}