[PATCH] D125728: [WebAssembly] Update supported features in -mcpu=generic

Dan Gohman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 20 14:46:46 PDT 2022


sunfish updated this revision to Diff 431064.
sunfish added a comment.

Add a driver test, and add release notes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125728/new/

https://reviews.llvm.org/D125728

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/test/Driver/wasm-features.c


Index: clang/test/Driver/wasm-features.c
===================================================================
--- clang/test/Driver/wasm-features.c
+++ clang/test/Driver/wasm-features.c
@@ -0,0 +1,33 @@
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -fsyntax-only 2>&1 | FileCheck %s
+
+// CHECK: "-fvisibility" "hidden"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mbulk-memory 2>&1 | FileCheck %s -check-prefix=BULK-MEMORY
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-bulk-memory 2>&1 | FileCheck %s -check-prefix=NO-BULK-MEMORY
+
+// BULK-MEMORY: "-target-feature" "+bulk-memory"
+// NO-BULK-MEMORY: "-target-feature" "-bulk-memory"
+// DEFAULT-NOT: "-target-feature" "-bulk-memory"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mmutable-globals 2>&1 | FileCheck %s -check-prefix=MUTABLE-GLOBALS
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-mutable-globals 2>&1 | FileCheck %s -check-prefix=NO-MUTABLE-GLOBALS
+
+// MUTABLE-GLOBALS: "-target-feature" "+mutable-globals"
+// NO-MUTABLE-GLOBALS: "-target-feature" "-mutable-globals"
+// DEFAULT-NOT: "-target-feature" "-mutable-globals"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -msign-ext 2>&1 | FileCheck %s -check-prefix=SIGN-EXT
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-sign-ext 2>&1 | FileCheck %s -check-prefix=NO-SIGN-EXT
+
+// SIGN-EXT: "-target-feature" "+sign-ext"
+// NO-SIGN-EXT: "-target-feature" "-sign-ext"
+// DEFAULT-NOT: "-target-feature" "-sign-ext"
+
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mnontrapping-fptoint 2>&1 | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mno-nontrapping-fptoint 2>&1 | FileCheck %s -check-prefix=NO-NONTRAPPING-FPTOINT
+
+// NONTRAPPING-FPTOINT: "-target-feature" "+nontrapping-fptoint"
+// NO-NONTRAPPING-FPTOINT: "-target-feature" "-nontrapping-fptoint"
+// DEFAULT-NOT: "-target-feature" "-nontrapping-fptoint"
Index: clang/lib/Basic/Targets/WebAssembly.cpp
===================================================================
--- clang/lib/Basic/Targets/WebAssembly.cpp
+++ clang/lib/Basic/Targets/WebAssembly.cpp
@@ -147,6 +147,11 @@
     Features["mutable-globals"] = true;
     Features["tail-call"] = true;
     setSIMDLevel(Features, SIMD128, true);
+  } else if (CPU == "generic") {
+    Features["nontrapping-fptoint"] = true;
+    Features["sign-ext"] = true;
+    Features["bulk-memory"] = true;
+    Features["mutable-globals"] = true;
   }
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -437,6 +437,13 @@
 X86 Support in Clang
 --------------------
 
+WebAssembly Support in Clang
+----------------------------
+
+The -mcpu=generic configuration now enables nontrapping-fptoint, sign-ext,
+bulk-memory, and mutable-globals. These proposals are standardized and
+available in all major engines.
+
 DWARF Support in Clang
 ----------------------
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125728.431064.patch
Type: text/x-patch
Size: 3234 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220520/930a2f22/attachment-0001.bin>


More information about the cfe-commits mailing list