[clang] [WebAssembly] Add tests for generic CPU config (PR #80775)
Heejin Ahn via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 6 11:24:23 PST 2024
https://github.com/aheejin updated https://github.com/llvm/llvm-project/pull/80775
>From dbb74ca85ef047260a2820f6d470448279ea44f4 Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Tue, 6 Feb 2024 00:51:40 +0000
Subject: [PATCH 1/3] [WebAssembly] Add tests for generic CPU config
This adds tests for `generic` cpu configuration. We had tests for `mvp`
and `bleeding-edge` configs but not `generic`.
---
clang/test/Driver/wasm-features.c | 6 ++++++
.../test/Preprocessor/wasm-target-features.c | 21 +++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/clang/test/Driver/wasm-features.c b/clang/test/Driver/wasm-features.c
index 1a43361a4a1080..33058051f67eb3 100644
--- a/clang/test/Driver/wasm-features.c
+++ b/clang/test/Driver/wasm-features.c
@@ -4,6 +4,7 @@
// RUN: %clang --target=wasm32-unknown-unknown -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mcpu=mvp 2>&1 | FileCheck %s -check-prefix=MVP
+// RUN: %clang --target=wasm32-unknown-unknown -### %s -mcpu=generic 2>&1 | FileCheck %s -check-prefix=GENERIC
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mcpu=bleeding-edge 2>&1 | FileCheck %s -check-prefix=BLEEDING-EDGE
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mbulk-memory 2>&1 | FileCheck %s -check-prefix=BULK-MEMORY
@@ -13,6 +14,7 @@
// NO-BULK-MEMORY: "-target-feature" "-bulk-memory"
// DEFAULT-NOT: "-target-feature" "-bulk-memory"
// MVP-NOT: "-target-feature" "+bulk-memory"
+// GENERIC-NOT: "-target-feature" "+bulk-memory"
// BLEEDING-EDGE-NOT: "-target-feature" "-bulk-memory"
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mmutable-globals 2>&1 | FileCheck %s -check-prefix=MUTABLE-GLOBALS
@@ -22,6 +24,7 @@
// NO-MUTABLE-GLOBALS: "-target-feature" "-mutable-globals"
// DEFAULT-NOT: "-target-feature" "-mutable-globals"
// MVP-NOT: "-target-feature" "+mutable-globals"
+// GENERIC-NOT: "-target-feature" "-mutable-globals"
// BLEEDING-EDGE-NOT: "-target-feature" "-mutable-globals"
// RUN: %clang --target=wasm32-unknown-unknown -### %s -msign-ext 2>&1 | FileCheck %s -check-prefix=SIGN-EXT
@@ -31,6 +34,7 @@
// NO-SIGN-EXT: "-target-feature" "-sign-ext"
// DEFAULT-NOT: "-target-feature" "-sign-ext"
// MVP-NOT: "-target-feature" "+sign-ext"
+// GENERIC-NOT: "-target-feature" "-sign-ext"
// BLEEDING-EDGE-NOT: "-target-feature" "-sign-ext"
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mnontrapping-fptoint 2>&1 | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT
@@ -40,6 +44,7 @@
// NO-NONTRAPPING-FPTOINT: "-target-feature" "-nontrapping-fptoint"
// DEFAULT-NOT: "-target-feature" "-nontrapping-fptoint"
// MVP-NOT: "-target-feature" "+nontrapping-fptoint"
+// GENERIC-NOT: "-target-feature" "+nontrapping-fptoint"
// BLEEDING-EDGE-NOT: "-target-feature" "-nontrapping-fptoint"
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mmultimemory 2>&1 | FileCheck %s -check-prefix=MULTIMEMORY
@@ -49,4 +54,5 @@
// NO-MULTIMEMORY: "-target-feature" "-multimemory"
// DEFAULT-NOT: "-target-feature" "-multimemory"
// MVP-NOT: "-target-feature" "+multimemory"
+// GENERIC-NOT: "-target-feature" "+multimemory"
// BLEEDING-EDGE-NOT: "-target-feature" "-multimemory"
diff --git a/clang/test/Preprocessor/wasm-target-features.c b/clang/test/Preprocessor/wasm-target-features.c
index c225e226b69ba1..17f75c83ef7341 100644
--- a/clang/test/Preprocessor/wasm-target-features.c
+++ b/clang/test/Preprocessor/wasm-target-features.c
@@ -145,6 +145,27 @@
// MVP-NOT:#define __wasm_extended_const__
// MVP-NOT:#define __wasm_multimemory__
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mcpu=generic \
+// RUN: | FileCheck %s -check-prefix=GENERIC
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mcpu=generic \
+// RUN: | FileCheck %s -check-prefix=GENERIC
+//
+// 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-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_unimplemented_simd128__ 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 \
// RUN: -target wasm32-unknown-unknown -mcpu=bleeding-edge \
// RUN: | FileCheck %s -check-prefix=BLEEDING-EDGE
>From d1e55d8e117bf1a294746d483495018b21f83757 Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Tue, 6 Feb 2024 01:07:53 +0000
Subject: [PATCH 2/3] Delete unnecessary line
---
clang/test/Preprocessor/wasm-target-features.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/clang/test/Preprocessor/wasm-target-features.c b/clang/test/Preprocessor/wasm-target-features.c
index 17f75c83ef7341..4c21d5e143d51a 100644
--- a/clang/test/Preprocessor/wasm-target-features.c
+++ b/clang/test/Preprocessor/wasm-target-features.c
@@ -160,7 +160,6 @@
// GENERIC-NOT:#define __wasm_atomics__ 1{{$}}
// GENERIC-NOT:#define __wasm_tail_call__ 1{{$}}
// GENERIC-NOT:#define __wasm_multimemory__ 1{{$}}
-// GENERIC-NOT:#define __wasm_unimplemented_simd128__ 1{{$}}
// GENERIC-NOT:#define __wasm_exception_handling__ 1{{$}}
// GENERIC-NOT:#define __wasm_multivalue__ 1{{$}}
// GENERIC-NOT:#define __wasm_reference_types__ 1{{$}}
>From 9a1a55b3f316acbc7e43b86373911a714bff39c2 Mon Sep 17 00:00:00 2001
From: Heejin Ahn <aheejin at gmail.com>
Date: Tue, 6 Feb 2024 19:24:07 +0000
Subject: [PATCH 3/3] Revert changes in wasm-features.c
---
clang/test/Driver/wasm-features.c | 6 ------
1 file changed, 6 deletions(-)
diff --git a/clang/test/Driver/wasm-features.c b/clang/test/Driver/wasm-features.c
index 33058051f67eb3..1a43361a4a1080 100644
--- a/clang/test/Driver/wasm-features.c
+++ b/clang/test/Driver/wasm-features.c
@@ -4,7 +4,6 @@
// RUN: %clang --target=wasm32-unknown-unknown -### %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mcpu=mvp 2>&1 | FileCheck %s -check-prefix=MVP
-// RUN: %clang --target=wasm32-unknown-unknown -### %s -mcpu=generic 2>&1 | FileCheck %s -check-prefix=GENERIC
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mcpu=bleeding-edge 2>&1 | FileCheck %s -check-prefix=BLEEDING-EDGE
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mbulk-memory 2>&1 | FileCheck %s -check-prefix=BULK-MEMORY
@@ -14,7 +13,6 @@
// NO-BULK-MEMORY: "-target-feature" "-bulk-memory"
// DEFAULT-NOT: "-target-feature" "-bulk-memory"
// MVP-NOT: "-target-feature" "+bulk-memory"
-// GENERIC-NOT: "-target-feature" "+bulk-memory"
// BLEEDING-EDGE-NOT: "-target-feature" "-bulk-memory"
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mmutable-globals 2>&1 | FileCheck %s -check-prefix=MUTABLE-GLOBALS
@@ -24,7 +22,6 @@
// NO-MUTABLE-GLOBALS: "-target-feature" "-mutable-globals"
// DEFAULT-NOT: "-target-feature" "-mutable-globals"
// MVP-NOT: "-target-feature" "+mutable-globals"
-// GENERIC-NOT: "-target-feature" "-mutable-globals"
// BLEEDING-EDGE-NOT: "-target-feature" "-mutable-globals"
// RUN: %clang --target=wasm32-unknown-unknown -### %s -msign-ext 2>&1 | FileCheck %s -check-prefix=SIGN-EXT
@@ -34,7 +31,6 @@
// NO-SIGN-EXT: "-target-feature" "-sign-ext"
// DEFAULT-NOT: "-target-feature" "-sign-ext"
// MVP-NOT: "-target-feature" "+sign-ext"
-// GENERIC-NOT: "-target-feature" "-sign-ext"
// BLEEDING-EDGE-NOT: "-target-feature" "-sign-ext"
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mnontrapping-fptoint 2>&1 | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT
@@ -44,7 +40,6 @@
// NO-NONTRAPPING-FPTOINT: "-target-feature" "-nontrapping-fptoint"
// DEFAULT-NOT: "-target-feature" "-nontrapping-fptoint"
// MVP-NOT: "-target-feature" "+nontrapping-fptoint"
-// GENERIC-NOT: "-target-feature" "+nontrapping-fptoint"
// BLEEDING-EDGE-NOT: "-target-feature" "-nontrapping-fptoint"
// RUN: %clang --target=wasm32-unknown-unknown -### %s -mmultimemory 2>&1 | FileCheck %s -check-prefix=MULTIMEMORY
@@ -54,5 +49,4 @@
// NO-MULTIMEMORY: "-target-feature" "-multimemory"
// DEFAULT-NOT: "-target-feature" "-multimemory"
// MVP-NOT: "-target-feature" "+multimemory"
-// GENERIC-NOT: "-target-feature" "+multimemory"
// BLEEDING-EDGE-NOT: "-target-feature" "-multimemory"
More information about the cfe-commits
mailing list