mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
7d48e98f5e
The default code generation model for Embedded Swift is "inlinable". DeferredCodeGen made the default code generation model "implementation", and there was no spelling for "interface". Introduce the experimental feature CodeGenerationModel=<model>, which can be any of those three options. The default remains "inlinable", but one can now specify "implementation" (which keeps most everything in SIL) or "interface" (which only keeps the generic things in SIL). The "interface" mode is more like non-embedded Swift for non-generic declarations, emitting them into the IR (only) but not SIL. Generic declarations would remain in SIL. Implements rdar://172433062.
32 lines
1.2 KiB
Swift
32 lines
1.2 KiB
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: split-file %s %t
|
|
|
|
// Library module
|
|
|
|
// SIL checking
|
|
// RUN: %target-swift-frontend %t/Library.swift -parse-as-library -entry-point-function-name Library_main -enable-experimental-feature Embedded -enable-experimental-feature CodeGenerationModel=implementation -emit-sil -emit-module-path %t/Modules/Library.swiftmodule -o - | %FileCheck -check-prefix LIBRARY-SIL %s
|
|
|
|
// RUN: %target-swift-frontend %t/Application.swift -I %t/Modules -parse-as-library -entry-point-function-name Application_main -enable-experimental-feature Embedded -emit-sil -o - | %FileCheck -check-prefix APPLICATION-SIL %s
|
|
|
|
// REQUIRES: swift_in_compiler
|
|
// REQUIRES: swift_feature_Embedded
|
|
|
|
//--- Library.swift
|
|
|
|
func internalFunc() { }
|
|
|
|
// LIBRARY-SIL: sil [export_implementation] [asmname "swift_dosomething"] @$e7Library17swift_dosomethingyyFTo : $@convention(c) () -> () {
|
|
@c
|
|
public func swift_dosomething() {
|
|
internalFunc()
|
|
}
|
|
|
|
//--- Application.swift
|
|
import Library
|
|
|
|
// APPLICATION-SIL-LABEL: sil @$e11Application4testyyF : $@convention(thin) () -> ()
|
|
public func test() {
|
|
// CHECK: function_ref @$e7Library17swift_dosomethingyyFTo : $@convention(c) () -> ()
|
|
swift_dosomething()
|
|
}
|