File: select_enum_single_payload.sil

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 (54 lines) | stat: -rw-r--r-- 2,050 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// RUN: %target-swift-frontend %s -emit-ir | %FileCheck %s --check-prefix=CHECK-%target-ptrsize
// REQUIRES: CPU=i386 || CPU=x86_64

sil_stage canonical

import Builtin

enum ManyEmptyCases {
    case A
    case B
    case C(Builtin.Int32)
}

// CHECK-LABEL-64: define{{( protected)?}} swiftcc i1 @select_enum_A(i64)
// CHECK-64:  %2 = load i32, ptr %temp-coercion.coerced
// CHECK-64:  %4 = load i1, ptr %3
// CHECK-64:  [[PAYLOAD:%.*]] = icmp eq i32 %2, 0
// CHECK-64:  [[EXTRA:%.*]] = and i1 %4, [[PAYLOAD]]
// CHECK-64:  ret i1 [[EXTRA]]

// CHECK-LABEL-32: define{{( protected)?}} swiftcc i1 @select_enum_A(i32, i8) {{.*}}{
// CHECK-32: entry:
// CHECK-32:   %2 = trunc i8 %1 to i1
// CHECK-32:   %3 = icmp eq i32 %0, 0
// CHECK-32:   %4 = and i1 %2, %3
// CHECK-32:   ret i1 %4
sil @select_enum_A : $@convention(thin) (ManyEmptyCases) -> Builtin.Int1 {
entry(%0 : $ManyEmptyCases):
  %4 = integer_literal $Builtin.Int1, -1          // user: %6
  %5 = integer_literal $Builtin.Int1, 0           // user: %6
  %6 = select_enum %0 : $ManyEmptyCases, case #ManyEmptyCases.A!enumelt: %4, default %5 : $Builtin.Int1
  return %6 : $Builtin.Int1
}

// CHECK-LABEL-64: define{{( protected)?}} swiftcc i1 @select_enum_B(i64)
// CHECK-64:  %2 = load i32, ptr %temp-coercion.coerced
// CHECK-64:  %4 = load i1, ptr %3
// CHECK-64:  [[PAYLOAD:%.*]] = icmp eq i32 %2, 1
// CHECK-64:  [[EXTRA:%.*]] = and i1 %4, [[PAYLOAD]]
// CHECK-64:  ret i1 [[EXTRA]]

// CHECK-LABEL-32: define{{( protected)?}} swiftcc i1 @select_enum_A(i32, i8) {{.*}}{
// CHECK-32: entry:
// CHECK-32:   %2 = trunc i8 %1 to i1
// CHECK-32:   %3 = icmp eq i32 %0, 1
// CHECK-32:   %4 = and i1 %2, %3
// CHECK-32:   ret i1 %4
sil @select_enum_B : $@convention(thin) (ManyEmptyCases) -> Builtin.Int1 {
entry(%0 : $ManyEmptyCases):
  %4 = integer_literal $Builtin.Int1, -1          // user: %6
  %5 = integer_literal $Builtin.Int1, 0           // user: %6
  %6 = select_enum %0 : $ManyEmptyCases, case #ManyEmptyCases.B!enumelt: %4, default %5 : $Builtin.Int1
  return %6 : $Builtin.Int1
}