File: function-template-silgen.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (31 lines) | stat: -rw-r--r-- 1,745 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// RUN: %target-swift-emit-sil %s -I %S/Inputs -enable-experimental-cxx-interop | %FileCheck %s

import FunctionTemplates

// CHECK-LABEL: sil @$s4main4test1xs5Int32VAE_tF

// CHECK: bb0(%0 : $Int32):
// CHECK:   [[IL_ZERO:%.*]] = integer_literal $Builtin.Int32, 0
// CHECK:   [[ZERO:%.*]] = struct $Int32 ([[IL_ZERO]] : $Builtin.Int32)
// CHECK:   [[PASS_THROUGH_CONST_FN:%.*]] = function_ref @{{_Z16passThroughConstIiEKT_S0_|\?\?\$passThroughConst@H@@YA\?BHH@Z}} : $@convention(c) (Int32) -> Int32
// CHECK:   [[A:%.*]] = apply [[PASS_THROUGH_CONST_FN]]([[ZERO]]) : $@convention(c) (Int32) -> Int32

// CHECK:   [[PASS_THROUGH_FN:%.*]] = function_ref @{{_Z11passThroughIiET_S0_|\?\?\$passThrough@H@@YAHH@Z}} : $@convention(c) (Int32) -> Int32
// CHECK:   [[B:%.*]] = apply [[PASS_THROUGH_FN]](%0) : $@convention(c) (Int32) -> Int32

// CHECK:   [[ADD_TWO_FN:%.*]] = function_ref @{{_Z18addMixedTypeParamsIiiET_S0_T0_|\?\?\$addMixedTypeParams@HH@@YAHHH@Z}} : $@convention(c) (Int32, Int32) -> Int32
// CHECK:   [[C:%.*]] = apply [[ADD_TWO_FN]]([[A]], [[B]]) : $@convention(c) (Int32, Int32) -> Int32

// CHECK:   [[C_32_ADDR:%.*]] = alloc_stack $Int32
// CHECK:   [[C_32:%.*]] = load [[C_32_ADDR]] : $*Int32
// CHECK:   [[ADD_FN:%.*]] = function_ref @{{_Z17addSameTypeParamsIiET_S0_S0_|\?\?\$addSameTypeParams@H@@YAHHH@Z}} : $@convention(c) (Int32, Int32) -> Int32
// CHECK:   [[OUT:%.*]] = apply [[ADD_FN]]([[B]], [[C_32]]) : $@convention(c) (Int32, Int32) -> Int32
// CHECK:   return [[OUT]] : $Int32

// CHECK-LABEL: end sil function '$s4main4test1xs5Int32VAE_tF'
public func test(x: Int32) -> Int32 {
  let a = passThroughConst(Int32(0))
  let b = passThrough(x)
  let c = addMixedTypeParams(a, b)
  return addSameTypeParams(b, Int32(c))
}