[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-29 Thread Heejin Ahn via cfe-commits

https://github.com/aheejin closed 
https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-29 Thread Heejin Ahn via cfe-commits

https://github.com/aheejin edited 
https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-29 Thread Heejin Ahn via cfe-commits

https://github.com/aheejin edited 
https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-24 Thread Heejin Ahn via cfe-commits

https://github.com/aheejin updated 
https://github.com/llvm/llvm-project/pull/80923

>From d6fd48794112d6c140024d7cd55b5fe5e55e Mon Sep 17 00:00:00 2001
From: Heejin Ahn 
Date: Tue, 6 Feb 2024 00:31:59 +
Subject: [PATCH 1/5] [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 WebAssemblyTargetInfo::initFeatureMap(
 llvm::StringMap , DiagnosticsEngine , StringRef CPU,
 const std::vector ) 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 
Date: Fri, 23 Feb 2024 00:31:41 +
Subject: [PATCH 2/5] 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 
Date: Tue, 23 Apr 2024 13:21:15 +
Subject: [PATCH 3/5] Enable only multivalue and reference types

---
 clang/docs/ReleaseNotes.rst|  8 
 

[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Heejin Ahn via cfe-commits

https://github.com/aheejin updated 
https://github.com/llvm/llvm-project/pull/80923

>From d6fd48794112d6c140024d7cd55b5fe5e55e Mon Sep 17 00:00:00 2001
From: Heejin Ahn 
Date: Tue, 6 Feb 2024 00:31:59 +
Subject: [PATCH 1/5] [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 WebAssemblyTargetInfo::initFeatureMap(
 llvm::StringMap , DiagnosticsEngine , StringRef CPU,
 const std::vector ) 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 
Date: Fri, 23 Feb 2024 00:31:41 +
Subject: [PATCH 2/5] 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 
Date: Tue, 23 Apr 2024 13:21:15 +
Subject: [PATCH 3/5] Enable only multivalue and reference types

---
 clang/docs/ReleaseNotes.rst|  8 
 

[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Derek Schuff via cfe-commits

https://github.com/dschuff approved this pull request.

(also LGTM FTR)

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Derek Schuff via cfe-commits

https://github.com/dschuff edited 
https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Derek Schuff via cfe-commits


@@ -147,19 +147,25 @@ void 
WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap ,
 bool WebAssemblyTargetInfo::initFeatureMap(
 llvm::StringMap , DiagnosticsEngine , StringRef CPU,
 const std::vector ) const {
-  if (CPU == "bleeding-edge") {
-Features["nontrapping-fptoint"] = true;
+  auto addGenericFeatures = [&]() {
 Features["sign-ext"] = true;
+Features["mutable-globals"] = true;
+Features["reference-types"] = true;
+Features["multivalue"] = true;
+  };
+  auto addBleedingEdgeFeatures = [&]() {
+addGenericFeatures();
+Features["nontrapping-fptoint"] = true;

dschuff wrote:

MV and reftypes are required to use exnref, that's the thing that's on the 
critical path here. So yes, we definitely want to land these two without 
blocking on nontrapping-fptoint.

Relatedly (to nontrapping-fptoint, but unrelatedly to this PR), I prototyped a 
Binaryen pass to lower away LLVM's use of nontrapping-fptoint* which is what 
would allow us to improve codegen. I think it works, but I discovered that some 
of emscripten's tests fail when we enable nontrapping fptoint, and I haven't 
yet looked at why that's the case (either a bug in emscripten's tests, or a bug 
in V8's implementation of nontrapping fptoint). We'd need to also fix that to 
unblock enabling this. 

* (This isn't exactly the same as a full lowering of nontrapping-fptoint as 
spec'ed, because it takes advantage of knowledge of the semantics of LLVM's 
fptosi intrinsics)

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Sam Clegg via cfe-commits


@@ -147,19 +147,25 @@ void 
WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap ,
 bool WebAssemblyTargetInfo::initFeatureMap(
 llvm::StringMap , DiagnosticsEngine , StringRef CPU,
 const std::vector ) const {
-  if (CPU == "bleeding-edge") {
-Features["nontrapping-fptoint"] = true;
+  auto addGenericFeatures = [&]() {
 Features["sign-ext"] = true;
+Features["mutable-globals"] = true;
+Features["reference-types"] = true;
+Features["multivalue"] = true;
+  };
+  auto addBleedingEdgeFeatures = [&]() {
+addGenericFeatures();
+Features["nontrapping-fptoint"] = true;

sbc100 wrote:

I'm a bit sad not to see this added, since this is the one that can actually 
improve codegen.   If we know we want to enable to this, is there any downside 
to doing two different rounds (i.e. are there advantages to waiting on this 
until we have the lowering pass in place?)

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Thomas Lively via cfe-commits


@@ -147,19 +147,25 @@ void 
WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap ,
 bool WebAssemblyTargetInfo::initFeatureMap(
 llvm::StringMap , DiagnosticsEngine , StringRef CPU,
 const std::vector ) const {
-  if (CPU == "bleeding-edge") {
-Features["nontrapping-fptoint"] = true;
+  auto addGenericFeatures = [&]() {
 Features["sign-ext"] = true;
+Features["mutable-globals"] = true;
+Features["reference-types"] = true;
+Features["multivalue"] = true;
+  };
+  auto addBleedingEdgeFeatures = [&]() {
+addGenericFeatures();
+Features["nontrapping-fptoint"] = true;

tlively wrote:

Oh, I see, if we think we would need a Binaryen lowering pass first, then 
proceeding without this SGTM.

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Thomas Lively via cfe-commits


@@ -147,19 +147,25 @@ void 
WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap ,
 bool WebAssemblyTargetInfo::initFeatureMap(
 llvm::StringMap , DiagnosticsEngine , StringRef CPU,
 const std::vector ) const {
-  if (CPU == "bleeding-edge") {
-Features["nontrapping-fptoint"] = true;
+  auto addGenericFeatures = [&]() {
 Features["sign-ext"] = true;
+Features["mutable-globals"] = true;
+Features["reference-types"] = true;
+Features["multivalue"] = true;
+  };
+  auto addBleedingEdgeFeatures = [&]() {
+addGenericFeatures();
+Features["nontrapping-fptoint"] = true;

tlively wrote:

Looks like this was enabled in Safari in September 2021. Should we enable this 
by default as well?

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Thomas Lively via cfe-commits

https://github.com/tlively approved this pull request.


https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Thomas Lively via cfe-commits

https://github.com/tlively edited 
https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Derek Schuff via cfe-commits

dschuff wrote:

I think "generic" is the default CPU so object files will have it enabled by 
default. You can still specify "mvp" as the CPU as before to avoid it.

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Sam Clegg via cfe-commits

sbc100 wrote:

After this lands does that mean that all object files will have `multi-value` 
in the features section?  Or only object files that actually use `mutli-value`? 
   

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Alon Zakai via cfe-commits


@@ -668,6 +668,11 @@ AIX Support
 WebAssembly Support
 ^^^
 
+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.

kripken wrote:

Maybe worth adding something like this:
```suggestion
multivalue ABI (this enables non-ABI uses of multivalue, like exnref).
```

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Alon Zakai via cfe-commits

https://github.com/kripken edited 
https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Alon Zakai via cfe-commits

https://github.com/kripken commented:

Enabling multivalue and reference-types first sgtm.

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Heejin Ahn via cfe-commits

https://github.com/aheejin updated 
https://github.com/llvm/llvm-project/pull/80923

>From d6fd48794112d6c140024d7cd55b5fe5e55e Mon Sep 17 00:00:00 2001
From: Heejin Ahn 
Date: Tue, 6 Feb 2024 00:31:59 +
Subject: [PATCH 1/4] [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 WebAssemblyTargetInfo::initFeatureMap(
 llvm::StringMap , DiagnosticsEngine , StringRef CPU,
 const std::vector ) 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 
Date: Fri, 23 Feb 2024 00:31:41 +
Subject: [PATCH 2/4] 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 
Date: Tue, 23 Apr 2024 13:21:15 +
Subject: [PATCH 3/4] Enable only multivalue and reference types

---
 clang/docs/ReleaseNotes.rst|  8 
 

[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Heejin Ahn via cfe-commits

aheejin wrote:

cc @kripken too (You don't show up in the reviewers list, so I couldn't add you)

https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [WebAssembly] Enable multivalue and reference-types in generic CPU config (PR #80923)

2024-04-23 Thread Heejin Ahn via cfe-commits

https://github.com/aheejin edited 
https://github.com/llvm/llvm-project/pull/80923
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits