[clang] [llvm] [WebAssembly] Enable extended-const feature by default (PR #127721)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 18 15:46:53 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Sam Clegg (sbc100)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/127721.diff


6 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+7) 
- (modified) clang/lib/Basic/Targets/WebAssembly.cpp (+1) 
- (modified) clang/test/Preprocessor/wasm-target-features.c (+1-1) 
- (modified) llvm/docs/ReleaseNotes.md (+7) 
- (modified) llvm/lib/Target/WebAssembly/WebAssembly.td (+4-3) 
- (modified) llvm/test/CodeGen/WebAssembly/target-features-cpus.ll (+4-1) 


``````````diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6056a6964fbcc..7b90d4686d96f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -235,6 +235,13 @@ NetBSD Support
 WebAssembly Support
 ^^^^^^^^^^^^^^^^^^^
 
+The default target CPU, "generic", now enables the `-mextended-const`
+flag, which correspond to the [Extended Const] proposal, which is
+[widely implemented in engines].
+
+[Extended Const]: https://github.com/WebAssembly/extended-const
+[widely implemented in engines]: https://webassembly.org/features/
+
 AVR Support
 ^^^^^^^^^^^
 
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp
index f19c57f1a3a50..848b28441e22d 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -168,6 +168,7 @@ bool WebAssemblyTargetInfo::initFeatureMap(
     Features["bulk-memory"] = true;
     Features["bulk-memory-opt"] = true;
     Features["call-indirect-overlong"] = true;
+    Features["extended-const"] = true;
     Features["multivalue"] = true;
     Features["mutable-globals"] = true;
     Features["nontrapping-fptoint"] = true;
diff --git a/clang/test/Preprocessor/wasm-target-features.c b/clang/test/Preprocessor/wasm-target-features.c
index 71b7cf6a5d43c..ed1917b7e1b77 100644
--- a/clang/test/Preprocessor/wasm-target-features.c
+++ b/clang/test/Preprocessor/wasm-target-features.c
@@ -164,6 +164,7 @@
 // RUN:   | FileCheck %s -check-prefix=GENERIC-INCLUDE
 //
 // GENERIC-INCLUDE-DAG: #define __wasm_bulk_memory__ 1{{$}}
+// GENERIC-INCLUDE-DAG: #define __wasm_extended_const__ 1{{$}}
 // GENERIC-INCLUDE-DAG: #define __wasm_multivalue__ 1{{$}}
 // GENERIC-INCLUDE-DAG: #define __wasm_mutable_globals__ 1{{$}}
 // GENERIC-INCLUDE-DAG: #define __wasm_nontrapping_fptoint__ 1{{$}}
@@ -179,7 +180,6 @@
 //
 // GENERIC-NOT: #define __wasm_atomics__ 1{{$}}
 // GENERIC-NOT: #define __wasm_exception_handling__ 1{{$}}
-// GENERIC-NOT: #define __wasm_extended_const__ 1{{$}}
 // GENERIC-NOT: #define __wasm__fp16__ 1{{$}}
 // GENERIC-NOT: #define __wasm_multimemory__ 1{{$}}
 // GENERIC-NOT: #define __wasm_relaxed_simd__ 1{{$}}
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index c9543ff09217a..e83962184d953 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -110,6 +110,13 @@ Changes to the RISC-V Backend
 Changes to the WebAssembly Backend
 ----------------------------------
 
+The default target CPU, "generic", now enables the `-mextended-const`
+flag, which correspond to the [Extended Const] proposal, which is
+[widely implemented in engines].
+
+[Extended Const]: https://github.com/WebAssembly/extended-const
+[widely implemented in engines]: https://webassembly.org/features/
+
 Changes to the Windows Target
 -----------------------------
 
diff --git a/llvm/lib/Target/WebAssembly/WebAssembly.td b/llvm/lib/Target/WebAssembly/WebAssembly.td
index 13603f8181198..d574f27f2f226 100644
--- a/llvm/lib/Target/WebAssembly/WebAssembly.td
+++ b/llvm/lib/Target/WebAssembly/WebAssembly.td
@@ -123,9 +123,10 @@ def : ProcessorModel<"mvp", NoSchedModel, []>;
 // the importance of the features.
 def : ProcessorModel<"generic", NoSchedModel,
                       [FeatureBulkMemory, FeatureBulkMemoryOpt,
-                       FeatureCallIndirectOverlong, FeatureMultivalue,
-                       FeatureMutableGlobals, FeatureNontrappingFPToInt,
-                       FeatureReferenceTypes, FeatureSignExt]>;
+                       FeatureCallIndirectOverlong, FeatureExtendedConst,
+                       FeatureMultivalue, FeatureMutableGlobals,
+                       FeatureNontrappingFPToInt, FeatureReferenceTypes,
+                       FeatureSignExt]>;
 
 // Lime1: <https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1>
 def : ProcessorModel<"lime1", NoSchedModel,
diff --git a/llvm/test/CodeGen/WebAssembly/target-features-cpus.ll b/llvm/test/CodeGen/WebAssembly/target-features-cpus.ll
index 1c77ad5c049a5..e363910726934 100644
--- a/llvm/test/CodeGen/WebAssembly/target-features-cpus.ll
+++ b/llvm/test/CodeGen/WebAssembly/target-features-cpus.ll
@@ -14,7 +14,7 @@ target triple = "wasm32-unknown-unknown"
 
 ; generic: +call-indirect-overlong, +multivalue, +mutable-globals, +reference-types, +sign-ext
 ; GENERIC-LABEL: .custom_section.target_features,"",@
-; GENERIC-NEXT: .int8  8
+; GENERIC-NEXT: .int8  9
 ; GENERIC-NEXT: .int8  43
 ; GENERIC-NEXT: .int8  11
 ; GENERIC-NEXT: .ascii  "bulk-memory"
@@ -25,6 +25,9 @@ target triple = "wasm32-unknown-unknown"
 ; GENERIC-NEXT: .int8  22
 ; GENERIC-NEXT: .ascii  "call-indirect-overlong"
 ; GENERIC-NEXT: .int8  43
+; GENERIC-NEXT: .int8  14
+; GENERIC-NEXT: .ascii  "extended-const"
+; GENERIC-NEXT: .int8  43
 ; GENERIC-NEXT: .int8  10
 ; GENERIC-NEXT: .ascii  "multivalue"
 ; GENERIC-NEXT: .int8  43

``````````

</details>


https://github.com/llvm/llvm-project/pull/127721


More information about the llvm-commits mailing list