https://github.com/aheejin updated https://github.com/llvm/llvm-project/pull/80923
>From d6fd48794112d6c1402222024d7cd55b5fe5e55e Mon Sep 17 00:00:00 2001 From: Heejin Ahn <ahee...@gmail.com> Date: Tue, 6 Feb 2024 00:31:59 +0000 Subject: [PATCH 1/3] [WebAssembly] Add more features to generic CPU config This enables nontrapping-fptoint, multivlaue, reference-types, and bulk-memory in `-mcpu=generic` configuration. These proposals have been standardized and supported in all major browsers for several years at this point: https://github.com/WebAssembly/proposals/blob/main/finished-proposals.md --- clang/docs/ReleaseNotes.rst | 4 ++++ clang/lib/Basic/Targets/WebAssembly.cpp | 18 ++++++++++++------ clang/test/Preprocessor/wasm-target-features.c | 8 ++++---- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 802c44b6c86080..5a07dcca106876 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -259,6 +259,10 @@ AIX Support WebAssembly Support ^^^^^^^^^^^^^^^^^^^ +The -mcpu=generic configuration now enables nontrapping-fptoint, multivalue, +reference-types, and bulk-memory.These proposals are standardized and available +in all major engines. + AVR Support ^^^^^^^^^^^ diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp index f1c925d90cb649..38fe4013090f40 100644 --- a/clang/lib/Basic/Targets/WebAssembly.cpp +++ b/clang/lib/Basic/Targets/WebAssembly.cpp @@ -147,19 +147,25 @@ void WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features, bool WebAssemblyTargetInfo::initFeatureMap( llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU, const std::vector<std::string> &FeaturesVec) const { - if (CPU == "bleeding-edge") { - Features["nontrapping-fptoint"] = true; + auto addGenericFeatures = [&]() { Features["sign-ext"] = true; + Features["mutable-globals"] = true; + Features["nontrapping-fptoint"] = true; Features["bulk-memory"] = true; + Features["reference-types"] = true; + Features["multivalue"] = true; + }; + auto addBleedingEdgeFeatures = [&]() { Features["atomics"] = true; - Features["mutable-globals"] = true; Features["tail-call"] = true; - Features["reference-types"] = true; Features["multimemory"] = true; setSIMDLevel(Features, SIMD128, true); + }; + if (CPU == "bleeding-edge") { + addGenericFeatures(); + addBleedingEdgeFeatures(); } else if (CPU == "generic") { - Features["sign-ext"] = true; - Features["mutable-globals"] = true; + addGenericFeatures(); } return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); diff --git a/clang/test/Preprocessor/wasm-target-features.c b/clang/test/Preprocessor/wasm-target-features.c index eccd432aa8eee6..5834e6d183bc9c 100644 --- a/clang/test/Preprocessor/wasm-target-features.c +++ b/clang/test/Preprocessor/wasm-target-features.c @@ -155,15 +155,15 @@ // // GENERIC-DAG:#define __wasm_sign_ext__ 1{{$}} // GENERIC-DAG:#define __wasm_mutable_globals__ 1{{$}} -// GENERIC-NOT:#define __wasm_nontrapping_fptoint__ 1{{$}} -// GENERIC-NOT:#define __wasm_bulk_memory__ 1{{$}} +// GENERIC-DAG:#define __wasm_nontrapping_fptoint__ 1{{$}} +// GENERIC-DAG:#define __wasm_bulk_memory__ 1{{$}} +// GENERIC-DAG:#define __wasm_multivalue__ 1{{$}} +// GENERIC-DAG:#define __wasm_reference_types__ 1{{$}} // GENERIC-NOT:#define __wasm_simd128__ 1{{$}} // GENERIC-NOT:#define __wasm_atomics__ 1{{$}} // GENERIC-NOT:#define __wasm_tail_call__ 1{{$}} // GENERIC-NOT:#define __wasm_multimemory__ 1{{$}} // GENERIC-NOT:#define __wasm_exception_handling__ 1{{$}} -// GENERIC-NOT:#define __wasm_multivalue__ 1{{$}} -// GENERIC-NOT:#define __wasm_reference_types__ 1{{$}} // GENERIC-NOT:#define __wasm_extended_const__ 1{{$}} // RUN: %clang -E -dM %s -o - 2>&1 \ >From 01ac8bd38aaa86e62b00709790a36e050528f853 Mon Sep 17 00:00:00 2001 From: Heejin Ahn <ahee...@gmail.com> Date: Fri, 23 Feb 2024 00:31:41 +0000 Subject: [PATCH 2/3] Mention that ABI is not turned on --- clang/docs/ReleaseNotes.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 5a07dcca106876..ec85d8882c1861 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -261,7 +261,8 @@ WebAssembly Support The -mcpu=generic configuration now enables nontrapping-fptoint, multivalue, reference-types, and bulk-memory.These proposals are standardized and available -in all major engines. +in all major engines. Enabling multivalue here only enables the language feature +but does not turn on the multivalue ABI. AVR Support ^^^^^^^^^^^ >From de6aa6aa0891bb11ae7402d2cbccbcd82cd4fc77 Mon Sep 17 00:00:00 2001 From: Heejin Ahn <ahee...@gmail.com> Date: Tue, 23 Apr 2024 13:21:15 +0000 Subject: [PATCH 3/3] Enable only multivalue and reference types --- clang/docs/ReleaseNotes.rst | 8 ++++---- clang/lib/Basic/Targets/WebAssembly.cpp | 10 +++++----- clang/test/Preprocessor/wasm-target-features.c | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 731dc198559928..68a16c00311523 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -668,10 +668,10 @@ AIX Support WebAssembly Support ^^^^^^^^^^^^^^^^^^^ -The -mcpu=generic configuration now enables nontrapping-fptoint, multivalue, -reference-types, and bulk-memory.These proposals are standardized and available -in all major engines. Enabling multivalue here only enables the language feature -but does not turn on the multivalue ABI. +The -mcpu=generic configuration now enables multivalue and reference-types.These +proposals are standardized and available in all major engines. Enabling +multivalue here only enables the language feature but does not turn on the +multivalue ABI. AVR Support ^^^^^^^^^^^ diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp index 38fe4013090f40..dd366093547308 100644 --- a/clang/lib/Basic/Targets/WebAssembly.cpp +++ b/clang/lib/Basic/Targets/WebAssembly.cpp @@ -150,22 +150,22 @@ bool WebAssemblyTargetInfo::initFeatureMap( auto addGenericFeatures = [&]() { Features["sign-ext"] = true; Features["mutable-globals"] = true; - Features["nontrapping-fptoint"] = true; - Features["bulk-memory"] = true; Features["reference-types"] = true; Features["multivalue"] = true; }; auto addBleedingEdgeFeatures = [&]() { + addGenericFeatures(); + Features["nontrapping-fptoint"] = true; + Features["bulk-memory"] = true; Features["atomics"] = true; Features["tail-call"] = true; Features["multimemory"] = true; setSIMDLevel(Features, SIMD128, true); }; - if (CPU == "bleeding-edge") { + if (CPU == "generic") { addGenericFeatures(); + } else if (CPU == "bleeding-edge") { addBleedingEdgeFeatures(); - } else if (CPU == "generic") { - addGenericFeatures(); } return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec); diff --git a/clang/test/Preprocessor/wasm-target-features.c b/clang/test/Preprocessor/wasm-target-features.c index 5834e6d183bc9c..150b4f4a6a8897 100644 --- a/clang/test/Preprocessor/wasm-target-features.c +++ b/clang/test/Preprocessor/wasm-target-features.c @@ -155,10 +155,10 @@ // // GENERIC-DAG:#define __wasm_sign_ext__ 1{{$}} // GENERIC-DAG:#define __wasm_mutable_globals__ 1{{$}} -// GENERIC-DAG:#define __wasm_nontrapping_fptoint__ 1{{$}} -// GENERIC-DAG:#define __wasm_bulk_memory__ 1{{$}} // GENERIC-DAG:#define __wasm_multivalue__ 1{{$}} // GENERIC-DAG:#define __wasm_reference_types__ 1{{$}} +// GENERIC-NOT:#define __wasm_nontrapping_fptoint__ 1{{$}} +// GENERIC-NOT:#define __wasm_bulk_memory__ 1{{$}} // GENERIC-NOT:#define __wasm_simd128__ 1{{$}} // GENERIC-NOT:#define __wasm_atomics__ 1{{$}} // GENERIC-NOT:#define __wasm_tail_call__ 1{{$}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits