Skip to content

Commit da5aec2

Browse files
Merge pull request #69042 from kateinoigakukun/pr-23db49b4704f0a955be1a1a5fd7cff5369ecb542
[test][IRGen] Split out objc-interop specific part in abitypes.swift (take 2)
2 parents 622ff07 + 153147a commit da5aec2

File tree

6 files changed

+95
-83
lines changed

6 files changed

+95
-83
lines changed

test/IRGen/Inputs/abi/CGadget.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
struct MyRect {
2+
float x;
3+
float y;
4+
float width;
5+
float height;
6+
};
7+
8+
struct Trio {
9+
double i;
10+
double j;
11+
double k;
12+
};
13+
14+
struct IntPair {
15+
int a;
16+
int b;
17+
};
18+
19+
struct NestedInts {
20+
struct A {
21+
int value;
22+
} a;
23+
struct B {
24+
int value;
25+
} b;
26+
};
27+
28+
struct BigStruct {
29+
char a[32];
30+
};
31+
32+
enum RawEnum {
33+
Intergalactic,
34+
Planetary
35+
};
36+
37+
typedef struct One {
38+
float first;
39+
float second;
40+
} One;
41+
42+
static inline One makeOne(float f, float s) {
43+
One one;
44+
one.first = f;
45+
one.second = s;
46+
47+
return one;
48+
}
49+
50+
static inline float MyRect_Area(struct MyRect rect) {
51+
return rect.width * rect.height;
52+
}

test/IRGen/Inputs/abi/Gadget.h

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,5 @@
11
@import Foundation;
2-
3-
struct MyRect {
4-
float x;
5-
float y;
6-
float width;
7-
float height;
8-
};
9-
10-
struct Trio {
11-
double i;
12-
double j;
13-
double k;
14-
};
15-
16-
struct IntPair {
17-
int a;
18-
int b;
19-
};
20-
21-
struct NestedInts {
22-
struct A {
23-
int value;
24-
} a;
25-
struct B {
26-
int value;
27-
} b;
28-
};
29-
30-
struct BigStruct {
31-
char a[32];
32-
};
2+
#include "CGadget.h"
333

344
@interface StructReturns : NSObject
355
- (struct MyRect)newRect;
@@ -58,28 +28,6 @@ typedef NS_ENUM(unsigned short, ChooseTo) {
5828
ChooseToLeaveIt = 1709
5929
};
6030

61-
enum RawEnum {
62-
Intergalactic,
63-
Planetary
64-
};
65-
66-
typedef struct One {
67-
float first;
68-
float second;
69-
} One;
70-
71-
static inline One makeOne(float f, float s) {
72-
One one;
73-
one.first = f;
74-
one.second = s;
75-
76-
return one;
77-
}
78-
79-
static inline float MyRect_Area(struct MyRect rect) {
80-
return rect.width * rect.height;
81-
}
82-
8331
// @literals inside static inline function
8432
static inline void* giveMeASelector(void) {
8533
return @selector(init);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
module gadget { header "Gadget.h" }
2+
module c_gadget { header "CGadget.h" }
23
module c_layout { header "c_layout.h" }

test/IRGen/abitypes_arm.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// 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
2+
// REQUIRES: CPU=armv7 || CPU=armv7k || CPU=armv7s
3+
4+
import c_gadget
5+
6+
class Foo {
7+
// Test that the makeOne() that we generate somewhere below doesn't
8+
// use arm_aapcscc for armv7.
9+
func callInline() -> Float {
10+
return makeOne(3,5).second
11+
}
12+
}
13+
14+
// armv7: define internal void @makeOne(ptr noalias sret({{.*}}) align 4 %agg.result, float %f, float %s)
15+
// armv7s: define internal void @makeOne(ptr noalias sret({{.*}}) align 4 %agg.result, float %f, float %s)
16+
// armv7k: define internal %struct.One @makeOne(float {{.*}}%f, float {{.*}}%s)

test/IRGen/abitypes.swift renamed to test/IRGen/abitypes_objc.swift

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// 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
1+
// 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
22

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

65
import gadget
6+
import c_gadget
77
import Foundation
88

99
@objc protocol P1 {}
@@ -559,33 +559,6 @@ class Foo {
559559
@objc dynamic func callJustReturn(_ r: StructReturns, with v: BigStruct) -> BigStruct {
560560
return r.justReturn(v)
561561
}
562-
563-
// Test that the makeOne() that we generate somewhere below doesn't
564-
// use arm_aapcscc for armv7.
565-
func callInline() -> Float {
566-
return makeOne(3,5).second
567-
}
568-
}
569-
570-
// armv7-ios: define internal void @makeOne(ptr noalias sret({{.*}}) align 4 %agg.result, float %f, float %s)
571-
// armv7s-ios: define internal void @makeOne(ptr noalias sret({{.*}}) align 4 %agg.result, float %f, float %s)
572-
// armv7k-watchos: define internal %struct.One @makeOne(float {{.*}}%f, float {{.*}}%s)
573-
574-
// rdar://17631440 - Expand direct arguments that are coerced to aggregates.
575-
// x86_64-macosx: define{{( protected)?}} swiftcc float @"$s8abitypes13testInlineAggySfSo6MyRectVF"(float %0, float %1, float %2, float %3) {{.*}} {
576-
// x86_64-macosx: [[COERCED:%.*]] = alloca %TSo6MyRectV, align 8
577-
// x86_64-macosx: store float %0,
578-
// x86_64-macosx: store float %1,
579-
// x86_64-macosx: store float %2,
580-
// x86_64-macosx: store float %3,
581-
// x86_64-macosx: [[T0:%.*]] = getelementptr inbounds { <2 x float>, <2 x float> }, ptr [[COERCED]], i32 0, i32 0
582-
// x86_64-macosx: [[FIRST_HALF:%.*]] = load <2 x float>, ptr [[T0]], align 8
583-
// x86_64-macosx: [[T0:%.*]] = getelementptr inbounds { <2 x float>, <2 x float> }, ptr [[COERCED]], i32 0, i32 1
584-
// x86_64-macosx: [[SECOND_HALF:%.*]] = load <2 x float>, ptr [[T0]], align 8
585-
// x86_64-macosx: [[RESULT:%.*]] = call float @MyRect_Area(<2 x float> [[FIRST_HALF]], <2 x float> [[SECOND_HALF]])
586-
// x86_64-macosx: ret float [[RESULT]]
587-
public func testInlineAgg(_ rect: MyRect) -> Float {
588-
return MyRect_Area(rect)
589562
}
590563

591564
// We need to allocate enough memory on the stack to hold the argument value we load.

test/IRGen/abitypes_x86_64.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// 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
2+
// REQUIRES: CPU=x86_64
3+
// UNSUPPORTED: OS=windows-msvc
4+
5+
import c_gadget
6+
7+
// rdar://17631440 - Expand direct arguments that are coerced to aggregates.
8+
// x86_64: define{{( dllexport)?}}{{( protected)?}} swiftcc float @"$s8abitypes13testInlineAggySfSo6MyRectVF"(float %0, float %1, float %2, float %3) {{.*}} {
9+
// x86_64: [[COERCED:%.*]] = alloca %TSo6MyRectV, align 8
10+
// x86_64: store float %0,
11+
// x86_64: store float %1,
12+
// x86_64: store float %2,
13+
// x86_64: store float %3,
14+
// x86_64: [[T0:%.*]] = getelementptr inbounds { <2 x float>, <2 x float> }, ptr [[COERCED]], i32 0, i32 0
15+
// x86_64: [[FIRST_HALF:%.*]] = load <2 x float>, ptr [[T0]], align 8
16+
// x86_64: [[T0:%.*]] = getelementptr inbounds { <2 x float>, <2 x float> }, ptr [[COERCED]], i32 0, i32 1
17+
// x86_64: [[SECOND_HALF:%.*]] = load <2 x float>, ptr [[T0]], align 8
18+
// x86_64: [[RESULT:%.*]] = call float @MyRect_Area(<2 x float> [[FIRST_HALF]], <2 x float> [[SECOND_HALF]])
19+
// x86_64: ret float [[RESULT]]
20+
public func testInlineAgg(_ rect: MyRect) -> Float {
21+
return MyRect_Area(rect)
22+
}

0 commit comments

Comments
 (0)