-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[WebAssembly] Tidy up wasm-target-features.c #89778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This tidies up `wasm-target-features.c` cosmetically: - Sorts the feature tests alphabetically - Adds a space after colons
@llvm/pr-subscribers-clang @llvm/pr-subscribers-backend-webassembly Author: Heejin Ahn (aheejin) ChangesThis tidies up
Full diff: https://github.com/llvm/llvm-project/pull/89778.diff 2 Files Affected:
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp
index f1c925d90cb649..d473fd19086460 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -148,18 +148,18 @@ bool WebAssemblyTargetInfo::initFeatureMap(
llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
const std::vector<std::string> &FeaturesVec) const {
if (CPU == "bleeding-edge") {
- Features["nontrapping-fptoint"] = true;
- Features["sign-ext"] = true;
- Features["bulk-memory"] = true;
Features["atomics"] = true;
+ Features["bulk-memory"] = true;
+ Features["multimemory"] = true;
Features["mutable-globals"] = true;
- Features["tail-call"] = true;
+ Features["nontrapping-fptoint"] = true;
Features["reference-types"] = true;
- Features["multimemory"] = true;
+ Features["sign-ext"] = true;
+ Features["tail-call"] = true;
setSIMDLevel(Features, SIMD128, true);
} else if (CPU == "generic") {
- Features["sign-ext"] = true;
Features["mutable-globals"] = true;
+ Features["sign-ext"] = true;
}
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..b460b6d67c9353 100644
--- a/clang/test/Preprocessor/wasm-target-features.c
+++ b/clang/test/Preprocessor/wasm-target-features.c
@@ -1,38 +1,29 @@
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm32-unknown-unknown -msimd128 \
-// RUN: | FileCheck %s -check-prefix=SIMD128
-// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm64-unknown-unknown -msimd128 \
-// RUN: | FileCheck %s -check-prefix=SIMD128
-//
-// SIMD128:#define __wasm_simd128__ 1{{$}}
-
-// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm32-unknown-unknown -mrelaxed-simd \
-// RUN: | FileCheck %s -check-prefix=RELAXED-SIMD
+// RUN: -target wasm32-unknown-unknown -matomics \
+// RUN: | FileCheck %s -check-prefix=ATOMICS
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm64-unknown-unknown -mrelaxed-simd \
-// RUN: | FileCheck %s -check-prefix=RELAXED-SIMD
+// RUN: -target wasm64-unknown-unknown -matomics \
+// RUN: | FileCheck %s -check-prefix=ATOMICS
//
-// RELAXED-SIMD:#define __wasm_relaxed_simd__ 1{{$}}
+// ATOMICS: #define __wasm_atomics__ 1{{$}}
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm32-unknown-unknown -mnontrapping-fptoint \
-// RUN: | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT
+// RUN: -target wasm32-unknown-unknown -pthread \
+// RUN: | FileCheck %s -check-prefix=PTHREAD
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm64-unknown-unknown -mnontrapping-fptoint \
-// RUN: | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT
+// RUN: -target wasm64-unknown-unknown -pthread \
+// RUN: | FileCheck %s -check-prefix=PTHREAD
//
-// NONTRAPPING-FPTOINT:#define __wasm_nontrapping_fptoint__ 1{{$}}
+// PTHREAD: #define __wasm_atomics__ 1{{$}}
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm32-unknown-unknown -msign-ext \
-// RUN: | FileCheck %s -check-prefix=SIGN-EXT
+// RUN: -target wasm32-unknown-unknown -mbulk-memory \
+// RUN: | FileCheck %s -check-prefix=BULK-MEMORY
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm64-unknown-unknown -msign-ext \
-// RUN: | FileCheck %s -check-prefix=SIGN-EXT
+// RUN: -target wasm64-unknown-unknown -mbulk-memory \
+// RUN: | FileCheck %s -check-prefix=BULK-MEMORY
//
-// SIGN-EXT:#define __wasm_sign_ext__ 1{{$}}
+// BULK-MEMORY: #define __wasm_bulk_memory__ 1{{$}}
// RUN: %clang -E -dM %s -o - 2>&1 \
// RUN: -target wasm32-unknown-unknown -mexception-handling \
@@ -41,34 +32,34 @@
// RUN: -target wasm64-unknown-unknown -mexception-handling \
// RUN: | FileCheck %s -check-prefix=EXCEPTION-HANDLING
//
-// EXCEPTION-HANDLING:#define __wasm_exception_handling__ 1{{$}}
+// EXCEPTION-HANDLING: #define __wasm_exception_handling__ 1{{$}}
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm32-unknown-unknown -mbulk-memory \
-// RUN: | FileCheck %s -check-prefix=BULK-MEMORY
+// RUN: -target wasm32-unknown-unknown -mextended-const \
+// RUN: | FileCheck %s -check-prefix=EXTENDED-CONST
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm64-unknown-unknown -mbulk-memory \
-// RUN: | FileCheck %s -check-prefix=BULK-MEMORY
+// RUN: -target wasm64-unknown-unknown -mextended-const \
+// RUN: | FileCheck %s -check-prefix=EXTENDED-CONST
//
-// BULK-MEMORY:#define __wasm_bulk_memory__ 1{{$}}
+// EXTENDED-CONST: #define __wasm_extended_const__ 1{{$}}
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm32-unknown-unknown -matomics \
-// RUN: | FileCheck %s -check-prefix=ATOMICS
+// RUN: -target wasm32-unknown-unknown -mmultimemory \
+// RUN: | FileCheck %s -check-prefix=MULTIMEMORY
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm64-unknown-unknown -matomics \
-// RUN: | FileCheck %s -check-prefix=ATOMICS
+// RUN: -target wasm64-unknown-unknown -mmultimemory \
+// RUN: | FileCheck %s -check-prefix=MULTIMEMORY
//
-// ATOMICS:#define __wasm_atomics__ 1{{$}}
+// MULTIMEMORY: #define __wasm_multimemory__ 1{{$}}
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm32-unknown-unknown -pthread \
-// RUN: | FileCheck %s -check-prefix=PTHREAD
+// RUN: -target wasm32-unknown-unknown -mmultivalue \
+// RUN: | FileCheck %s -check-prefix=MULTIVALUE
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm64-unknown-unknown -pthread \
-// RUN: | FileCheck %s -check-prefix=PTHREAD
+// RUN: -target wasm64-unknown-unknown -mmultivalue \
+// RUN: | FileCheck %s -check-prefix=MULTIVALUE
//
-// PTHREAD:#define __wasm_atomics__ 1{{$}}
+// MULTIVALUE: #define __wasm_multivalue__ 1{{$}}
// RUN: %clang -E -dM %s -o - 2>&1 \
// RUN: -target wasm32-unknown-unknown -mmutable-globals \
@@ -77,26 +68,17 @@
// RUN: -target wasm64-unknown-unknown -mmutable-globals \
// RUN: | FileCheck %s -check-prefix=MUTABLE-GLOBALS
//
-// MUTABLE-GLOBALS:#define __wasm_mutable_globals__ 1{{$}}
+// MUTABLE-GLOBALS: #define __wasm_mutable_globals__ 1{{$}}
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm32-unknown-unknown -mmultivalue \
-// RUN: | FileCheck %s -check-prefix=MULTIVALUE
+// RUN: -target wasm32-unknown-unknown -mnontrapping-fptoint \
+// RUN: | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm64-unknown-unknown -mmultivalue \
-// RUN: | FileCheck %s -check-prefix=MULTIVALUE
+// RUN: -target wasm64-unknown-unknown -mnontrapping-fptoint \
+// RUN: | FileCheck %s -check-prefix=NONTRAPPING-FPTOINT
//
-// MULTIVALUE:#define __wasm_multivalue__ 1{{$}}
+// NONTRAPPING-FPTOINT: #define __wasm_nontrapping_fptoint__ 1{{$}}
-// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm32-unknown-unknown -mtail-call \
-// RUN: | FileCheck %s -check-prefix=TAIL-CALL
-// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm64-unknown-unknown -mtail-call \
-// RUN: | FileCheck %s -check-prefix=TAIL-CALL
-//
-// TAIL-CALL:#define __wasm_tail_call__ 1{{$}}
-//
// RUN: %clang -E -dM %s -o - 2>&1 \
// RUN: -target wasm32-unknown-unknown -mreference-types \
// RUN: | FileCheck %s -check-prefix=REFERENCE-TYPES
@@ -104,26 +86,43 @@
// RUN: -target wasm64-unknown-unknown -mreference-types \
// RUN: | FileCheck %s -check-prefix=REFERENCE-TYPES
//
-// REFERENCE-TYPES:#define __wasm_reference_types__ 1{{$}}
-//
+// REFERENCE-TYPES: #define __wasm_reference_types__ 1{{$}}
+
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm32-unknown-unknown -mextended-const \
-// RUN: | FileCheck %s -check-prefix=EXTENDED-CONST
+// RUN: -target wasm32-unknown-unknown -mrelaxed-simd \
+// RUN: | FileCheck %s -check-prefix=RELAXED-SIMD
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm64-unknown-unknown -mextended-const \
-// RUN: | FileCheck %s -check-prefix=EXTENDED-CONST
+// RUN: -target wasm64-unknown-unknown -mrelaxed-simd \
+// RUN: | FileCheck %s -check-prefix=RELAXED-SIMD
//
-// EXTENDED-CONST:#define __wasm_extended_const__ 1{{$}}
+// RELAXED-SIMD: #define __wasm_relaxed_simd__ 1{{$}}
+
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -msign-ext \
+// RUN: | FileCheck %s -check-prefix=SIGN-EXT
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -msign-ext \
+// RUN: | FileCheck %s -check-prefix=SIGN-EXT
//
+// SIGN-EXT: #define __wasm_sign_ext__ 1{{$}}
+
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm32-unknown-unknown -mmultimemory \
-// RUN: | FileCheck %s -check-prefix=MULTIMEMORY
+// RUN: -target wasm32-unknown-unknown -msimd128 \
+// RUN: | FileCheck %s -check-prefix=SIMD128
// RUN: %clang -E -dM %s -o - 2>&1 \
-// RUN: -target wasm64-unknown-unknown -mmultimemory \
-// RUN: | FileCheck %s -check-prefix=MULTIMEMORY
+// RUN: -target wasm64-unknown-unknown -msimd128 \
+// RUN: | FileCheck %s -check-prefix=SIMD128
//
-// MULTIMEMORY:#define __wasm_multimemory__ 1{{$}}
+// SIMD128: #define __wasm_simd128__ 1{{$}}
+
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -mtail-call \
+// RUN: | FileCheck %s -check-prefix=TAIL-CALL
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -mtail-call \
+// RUN: | FileCheck %s -check-prefix=TAIL-CALL
//
+// TAIL-CALL: #define __wasm_tail_call__ 1{{$}}
// RUN: %clang -E -dM %s -o - 2>&1 \
// RUN: -target wasm32-unknown-unknown -mcpu=mvp \
@@ -194,4 +193,4 @@
// RUN: -target wasm64-unknown-unknown -mcpu=bleeding-edge -mno-simd128 \
// RUN: | FileCheck %s -check-prefix=BLEEDING-EDGE-NO-SIMD128
//
-// BLEEDING-EDGE-NO-SIMD128-NOT:#define __wasm_simd128__
+// BLEEDING-EDGE-NO-SIMD128-NOT: #define __wasm_simd128__ 1{{$}}
|
tlively
approved these changes
Apr 23, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backend:WebAssembly
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This tidies up
wasm-target-features.c
cosmetically: