Skip to content

[test][IRGen] Split out objc-interop specific part in abitypes.swift (take 2) #69042

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
52 changes: 52 additions & 0 deletions test/IRGen/Inputs/abi/CGadget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
struct MyRect {
float x;
float y;
float width;
float height;
};

struct Trio {
double i;
double j;
double k;
};

struct IntPair {
int a;
int b;
};

struct NestedInts {
struct A {
int value;
} a;
struct B {
int value;
} b;
};

struct BigStruct {
char a[32];
};

enum RawEnum {
Intergalactic,
Planetary
};

typedef struct One {
float first;
float second;
} One;

static inline One makeOne(float f, float s) {
One one;
one.first = f;
one.second = s;

return one;
}

static inline float MyRect_Area(struct MyRect rect) {
return rect.width * rect.height;
}
54 changes: 1 addition & 53 deletions test/IRGen/Inputs/abi/Gadget.h
Original file line number Diff line number Diff line change
@@ -1,35 +1,5 @@
@import Foundation;

struct MyRect {
float x;
float y;
float width;
float height;
};

struct Trio {
double i;
double j;
double k;
};

struct IntPair {
int a;
int b;
};

struct NestedInts {
struct A {
int value;
} a;
struct B {
int value;
} b;
};

struct BigStruct {
char a[32];
};
#include "CGadget.h"

@interface StructReturns : NSObject
- (struct MyRect)newRect;
Expand Down Expand Up @@ -58,28 +28,6 @@ typedef NS_ENUM(unsigned short, ChooseTo) {
ChooseToLeaveIt = 1709
};

enum RawEnum {
Intergalactic,
Planetary
};

typedef struct One {
float first;
float second;
} One;

static inline One makeOne(float f, float s) {
One one;
one.first = f;
one.second = s;

return one;
}

static inline float MyRect_Area(struct MyRect rect) {
return rect.width * rect.height;
}

// @literals inside static inline function
static inline void* giveMeASelector(void) {
return @selector(init);
Expand Down
1 change: 1 addition & 0 deletions test/IRGen/Inputs/abi/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
module gadget { header "Gadget.h" }
module c_gadget { header "CGadget.h" }
module c_layout { header "c_layout.h" }
16 changes: 16 additions & 0 deletions test/IRGen/abitypes_arm.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -module-name abitypes -I %S/Inputs/abi %s -emit-ir | %FileCheck -check-prefix=%target-cpu-%target-os-abi -check-prefix=%target-cpu %s
// REQUIRES: CPU=armv7 || CPU=armv7k || CPU=armv7s

import c_gadget

class Foo {
// Test that the makeOne() that we generate somewhere below doesn't
// use arm_aapcscc for armv7.
func callInline() -> Float {
return makeOne(3,5).second
}
}

// armv7: define internal void @makeOne(ptr noalias sret({{.*}}) align 4 %agg.result, float %f, float %s)
// armv7s: define internal void @makeOne(ptr noalias sret({{.*}}) align 4 %agg.result, float %f, float %s)
// armv7k: define internal %struct.One @makeOne(float {{.*}}%f, float {{.*}}%s)
33 changes: 3 additions & 30 deletions test/IRGen/abitypes.swift → test/IRGen/abitypes_objc.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/abi %s -emit-ir -enable-objc-interop | %FileCheck -check-prefix=%target-cpu-%target-os-abi %s
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/Inputs/abi %s -emit-ir -module-name abitypes -enable-objc-interop | %FileCheck -check-prefix=%target-cpu-%target-os-abi %s

// FIXME: rdar://problem/19648117 Needs splitting objc parts out
// XFAIL: OS=linux-gnu, OS=windows-msvc, OS=openbsd, OS=linux-android, OS=linux-androideabi
// REQUIRES: objc_interop

import gadget
import c_gadget
import Foundation

@objc protocol P1 {}
Expand Down Expand Up @@ -559,33 +559,6 @@ class Foo {
@objc dynamic func callJustReturn(_ r: StructReturns, with v: BigStruct) -> BigStruct {
return r.justReturn(v)
}

// Test that the makeOne() that we generate somewhere below doesn't
// use arm_aapcscc for armv7.
func callInline() -> Float {
return makeOne(3,5).second
}
}

// armv7-ios: define internal void @makeOne(ptr noalias sret({{.*}}) align 4 %agg.result, float %f, float %s)
// armv7s-ios: define internal void @makeOne(ptr noalias sret({{.*}}) align 4 %agg.result, float %f, float %s)
// armv7k-watchos: define internal %struct.One @makeOne(float {{.*}}%f, float {{.*}}%s)

// rdar://17631440 - Expand direct arguments that are coerced to aggregates.
// x86_64-macosx: define{{( protected)?}} swiftcc float @"$s8abitypes13testInlineAggySfSo6MyRectVF"(float %0, float %1, float %2, float %3) {{.*}} {
// x86_64-macosx: [[COERCED:%.*]] = alloca %TSo6MyRectV, align 8
// x86_64-macosx: store float %0,
// x86_64-macosx: store float %1,
// x86_64-macosx: store float %2,
// x86_64-macosx: store float %3,
// x86_64-macosx: [[T0:%.*]] = getelementptr inbounds { <2 x float>, <2 x float> }, ptr [[COERCED]], i32 0, i32 0
// x86_64-macosx: [[FIRST_HALF:%.*]] = load <2 x float>, ptr [[T0]], align 8
// x86_64-macosx: [[T0:%.*]] = getelementptr inbounds { <2 x float>, <2 x float> }, ptr [[COERCED]], i32 0, i32 1
// x86_64-macosx: [[SECOND_HALF:%.*]] = load <2 x float>, ptr [[T0]], align 8
// x86_64-macosx: [[RESULT:%.*]] = call float @MyRect_Area(<2 x float> [[FIRST_HALF]], <2 x float> [[SECOND_HALF]])
// x86_64-macosx: ret float [[RESULT]]
public func testInlineAgg(_ rect: MyRect) -> Float {
return MyRect_Area(rect)
}

// We need to allocate enough memory on the stack to hold the argument value we load.
Expand Down
22 changes: 22 additions & 0 deletions test/IRGen/abitypes_x86_64.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -module-name abitypes -I %S/Inputs/abi %s -emit-ir | %FileCheck -check-prefix=%target-cpu-%target-os-abi -check-prefix=%target-cpu %s
// REQUIRES: CPU=x86_64
// UNSUPPORTED: OS=windows-msvc

import c_gadget

// rdar://17631440 - Expand direct arguments that are coerced to aggregates.
// x86_64: define{{( dllexport)?}}{{( protected)?}} swiftcc float @"$s8abitypes13testInlineAggySfSo6MyRectVF"(float %0, float %1, float %2, float %3) {{.*}} {
// x86_64: [[COERCED:%.*]] = alloca %TSo6MyRectV, align 8
// x86_64: store float %0,
// x86_64: store float %1,
// x86_64: store float %2,
// x86_64: store float %3,
// x86_64: [[T0:%.*]] = getelementptr inbounds { <2 x float>, <2 x float> }, ptr [[COERCED]], i32 0, i32 0
// x86_64: [[FIRST_HALF:%.*]] = load <2 x float>, ptr [[T0]], align 8
// x86_64: [[T0:%.*]] = getelementptr inbounds { <2 x float>, <2 x float> }, ptr [[COERCED]], i32 0, i32 1
// x86_64: [[SECOND_HALF:%.*]] = load <2 x float>, ptr [[T0]], align 8
// x86_64: [[RESULT:%.*]] = call float @MyRect_Area(<2 x float> [[FIRST_HALF]], <2 x float> [[SECOND_HALF]])
// x86_64: ret float [[RESULT]]
public func testInlineAgg(_ rect: MyRect) -> Float {
return MyRect_Area(rect)
}