diff --git a/test/IRGen/Inputs/abi/CGadget.h b/test/IRGen/Inputs/abi/CGadget.h new file mode 100644 index 0000000000000..0415f979d3726 --- /dev/null +++ b/test/IRGen/Inputs/abi/CGadget.h @@ -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; +} diff --git a/test/IRGen/Inputs/abi/Gadget.h b/test/IRGen/Inputs/abi/Gadget.h index 7129d1d4239ac..5000614316400 100644 --- a/test/IRGen/Inputs/abi/Gadget.h +++ b/test/IRGen/Inputs/abi/Gadget.h @@ -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; @@ -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); diff --git a/test/IRGen/Inputs/abi/module.modulemap b/test/IRGen/Inputs/abi/module.modulemap index dd33aa515922b..e49444b47d628 100644 --- a/test/IRGen/Inputs/abi/module.modulemap +++ b/test/IRGen/Inputs/abi/module.modulemap @@ -1,2 +1,3 @@ module gadget { header "Gadget.h" } +module c_gadget { header "CGadget.h" } module c_layout { header "c_layout.h" } diff --git a/test/IRGen/abitypes_arm.swift b/test/IRGen/abitypes_arm.swift new file mode 100644 index 0000000000000..86b191f6a384b --- /dev/null +++ b/test/IRGen/abitypes_arm.swift @@ -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) diff --git a/test/IRGen/abitypes.swift b/test/IRGen/abitypes_objc.swift similarity index 96% rename from test/IRGen/abitypes.swift rename to test/IRGen/abitypes_objc.swift index 08bbef98bdc9e..c626728a81513 100644 --- a/test/IRGen/abitypes.swift +++ b/test/IRGen/abitypes_objc.swift @@ -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 {} @@ -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. diff --git a/test/IRGen/abitypes_x86_64.swift b/test/IRGen/abitypes_x86_64.swift new file mode 100644 index 0000000000000..80314b3fbad3a --- /dev/null +++ b/test/IRGen/abitypes_x86_64.swift @@ -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) +}