Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/Basic/LangOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static const StringRef SupportedConditionalCompilationOSs[] = {
"PS4",
"Cygwin",
"Haiku",
"WASI",
};

static const StringRef SupportedConditionalCompilationArches[] = {
Expand All @@ -48,7 +49,8 @@ static const StringRef SupportedConditionalCompilationArches[] = {
"x86_64",
"powerpc64",
"powerpc64le",
"s390x"
"s390x",
"wasm32",
};

static const StringRef SupportedConditionalCompilationEndianness[] = {
Expand Down Expand Up @@ -246,6 +248,9 @@ std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
case llvm::Triple::Haiku:
addPlatformConditionValue(PlatformConditionKind::OS, "Haiku");
break;
case llvm::Triple::WASI:
addPlatformConditionValue(PlatformConditionKind::OS, "WASI");
break;
default:
UnsupportedOS = true;
break;
Expand Down Expand Up @@ -277,6 +282,9 @@ std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
case llvm::Triple::ArchType::systemz:
addPlatformConditionValue(PlatformConditionKind::Arch, "s390x");
break;
case llvm::Triple::ArchType::wasm32:
addPlatformConditionValue(PlatformConditionKind::Arch, "wasm32");
break;
default:
UnsupportedArch = true;
}
Expand All @@ -291,6 +299,7 @@ std::pair<bool, bool> LangOptions::setTarget(llvm::Triple triple) {
case llvm::Triple::ArchType::thumb:
case llvm::Triple::ArchType::aarch64:
case llvm::Triple::ArchType::ppc64le:
case llvm::Triple::ArchType::wasm32:
case llvm::Triple::ArchType::x86:
case llvm::Triple::ArchType::x86_64:
addPlatformConditionValue(PlatformConditionKind::Endianness, "little");
Expand Down
8 changes: 8 additions & 0 deletions test/Parse/ConditionalCompilation/wasm32Target.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// RUN: %swift -typecheck %s -verify -target wasm32-unknown-wasi -disable-objc-interop -parse-stdlib
// RUN: %swift-ide-test -test-input-complete -source-filename %s -target wasm32-unknown-wasi

#if arch(wasm32) && os(WASI) && _runtime(_Native) && _endian(little)
class C {}
var x = C()
#endif
var y = x