Skip to content
4 changes: 4 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ AIX Support
WebAssembly Support
^^^^^^^^^^^^^^^^^^^

The -mcpu=generic configuration now enables nontrapping-fptoint, multivalue,
reference-types, and bulk-memory.These proposals are standardized and available
in all major engines.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also mention that enabling multivalue here just means enabling the language feauture, and not changing the ABI?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


AVR Support
^^^^^^^^^^^

Expand Down
18 changes: 12 additions & 6 deletions clang/lib/Basic/Targets/WebAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,19 +147,25 @@ void WebAssemblyTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
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;
auto addGenericFeatures = [&]() {
Features["sign-ext"] = true;
Features["mutable-globals"] = true;
Features["nontrapping-fptoint"] = true;
Features["bulk-memory"] = true;
Features["reference-types"] = true;
Features["multivalue"] = true;
};
auto addBleedingEdgeFeatures = [&]() {
Features["atomics"] = true;
Features["mutable-globals"] = true;
Features["tail-call"] = true;
Features["reference-types"] = true;
Features["multimemory"] = true;
setSIMDLevel(Features, SIMD128, true);
};
if (CPU == "bleeding-edge") {
addGenericFeatures();
addBleedingEdgeFeatures();
} else if (CPU == "generic") {
Features["sign-ext"] = true;
Features["mutable-globals"] = true;
addGenericFeatures();
}

return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
Expand Down
8 changes: 4 additions & 4 deletions clang/test/Preprocessor/wasm-target-features.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@
//
// 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-DAG:#define __wasm_nontrapping_fptoint__ 1{{$}}
// GENERIC-DAG:#define __wasm_bulk_memory__ 1{{$}}
// GENERIC-DAG:#define __wasm_multivalue__ 1{{$}}
// GENERIC-DAG:#define __wasm_reference_types__ 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_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 \
Expand Down