From d7f081ba04702ae81ca929a2d4fe61aae90296f9 Mon Sep 17 00:00:00 2001 From: Xiaodi Wu Date: Mon, 5 Feb 2018 14:42:09 -0600 Subject: [PATCH 1/3] Add _native_word_size platform condition --- include/swift/Basic/LangOptions.h | 6 ++-- lib/Basic/LangOptions.cpp | 36 +++++++++++++++++++ lib/Parse/ParseIfConfig.cpp | 5 ++- .../arm64AppleTVOSTarget.swift | 2 +- .../arm64IOSTarget.swift | 2 +- .../armAndroidTarget.swift | 2 +- .../ConditionalCompilation/armIOSTarget.swift | 2 +- .../armWatchOSTarget.swift | 2 +- .../i386AppleTVOSTarget.swift | 2 +- .../i386IOSTarget.swift | 2 +- .../i386WatchOSTarget.swift | 2 +- .../identifierName.swift | 11 ++++-- .../powerpc64LinuxTarget.swift | 2 +- .../powerpc64leLinuxTarget.swift | 2 +- .../s390xLinuxTarget.swift | 2 +- .../x64AppleTVOSTarget.swift | 2 +- .../x64CygwinTarget.swift | 2 +- .../x64FreeBSDTarget.swift | 2 +- .../ConditionalCompilation/x64IOSTarget.swift | 2 +- .../x64LinuxTarget.swift | 2 +- .../ConditionalCompilation/x64OSXTarget.swift | 4 +-- .../x64WindowsTarget.swift | 2 +- .../x86_64PS4Target.swift | 2 +- 23 files changed, 72 insertions(+), 26 deletions(-) diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h index 37f80344e4754..a4e61dd236c68 100644 --- a/include/swift/Basic/LangOptions.h +++ b/include/swift/Basic/LangOptions.h @@ -43,11 +43,13 @@ namespace swift { Arch, /// The active endianness target (big or little) Endianness, + /// The active native word size target (32 or 64) + NativeWordSize, /// Runtime support (_ObjC or _Native) Runtime, /// Conditional import of module CanImport, - /// Target Environment (currently just 'simulator' or absent) + /// Target environment (currently just 'simulator' or absent) TargetEnvironment, }; @@ -360,7 +362,7 @@ namespace swift { } private: - llvm::SmallVector, 5> + llvm::SmallVector, 6> PlatformConditionValues; llvm::SmallVector CustomConditionalCompilationFlags; }; diff --git a/lib/Basic/LangOptions.cpp b/lib/Basic/LangOptions.cpp index 53d526a9b6b0f..ab34ee4ae4de4 100644 --- a/lib/Basic/LangOptions.cpp +++ b/lib/Basic/LangOptions.cpp @@ -56,6 +56,11 @@ static const StringRef SupportedConditionalCompilationEndianness[] = { "big" }; +static const StringRef SupportedConditionalCompilationNativeWordSizes[] = { + "32", + "64" +}; + static const StringRef SupportedConditionalCompilationRuntimes[] = { "_ObjC", "_Native", @@ -101,6 +106,9 @@ checkPlatformConditionSupported(PlatformConditionKind Kind, StringRef Value, case PlatformConditionKind::Endianness: return contains(SupportedConditionalCompilationEndianness, Value, suggestions); + case PlatformConditionKind::NativeWordSize: + return contains(SupportedConditionalCompilationNativeWordSizes, Value, + suggestions); case PlatformConditionKind::Runtime: return contains(SupportedConditionalCompilationRuntimes, Value, suggestions); @@ -256,6 +264,34 @@ std::pair LangOptions::setTarget(llvm::Triple triple) { llvm_unreachable("undefined architecture endianness"); } + // Set the "_native_word_size" platform condition. + switch (Target.getArch()) { + case llvm::Triple::ArchType::arm: + case llvm::Triple::ArchType::thumb: + addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "32"); + break; + case llvm::Triple::ArchType::aarch64: + addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "64"); + break; + case llvm::Triple::ArchType::ppc64: + addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "64"); + break; + case llvm::Triple::ArchType::ppc64le: + addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "64"); + break; + case llvm::Triple::ArchType::x86: + addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "32"); + break; + case llvm::Triple::ArchType::x86_64: + addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "64"); + break; + case llvm::Triple::ArchType::systemz: + addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "64"); + break; + default: + llvm_unreachable("undefined architecture native word size"); + } + // Set the "runtime" platform condition. if (EnableObjCInterop) addPlatformConditionValue(PlatformConditionKind::Runtime, "_ObjC"); diff --git a/lib/Parse/ParseIfConfig.cpp b/lib/Parse/ParseIfConfig.cpp index 57836f723b98a..b97badbb405f5 100644 --- a/lib/Parse/ParseIfConfig.cpp +++ b/lib/Parse/ParseIfConfig.cpp @@ -40,6 +40,7 @@ Optional getPlatformConditionKind(StringRef Name) { .Case("os", PlatformConditionKind::OS) .Case("arch", PlatformConditionKind::Arch) .Case("_endian", PlatformConditionKind::Endianness) + .Case("_native_word_size", PlatformConditionKind::NativeWordSize) .Case("_runtime", PlatformConditionKind::Runtime) .Case("canImport", PlatformConditionKind::CanImport) .Case("targetEnvironment", PlatformConditionKind::TargetEnvironment) @@ -296,7 +297,7 @@ class ValidateIfConfigCondition : return E; } - // ( 'os' | 'arch' | '_endian' | '_runtime' | 'canImport') '(' identifier ')'' + // ( 'os' | 'arch' | '_endian' | '_native_word_size' | '_runtime' | 'canImport') '(' identifier ')'' auto Kind = getPlatformConditionKind(*KindName); if (!Kind.hasValue()) { D.diagnose(E->getLoc(), diag::unsupported_platform_condition_expression); @@ -329,6 +330,8 @@ class ValidateIfConfigCondition : DiagName = "architecture"; break; case PlatformConditionKind::Endianness: DiagName = "endianness"; break; + case PlatformConditionKind::NativeWordSize: + DiagName = "native word size"; break; case PlatformConditionKind::CanImport: DiagName = "import conditional"; break; case PlatformConditionKind::TargetEnvironment: diff --git a/test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift b/test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift index 7c72ff83ff084..584220d9c0900 100644 --- a/test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift +++ b/test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm64) && os(tvOS) && _runtime(_ObjC) && _endian(little) +#if arch(arm64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/arm64IOSTarget.swift b/test/Parse/ConditionalCompilation/arm64IOSTarget.swift index d94de8f05bc43..d861c047cf56d 100644 --- a/test/Parse/ConditionalCompilation/arm64IOSTarget.swift +++ b/test/Parse/ConditionalCompilation/arm64IOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm64) && os(iOS) && _runtime(_ObjC) && _endian(little) +#if arch(arm64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/armAndroidTarget.swift b/test/Parse/ConditionalCompilation/armAndroidTarget.swift index 8ecd7c15bbde3..fb5096f2d1025 100644 --- a/test/Parse/ConditionalCompilation/armAndroidTarget.swift +++ b/test/Parse/ConditionalCompilation/armAndroidTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm) && os(Android) && _runtime(_Native) && _endian(little) +#if arch(arm) && os(Android) && _runtime(_Native) && _endian(little) && _native_word_size(32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/armIOSTarget.swift b/test/Parse/ConditionalCompilation/armIOSTarget.swift index 5e2c69e948500..d078b5d945348 100644 --- a/test/Parse/ConditionalCompilation/armIOSTarget.swift +++ b/test/Parse/ConditionalCompilation/armIOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm) && os(iOS) && _runtime(_ObjC) && _endian(little) +#if arch(arm) && os(iOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/armWatchOSTarget.swift b/test/Parse/ConditionalCompilation/armWatchOSTarget.swift index c7e4a36312c1f..cd40b9f980274 100644 --- a/test/Parse/ConditionalCompilation/armWatchOSTarget.swift +++ b/test/Parse/ConditionalCompilation/armWatchOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm) && os(watchOS) && _runtime(_ObjC) && _endian(little) +#if arch(arm) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift b/test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift index f3fc4f38519ef..80f33ffa42788 100644 --- a/test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift +++ b/test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(i386) && os(tvOS) && _runtime(_ObjC) && _endian(little) +#if arch(i386) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/i386IOSTarget.swift b/test/Parse/ConditionalCompilation/i386IOSTarget.swift index bb857b8aaca7d..2f23a3d1f0623 100644 --- a/test/Parse/ConditionalCompilation/i386IOSTarget.swift +++ b/test/Parse/ConditionalCompilation/i386IOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(i386) && os(iOS) && _runtime(_ObjC) && _endian(little) +#if arch(i386) && os(iOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/i386WatchOSTarget.swift b/test/Parse/ConditionalCompilation/i386WatchOSTarget.swift index e3e73bf9cab91..9e4351f659845 100644 --- a/test/Parse/ConditionalCompilation/i386WatchOSTarget.swift +++ b/test/Parse/ConditionalCompilation/i386WatchOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(i386) && os(watchOS) && _runtime(_ObjC) && _endian(little) +#if arch(i386) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/identifierName.swift b/test/Parse/ConditionalCompilation/identifierName.swift index 53cec7561a182..6dae9e5557946 100644 --- a/test/Parse/ConditionalCompilation/identifierName.swift +++ b/test/Parse/ConditionalCompilation/identifierName.swift @@ -5,7 +5,7 @@ func f2( FOO: Int, swift: Int, _compiler_version: Int, - os: Int, arch: Int, _endian: Int, _runtime: Int, + os: Int, arch: Int, _endian: Int, _native_word_size: Int, _runtime: Int, targetEnvironment: Int, arm: Int, i386: Int, macOS: Int, OSX: Int, Linux: Int, big: Int, little: Int, @@ -21,6 +21,8 @@ func f2( _ = arch + i386 + arm #elseif _endian(big) && _endian(little) _ = _endian + big + little +#elseif _native_word_size(32) && _native_word_size(64) + _ = _native_word_size #elseif _runtime(_ObjC) && _runtime(_Native) _ = _runtime + _ObjC + _Native #elseif swift(>=1.0) && _compiler_version("3.*.0") @@ -34,7 +36,7 @@ func f2( func f2() { let FOO = 1, swift = 1, _compiler_version = 1, - os = 1, arch = 1, _endian = 1, _runtime = 1, + os = 1, arch = 1, _endian = 1, _native_word_size = 1, _runtime = 1, targetEnvironment = 1, arm = 1, i386 = 1, macOS = 1, OSX = 1, Linux = 1, big = 1, little = 1, @@ -49,6 +51,8 @@ func f2() { _ = arch + i386 + arm #elseif _endian(big) && _endian(little) _ = _endian + big + little +#elseif _native_word_size(32) && _native_word_size(64) + _ = _native_word_size #elseif _runtime(_ObjC) && _runtime(_Native) _ = _runtime + _ObjC + _Native #elseif swift(>=1.0) && _compiler_version("3.*.0") @@ -62,7 +66,7 @@ func f2() { struct S { let FOO = 1, swift = 1, _compiler_version = 1, - os = 1, arch = 1, _endian = 1, _runtime = 1, + os = 1, arch = 1, _endian = 1, _native_word_size = 1, _runtime = 1, targetEnvironment = 1, arm = 1, i386 = 1, macOS = 1, OSX = 1, Linux = 1, big = 1, little = 1, @@ -73,6 +77,7 @@ struct S { #elseif os(macOS) && os(OSX) && os(Linux) #elseif arch(i386) && arch(arm) #elseif _endian(big) && _endian(little) +#elseif _native_word_size(32) && _native_word_size(64) #elseif _runtime(_ObjC) && _runtime(_Native) #elseif swift(>=1.0) && _compiler_version("3.*.0") #elseif targetEnvironment(simulator) diff --git a/test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift b/test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift index 308d2cd54272e..edca9de480b22 100644 --- a/test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift +++ b/test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target powerpc64-unknown-linux-gnu -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target powerpc64-unknown-linux-gnu -#if arch(powerpc64) && os(Linux) && _runtime(_Native) && _endian(big) +#if arch(powerpc64) && os(Linux) && _runtime(_Native) && _endian(big) && _native_word_size(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift b/test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift index 8c9ab9209381c..2fae0d9311ad6 100644 --- a/test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift +++ b/test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target powerpc64le-unknown-linux-gnu -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target powerpc64le-unknown-linux-gnu -#if arch(powerpc64le) && os(Linux) && _runtime(_Native) && _endian(little) +#if arch(powerpc64le) && os(Linux) && _runtime(_Native) && _endian(little) && _native_word_size(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/s390xLinuxTarget.swift b/test/Parse/ConditionalCompilation/s390xLinuxTarget.swift index 799be0512f162..1a0b1f358db34 100644 --- a/test/Parse/ConditionalCompilation/s390xLinuxTarget.swift +++ b/test/Parse/ConditionalCompilation/s390xLinuxTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target s390x-unknown-linux-gnu -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target s390x-unknown-linux-gnu -#if arch(s390x) && os(Linux) && _runtime(_Native) && _endian(big) +#if arch(s390x) && os(Linux) && _runtime(_Native) && _endian(big) && _native_word_size(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift b/test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift index f9052ef9308f7..8b2dab704d37d 100644 --- a/test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift +++ b/test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(x86_64) && os(tvOS) && _runtime(_ObjC) && _endian(little) +#if arch(x86_64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64CygwinTarget.swift b/test/Parse/ConditionalCompilation/x64CygwinTarget.swift index 0af7084f942cd..051b820379b3a 100644 --- a/test/Parse/ConditionalCompilation/x64CygwinTarget.swift +++ b/test/Parse/ConditionalCompilation/x64CygwinTarget.swift @@ -1,6 +1,6 @@ // RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-unknown-windows-cygnus -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-cygnus -#if arch(x86_64) && os(Cygwin) && _runtime(_Native) +#if arch(x86_64) && os(Cygwin) && _runtime(_Native) && _native_word_size(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift b/test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift index 76d69afefa686..305ce8da411e0 100644 --- a/test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift +++ b/test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target x86_64-unknown-freebsd10 -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-freebsd10 -#if arch(x86_64) && os(FreeBSD) && _runtime(_Native) && _endian(little) +#if arch(x86_64) && os(FreeBSD) && _runtime(_Native) && _endian(little) && _native_word_size(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64IOSTarget.swift b/test/Parse/ConditionalCompilation/x64IOSTarget.swift index 65c251a59b1ff..1fbaa2bae3451 100644 --- a/test/Parse/ConditionalCompilation/x64IOSTarget.swift +++ b/test/Parse/ConditionalCompilation/x64IOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(x86_64) && os(iOS) && _runtime(_ObjC) && _endian(little) +#if arch(x86_64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64LinuxTarget.swift b/test/Parse/ConditionalCompilation/x64LinuxTarget.swift index 0c9a74956b372..d03db6f5891e6 100644 --- a/test/Parse/ConditionalCompilation/x64LinuxTarget.swift +++ b/test/Parse/ConditionalCompilation/x64LinuxTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target x86_64-unknown-linux-gnu -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-linux-gnu -#if arch(x86_64) && os(Linux) && _runtime(_Native) && _endian(little) +#if arch(x86_64) && os(Linux) && _runtime(_Native) && _endian(little) && _native_word_size(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64OSXTarget.swift b/test/Parse/ConditionalCompilation/x64OSXTarget.swift index c85cee971b894..5af6b5b88dadb 100644 --- a/test/Parse/ConditionalCompilation/x64OSXTarget.swift +++ b/test/Parse/ConditionalCompilation/x64OSXTarget.swift @@ -1,14 +1,14 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target x86_64-apple-macosx10.9 -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-apple-macosx10.9 -#if arch(x86_64) && os(OSX) && _runtime(_ObjC) && _endian(little) +#if arch(x86_64) && os(OSX) && _runtime(_ObjC) && _endian(little) && _native_word_size(64) class C {} var x = C() #endif var y = x -#if arch(x86_64) && os(macOS) && _runtime(_ObjC) && _endian(little) +#if arch(x86_64) && os(macOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(64) class CC {} var xx = CC() #endif diff --git a/test/Parse/ConditionalCompilation/x64WindowsTarget.swift b/test/Parse/ConditionalCompilation/x64WindowsTarget.swift index f89314c1ad6ef..68805ad6eb76c 100644 --- a/test/Parse/ConditionalCompilation/x64WindowsTarget.swift +++ b/test/Parse/ConditionalCompilation/x64WindowsTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target x86_64-unknown-windows-msvc -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-msvc -#if arch(x86_64) && os(Windows) && _runtime(_Native) && _endian(little) +#if arch(x86_64) && os(Windows) && _runtime(_Native) && _endian(little) && _native_word_size(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x86_64PS4Target.swift b/test/Parse/ConditionalCompilation/x86_64PS4Target.swift index 4c1c80970351c..c4606ae10b64c 100644 --- a/test/Parse/ConditionalCompilation/x86_64PS4Target.swift +++ b/test/Parse/ConditionalCompilation/x86_64PS4Target.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(x86_64) && os(PS4) && _runtime(_Native) && _endian(little) +#if arch(x86_64) && os(PS4) && _runtime(_Native) && _endian(little) && _native_word_size(64) class C {} var x = C() #endif From 727c464ed4c4272619e7a29cadcfe4623bb7ff84 Mon Sep 17 00:00:00 2001 From: Xiaodi Wu Date: Mon, 5 Feb 2018 18:32:01 -0600 Subject: [PATCH 2/3] Rename _native_word_size to _pointer_bit_width --- include/swift/Basic/LangOptions.h | 6 ++--- lib/Basic/LangOptions.cpp | 22 +++++++++---------- lib/Parse/ParseIfConfig.cpp | 8 +++---- .../arm64AppleTVOSTarget.swift | 2 +- .../arm64IOSTarget.swift | 2 +- .../armAndroidTarget.swift | 2 +- .../ConditionalCompilation/armIOSTarget.swift | 2 +- .../armWatchOSTarget.swift | 2 +- .../i386AppleTVOSTarget.swift | 2 +- .../i386IOSTarget.swift | 2 +- .../i386WatchOSTarget.swift | 2 +- .../identifierName.swift | 16 +++++++------- .../powerpc64LinuxTarget.swift | 2 +- .../powerpc64leLinuxTarget.swift | 2 +- .../s390xLinuxTarget.swift | 2 +- .../x64AppleTVOSTarget.swift | 2 +- .../x64CygwinTarget.swift | 2 +- .../x64FreeBSDTarget.swift | 2 +- .../ConditionalCompilation/x64IOSTarget.swift | 2 +- .../x64LinuxTarget.swift | 2 +- .../ConditionalCompilation/x64OSXTarget.swift | 4 ++-- .../x64WindowsTarget.swift | 2 +- .../x86_64PS4Target.swift | 2 +- 23 files changed, 46 insertions(+), 46 deletions(-) diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h index a4e61dd236c68..55f9e2598b8d2 100644 --- a/include/swift/Basic/LangOptions.h +++ b/include/swift/Basic/LangOptions.h @@ -41,10 +41,10 @@ namespace swift { OS, /// The active arch target (x86_64, i386, arm, arm64, etc.) Arch, - /// The active endianness target (big or little) + /// The active arch target endianness (big or little) Endianness, - /// The active native word size target (32 or 64) - NativeWordSize, + /// The active arch target pointer bit width (32 or 64) + PointerBitWidth, /// Runtime support (_ObjC or _Native) Runtime, /// Conditional import of module diff --git a/lib/Basic/LangOptions.cpp b/lib/Basic/LangOptions.cpp index ab34ee4ae4de4..8406f3a40525c 100644 --- a/lib/Basic/LangOptions.cpp +++ b/lib/Basic/LangOptions.cpp @@ -56,7 +56,7 @@ static const StringRef SupportedConditionalCompilationEndianness[] = { "big" }; -static const StringRef SupportedConditionalCompilationNativeWordSizes[] = { +static const StringRef SupportedConditionalCompilationPointerBitWidths[] = { "32", "64" }; @@ -106,8 +106,8 @@ checkPlatformConditionSupported(PlatformConditionKind Kind, StringRef Value, case PlatformConditionKind::Endianness: return contains(SupportedConditionalCompilationEndianness, Value, suggestions); - case PlatformConditionKind::NativeWordSize: - return contains(SupportedConditionalCompilationNativeWordSizes, Value, + case PlatformConditionKind::PointerBitWidth: + return contains(SupportedConditionalCompilationPointerBitWidths, Value, suggestions); case PlatformConditionKind::Runtime: return contains(SupportedConditionalCompilationRuntimes, Value, @@ -268,28 +268,28 @@ std::pair LangOptions::setTarget(llvm::Triple triple) { switch (Target.getArch()) { case llvm::Triple::ArchType::arm: case llvm::Triple::ArchType::thumb: - addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "32"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "32"); break; case llvm::Triple::ArchType::aarch64: - addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "64"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "64"); break; case llvm::Triple::ArchType::ppc64: - addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "64"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "64"); break; case llvm::Triple::ArchType::ppc64le: - addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "64"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "64"); break; case llvm::Triple::ArchType::x86: - addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "32"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "32"); break; case llvm::Triple::ArchType::x86_64: - addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "64"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "64"); break; case llvm::Triple::ArchType::systemz: - addPlatformConditionValue(PlatformConditionKind::NativeWordSize, "64"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "64"); break; default: - llvm_unreachable("undefined architecture native word size"); + llvm_unreachable("undefined architecture pointer bit width"); } // Set the "runtime" platform condition. diff --git a/lib/Parse/ParseIfConfig.cpp b/lib/Parse/ParseIfConfig.cpp index b97badbb405f5..79b3bbbf4c000 100644 --- a/lib/Parse/ParseIfConfig.cpp +++ b/lib/Parse/ParseIfConfig.cpp @@ -40,7 +40,7 @@ Optional getPlatformConditionKind(StringRef Name) { .Case("os", PlatformConditionKind::OS) .Case("arch", PlatformConditionKind::Arch) .Case("_endian", PlatformConditionKind::Endianness) - .Case("_native_word_size", PlatformConditionKind::NativeWordSize) + .Case("_pointer_bit_width", PlatformConditionKind::PointerBitWidth) .Case("_runtime", PlatformConditionKind::Runtime) .Case("canImport", PlatformConditionKind::CanImport) .Case("targetEnvironment", PlatformConditionKind::TargetEnvironment) @@ -297,7 +297,7 @@ class ValidateIfConfigCondition : return E; } - // ( 'os' | 'arch' | '_endian' | '_native_word_size' | '_runtime' | 'canImport') '(' identifier ')'' + // ( 'os' | 'arch' | '_endian' | '_pointer_bit_width' | '_runtime' | 'canImport') '(' identifier ')'' auto Kind = getPlatformConditionKind(*KindName); if (!Kind.hasValue()) { D.diagnose(E->getLoc(), diag::unsupported_platform_condition_expression); @@ -330,8 +330,8 @@ class ValidateIfConfigCondition : DiagName = "architecture"; break; case PlatformConditionKind::Endianness: DiagName = "endianness"; break; - case PlatformConditionKind::NativeWordSize: - DiagName = "native word size"; break; + case PlatformConditionKind::PointerBitWidth: + DiagName = "pointer bit width"; break; case PlatformConditionKind::CanImport: DiagName = "import conditional"; break; case PlatformConditionKind::TargetEnvironment: diff --git a/test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift b/test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift index 584220d9c0900..533ddfdd42459 100644 --- a/test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift +++ b/test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(64) +#if arch(arm64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/arm64IOSTarget.swift b/test/Parse/ConditionalCompilation/arm64IOSTarget.swift index d861c047cf56d..cc4bf7cf181ec 100644 --- a/test/Parse/ConditionalCompilation/arm64IOSTarget.swift +++ b/test/Parse/ConditionalCompilation/arm64IOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(64) +#if arch(arm64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/armAndroidTarget.swift b/test/Parse/ConditionalCompilation/armAndroidTarget.swift index fb5096f2d1025..3bbe36c72d568 100644 --- a/test/Parse/ConditionalCompilation/armAndroidTarget.swift +++ b/test/Parse/ConditionalCompilation/armAndroidTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm) && os(Android) && _runtime(_Native) && _endian(little) && _native_word_size(32) +#if arch(arm) && os(Android) && _runtime(_Native) && _endian(little) && _pointer_bit_width(32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/armIOSTarget.swift b/test/Parse/ConditionalCompilation/armIOSTarget.swift index d078b5d945348..1ecc122b24535 100644 --- a/test/Parse/ConditionalCompilation/armIOSTarget.swift +++ b/test/Parse/ConditionalCompilation/armIOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm) && os(iOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(32) +#if arch(arm) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/armWatchOSTarget.swift b/test/Parse/ConditionalCompilation/armWatchOSTarget.swift index cd40b9f980274..1a19efde708c6 100644 --- a/test/Parse/ConditionalCompilation/armWatchOSTarget.swift +++ b/test/Parse/ConditionalCompilation/armWatchOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(32) +#if arch(arm) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift b/test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift index 80f33ffa42788..5c56619f72930 100644 --- a/test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift +++ b/test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(i386) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(32) +#if arch(i386) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/i386IOSTarget.swift b/test/Parse/ConditionalCompilation/i386IOSTarget.swift index 2f23a3d1f0623..50b96e93ae34f 100644 --- a/test/Parse/ConditionalCompilation/i386IOSTarget.swift +++ b/test/Parse/ConditionalCompilation/i386IOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(i386) && os(iOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(32) +#if arch(i386) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/i386WatchOSTarget.swift b/test/Parse/ConditionalCompilation/i386WatchOSTarget.swift index 9e4351f659845..22f30c04ef9ef 100644 --- a/test/Parse/ConditionalCompilation/i386WatchOSTarget.swift +++ b/test/Parse/ConditionalCompilation/i386WatchOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(i386) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(32) +#if arch(i386) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/identifierName.swift b/test/Parse/ConditionalCompilation/identifierName.swift index 6dae9e5557946..68500a73ce5df 100644 --- a/test/Parse/ConditionalCompilation/identifierName.swift +++ b/test/Parse/ConditionalCompilation/identifierName.swift @@ -5,7 +5,7 @@ func f2( FOO: Int, swift: Int, _compiler_version: Int, - os: Int, arch: Int, _endian: Int, _native_word_size: Int, _runtime: Int, + os: Int, arch: Int, _endian: Int, _pointer_bit_width: Int, _runtime: Int, targetEnvironment: Int, arm: Int, i386: Int, macOS: Int, OSX: Int, Linux: Int, big: Int, little: Int, @@ -21,8 +21,8 @@ func f2( _ = arch + i386 + arm #elseif _endian(big) && _endian(little) _ = _endian + big + little -#elseif _native_word_size(32) && _native_word_size(64) - _ = _native_word_size +#elseif _pointer_bit_width(32) && _pointer_bit_width(64) + _ = _pointer_bit_width #elseif _runtime(_ObjC) && _runtime(_Native) _ = _runtime + _ObjC + _Native #elseif swift(>=1.0) && _compiler_version("3.*.0") @@ -36,7 +36,7 @@ func f2( func f2() { let FOO = 1, swift = 1, _compiler_version = 1, - os = 1, arch = 1, _endian = 1, _native_word_size = 1, _runtime = 1, + os = 1, arch = 1, _endian = 1, _pointer_bit_width = 1, _runtime = 1, targetEnvironment = 1, arm = 1, i386 = 1, macOS = 1, OSX = 1, Linux = 1, big = 1, little = 1, @@ -51,8 +51,8 @@ func f2() { _ = arch + i386 + arm #elseif _endian(big) && _endian(little) _ = _endian + big + little -#elseif _native_word_size(32) && _native_word_size(64) - _ = _native_word_size +#elseif _pointer_bit_width(32) && _pointer_bit_width(64) + _ = _pointer_bit_width #elseif _runtime(_ObjC) && _runtime(_Native) _ = _runtime + _ObjC + _Native #elseif swift(>=1.0) && _compiler_version("3.*.0") @@ -66,7 +66,7 @@ func f2() { struct S { let FOO = 1, swift = 1, _compiler_version = 1, - os = 1, arch = 1, _endian = 1, _native_word_size = 1, _runtime = 1, + os = 1, arch = 1, _endian = 1, _pointer_bit_width = 1, _runtime = 1, targetEnvironment = 1, arm = 1, i386 = 1, macOS = 1, OSX = 1, Linux = 1, big = 1, little = 1, @@ -77,7 +77,7 @@ struct S { #elseif os(macOS) && os(OSX) && os(Linux) #elseif arch(i386) && arch(arm) #elseif _endian(big) && _endian(little) -#elseif _native_word_size(32) && _native_word_size(64) +#elseif _pointer_bit_width(32) && _pointer_bit_width(64) #elseif _runtime(_ObjC) && _runtime(_Native) #elseif swift(>=1.0) && _compiler_version("3.*.0") #elseif targetEnvironment(simulator) diff --git a/test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift b/test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift index edca9de480b22..b2a7dbfa8d691 100644 --- a/test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift +++ b/test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target powerpc64-unknown-linux-gnu -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target powerpc64-unknown-linux-gnu -#if arch(powerpc64) && os(Linux) && _runtime(_Native) && _endian(big) && _native_word_size(64) +#if arch(powerpc64) && os(Linux) && _runtime(_Native) && _endian(big) && _pointer_bit_width(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift b/test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift index 2fae0d9311ad6..03803571a3a97 100644 --- a/test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift +++ b/test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target powerpc64le-unknown-linux-gnu -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target powerpc64le-unknown-linux-gnu -#if arch(powerpc64le) && os(Linux) && _runtime(_Native) && _endian(little) && _native_word_size(64) +#if arch(powerpc64le) && os(Linux) && _runtime(_Native) && _endian(little) && _pointer_bit_width(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/s390xLinuxTarget.swift b/test/Parse/ConditionalCompilation/s390xLinuxTarget.swift index 1a0b1f358db34..ae01da5c66901 100644 --- a/test/Parse/ConditionalCompilation/s390xLinuxTarget.swift +++ b/test/Parse/ConditionalCompilation/s390xLinuxTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target s390x-unknown-linux-gnu -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target s390x-unknown-linux-gnu -#if arch(s390x) && os(Linux) && _runtime(_Native) && _endian(big) && _native_word_size(64) +#if arch(s390x) && os(Linux) && _runtime(_Native) && _endian(big) && _pointer_bit_width(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift b/test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift index 8b2dab704d37d..b48cb5dc2b7b6 100644 --- a/test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift +++ b/test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(x86_64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(64) +#if arch(x86_64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64CygwinTarget.swift b/test/Parse/ConditionalCompilation/x64CygwinTarget.swift index 051b820379b3a..c3f4bc2ed0ba7 100644 --- a/test/Parse/ConditionalCompilation/x64CygwinTarget.swift +++ b/test/Parse/ConditionalCompilation/x64CygwinTarget.swift @@ -1,6 +1,6 @@ // RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-unknown-windows-cygnus -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-cygnus -#if arch(x86_64) && os(Cygwin) && _runtime(_Native) && _native_word_size(64) +#if arch(x86_64) && os(Cygwin) && _runtime(_Native) && _pointer_bit_width(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift b/test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift index 305ce8da411e0..49536f971292d 100644 --- a/test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift +++ b/test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target x86_64-unknown-freebsd10 -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-freebsd10 -#if arch(x86_64) && os(FreeBSD) && _runtime(_Native) && _endian(little) && _native_word_size(64) +#if arch(x86_64) && os(FreeBSD) && _runtime(_Native) && _endian(little) && _pointer_bit_width(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64IOSTarget.swift b/test/Parse/ConditionalCompilation/x64IOSTarget.swift index 1fbaa2bae3451..8209f74875f4c 100644 --- a/test/Parse/ConditionalCompilation/x64IOSTarget.swift +++ b/test/Parse/ConditionalCompilation/x64IOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(x86_64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(64) +#if arch(x86_64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64LinuxTarget.swift b/test/Parse/ConditionalCompilation/x64LinuxTarget.swift index d03db6f5891e6..8680c015a4089 100644 --- a/test/Parse/ConditionalCompilation/x64LinuxTarget.swift +++ b/test/Parse/ConditionalCompilation/x64LinuxTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target x86_64-unknown-linux-gnu -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-linux-gnu -#if arch(x86_64) && os(Linux) && _runtime(_Native) && _endian(little) && _native_word_size(64) +#if arch(x86_64) && os(Linux) && _runtime(_Native) && _endian(little) && _pointer_bit_width(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64OSXTarget.swift b/test/Parse/ConditionalCompilation/x64OSXTarget.swift index 5af6b5b88dadb..b3523895b91b4 100644 --- a/test/Parse/ConditionalCompilation/x64OSXTarget.swift +++ b/test/Parse/ConditionalCompilation/x64OSXTarget.swift @@ -1,14 +1,14 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target x86_64-apple-macosx10.9 -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-apple-macosx10.9 -#if arch(x86_64) && os(OSX) && _runtime(_ObjC) && _endian(little) && _native_word_size(64) +#if arch(x86_64) && os(OSX) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(64) class C {} var x = C() #endif var y = x -#if arch(x86_64) && os(macOS) && _runtime(_ObjC) && _endian(little) && _native_word_size(64) +#if arch(x86_64) && os(macOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(64) class CC {} var xx = CC() #endif diff --git a/test/Parse/ConditionalCompilation/x64WindowsTarget.swift b/test/Parse/ConditionalCompilation/x64WindowsTarget.swift index 68805ad6eb76c..64ee7306bf2a3 100644 --- a/test/Parse/ConditionalCompilation/x64WindowsTarget.swift +++ b/test/Parse/ConditionalCompilation/x64WindowsTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target x86_64-unknown-windows-msvc -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-msvc -#if arch(x86_64) && os(Windows) && _runtime(_Native) && _endian(little) && _native_word_size(64) +#if arch(x86_64) && os(Windows) && _runtime(_Native) && _endian(little) && _pointer_bit_width(64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x86_64PS4Target.swift b/test/Parse/ConditionalCompilation/x86_64PS4Target.swift index c4606ae10b64c..116ed364e5429 100644 --- a/test/Parse/ConditionalCompilation/x86_64PS4Target.swift +++ b/test/Parse/ConditionalCompilation/x86_64PS4Target.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(x86_64) && os(PS4) && _runtime(_Native) && _endian(little) && _native_word_size(64) +#if arch(x86_64) && os(PS4) && _runtime(_Native) && _endian(little) && _pointer_bit_width(64) class C {} var x = C() #endif From a7ad86e57c32d1a29dbf83ee2f2d4aa14d34eb1e Mon Sep 17 00:00:00 2001 From: Xiaodi Wu Date: Mon, 5 Feb 2018 19:15:25 -0600 Subject: [PATCH 3/3] Use bona fide identifiers for _pointer_bit_width arguments --- include/swift/Basic/LangOptions.h | 2 +- lib/Basic/LangOptions.cpp | 18 +++++++++--------- .../arm64AppleTVOSTarget.swift | 2 +- .../arm64IOSTarget.swift | 2 +- .../armAndroidTarget.swift | 2 +- .../ConditionalCompilation/armIOSTarget.swift | 2 +- .../armWatchOSTarget.swift | 2 +- .../i386AppleTVOSTarget.swift | 2 +- .../ConditionalCompilation/i386IOSTarget.swift | 2 +- .../i386WatchOSTarget.swift | 2 +- .../identifierName.swift | 13 ++++++++----- .../powerpc64LinuxTarget.swift | 2 +- .../powerpc64leLinuxTarget.swift | 2 +- .../s390xLinuxTarget.swift | 2 +- .../x64AppleTVOSTarget.swift | 2 +- .../x64CygwinTarget.swift | 2 +- .../x64FreeBSDTarget.swift | 2 +- .../ConditionalCompilation/x64IOSTarget.swift | 2 +- .../x64LinuxTarget.swift | 2 +- .../ConditionalCompilation/x64OSXTarget.swift | 4 ++-- .../x64WindowsTarget.swift | 2 +- .../x86_64PS4Target.swift | 2 +- 22 files changed, 38 insertions(+), 35 deletions(-) diff --git a/include/swift/Basic/LangOptions.h b/include/swift/Basic/LangOptions.h index 55f9e2598b8d2..25a4c210d945a 100644 --- a/include/swift/Basic/LangOptions.h +++ b/include/swift/Basic/LangOptions.h @@ -43,7 +43,7 @@ namespace swift { Arch, /// The active arch target endianness (big or little) Endianness, - /// The active arch target pointer bit width (32 or 64) + /// The active arch target pointer bit width (_32 or _64) PointerBitWidth, /// Runtime support (_ObjC or _Native) Runtime, diff --git a/lib/Basic/LangOptions.cpp b/lib/Basic/LangOptions.cpp index 8406f3a40525c..87a4fce0cff5d 100644 --- a/lib/Basic/LangOptions.cpp +++ b/lib/Basic/LangOptions.cpp @@ -57,8 +57,8 @@ static const StringRef SupportedConditionalCompilationEndianness[] = { }; static const StringRef SupportedConditionalCompilationPointerBitWidths[] = { - "32", - "64" + "_32", + "_64" }; static const StringRef SupportedConditionalCompilationRuntimes[] = { @@ -268,25 +268,25 @@ std::pair LangOptions::setTarget(llvm::Triple triple) { switch (Target.getArch()) { case llvm::Triple::ArchType::arm: case llvm::Triple::ArchType::thumb: - addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "32"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_32"); break; case llvm::Triple::ArchType::aarch64: - addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "64"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64"); break; case llvm::Triple::ArchType::ppc64: - addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "64"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64"); break; case llvm::Triple::ArchType::ppc64le: - addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "64"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64"); break; case llvm::Triple::ArchType::x86: - addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "32"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_32"); break; case llvm::Triple::ArchType::x86_64: - addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "64"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64"); break; case llvm::Triple::ArchType::systemz: - addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "64"); + addPlatformConditionValue(PlatformConditionKind::PointerBitWidth, "_64"); break; default: llvm_unreachable("undefined architecture pointer bit width"); diff --git a/test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift b/test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift index 533ddfdd42459..91537eea2871e 100644 --- a/test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift +++ b/test/Parse/ConditionalCompilation/arm64AppleTVOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(64) +#if arch(arm64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/arm64IOSTarget.swift b/test/Parse/ConditionalCompilation/arm64IOSTarget.swift index cc4bf7cf181ec..222e5268a5887 100644 --- a/test/Parse/ConditionalCompilation/arm64IOSTarget.swift +++ b/test/Parse/ConditionalCompilation/arm64IOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(64) +#if arch(arm64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/armAndroidTarget.swift b/test/Parse/ConditionalCompilation/armAndroidTarget.swift index 3bbe36c72d568..074d2e41dd9a8 100644 --- a/test/Parse/ConditionalCompilation/armAndroidTarget.swift +++ b/test/Parse/ConditionalCompilation/armAndroidTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm) && os(Android) && _runtime(_Native) && _endian(little) && _pointer_bit_width(32) +#if arch(arm) && os(Android) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/armIOSTarget.swift b/test/Parse/ConditionalCompilation/armIOSTarget.swift index 1ecc122b24535..93ddb9b08b180 100644 --- a/test/Parse/ConditionalCompilation/armIOSTarget.swift +++ b/test/Parse/ConditionalCompilation/armIOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(32) +#if arch(arm) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/armWatchOSTarget.swift b/test/Parse/ConditionalCompilation/armWatchOSTarget.swift index 1a19efde708c6..198738fabea6b 100644 --- a/test/Parse/ConditionalCompilation/armWatchOSTarget.swift +++ b/test/Parse/ConditionalCompilation/armWatchOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(arm) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(32) +#if arch(arm) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift b/test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift index 5c56619f72930..982512174823b 100644 --- a/test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift +++ b/test/Parse/ConditionalCompilation/i386AppleTVOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(i386) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(32) +#if arch(i386) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/i386IOSTarget.swift b/test/Parse/ConditionalCompilation/i386IOSTarget.swift index 50b96e93ae34f..a644093302c69 100644 --- a/test/Parse/ConditionalCompilation/i386IOSTarget.swift +++ b/test/Parse/ConditionalCompilation/i386IOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(i386) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(32) +#if arch(i386) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/i386WatchOSTarget.swift b/test/Parse/ConditionalCompilation/i386WatchOSTarget.swift index 22f30c04ef9ef..a978f25f4878f 100644 --- a/test/Parse/ConditionalCompilation/i386WatchOSTarget.swift +++ b/test/Parse/ConditionalCompilation/i386WatchOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(i386) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(32) +#if arch(i386) && os(watchOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_32) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/identifierName.swift b/test/Parse/ConditionalCompilation/identifierName.swift index 68500a73ce5df..d94597d65acc2 100644 --- a/test/Parse/ConditionalCompilation/identifierName.swift +++ b/test/Parse/ConditionalCompilation/identifierName.swift @@ -9,6 +9,7 @@ func f2( targetEnvironment: Int, arm: Int, i386: Int, macOS: Int, OSX: Int, Linux: Int, big: Int, little: Int, + _32: Int, _64: Int, _ObjC: Int, _Native: Int, simulator: Int ) { @@ -21,8 +22,8 @@ func f2( _ = arch + i386 + arm #elseif _endian(big) && _endian(little) _ = _endian + big + little -#elseif _pointer_bit_width(32) && _pointer_bit_width(64) - _ = _pointer_bit_width +#elseif _pointer_bit_width(_32) && _pointer_bit_width(_64) + _ = _pointer_bit_width + _32 + _64 #elseif _runtime(_ObjC) && _runtime(_Native) _ = _runtime + _ObjC + _Native #elseif swift(>=1.0) && _compiler_version("3.*.0") @@ -40,6 +41,7 @@ func f2() { targetEnvironment = 1, arm = 1, i386 = 1, macOS = 1, OSX = 1, Linux = 1, big = 1, little = 1, + _32 = 1, _64 = 1, _ObjC = 1, _Native = 1, simulator = 1 @@ -51,8 +53,8 @@ func f2() { _ = arch + i386 + arm #elseif _endian(big) && _endian(little) _ = _endian + big + little -#elseif _pointer_bit_width(32) && _pointer_bit_width(64) - _ = _pointer_bit_width +#elseif _pointer_bit_width(_32) && _pointer_bit_width(_64) + _ = _pointer_bit_width + _32 + _64 #elseif _runtime(_ObjC) && _runtime(_Native) _ = _runtime + _ObjC + _Native #elseif swift(>=1.0) && _compiler_version("3.*.0") @@ -70,6 +72,7 @@ struct S { targetEnvironment = 1, arm = 1, i386 = 1, macOS = 1, OSX = 1, Linux = 1, big = 1, little = 1, + _32 = 1, _64 = 1, _ObjC = 1, _Native = 1, simulator = 1 @@ -77,7 +80,7 @@ struct S { #elseif os(macOS) && os(OSX) && os(Linux) #elseif arch(i386) && arch(arm) #elseif _endian(big) && _endian(little) -#elseif _pointer_bit_width(32) && _pointer_bit_width(64) +#elseif _pointer_bit_width(_32) && _pointer_bit_width(_64) #elseif _runtime(_ObjC) && _runtime(_Native) #elseif swift(>=1.0) && _compiler_version("3.*.0") #elseif targetEnvironment(simulator) diff --git a/test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift b/test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift index b2a7dbfa8d691..924cec207a6cd 100644 --- a/test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift +++ b/test/Parse/ConditionalCompilation/powerpc64LinuxTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target powerpc64-unknown-linux-gnu -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target powerpc64-unknown-linux-gnu -#if arch(powerpc64) && os(Linux) && _runtime(_Native) && _endian(big) && _pointer_bit_width(64) +#if arch(powerpc64) && os(Linux) && _runtime(_Native) && _endian(big) && _pointer_bit_width(_64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift b/test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift index 03803571a3a97..8d1f1928eb5ce 100644 --- a/test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift +++ b/test/Parse/ConditionalCompilation/powerpc64leLinuxTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target powerpc64le-unknown-linux-gnu -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target powerpc64le-unknown-linux-gnu -#if arch(powerpc64le) && os(Linux) && _runtime(_Native) && _endian(little) && _pointer_bit_width(64) +#if arch(powerpc64le) && os(Linux) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/s390xLinuxTarget.swift b/test/Parse/ConditionalCompilation/s390xLinuxTarget.swift index ae01da5c66901..1e9382a5a7229 100644 --- a/test/Parse/ConditionalCompilation/s390xLinuxTarget.swift +++ b/test/Parse/ConditionalCompilation/s390xLinuxTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target s390x-unknown-linux-gnu -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target s390x-unknown-linux-gnu -#if arch(s390x) && os(Linux) && _runtime(_Native) && _endian(big) && _pointer_bit_width(64) +#if arch(s390x) && os(Linux) && _runtime(_Native) && _endian(big) && _pointer_bit_width(_64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift b/test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift index b48cb5dc2b7b6..de16cff7ed8bb 100644 --- a/test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift +++ b/test/Parse/ConditionalCompilation/x64AppleTVOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(x86_64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(64) +#if arch(x86_64) && os(tvOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64CygwinTarget.swift b/test/Parse/ConditionalCompilation/x64CygwinTarget.swift index c3f4bc2ed0ba7..e14c08cd5e167 100644 --- a/test/Parse/ConditionalCompilation/x64CygwinTarget.swift +++ b/test/Parse/ConditionalCompilation/x64CygwinTarget.swift @@ -1,6 +1,6 @@ // RUN: %swift -parse %s -verify -D FOO -D BAR -target x86_64-unknown-windows-cygnus -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-cygnus -#if arch(x86_64) && os(Cygwin) && _runtime(_Native) && _pointer_bit_width(64) +#if arch(x86_64) && os(Cygwin) && _runtime(_Native) && _pointer_bit_width(_64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift b/test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift index 49536f971292d..24acb71c67190 100644 --- a/test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift +++ b/test/Parse/ConditionalCompilation/x64FreeBSDTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target x86_64-unknown-freebsd10 -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-freebsd10 -#if arch(x86_64) && os(FreeBSD) && _runtime(_Native) && _endian(little) && _pointer_bit_width(64) +#if arch(x86_64) && os(FreeBSD) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64IOSTarget.swift b/test/Parse/ConditionalCompilation/x64IOSTarget.swift index 8209f74875f4c..55b71f65e8e49 100644 --- a/test/Parse/ConditionalCompilation/x64IOSTarget.swift +++ b/test/Parse/ConditionalCompilation/x64IOSTarget.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(x86_64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(64) +#if arch(x86_64) && os(iOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64LinuxTarget.swift b/test/Parse/ConditionalCompilation/x64LinuxTarget.swift index 8680c015a4089..ef14fab76c1fe 100644 --- a/test/Parse/ConditionalCompilation/x64LinuxTarget.swift +++ b/test/Parse/ConditionalCompilation/x64LinuxTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target x86_64-unknown-linux-gnu -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-linux-gnu -#if arch(x86_64) && os(Linux) && _runtime(_Native) && _endian(little) && _pointer_bit_width(64) +#if arch(x86_64) && os(Linux) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x64OSXTarget.swift b/test/Parse/ConditionalCompilation/x64OSXTarget.swift index b3523895b91b4..0a1df84031cf1 100644 --- a/test/Parse/ConditionalCompilation/x64OSXTarget.swift +++ b/test/Parse/ConditionalCompilation/x64OSXTarget.swift @@ -1,14 +1,14 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target x86_64-apple-macosx10.9 -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-apple-macosx10.9 -#if arch(x86_64) && os(OSX) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(64) +#if arch(x86_64) && os(OSX) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64) class C {} var x = C() #endif var y = x -#if arch(x86_64) && os(macOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(64) +#if arch(x86_64) && os(macOS) && _runtime(_ObjC) && _endian(little) && _pointer_bit_width(_64) class CC {} var xx = CC() #endif diff --git a/test/Parse/ConditionalCompilation/x64WindowsTarget.swift b/test/Parse/ConditionalCompilation/x64WindowsTarget.swift index 64ee7306bf2a3..f7aff1c7ec022 100644 --- a/test/Parse/ConditionalCompilation/x64WindowsTarget.swift +++ b/test/Parse/ConditionalCompilation/x64WindowsTarget.swift @@ -1,7 +1,7 @@ // RUN: %swift -typecheck %s -verify -D FOO -D BAR -target x86_64-unknown-windows-msvc -disable-objc-interop -D FOO -parse-stdlib // RUN: %swift-ide-test -test-input-complete -source-filename=%s -target x86_64-unknown-windows-msvc -#if arch(x86_64) && os(Windows) && _runtime(_Native) && _endian(little) && _pointer_bit_width(64) +#if arch(x86_64) && os(Windows) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64) class C {} var x = C() #endif diff --git a/test/Parse/ConditionalCompilation/x86_64PS4Target.swift b/test/Parse/ConditionalCompilation/x86_64PS4Target.swift index 116ed364e5429..a7afdda30e1c8 100644 --- a/test/Parse/ConditionalCompilation/x86_64PS4Target.swift +++ b/test/Parse/ConditionalCompilation/x86_64PS4Target.swift @@ -7,7 +7,7 @@ let i: Int = "Hello" #endif -#if arch(x86_64) && os(PS4) && _runtime(_Native) && _endian(little) && _pointer_bit_width(64) +#if arch(x86_64) && os(PS4) && _runtime(_Native) && _endian(little) && _pointer_bit_width(_64) class C {} var x = C() #endif