Skip to content

Commit 1e4e243

Browse files
committed
[WebAssembly] Update supported features in the generic CPU configuration
Enable sign-ext and mutable-globals in -mcpu=generic. This makes these features enabled by default. These features are all [finished proposals], and all major wasm engines support them. [finished proposals]: https://github.com/WebAssembly/proposals/blob/main/finished-proposals.md Differential Revision: https://reviews.llvm.org/D125728
1 parent 11afbf3 commit 1e4e243

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

clang/docs/ReleaseNotes.rst

+6
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,12 @@ X86 Support in Clang
607607
* Support intrinsic of ``__cmpccxadd_epi32``.
608608
* Support intrinsic of ``__cmpccxadd_epi64``.
609609

610+
WebAssembly Support in Clang
611+
----------------------------
612+
613+
The -mcpu=generic configuration now enables sign-ext and mutable-globals. These
614+
proposals are standardized and available in all major engines.
615+
610616
DWARF Support in Clang
611617
----------------------
612618

clang/lib/Basic/Targets/WebAssembly.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ bool WebAssemblyTargetInfo::initFeatureMap(
147147
Features["mutable-globals"] = true;
148148
Features["tail-call"] = true;
149149
setSIMDLevel(Features, SIMD128, true);
150+
} else if (CPU == "generic") {
151+
Features["sign-ext"] = true;
152+
Features["mutable-globals"] = true;
150153
}
151154

152155
return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);

clang/test/Driver/wasm-features.c

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// RUN: %clang --target=wasm32-unknown-unknown -### %s -fsyntax-only 2>&1 | FileCheck %s
2+
3+
// CHECK: "-fvisibility=hidden"
4+
5+
// RUN: %clang --target=wasm32-unknown-unknown -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
6+
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mcpu=mvp 2>&1 | FileCheck %s -check-prefix=MVP
7+
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mcpu=bleeding-edge 2>&1 | FileCheck %s -check-prefix=BLEEDING-EDGE
8+
9+
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mbulk-memory 2>&1 | FileCheck %s -check-prefix=BULK-MEMORY
10+
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-bulk-memory 2>&1 | FileCheck %s -check-prefix=NO-BULK-MEMORY
11+
12+
// BULK-MEMORY: "-target-feature" "+bulk-memory"
13+
// NO-BULK-MEMORY: "-target-feature" "-bulk-memory"
14+
// DEFAULT-NOT: "-target-feature" "-bulk-memory"
15+
// MVP-NOT: "-target-feature" "+bulk-memory"
16+
// BLEEDING-EDGE-NOT: "-target-feature" "-bulk-memory"
17+
18+
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mmutable-globals 2>&1 | FileCheck %s -check-prefix=MUTABLE-GLOBALS
19+
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-mutable-globals 2>&1 | FileCheck %s -check-prefix=NO-MUTABLE-GLOBALS
20+
21+
// MUTABLE-GLOBALS: "-target-feature" "+mutable-globals"
22+
// NO-MUTABLE-GLOBALS: "-target-feature" "-mutable-globals"
23+
// DEFAULT-NOT: "-target-feature" "-mutable-globals"
24+
// MVP-NOT: "-target-feature" "+mutable-globals"
25+
// BLEEDING-EDGE-NOT: "-target-feature" "-mutable-globals"
26+
27+
// RUN: %clang --target=wasm32-unknown-unknown -### %s -msign-ext 2>&1 | FileCheck %s -check-prefix=SIGN-EXT
28+
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-sign-ext 2>&1 | FileCheck %s -check-prefix=NO-SIGN-EXT
29+
30+
// SIGN-EXT: "-target-feature" "+sign-ext"
31+
// NO-SIGN-EXT: "-target-feature" "-sign-ext"
32+
// DEFAULT-NOT: "-target-feature" "-sign-ext"
33+
// MVP-NOT: "-target-feature" "+sign-ext"
34+
// BLEEDING-EDGE-NOT: "-target-feature" "-sign-ext"
35+
36+
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mnontrapping-fptoint 2>&1 | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT
37+
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-nontrapping-fptoint 2>&1 | FileCheck %s -check-prefix=NO-NONTRAPPING-FPTOINT
38+
39+
// NONTRAPPING-FPTOINT: "-target-feature" "+nontrapping-fptoint"
40+
// NO-NONTRAPPING-FPTOINT: "-target-feature" "-nontrapping-fptoint"
41+
// DEFAULT-NOT: "-target-feature" "-nontrapping-fptoint"
42+
// MVP-NOT: "-target-feature" "+nontrapping-fptoint"
43+
// BLEEDING-EDGE-NOT: "-target-feature" "-nontrapping-fptoint"

0 commit comments

Comments
 (0)