2 Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
3 Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign,
8 #[rustfmt::skip] // work around for https://github.com/rust-lang/rustfmt/issues/4823
9 macro_rules! make_types {
12 $(#[scalar = $ScalarBool:ident])?
16 $(#[scalar = $ScalarU8:ident])?
20 $(#[scalar = $ScalarU16:ident])?
24 $(#[scalar = $ScalarU32:ident])?
28 $(#[scalar = $ScalarU64:ident])?
32 $(#[scalar = $ScalarI8:ident])?
36 $(#[scalar = $ScalarI16:ident])?
40 $(#[scalar = $ScalarI32:ident])?
44 $(#[scalar = $ScalarI64:ident])?
48 $(#[scalar = $ScalarF16:ident])?
52 $(#[scalar = $ScalarF32:ident])?
56 $(#[scalar = $ScalarF64:ident])?
59 type Bool: Bool + Make<Self, Prim = bool> + Select<Self::Bool>;
60 type U8: UInt<Self::U32>
61 + Compare<Bool = Self::Bool>
62 + Make<Self, Prim = u8>
73 type U16: UInt<Self::U32>
74 + Compare<Bool = Self::Bool>
75 + Make<Self, Prim = u16>
78 + ConvertTo<Self::I16>
79 + ConvertTo<Self::F16>
86 type U32: UInt<Self::U32>
87 + Compare<Bool = Self::Bool>
88 + Make<Self, Prim = u32>
91 + ConvertTo<Self::U16>
92 + ConvertTo<Self::I16>
93 + ConvertTo<Self::F16>
94 + ConvertTo<Self::I32>
95 + ConvertTo<Self::F32>
99 type U64: UInt<Self::U32>
100 + Compare<Bool = Self::Bool>
101 + Make<Self, Prim = u64>
102 + ConvertTo<Self::U8>
103 + ConvertTo<Self::I8>
104 + ConvertTo<Self::U16>
105 + ConvertTo<Self::I16>
106 + ConvertTo<Self::F16>
107 + ConvertTo<Self::U32>
108 + ConvertTo<Self::I32>
109 + ConvertTo<Self::F32>
110 + ConvertTo<Self::I64>
111 + ConvertTo<Self::F64>;
112 type I8: SInt<Self::U32>
113 + Compare<Bool = Self::Bool>
114 + Make<Self, Prim = i8>
115 + ConvertTo<Self::U8>
116 + ConvertTo<Self::U16>
119 + ConvertTo<Self::U32>
122 + ConvertTo<Self::U64>
125 type I16: SInt<Self::U32>
126 + Compare<Bool = Self::Bool>
127 + Make<Self, Prim = i16>
128 + ConvertTo<Self::U8>
129 + ConvertTo<Self::I8>
130 + ConvertTo<Self::U16>
131 + ConvertTo<Self::F16>
132 + ConvertTo<Self::U32>
135 + ConvertTo<Self::U64>
138 type I32: SInt<Self::U32>
139 + Compare<Bool = Self::Bool>
140 + Make<Self, Prim = i32>
141 + ConvertTo<Self::U8>
142 + ConvertTo<Self::I8>
143 + ConvertTo<Self::U16>
144 + ConvertTo<Self::I16>
145 + ConvertTo<Self::F16>
146 + ConvertTo<Self::U32>
147 + ConvertTo<Self::F32>
148 + ConvertTo<Self::U64>
151 type I64: SInt<Self::U32>
152 + Compare<Bool = Self::Bool>
153 + Make<Self, Prim = i64>
154 + ConvertTo<Self::U8>
155 + ConvertTo<Self::I8>
156 + ConvertTo<Self::U16>
157 + ConvertTo<Self::I16>
158 + ConvertTo<Self::F16>
159 + ConvertTo<Self::U32>
160 + ConvertTo<Self::I32>
161 + ConvertTo<Self::F32>
162 + ConvertTo<Self::U64>
163 + ConvertTo<Self::F64>;
164 type F16: Float<Self::U32, BitsType = Self::U16>
165 + Compare<Bool = Self::Bool>
166 + Make<Self, Prim = F16>
167 + ConvertTo<Self::U8>
168 + ConvertTo<Self::I8>
169 + ConvertTo<Self::U16>
170 + ConvertTo<Self::I16>
171 + ConvertTo<Self::U32>
172 + ConvertTo<Self::I32>
174 + ConvertTo<Self::U64>
175 + ConvertTo<Self::I64>
177 type F32: Float<Self::U32, BitsType = Self::U32>
178 + Compare<Bool = Self::Bool>
179 + Make<Self, Prim = f32>
180 + ConvertTo<Self::U8>
181 + ConvertTo<Self::I8>
182 + ConvertTo<Self::U16>
183 + ConvertTo<Self::I16>
184 + ConvertTo<Self::F16>
185 + ConvertTo<Self::U32>
186 + ConvertTo<Self::I32>
187 + ConvertTo<Self::U64>
188 + ConvertTo<Self::I64>
190 type F64: Float<Self::U32, BitsType = Self::U64>
191 + Compare<Bool = Self::Bool>
192 + Make<Self, Prim = f64>
193 + ConvertTo<Self::U8>
194 + ConvertTo<Self::I8>
195 + ConvertTo<Self::U16>
196 + ConvertTo<Self::I16>
197 + ConvertTo<Self::F16>
198 + ConvertTo<Self::U32>
199 + ConvertTo<Self::I32>
200 + ConvertTo<Self::F32>
201 + ConvertTo<Self::U64>
202 + ConvertTo<Self::I64>;
206 /// reference used to build IR for Kazan; an empty type for `core::simd`
207 pub trait Context: Copy {
247 #[scalar = ScalarBool]
255 #[scalar = ScalarU16]
259 #[scalar = ScalarU32]
263 #[scalar = ScalarU64]
271 #[scalar = ScalarI16]
275 #[scalar = ScalarI32]
279 #[scalar = ScalarI64]
283 #[scalar = ScalarF16]
287 #[scalar = ScalarF32]
291 #[scalar = ScalarF64]
294 type Bool: Bool + Make<Self, Prim = bool> + Select<Self::Bool>;
295 type U8: UInt<Self::U32>
296 + Compare<Bool = Self::Bool>
297 + Make<Self, Prim = u8>
298 + ConvertTo<Self::I8>
308 type U16: UInt<Self::U32>
309 + Compare<Bool = Self::Bool>
310 + Make<Self, Prim = u16>
311 + ConvertTo<Self::U8>
312 + ConvertTo<Self::I8>
313 + ConvertTo<Self::I16>
314 + ConvertTo<Self::F16>
321 type U32: UInt<Self::U32>
322 + Compare<Bool = Self::Bool>
323 + Make<Self, Prim = u32>
324 + ConvertTo<Self::U8>
325 + ConvertTo<Self::I8>
326 + ConvertTo<Self::U16>
327 + ConvertTo<Self::I16>
328 + ConvertTo<Self::F16>
329 + ConvertTo<Self::I32>
330 + ConvertTo<Self::F32>
334 type U64: UInt<Self::U32>
335 + Compare<Bool = Self::Bool>
336 + Make<Self, Prim = u64>
337 + ConvertTo<Self::U8>
338 + ConvertTo<Self::I8>
339 + ConvertTo<Self::U16>
340 + ConvertTo<Self::I16>
341 + ConvertTo<Self::F16>
342 + ConvertTo<Self::U32>
343 + ConvertTo<Self::I32>
344 + ConvertTo<Self::F32>
345 + ConvertTo<Self::I64>
346 + ConvertTo<Self::F64>;
347 type I8: SInt<Self::U32>
348 + Compare<Bool = Self::Bool>
349 + Make<Self, Prim = i8>
350 + ConvertTo<Self::U8>
351 + ConvertTo<Self::U16>
354 + ConvertTo<Self::U32>
357 + ConvertTo<Self::U64>
360 type I16: SInt<Self::U32>
361 + Compare<Bool = Self::Bool>
362 + Make<Self, Prim = i16>
363 + ConvertTo<Self::U8>
364 + ConvertTo<Self::I8>
365 + ConvertTo<Self::U16>
366 + ConvertTo<Self::F16>
367 + ConvertTo<Self::U32>
370 + ConvertTo<Self::U64>
373 type I32: SInt<Self::U32>
374 + Compare<Bool = Self::Bool>
375 + Make<Self, Prim = i32>
376 + ConvertTo<Self::U8>
377 + ConvertTo<Self::I8>
378 + ConvertTo<Self::U16>
379 + ConvertTo<Self::I16>
380 + ConvertTo<Self::F16>
381 + ConvertTo<Self::U32>
382 + ConvertTo<Self::F32>
383 + ConvertTo<Self::U64>
386 type I64: SInt<Self::U32>
387 + Compare<Bool = Self::Bool>
388 + Make<Self, Prim = i64>
389 + ConvertTo<Self::U8>
390 + ConvertTo<Self::I8>
391 + ConvertTo<Self::U16>
392 + ConvertTo<Self::I16>
393 + ConvertTo<Self::F16>
394 + ConvertTo<Self::U32>
395 + ConvertTo<Self::I32>
396 + ConvertTo<Self::F32>
397 + ConvertTo<Self::U64>
398 + ConvertTo<Self::F64>;
399 type F16: Float<Self::U32, BitsType = Self::U16>
400 + Compare<Bool = Self::Bool>
401 + Make<Self, Prim = F16>
402 + ConvertTo<Self::U8>
403 + ConvertTo<Self::I8>
404 + ConvertTo<Self::U16>
405 + ConvertTo<Self::I16>
406 + ConvertTo<Self::U32>
407 + ConvertTo<Self::I32>
409 + ConvertTo<Self::U64>
410 + ConvertTo<Self::I64>
412 type F32: Float<Self::U32, BitsType = Self::U32>
413 + Compare<Bool = Self::Bool>
414 + Make<Self, Prim = f32>
415 + ConvertTo<Self::U8>
416 + ConvertTo<Self::I8>
417 + ConvertTo<Self::U16>
418 + ConvertTo<Self::I16>
419 + ConvertTo<Self::F16>
420 + ConvertTo<Self::U32>
421 + ConvertTo<Self::I32>
422 + ConvertTo<Self::U64>
423 + ConvertTo<Self::I64>
425 type F64: Float<Self::U32, BitsType = Self::U64>
426 + Compare<Bool = Self::Bool>
427 + Make<Self, Prim = f64>
428 + ConvertTo<Self::U8>
429 + ConvertTo<Self::I8>
430 + ConvertTo<Self::U16>
431 + ConvertTo<Self::I16>
432 + ConvertTo<Self::F16>
433 + ConvertTo<Self::U32>
434 + ConvertTo<Self::I32>
435 + ConvertTo<Self::F32>
436 + ConvertTo<Self::U64>
437 + ConvertTo<Self::I64>;
439 type VecBool: From<Self::Bool> + Bool + Make<Self, Prim = bool> + Select<Self::VecBool>;
440 type VecU8: From<Self::U8>
442 + Compare<Bool = Self::VecBool>
443 + Make<Self, Prim = u8>;
444 type VecI8: From<Self::I8>
446 + Compare<Bool = Self::VecBool>
447 + Make<Self, Prim = i8>;
448 type VecU16: From<Self::U16>
450 + Compare<Bool = Self::VecBool>
451 + Make<Self, Prim = u16>;
452 type VecI16: From<Self::I16>
454 + Compare<Bool = Self::VecBool>
455 + Make<Self, Prim = i16>;
456 type VecF16: From<Self::F16> + Float + Compare<Bool = Self::VecBool> + Make<Self, Prim = F16>;
457 type VecU32: From<Self::U32>
459 + Compare<Bool = Self::VecBool>
460 + Make<Self, Prim = u32>;
461 type VecI32: From<Self::I32>
463 + Compare<Bool = Self::VecBool>
464 + Make<Self, Prim = i32>;
465 type VecF32: From<Self::F32> + Float + Compare<Bool = Self::VecBool> + Make<Self, Prim = f32>;
466 type VecU64: From<Self::U64>
468 + Compare<Bool = Self::VecBool>
469 + Make<Self, Prim = u64>;
470 type VecI64: From<Self::I64>
472 + Compare<Bool = Self::VecBool>
473 + Make<Self, Prim = i64>;
474 type VecF64: From<Self::F64> + Float + Compare<Bool = Self::VecBool> + Make<Self, Prim = f64>;
475 fn make<T: Make<Self>>(self, v: T::Prim) -> T {
480 pub trait Make<Context>: Sized {
482 fn make(ctx: Context, v: Self::Prim) -> Self;
485 pub trait ConvertTo<T> {
489 impl<T, U: Into<T>> ConvertTo<T> for U {
512 + BitAnd<Output = Self>
513 + BitOr<Output = Self>
514 + BitXor<Output = Self>
522 pub trait Int<ShiftRhs>:
525 + Shl<ShiftRhs, Output = Self>
526 + Shr<ShiftRhs, Output = Self>
527 + ShlAssign<ShiftRhs>
528 + ShrAssign<ShiftRhs>
532 pub trait UInt<ShiftRhs>: Int<ShiftRhs> {}
534 pub trait SInt<ShiftRhs>: Int<ShiftRhs> + Neg<Output = Self> {}
536 pub trait Float<BitsShiftRhs>: Number + Neg<Output = Self> {
537 type BitsType: UInt<BitsShiftRhs>;
538 fn abs(self) -> Self;
539 fn trunc(self) -> Self;
540 fn ceil(self) -> Self;
541 fn floor(self) -> Self;
542 fn round(self) -> Self;
543 fn fma(self, a: Self, b: Self) -> Self;
544 fn is_nan(self) -> Self::Bool;
545 fn is_infinity(self) -> Self::Bool;
546 fn is_finite(self) -> Self::Bool;
547 fn from_bits(v: Self::BitsType) -> Self;
548 fn to_bits(self) -> Self::BitsType;
551 pub trait Bool: BitOps {}
553 pub trait Select<T>: Bool {
554 fn select(self, true_v: T, false_v: T) -> T;
557 pub trait Compare: Copy {
558 type Bool: Bool + Select<Self>;
559 fn eq(self, rhs: Self) -> Self::Bool;
560 fn ne(self, rhs: Self) -> Self::Bool;
561 fn lt(self, rhs: Self) -> Self::Bool;
562 fn gt(self, rhs: Self) -> Self::Bool;
563 fn le(self, rhs: Self) -> Self::Bool;
564 fn ge(self, rhs: Self) -> Self::Bool;