@@ -33,8 +33,12 @@ prefix operator .!
33
33
/// conform to `SIMD`.
34
34
public protocol SIMDStorage {
35
35
/// The type of scalars in the vector space.
36
+ #if $Embedded
37
+ associatedtype Scalar : Hashable
38
+ #else
36
39
associatedtype Scalar : Codable , Hashable
37
-
40
+ #endif
41
+
38
42
/// The number of scalars, or elements, in the vector.
39
43
var scalarCount : Int { get }
40
44
@@ -71,6 +75,20 @@ public protocol SIMDScalar {
71
75
associatedtype SIMD64Storage : SIMDStorage where SIMD64Storage. Scalar == Self
72
76
}
73
77
78
+ #if !$Embedded
79
+ /// A SIMD vector of a fixed number of elements.
80
+ public protocol SIMD < Scalar> :
81
+ SIMDStorage ,
82
+ Hashable ,
83
+ ExpressibleByArrayLiteral
84
+ {
85
+ /// The mask type resulting from pointwise comparisons of this vector type.
86
+ associatedtype MaskStorage : SIMD
87
+ where MaskStorage. Scalar: FixedWidthInteger & SignedInteger
88
+ }
89
+
90
+ #else
91
+
74
92
/// A SIMD vector of a fixed number of elements.
75
93
public protocol SIMD < Scalar> :
76
94
SIMDStorage ,
@@ -84,6 +102,8 @@ public protocol SIMD<Scalar>:
84
102
where MaskStorage. Scalar: FixedWidthInteger & SignedInteger
85
103
}
86
104
105
+ #endif
106
+
87
107
extension SIMD {
88
108
/// The valid indices for subscripting the vector.
89
109
@_transparent
@@ -111,6 +131,8 @@ extension SIMD {
111
131
public func hash( into hasher: inout Hasher ) {
112
132
for i in indices { hasher. combine ( self [ i] ) }
113
133
}
134
+
135
+ #if !$Embedded
114
136
115
137
/// Encodes the scalars of this vector into the given encoder in an unkeyed
116
138
/// container.
@@ -154,7 +176,9 @@ extension SIMD {
154
176
return " \( Self . self) ( " + indices. map ( { " \( self [ $0] ) " } ) . joined ( separator: " , " ) + " ) "
155
177
}
156
178
}
157
-
179
+
180
+ #endif
181
+
158
182
/// A vector mask with the result of a pointwise equality comparison.
159
183
///
160
184
/// Equivalent to:
@@ -539,6 +563,8 @@ extension SIMD where Scalar: FixedWidthInteger {
539
563
return Self ( repeating: 1 )
540
564
}
541
565
566
+ #if !$Embedded
567
+
542
568
/// Returns a vector with random values from within the specified range in
543
569
/// all lanes, using the given generator as a source for randomness.
544
570
@inlinable
@@ -560,7 +586,7 @@ extension SIMD where Scalar: FixedWidthInteger {
560
586
var g = SystemRandomNumberGenerator ( )
561
587
return Self . random ( in: range, using: & g)
562
588
}
563
-
589
+
564
590
/// Returns a vector with random values from within the specified range in
565
591
/// all lanes, using the given generator as a source for randomness.
566
592
@inlinable
@@ -582,6 +608,9 @@ extension SIMD where Scalar: FixedWidthInteger {
582
608
var g = SystemRandomNumberGenerator ( )
583
609
return Self . random ( in: range, using: & g)
584
610
}
611
+
612
+ #endif
613
+
585
614
}
586
615
587
616
extension SIMD where Scalar: FloatingPoint {
@@ -608,6 +637,8 @@ extension SIMD where Scalar: FloatingPoint {
608
637
}
609
638
}
610
639
640
+ #if !$Embedded
641
+
611
642
extension SIMD
612
643
where Scalar: BinaryFloatingPoint , Scalar. RawSignificand: FixedWidthInteger {
613
644
/// Returns a vector with random values from within the specified range in
@@ -655,6 +686,8 @@ where Scalar: BinaryFloatingPoint, Scalar.RawSignificand: FixedWidthInteger {
655
686
}
656
687
}
657
688
689
+ #endif
690
+
658
691
@frozen
659
692
public struct SIMDMask < Storage> : SIMD
660
693
where Storage: SIMD ,
@@ -695,6 +728,8 @@ public struct SIMDMask<Storage>: SIMD
695
728
}
696
729
}
697
730
731
+ #if !$Embedded
732
+
698
733
extension SIMDMask {
699
734
/// Returns a vector mask with `true` or `false` randomly assigned in each
700
735
/// lane, using the given generator as a source for randomness.
@@ -714,6 +749,8 @@ extension SIMDMask {
714
749
}
715
750
}
716
751
752
+ #endif
753
+
717
754
// Implementations of integer operations. These should eventually all
718
755
// be replaced with @_semantics to lower directly to vector IR nodes.
719
756
extension SIMD where Scalar: FixedWidthInteger {
0 commit comments