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 | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp index 2309997eb77b..f1c925d90cb6 100644 --- a/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp +++ b/contrib/llvm-project/clang/lib/Basic/Targets/WebAssembly.cpp @@ -20,13 +20,13 @@ using namespace clang; using namespace clang::targets; -const Builtin::Info WebAssemblyTargetInfo::BuiltinInfo[] = { +static constexpr Builtin::Info BuiltinInfo[] = { #define BUILTIN(ID, TYPE, ATTRS) \ - {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr}, + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \ - {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE}, + {#ID, TYPE, ATTRS, FEATURE, HeaderDesc::NO_HEADER, ALL_LANGUAGES}, #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER) \ - {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr}, + {#ID, TYPE, ATTRS, nullptr, HeaderDesc::HEADER, ALL_LANGUAGES}, #include "clang/Basic/BuiltinsWebAssembly.def" }; @@ -56,6 +56,8 @@ bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const { .Case("multivalue", HasMultivalue) .Case("tail-call", HasTailCall) .Case("reference-types", HasReferenceTypes) + .Case("extended-const", HasExtendedConst) + .Case("multimemory", HasMultiMemory) .Default(false); } @@ -93,6 +95,15 @@ void WebAssemblyTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__wasm_tail_call__"); if (HasReferenceTypes) Builder.defineMacro("__wasm_reference_types__"); + if (HasExtendedConst) + Builder.defineMacro("__wasm_extended_const__"); + if (HasMultiMemory) + Builder.defineMacro("__wasm_multimemory__"); + + Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1"); + Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2"); + Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4"); + Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"); } void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features, @@ -101,10 +112,10 @@ void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features, switch (Level) { case RelaxedSIMD: Features["relaxed-simd"] = true; - LLVM_FALLTHROUGH; + [[fallthrough]]; case SIMD128: Features["simd128"] = true; - LLVM_FALLTHROUGH; + [[fallthrough]]; case NoSIMD: break; } @@ -115,7 +126,7 @@ void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap<bool> &Features, case NoSIMD: case SIMD128: Features["simd128"] = false; - LLVM_FALLTHROUGH; + [[fallthrough]]; case RelaxedSIMD: Features["relaxed-simd"] = false; break; @@ -143,7 +154,12 @@ bool WebAssemblyTargetInfo::initFeatureMap( Features["atomics"] = true; Features["mutable-globals"] = true; Features["tail-call"] = true; + Features["reference-types"] = true; + Features["multimemory"] = true; setSIMDLevel(Features, SIMD128, true); + } else if (CPU == "generic") { + Features["sign-ext"] = true; + Features["mutable-globals"] = true; } return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); @@ -240,6 +256,22 @@ bool WebAssemblyTargetInfo::handleTargetFeatures( HasReferenceTypes = false; continue; } + if (Feature == "+extended-const") { + HasExtendedConst = true; + continue; + } + if (Feature == "-extended-const") { + HasExtendedConst = false; + continue; + } + if (Feature == "+multimemory") { + HasMultiMemory = true; + continue; + } + if (Feature == "-multimemory") { + HasMultiMemory = false; + continue; + } Diags.Report(diag::err_opt_not_valid_with_opt) << Feature << "-target-feature"; @@ -249,15 +281,17 @@ bool WebAssemblyTargetInfo::handleTargetFeatures( } ArrayRef<Builtin::Info> WebAssemblyTargetInfo::getTargetBuiltins() const { - return llvm::makeArrayRef(BuiltinInfo, clang::WebAssembly::LastTSBuiltin - - Builtin::FirstTSBuiltin); + return llvm::ArrayRef(BuiltinInfo, clang::WebAssembly::LastTSBuiltin - + Builtin::FirstTSBuiltin); } void WebAssemblyTargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) { - // If the Atomics feature isn't available, turn off POSIXThreads and - // ThreadModel, so that we don't predefine _REENTRANT or __STDCPP_THREADS__. - if (!HasAtomics) { + TargetInfo::adjust(Diags, Opts); + // Turn off POSIXThreads and ThreadModel so that we don't predefine _REENTRANT + // or __STDCPP_THREADS__ if we will eventually end up stripping atomics + // because they are unsupported. + if (!HasAtomics || !HasBulkMemory) { Opts.POSIXThreads = false; Opts.setThreadModel(LangOptions::ThreadModelKind::Single); Opts.ThreadsafeStatics = false; |