aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/Targets/WebAssembly.cpp
diff options
context:
space:
mode:
authorDan Gohman <dev@sunfishcode.online>2024-12-03 16:35:23 -0800
committerGitHub <noreply@github.com>2024-12-03 16:35:23 -0800
commit35cce408eef1a253df12c0023c993d78b180b1f3 (patch)
tree4b9d7fae673d3ab1dada89038cebdbe8d5f525a9 /clang/lib/Basic/Targets/WebAssembly.cpp
parente9dc6c5fbb6d2c2c93095acb6ff4ca0b515057ed (diff)
downloadllvm-35cce408eef1a253df12c0023c993d78b180b1f3.zip
llvm-35cce408eef1a253df12c0023c993d78b180b1f3.tar.gz
llvm-35cce408eef1a253df12c0023c993d78b180b1f3.tar.bz2
[WebAssembly] Support the new "Lime1" CPU (#112035)
This adds WebAssembly support for the new [Lime1 CPU]. First, this defines some new target features. These are subsets of existing features that reflect implementation concerns: - "call-indirect-overlong" - implied by "reference-types"; just the overlong encoding for the `call_indirect` immediate, and not the actual reference types. - "bulk-memory-opt" - implied by "bulk-memory": just `memory.copy` and `memory.fill`, and not the other instructions in the bulk-memory proposal. Next, this defines a new target CPU, "lime1", which enables mutable-globals, bulk-memory-opt, multivalue, sign-ext, nontrapping-fptoint, extended-const, and call-indirect-overlong. Unlike the default "generic" CPU, "lime1" is meant to be frozen, and followed up by "lime2" and so on when new features are desired. [Lime1 CPU]: https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1 --------- Co-authored-by: Heejin Ahn <aheejin@gmail.com>
Diffstat (limited to 'clang/lib/Basic/Targets/WebAssembly.cpp')
-rw-r--r--clang/lib/Basic/Targets/WebAssembly.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/clang/lib/Basic/Targets/WebAssembly.cpp b/clang/lib/Basic/Targets/WebAssembly.cpp
index d9d01bc..85e550a 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -31,7 +31,7 @@ static constexpr Builtin::Info BuiltinInfo[] = {
};
static constexpr llvm::StringLiteral ValidCPUNames[] = {
- {"mvp"}, {"bleeding-edge"}, {"generic"}};
+ {"mvp"}, {"bleeding-edge"}, {"generic"}, {"lime"}};
StringRef WebAssemblyTargetInfo::getABI() const { return ABI; }
@@ -167,6 +167,17 @@ bool WebAssemblyTargetInfo::initFeatureMap(
Features["reference-types"] = true;
Features["sign-ext"] = true;
};
+ auto addLime1Features = [&]() {
+ // Lime1:
+ // <https://github.com/WebAssembly/tool-conventions/blob/main/Lime.md#lime1>
+ Features["bulk-memory-opt"] = true;
+ Features["call-indirect-overlong"] = true;
+ Features["extended-const"] = true;
+ Features["multivalue"] = true;
+ Features["mutable-globals"] = true;
+ Features["nontrapping-fptoint"] = true;
+ Features["sign-ext"] = true;
+ };
auto addBleedingEdgeFeatures = [&]() {
addGenericFeatures();
Features["atomics"] = true;
@@ -180,6 +191,8 @@ bool WebAssemblyTargetInfo::initFeatureMap(
};
if (CPU == "generic") {
addGenericFeatures();
+ } else if (CPU == "lime1") {
+ addLime1Features();
} else if (CPU == "bleeding-edge") {
addBleedingEdgeFeatures();
}