diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp index b16442b99b62..6746768090f5 100644 --- a/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp +++ b/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp @@ -33,6 +33,16 @@ const Builtin::Info WebAssemblyTargetInfo::BuiltinInfo[] = { static constexpr llvm::StringLiteral ValidCPUNames[] = { {"mvp"}, {"bleeding-edge"}, {"generic"}}; +StringRef WebAssemblyTargetInfo::getABI() const { return ABI; } + +bool WebAssemblyTargetInfo::setABI(const std::string &Name) { + if (Name != "mvp" && Name != "experimental-mv") + return false; + + ABI = Name; + return true; +} + bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const { return llvm::StringSwitch<bool>(Feature) .Case("simd128", SIMDLevel >= SIMD128) @@ -45,6 +55,7 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const { .Case("mutable-globals", HasMutableGlobals) .Case("multivalue", HasMultivalue) .Case("tail-call", HasTailCall) + .Case("reference-types", HasReferenceTypes) .Default(false); } @@ -80,6 +91,8 @@ void WebAssemblyTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__wasm_multivalue__"); if (HasTailCall) Builder.defineMacro("__wasm_tail_call__"); + if (HasReferenceTypes) + Builder.defineMacro("__wasm_reference_types__"); } void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features, @@ -102,8 +115,10 @@ bool WebAssemblyTargetInfo::initFeatureMap( if (CPU == "bleeding-edge") { Features["nontrapping-fptoint"] = true; Features["sign-ext"] = true; + Features["bulk-memory"] = true; Features["atomics"] = true; Features["mutable-globals"] = true; + Features["tail-call"] = true; setSIMDLevel(Features, SIMD128); } // Other targets do not consider user-configured features here, but while we @@ -126,6 +141,8 @@ bool WebAssemblyTargetInfo::initFeatureMap( Features["multivalue"] = true; if (HasTailCall) Features["tail-call"] = true; + if (HasReferenceTypes) + Features["reference-types"] = true; return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); } @@ -213,6 +230,14 @@ bool WebAssemblyTargetInfo::handleTargetFeatures( HasTailCall = false; continue; } + if (Feature == "+reference-types") { + HasReferenceTypes = true; + continue; + } + if (Feature == "-reference-types") { + HasReferenceTypes = false; + continue; + } Diags.Report(diag::err_opt_not_valid_with_opt) << Feature << "-target-feature"; |