mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Use the generic type lowering algorithm described in "docs/CallingConvention.rst#physical-lowering" to map from IRGen's explosion type to the type expected by the ABI. Change IRGen to use the swift calling convention (swiftcc) for native swift functions. Use the 'swiftself' attribute on self parameters and for closures contexts. Use the 'swifterror' parameter for swift error parameters. Change functions in the runtime that are called as native swift functions to use the swift calling convention. rdar://19978563
41 lines
1.1 KiB
Swift
41 lines
1.1 KiB
Swift
// RUN: %target-swift-frontend -Xllvm -new-mangling-for-tests %s -emit-ir -g -o - | %FileCheck %s
|
|
|
|
protocol PointUtils {
|
|
func distanceFromOrigin() -> Float
|
|
}
|
|
// CHECK: define {{.*}}float @_T08protocol{{.*}}FTW({{.*}} !dbg !{{[0-9]+}}
|
|
|
|
class Point : PointUtils {
|
|
var x : Float
|
|
var y : Float
|
|
init (_x : Float, _y : Float) {
|
|
x = _x
|
|
y = _y
|
|
}
|
|
|
|
func distanceFromOrigin() -> Float {
|
|
return 1.0
|
|
}
|
|
|
|
}
|
|
|
|
// CHECK: define hidden {{.*}}i64 @_T08protocol4mains5Int64VyF() {{.*}} {
|
|
func main() -> Int64 {
|
|
var pt = Point(_x: 2.5, _y: 4.25)
|
|
// CHECK: [[LOC2D:%[a-zA-Z0-9]+]] = alloca %P8protocol10PointUtils_, align {{(4|8)}}
|
|
// CHECK: call void @llvm.dbg.declare(metadata {{.*}} [[LOC2D]], metadata ![[LOC:.*]], metadata !{{[0-9]+}})
|
|
var loc2d : PointUtils = pt
|
|
var distance = loc2d.distanceFromOrigin()
|
|
|
|
return 0
|
|
}
|
|
|
|
// Self should be artificial.
|
|
// CHECK: !DILocalVariable(name: "self", arg: 1{{.*}} line: 16
|
|
// CHECK-SAME: DIFlagArtificial
|
|
|
|
// CHECK: ![[LOC]] = !DILocalVariable(name: "loc2d",{{.*}} line: [[@LINE-10]]
|
|
|
|
main()
|
|
|