Skip to content

Commit 71b1cea

Browse files
committed
Tests for uint vectors in simd.
1 parent 8187dfb commit 71b1cea

File tree

7 files changed

+16
-5
lines changed

7 files changed

+16
-5
lines changed

test/1_stdlib/simd.swift.gyb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import SwiftPrivate
1919
import ObjectiveC
2020
#endif
2121

22-
% scalar_types = ['Float', 'Double', 'Int32']
22+
% scalar_types = ['Float', 'Double', 'Int32', 'UInt32']
2323
% float_types = ['Float', 'Double']
24-
% ctype = { 'Float':'float', 'Double':'double', 'Int32':'int' }
24+
% ctype = { 'Float':'float', 'Double':'double', 'Int32':'int', 'UInt32':'uint'}
2525
% component = ['.x','.y','.z','.w']
2626

2727
% for type in scalar_types:
@@ -146,12 +146,12 @@ simdTestSuite.test("vector elements") {
146146

147147
// Check getting and setting .xyzw
148148
% for i in range(size):
149-
${vec + component[i]} = ${-i}
150-
expectEqual(${vec + component[i]}, ${-i})
149+
${vec + component[i]} = ${2*i}
150+
expectEqual(${vec + component[i]}, ${2*i})
151151
% end
152152

153153
// Check getting and setting [i]
154-
for i in 0..<${size} { ${vec}[i] = -${vec}[i] }
154+
for i in 0..<${size} { ${vec}[i] = ${vec}[i]/2 }
155155
expectEqual(${vec}, ${range(size)}, sameValue: same)
156156

157157
% end # for size in [2,3,4]

test/ClangModules/simd.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import simd
66
let f4: float4 = makes_float4()
77
let i3: int3 = makes_int3()
88
let d2: double2 = makes_double2()
9+
let u4: uint4 = makes_uint4()
910

1011
takes_float4(f4)
1112
takes_int3(i3)
1213
takes_double2(d2)
14+
takes_uint4(u4)
1315

1416
// byte17 isn't available since there isn't a type in the simd module to map it to.
1517

test/Inputs/clang-importer-sdk/swift-modules-without-ns/simd.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
@_alignment(16) public struct float4 { public var x, y, z, w: Float }
33
@_alignment(16) public struct double2 { public var x, y: Double }
44
@_alignment(16) public struct int3 { public var x, y, z: Int32 }
5+
@_alignment(16) public struct uint4 { public var x, y, z, w: UInt32 }

test/Inputs/clang-importer-sdk/swift-modules/simd.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
@_alignment(16) public struct float4 { public var x, y, z, w: Float }
33
@_alignment(16) public struct double2 { public var x, y: Double }
44
@_alignment(16) public struct int3 { public var x, y, z: Int32 }
5+
@_alignment(16) public struct uint4 { public var x, y, z, w: UInt32 }

test/Inputs/clang-importer-sdk/usr/include/simd.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ typedef int int3 __attribute__((__ext_vector_type__(3)));
22
typedef float float3 __attribute__((__ext_vector_type__(3)));
33
typedef float float4 __attribute__((__ext_vector_type__(4)));
44
typedef double double2 __attribute__((__ext_vector_type__(2)));
5+
typedef unsigned int uint4 __attribute__((__ext_vector_type__(4)));
56
typedef unsigned char byte17 __attribute__((__ext_vector_type__(17)));
67

78
int3 makes_int3(void);
9+
uint4 makes_uint4(void);
810
float3 makes_float3(void);
911
float4 makes_float4(void);
1012
double2 makes_double2(void);
1113
byte17 makes_byte17(void);
1214

1315
void takes_int3(int3 x);
16+
void takes_uint4(uint4 x);
1417
void takes_float3(float3 x);
1518
void takes_float4(float4 x);
1619
void takes_double2(double2 x);

test/PrintAsObjC/simd.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import simd
2222
// CHECK-LABEL: typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
2323
// CHECK-LABEL: typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
2424
// CHECK-LABEL: typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
25+
// CHECK-LABEL: typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
2526

2627
// -- The C simd module is useless to Swift.
2728
// CHECK-NOT: @import simd;
@@ -34,5 +35,7 @@ import simd
3435
@objc func doStuffWithDouble2(x: double2) -> double2 { return x }
3536
// CHECK-LABEL: - (swift_int3)doStuffWithInt3:(swift_int3)x;
3637
@objc func doStuffWithInt3(x: int3) -> int3 { return x }
38+
// CHECK-LABEL: - (swift_uint4)doStuffWithUInt4:(swift_uint4)x;
39+
@objc func doStuffWithUInt4(x: uint4) -> uint4 { return x }
3740
}
3841

test/attr/attr_objc_simd.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ import simd
99
@objc func doStuffWithFloat4(x: float4) -> float4 { return x }
1010
@objc func doStuffWithDouble2(x: double2) -> double2 { return x }
1111
@objc func doStuffWithInt3(x: int3) -> int3 { return x }
12+
@objc func doStuffWithUInt4(x: uint4) -> uint4 { return x }
1213
}
1314

0 commit comments

Comments
 (0)