Add powerpc64le Linux support #979
Conversation
Is |
Yes, powerpc64 is big endian. We hope to get big endian working, but for now are concentrating on the little endian port (powerpc64le). |
@@ -919,7 +919,7 @@ static const uintptr_t ObjCReservedBitsMask = | |||
static const unsigned ObjCReservedLowBits = | |||
SWIFT_ABI_X86_64_OBJC_NUM_RESERVED_LOW_BITS; | |||
|
|||
#elif defined(__arm64__) | |||
#elif defined(__arm64__) || defined(__powerpc64__) |
gribozavr
Jan 15, 2016
Collaborator
Is __powerpc64__
defined on BE, LE or both?
Is __powerpc64__
defined on BE, LE or both?
antonblanchard
Jan 15, 2016
Author
Contributor
It is defined on both BE and LE targets:
$ uname -m
ppc64le
$ cpp -dM < /dev/null | grep __powerpc64__
#define __powerpc64__ 1
$ uname -m
ppc64
$ cpp -dM < /dev/null | grep __powerpc64__
#define __powerpc64__ 1
It is defined on both BE and LE targets:
$ uname -m
ppc64le
$ cpp -dM < /dev/null | grep __powerpc64__
#define __powerpc64__ 1
$ uname -m
ppc64
$ cpp -dM < /dev/null | grep __powerpc64__
#define __powerpc64__ 1
gribozavr
Jan 15, 2016
Collaborator
The comment above this block says that lib/IRGen/SwiftTargetInfo.cpp
needs adjustments (you need to add a configurePowerPC
function there).
The comment above this block says that lib/IRGen/SwiftTargetInfo.cpp
needs adjustments (you need to add a configurePowerPC
function there).
@@ -27,7 +27,7 @@ public struct CGFloat { | |||
/// The native type used to store the CGFloat, which is Float on | |||
/// 32-bit architectures and Double on 64-bit architectures. | |||
public typealias NativeType = Float | |||
#elseif arch(x86_64) || arch(arm64) | |||
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) |
gribozavr
Jan 15, 2016
Collaborator
This file is not built on Linux, please revert this part.
This file is not built on Linux, please revert this part.
@@ -244,7 +244,7 @@ public struct ${Self} | |||
/// byte order if necessary. | |||
@_transparent public | |||
init(bigEndian value: ${Self}) { | |||
#if arch(i386) || arch(x86_64) || arch(arm) || arch(arm64) | |||
#if arch(i386) || arch(x86_64) || arch(arm) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) |
gribozavr
Jan 15, 2016
Collaborator
BE needs a different (the opposite!) implementation here and below.
BE needs a different (the opposite!) implementation here and below.
antonblanchard
Jan 15, 2016
Author
Contributor
Nice catch, fixing.
Nice catch, fixing.
@@ -462,7 +462,7 @@ - (BOOL)isNSValue__ { return NO; } | |||
|
|||
#if defined(__x86_64__) | |||
static uintptr_t const objectPointerIsObjCBit = 0x4000000000000000ULL; | |||
#elif defined(__arm64__) | |||
#elif defined(__arm64__) || defined(__powerpc64__) |
gribozavr
Jan 15, 2016
Collaborator
This code is not built on Linux, please revert this part.
This code is not built on Linux, please revert this part.
@@ -77,7 +77,7 @@ func isOSAtLeast(major: Int, _ minor: Int, patch: Int = 0) -> Bool { | |||
func expectTagged(s: NSString, _ expected: Bool) -> NSString { | |||
#if arch(x86_64) | |||
let mask: UInt = 0x8000000000000001 | |||
#elseif arch(arm64) | |||
#elseif arch(arm64) || arch(powerpc64) || arch(powerpc64le) |
gribozavr
Jan 15, 2016
Collaborator
This file is not built on Linux, please revert this part.
This file is not built on Linux, please revert this part.
@@ -10,6 +10,8 @@ import Swift | |||
// armv7k: [[OBJC:%objc_object]] = type | |||
// arm64: [[OBJC:%objc_object]] = type | |||
// i386: [[OBJC:%objc_object]] = type | |||
// powerpc64: [[OBJC:%objc_object]] = type | |||
// powerpc64le: [[OBJC:%objc_object]] = type |
gribozavr
Jan 15, 2016
Collaborator
This is an ObjC-runtime-specific test. Please add // REQUIRES: objc_interop
instead and revert the other changes.
This is an ObjC-runtime-specific test. Please add // REQUIRES: objc_interop
instead and revert the other changes.
@@ -8,7 +8,7 @@ public func == (lhs: CGPoint, rhs: CGPoint) -> Bool { | |||
public struct CGFloat { | |||
#if arch(i386) || arch(arm) | |||
public typealias UnderlyingType = Float | |||
#elseif arch(x86_64) || arch(arm64) | |||
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) |
gribozavr
Jan 15, 2016
Collaborator
This file shouldn't be built on Linux, is it actually built?
This file shouldn't be built on Linux, is it actually built?
@@ -37,7 +37,7 @@ if #available(iOS 8.0, *) { | |||
], | |||
bytesFromNSData(element.data)) | |||
expectEqual(4, element.bytesPerIndex) | |||
#elseif arch(x86_64) || arch(arm64) | |||
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) |
gribozavr
Jan 15, 2016
Collaborator
This file is not built on Linux, please revert this part.
This file is not built on Linux, please revert this part.
@@ -103,7 +103,7 @@ CoreAudioTestSuite.test( | |||
"AudioBuffer.init(_: UnsafeMutableBufferPointer, numberOfChannels: Int)/trap") { | |||
#if arch(i386) || arch(arm) | |||
let overflowingCount = Int.max | |||
#elseif arch(x86_64) || arch(arm64) | |||
#elseif arch(x86_64) || arch(arm64) || arch(powerpc64) || arch(powerpc64le) |
gribozavr
Jan 15, 2016
Collaborator
This file is not built on Linux, please revert this part.
This file is not built on Linux, please revert this part.
How far does this patch allows the port to go? Does the standard library build? Does hello world work? Do the tests run? |
The powerpc64le port builds and runs the test suite with a few failures:
And hello world works:
|
@antonblanchard I'm really impressed! |
Did you try the validation test suite |
Thanks, that's given me a few more failing tests to sort out:
|
Again, very impressed it is just 8 tests in total! |
Yes, I'm surprised by how clean the port is. Having the compiler written in c++ (vs the target language), and pulling in clang to get the ABI parameter passing rules helps. Other LLVM based languages have required a lot more work. Big endian still requires work, but we can attack that once the little endian port is solid. |
I'm not sure of the preferred workflow, but I'm happy to rebase and squash these commits. |
self = ${Self}(Builtin.int_bswap_${BuiltinName}(value._value) ) | ||
#else | ||
_UnsupportedArchitectureError() |
gribozavr
Jan 15, 2016
Collaborator
Please keep the unsupported error so that we get a loud error for new architectures. Just add an explicit #elseif arch(powerpc64)
for BE (here and below).
Please keep the unsupported error so that we get a loud error for new architectures. Just add an explicit #elseif arch(powerpc64)
for BE (here and below).
Yes, we prefer rebasing/squashing. |
break; | ||
case llvm::Triple::ArchType::ppc64le: | ||
addTargetConfigOption("arch", "powerpc64le"); | ||
break; |
gribozavr
Jan 15, 2016
Collaborator
This part needs a test like test/BuildConfigurations/x64LinuxTarget.swift
for each supported triple.
This part needs a test like test/BuildConfigurations/x64LinuxTarget.swift
for each supported triple.
antonblanchard
Jan 15, 2016
Author
Contributor
Thanks, will add these tests
Thanks, will add these tests
@antonblanchard Thank you! Looks good, but I have two more comments. |
Very cool, thank you for working on adding this! |
This patch adds powerpc64le Linux support. While the patch also adds the matching powerpc64 bits, there are endian issues that need to be sorted out. The PowerPC LLVM changes for the swift ABI (eg returning three element non-homogeneous aggregates) are still in the works, but a simple LLVM fix to allow those aggregates results in swift passing all but 8 test cases.
This comment has been minimized.
This comment has been minimized.
I'm wondering if this is correct. We should have access to the three bottom bits as a result of allocations being aligned, but do I need to care about _objectPointerIsObjCBit on powerpc64 Linux? Should it just be defined to 0? |
@antonblanchard The ObjC values should be dynamically dead as far as I understand. If you find they are also statically unused -- feel free to remove them! |
I ran tests on Ubuntu 14.04 x86_64 and OS X, and see no regressions. Merging. Thank you! |
Add powerpc64le Linux support
This comment has been minimized.
This comment has been minimized.
Hm. I wonder if we should start allowing this to be customized soon. LLVM targets aren't that quick to build. |
Thanks for your help @gribozavr! |
This patch adds powerpc64le Linux support. While the patch also adds
the matching powerpc64 bits, there are endian issues that need to be
sorted out.
The PowerPC LLVM changes for the swift ABI (eg returning three element
non-homogeneous aggregates) are still in the works, but a simple LLVM
fix to allow those aggregates results in swift passing all but 8
test cases.
Note: It would be nice if swift had conditional compilation based on pointer size, a
number of the test cases only care if the target is 32 or 64 bit.