Skip to content

Commit 35277b5

Browse files
authored
Merge pull request #25981 from gottesmm/pr-3ab738c62f9763112c2569149434e361ad22a07c
[irgen] Add a small test that provides an example of how to write vec…
2 parents cb8f249 + 9f26fc7 commit 35277b5

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/IRGen/builtin_vector.sil

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %target-swift-frontend -emit-ir -parse-sil %s -module-name Swift -parse-stdlib | %FileCheck %s
2+
3+
// This file provides examples on how vector computations are written at the SIL
4+
// level and how they are translated by IRGen to LLVM IR intrinsics.
5+
6+
import Builtin
7+
8+
// CHECK-LABEL: define{{( protected)?}} swiftcc <4 x i32> @vector_int_add(<4 x i32>, <4 x i32>) {{.*}} {
9+
// CHECK-NEXT: entry:
10+
// CHECK-NEXT: %2 = add <4 x i32> %0, %1
11+
// CHECK-NEXT: ret <4 x i32> %2
12+
// CHECK-NEXT: }
13+
sil @vector_int_add : $@convention(thin) (Builtin.Vec4xInt32, Builtin.Vec4xInt32) -> Builtin.Vec4xInt32 {
14+
bb0(%0 : $Builtin.Vec4xInt32, %1 : $Builtin.Vec4xInt32):
15+
%2 = builtin "add_Vec4xInt32" (%0 : $Builtin.Vec4xInt32, %1 : $Builtin.Vec4xInt32) : $Builtin.Vec4xInt32
16+
return %2 : $Builtin.Vec4xInt32
17+
}
18+
19+
// CHECK-LABEL: define{{( protected)?}} swiftcc <4 x float> @vector_float_add(<4 x float>, <4 x float>) {{.*}} {
20+
// CHECK-NEXT: entry:
21+
// CHECK-NEXT: %2 = fadd <4 x float> %0, %1
22+
// CHECK-NEXT: ret <4 x float> %2
23+
// CHECK-NEXT: }
24+
sil @vector_float_add : $@convention(thin) (Builtin.Vec4xFPIEEE32, Builtin.Vec4xFPIEEE32) -> Builtin.Vec4xFPIEEE32 {
25+
bb0(%0 : $Builtin.Vec4xFPIEEE32, %1 : $Builtin.Vec4xFPIEEE32):
26+
%2 = builtin "fadd_Vec4xFPIEEE32"(%0 : $Builtin.Vec4xFPIEEE32, %1 : $Builtin.Vec4xFPIEEE32) : $Builtin.Vec4xFPIEEE32
27+
return %2 : $Builtin.Vec4xFPIEEE32
28+
}

0 commit comments

Comments
 (0)