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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
//! `x86` 和 `x86_64` 内部函数。

use crate::{intrinsics, marker::Sized, mem::transmute};

#[macro_use]
mod macros;

types! {
    /// 128 位宽的整数 vector 类型,特定于 x86
    ///
    /// 此类型与 Intel 定义的 `__m128i` 类型相同,代表一个 128 位 SIMD 寄存器。
    /// 这种类型的用法通常对应于 x86/x86_64 的 `sse` 和 up 目标特性。
    ///
    /// 在内部,此类型可以被视为:
    ///
    /// * `i8x16` - 十六个 `i8` 变量包装在一起
    /// * `i16x8` - 八个 `i16` 变量包装在一起
    /// * `i32x4` - 四个 `i32` 变量包装在一起
    /// * `i64x2` - 两个 `i64` 变量包装在一起
    ///
    /// (以及未签名的版本)。
    /// 每个内部函数可能会以不同的方式解释内部位,请查看内部函数的文档以了解它是如何使用的。
    ///
    /// 请注意,这意味着 `__m128i` 的实例通常仅表示一个 "bag of bits",该 "bag of bits" 留待使用时进行解释。
    ///
    ///
    /// 大多数使用 `__m128i` 的内部函数都以 `_mm_` 作为前缀,并且整数类型往往对应于像 "epi8" 或 "epi32" 这样的后缀。
    ///
    /// # Examples
    ///
    /// ```
    /// #[cfg(target_arch = "x86")]
    /// use std::arch::x86::*;
    /// #[cfg(target_arch = "x86_64")]
    /// use std::arch::x86_64::*;
    ///
    /// # fn main() {
    /// # #[target_feature(enable = "sse2")]
    /// # unsafe fn foo() {
    /// let all_bytes_zero = _mm_setzero_si128();
    /// let all_bytes_one = _mm_set1_epi8(1);
    /// let four_i32 = _mm_set_epi32(1, 2, 3, 4);
    /// # }
    /// # if is_x86_feature_detected!("sse2") { unsafe { foo() } }
    /// # }
    /// ```
    ///
    ///
    ///
    #[stable(feature = "simd_x86", since = "1.27.0")]
    pub struct __m128i(i64, i64);

    /// 四种 `f32` 类型的 128 位宽集,特定于 x86
    ///
    /// 此类型与 Intel 定义的 `__m128` 类型相同,代表一个 128 位 SIMD 寄存器,该寄存器内部由四个包装的 `f32` 实例组成。
    ///
    /// 这种类型的用法通常对应于 x86/x86_64 的 `sse` 和 up 目标特性。
    ///
    /// 请注意,与 `__m128i` (128 位寄存器的整数版本) 不同,此 `__m128` 类型具有 *one* 解释。
    /// `__m128` 的每个实例始终与 `f32x4` 或包装在一起的四种 `f32` 类型相对应。
    ///
    /// 大多数使用 `__m128` 的内部函数都以 `_mm_` 为前缀,并以 "ps" 为后缀 (或另外包含 "ps")。
    /// 不要与用于 `__m128d` 的 "pd" 混淆。
    ///
    /// # Examples
    ///
    /// ```
    /// #[cfg(target_arch = "x86")]
    /// use std::arch::x86::*;
    /// #[cfg(target_arch = "x86_64")]
    /// use std::arch::x86_64::*;
    ///
    /// # fn main() {
    /// # #[target_feature(enable = "sse")]
    /// # unsafe fn foo() {
    /// let four_zeros = _mm_setzero_ps();
    /// let four_ones = _mm_set1_ps(1.0);
    /// let four_floats = _mm_set_ps(1.0, 2.0, 3.0, 4.0);
    /// # }
    /// # if is_x86_feature_detected!("sse") { unsafe { foo() } }
    /// # }
    /// ```
    ///
    ///
    ///
    ///
    #[stable(feature = "simd_x86", since = "1.27.0")]
    pub struct __m128(f32, f32, f32, f32);

    /// 两种 `f64` 类型的 128 位宽集,特定于 x86
    ///
    /// 此类型与 Intel 定义的 `__m128d` 类型相同,代表一个 128 位 SIMD 寄存器,该寄存器内部由两个包装的 `f64` 实例组成。
    ///
    /// 这种类型的用法通常对应于 x86/x86_64 的 `sse` 和 up 目标特性。
    ///
    /// 请注意,与 `__m128i` (128 位寄存器的整数版本) 不同,此 `__m128d` 类型具有 *one* 解释。
    /// `__m128d` 的每个实例始终对应于 `f64x2` 或包装在一起的两种 `f64` 类型。
    ///
    /// 大多数使用 `__m128d` 的内部函数都以 `_mm_` 为前缀,并以 "pd" 为后缀 (或另外包含 "pd")。
    /// 不要与用于 `__m128` 的 "ps" 混淆。
    ///
    /// # Examples
    ///
    /// ```
    /// #[cfg(target_arch = "x86")]
    /// use std::arch::x86::*;
    /// #[cfg(target_arch = "x86_64")]
    /// use std::arch::x86_64::*;
    ///
    /// # fn main() {
    /// # #[target_feature(enable = "sse")]
    /// # unsafe fn foo() {
    /// let two_zeros = _mm_setzero_pd();
    /// let two_ones = _mm_set1_pd(1.0);
    /// let two_floats = _mm_set_pd(1.0, 2.0);
    /// # }
    /// # if is_x86_feature_detected!("sse") { unsafe { foo() } }
    /// # }
    /// ```
    ///
    ///
    ///
    ///
    #[stable(feature = "simd_x86", since = "1.27.0")]
    pub struct __m128d(f64, f64);

    /// 256 位宽的整数 vector 类型,特定于 x86
    ///
    /// 此类型与 Intel 定义的 `__m256i` 类型相同,代表 256 位 SIMD 寄存器。
    /// 这种类型的用法通常对应于 x86/x86_64 的 `avx` 和 up 目标特性。
    ///
    /// 在内部,此类型可以被视为:
    ///
    /// * `i8x32` - 三十二个 `i8` 变量包装在一起
    /// * `i16x16` - 十六个 `i16` 变量包装在一起
    /// * `i32x8` - 八个 `i32` 变量包装在一起
    /// * `i64x4` - 四个 `i64` 变量包装在一起
    ///
    /// (以及未签名的版本)。
    /// 每个内部函数可能会以不同的方式解释内部位,请查看内部函数的文档以了解它是如何使用的。
    ///
    /// 请注意,这意味着 `__m256i` 的实例通常仅表示 "bag of bits",该 "bag of bits" 留待使用时进行解释。
    ///
    ///
    /// # Examples
    ///
    /// ```
    /// #[cfg(target_arch = "x86")]
    /// use std::arch::x86::*;
    /// #[cfg(target_arch = "x86_64")]
    /// use std::arch::x86_64::*;
    ///
    /// # fn main() {
    /// # #[target_feature(enable = "avx")]
    /// # unsafe fn foo() {
    /// let all_bytes_zero = _mm256_setzero_si256();
    /// let all_bytes_one = _mm256_set1_epi8(1);
    /// let eight_i32 = _mm256_set_epi32(1, 2, 3, 4, 5, 6, 7, 8);
    /// # }
    /// # if is_x86_feature_detected!("avx") { unsafe { foo() } }
    /// # }
    /// ```
    ///
    ///
    #[stable(feature = "simd_x86", since = "1.27.0")]
    pub struct __m256i(i64, i64, i64, i64);

    /// 256 位宽的八种 `f32` 类型的集合,特定于 x86
    ///
    /// 此类型与 Intel 定义的 `__m256` 类型相同,代表一个 256 位 SIMD 寄存器,该寄存器内部由八个包装的 `f32` 实例组成。
    ///
    /// 这种类型的用法通常对应于 x86/x86_64 的 `avx` 和 up 目标特性。
    ///
    /// 请注意,与 `__m256i` (256 位寄存器的整数版本) 不同,此 `__m256` 类型具有 *one* 解释。
    /// `__m256` 的每个实例始终对应于 `f32x8` 或包装在一起的八种 `f32` 类型。
    ///
    /// 大多数使用 `__m256` 的内部函数都以 `_mm256_` 为前缀,并以 "ps" 为后缀 (或另外包含 "ps")。
    /// 不要与用于 `__m256d` 的 "pd" 混淆。
    ///
    /// # Examples
    ///
    /// ```
    /// #[cfg(target_arch = "x86")]
    /// use std::arch::x86::*;
    /// #[cfg(target_arch = "x86_64")]
    /// use std::arch::x86_64::*;
    ///
    /// # fn main() {
    /// # #[target_feature(enable = "avx")]
    /// # unsafe fn foo() {
    /// let eight_zeros = _mm256_setzero_ps();
    /// let eight_ones = _mm256_set1_ps(1.0);
    /// let eight_floats = _mm256_set_ps(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0);
    /// # }
    /// # if is_x86_feature_detected!("avx") { unsafe { foo() } }
    /// # }
    /// ```
    ///
    ///
    ///
    ///
    #[stable(feature = "simd_x86", since = "1.27.0")]
    pub struct __m256(f32, f32, f32, f32, f32, f32, f32, f32);

    /// 256 位宽的四种 `f64` 类型的集合,特定于 x86
    ///
    /// 此类型与 Intel 定义的 `__m256d` 类型相同,代表一个 256 位 SIMD 寄存器,该寄存器内部由四个包装的 `f64` 实例组成。
    ///
    /// 这种类型的用法通常对应于 x86/x86_64 的 `avx` 和 up 目标特性。
    ///
    /// 请注意,与 `__m256i` (256 位寄存器的整数版本) 不同,此 `__m256d` 类型具有 *one* 解释。
    /// `__m256d` 的每个实例始终与 `f64x4` 或包装在一起的四种 `f64` 类型相对应。
    ///
    /// 大多数使用 `__m256d` 的内部函数都以 `_mm256_` 为前缀,并以 "pd" 为后缀 (或另外包含 "pd")。
    /// 不要与用于 `__m256` 的 "ps" 混淆。
    ///
    /// # Examples
    ///
    /// ```
    /// #[cfg(target_arch = "x86")]
    /// use std::arch::x86::*;
    /// #[cfg(target_arch = "x86_64")]
    /// use std::arch::x86_64::*;
    ///
    /// # fn main() {
    /// # #[target_feature(enable = "avx")]
    /// # unsafe fn foo() {
    /// let four_zeros = _mm256_setzero_pd();
    /// let four_ones = _mm256_set1_pd(1.0);
    /// let four_floats = _mm256_set_pd(1.0, 2.0, 3.0, 4.0);
    /// # }
    /// # if is_x86_feature_detected!("avx") { unsafe { foo() } }
    /// # }
    /// ```
    ///
    ///
    ///
    ///
    #[stable(feature = "simd_x86", since = "1.27.0")]
    pub struct __m256d(f64, f64, f64, f64);

    /// 512 位宽的整数 vector 类型,特定于 x86
    ///
    /// 此类型与 Intel 定义的 `__m512i` 类型相同,代表 512 位 SIMD 寄存器。
    /// 这种类型的用法通常对应于 x86/x86_64 的 `avx512*` 和 up 目标特性。
    ///
    /// 在内部,此类型可以被视为:
    ///
    /// * `i8x64`-64 个 `i8` 变量包装在一起
    /// * `i16x32` - 三十二个 `i16` 变量包装在一起
    /// * `i32x16` - 十六个 `i32` 变量包装在一起
    /// * `i64x8` - 八个 `i64` 变量包装在一起
    ///
    /// (以及未签名的版本)。
    /// 每个内部函数可能会以不同的方式解释内部位,请查看内部函数的文档以了解它是如何使用的。
    ///
    /// 请注意,这意味着 `__m512i` 的实例通常仅表示 "bag of bits",该 "bag of bits" 留待使用时进行解释。
    ///
    ///
    ///
    pub struct __m512i(i64, i64, i64, i64, i64, i64, i64, i64);

    /// 512 位宽的十六种 `f32` 类型集,特定于 x86
    ///
    /// 此类型与 Intel 定义的 `__m512` 类型相同,代表一个 512 位 SIMD 寄存器,该寄存器内部由八个包装的 `f32` 实例组成。
    ///
    /// 这种类型的用法通常对应于 x86/x86_64 的 `avx512*` 和 up 目标特性。
    ///
    /// 请注意,与 `__m512i` (512 位寄存器的整数版本) 不同,此 `__m512` 类型具有 *one* 解释。
    /// `__m512` 的每个实例始终对应于 `f32x16` 或包装在一起的十六种 `f32` 类型。
    ///
    /// 大多数使用 `__m512` 的内部函数都以 `_mm512_` 为前缀,并以 "ps" 为后缀 (或另外包含 "ps")。
    /// 不要与用于 `__m512d` 的 "pd" 混淆。
    ///
    ///
    ///
    ///
    pub struct __m512(
        f32, f32, f32, f32, f32, f32, f32, f32,
        f32, f32, f32, f32, f32, f32, f32, f32,
    );

    /// 八种 `f64` 类型的 512 位宽集,特定于 x86
    ///
    /// 此类型与 Intel 定义的 `__m512d` 类型相同,代表一个 512 位 SIMD 寄存器,该寄存器内部由八个包装的 `f64` 实例组成。
    ///
    /// 这种类型的用法通常对应于 x86/x86_64 的 `avx` 和 up 目标特性。
    ///
    /// 请注意,与 `__m512i` (512 位寄存器的整数版本) 不同,此 `__m512d` 类型具有 *one* 解释。
    /// `__m512d` 的每个实例始终对应于 `f64x4` 或包装在一起的八种 `f64` 类型。
    ///
    /// 大多数使用 `__m512d` 的内部函数都以 `_mm512_` 为前缀,并以 "pd" 为后缀 (或另外包含 "pd")。
    /// 不要与用于 `__m512` 的 "ps" 混淆。
    ///
    ///
    ///
    ///
    pub struct __m512d(f64, f64, f64, f64, f64, f64, f64, f64);

    /// 128 位宽的一组 8 个 `u16` 类型,特定于 x86
    ///
    /// 该类型代表一个 128 位的 SIMD 寄存器,内部由 8 个包装的 `u16` 实例组成。
    /// 它的目的是用于 bf16 相关的内部函数实现。
    ///
    pub struct __m128bh(u16, u16, u16, u16, u16, u16, u16, u16);

    /// 256 位宽的 16 种 `u16` 类型集,特定于 x86
    ///
    /// 该类型与 Intel 定义的 `__m256bh` 类型相同,表示一个 256 位的 SIMD 寄存器,其内部包括
    ///
    /// 16 个包装的 `u16` 实例。它的目的是用于 bf16 相关的内部函数实现。
    ///
    pub struct __m256bh(
        u16, u16, u16, u16, u16, u16, u16, u16,
        u16, u16, u16, u16, u16, u16, u16, u16
    );

    /// 512 位宽的 32 种 `u16` 类型集,特定于 x86
    ///
    /// 该类型与 Intel 定义的 `__m512bh` 类型相同,表示一个 512 位的 SIMD 寄存器,其内部包括
    ///
    /// 32 个包装的 `u16` 实例。它的目的是用于 bf16 相关的内部函数实现。
    ///
    pub struct __m512bh(
        u16, u16, u16, u16, u16, u16, u16, u16,
        u16, u16, u16, u16, u16, u16, u16, u16,
        u16, u16, u16, u16, u16, u16, u16, u16,
        u16, u16, u16, u16, u16, u16, u16, u16
    );
}

/// AVX-512 内部函数中使用的 `__mmask64` 类型,一个 64 位整数
#[allow(non_camel_case_types)]
pub type __mmask64 = u64;

/// AVX-512 内部函数中使用的 `__mmask32` 类型,一个 32 位整数
#[allow(non_camel_case_types)]
pub type __mmask32 = u32;

/// AVX-512 内部函数中使用的 `__mmask16` 类型,一个 16 位整数
#[allow(non_camel_case_types)]
pub type __mmask16 = u16;

/// AVX-512 内部函数中使用的 `__mmask8` 类型,一个 8 位整数
#[allow(non_camel_case_types)]
pub type __mmask8 = u8;

/// `_MM_CMPINT_ENUM` 类型用于在 AVX-512 内部函数中指定比较操作。
#[allow(non_camel_case_types)]
pub type _MM_CMPINT_ENUM = i32;

/// `MM_MANTISSA_NORM_ENUM` 类型用于指定 AVX-512 内部函数中的尾数归一化操作。
#[allow(non_camel_case_types)]
pub type _MM_MANTISSA_NORM_ENUM = i32;

/// `MM_MANTISSA_SIGN_ENUM` 类型用于指定 AVX-512 内部函数中的尾数签名操作。
#[allow(non_camel_case_types)]
pub type _MM_MANTISSA_SIGN_ENUM = i32;

/// `MM_PERM_ENUM` 类型用于指定在 AVX-512 内部函数中的重排操作。
#[allow(non_camel_case_types)]
pub type _MM_PERM_ENUM = i32;

#[cfg(test)]
mod test;
#[cfg(test)]
pub use self::test::*;

#[allow(non_camel_case_types)]
#[unstable(feature = "stdsimd_internal", issue = "none")]
pub(crate) trait m128iExt: Sized {
    fn as_m128i(self) -> __m128i;

    #[inline]
    fn as_u8x16(self) -> crate::core_arch::simd::u8x16 {
        unsafe { transmute(self.as_m128i()) }
    }

    #[inline]
    fn as_u16x8(self) -> crate::core_arch::simd::u16x8 {
        unsafe { transmute(self.as_m128i()) }
    }

    #[inline]
    fn as_u32x4(self) -> crate::core_arch::simd::u32x4 {
        unsafe { transmute(self.as_m128i()) }
    }

    #[inline]
    fn as_u64x2(self) -> crate::core_arch::simd::u64x2 {
        unsafe { transmute(self.as_m128i()) }
    }

    #[inline]
    fn as_i8x16(self) -> crate::core_arch::simd::i8x16 {
        unsafe { transmute(self.as_m128i()) }
    }

    #[inline]
    fn as_i16x8(self) -> crate::core_arch::simd::i16x8 {
        unsafe { transmute(self.as_m128i()) }
    }

    #[inline]
    fn as_i32x4(self) -> crate::core_arch::simd::i32x4 {
        unsafe { transmute(self.as_m128i()) }
    }

    #[inline]
    fn as_i64x2(self) -> crate::core_arch::simd::i64x2 {
        unsafe { transmute(self.as_m128i()) }
    }
}

impl m128iExt for __m128i {
    #[inline]
    fn as_m128i(self) -> Self {
        self
    }
}

#[allow(non_camel_case_types)]
#[unstable(feature = "stdsimd_internal", issue = "none")]
pub(crate) trait m256iExt: Sized {
    fn as_m256i(self) -> __m256i;

    #[inline]
    fn as_u8x32(self) -> crate::core_arch::simd::u8x32 {
        unsafe { transmute(self.as_m256i()) }
    }

    #[inline]
    fn as_u16x16(self) -> crate::core_arch::simd::u16x16 {
        unsafe { transmute(self.as_m256i()) }
    }

    #[inline]
    fn as_u32x8(self) -> crate::core_arch::simd::u32x8 {
        unsafe { transmute(self.as_m256i()) }
    }

    #[inline]
    fn as_u64x4(self) -> crate::core_arch::simd::u64x4 {
        unsafe { transmute(self.as_m256i()) }
    }

    #[inline]
    fn as_i8x32(self) -> crate::core_arch::simd::i8x32 {
        unsafe { transmute(self.as_m256i()) }
    }

    #[inline]
    fn as_i16x16(self) -> crate::core_arch::simd::i16x16 {
        unsafe { transmute(self.as_m256i()) }
    }

    #[inline]
    fn as_i32x8(self) -> crate::core_arch::simd::i32x8 {
        unsafe { transmute(self.as_m256i()) }
    }

    #[inline]
    fn as_i64x4(self) -> crate::core_arch::simd::i64x4 {
        unsafe { transmute(self.as_m256i()) }
    }
}

impl m256iExt for __m256i {
    #[inline]
    fn as_m256i(self) -> Self {
        self
    }
}

#[allow(non_camel_case_types)]
#[unstable(feature = "stdsimd_internal", issue = "none")]
pub(crate) trait m128Ext: Sized {
    fn as_m128(self) -> __m128;

    #[inline]
    fn as_f32x4(self) -> crate::core_arch::simd::f32x4 {
        unsafe { transmute(self.as_m128()) }
    }
}

impl m128Ext for __m128 {
    #[inline]
    fn as_m128(self) -> Self {
        self
    }
}

#[allow(non_camel_case_types)]
#[unstable(feature = "stdsimd_internal", issue = "none")]
pub(crate) trait m128dExt: Sized {
    fn as_m128d(self) -> __m128d;

    #[inline]
    fn as_f64x2(self) -> crate::core_arch::simd::f64x2 {
        unsafe { transmute(self.as_m128d()) }
    }
}

impl m128dExt for __m128d {
    #[inline]
    fn as_m128d(self) -> Self {
        self
    }
}

#[allow(non_camel_case_types)]
#[unstable(feature = "stdsimd_internal", issue = "none")]
pub(crate) trait m256Ext: Sized {
    fn as_m256(self) -> __m256;

    #[inline]
    fn as_f32x8(self) -> crate::core_arch::simd::f32x8 {
        unsafe { transmute(self.as_m256()) }
    }
}

impl m256Ext for __m256 {
    #[inline]
    fn as_m256(self) -> Self {
        self
    }
}

#[allow(non_camel_case_types)]
#[unstable(feature = "stdsimd_internal", issue = "none")]
pub(crate) trait m256dExt: Sized {
    fn as_m256d(self) -> __m256d;

    #[inline]
    fn as_f64x4(self) -> crate::core_arch::simd::f64x4 {
        unsafe { transmute(self.as_m256d()) }
    }
}

impl m256dExt for __m256d {
    #[inline]
    fn as_m256d(self) -> Self {
        self
    }
}

#[allow(non_camel_case_types)]
#[unstable(feature = "stdsimd_internal", issue = "none")]
pub(crate) trait m512iExt: Sized {
    fn as_m512i(self) -> __m512i;

    #[inline]
    fn as_u8x64(self) -> crate::core_arch::simd::u8x64 {
        unsafe { transmute(self.as_m512i()) }
    }

    #[inline]
    fn as_i8x64(self) -> crate::core_arch::simd::i8x64 {
        unsafe { transmute(self.as_m512i()) }
    }

    #[inline]
    fn as_u16x32(self) -> crate::core_arch::simd::u16x32 {
        unsafe { transmute(self.as_m512i()) }
    }

    #[inline]
    fn as_i16x32(self) -> crate::core_arch::simd::i16x32 {
        unsafe { transmute(self.as_m512i()) }
    }

    #[inline]
    fn as_u32x16(self) -> crate::core_arch::simd::u32x16 {
        unsafe { transmute(self.as_m512i()) }
    }

    #[inline]
    fn as_i32x16(self) -> crate::core_arch::simd::i32x16 {
        unsafe { transmute(self.as_m512i()) }
    }

    #[inline]
    fn as_u64x8(self) -> crate::core_arch::simd::u64x8 {
        unsafe { transmute(self.as_m512i()) }
    }

    #[inline]
    fn as_i64x8(self) -> crate::core_arch::simd::i64x8 {
        unsafe { transmute(self.as_m512i()) }
    }
}

impl m512iExt for __m512i {
    #[inline]
    fn as_m512i(self) -> Self {
        self
    }
}

#[allow(non_camel_case_types)]
#[unstable(feature = "stdsimd_internal", issue = "none")]
pub(crate) trait m512Ext: Sized {
    fn as_m512(self) -> __m512;

    #[inline]
    fn as_f32x16(self) -> crate::core_arch::simd::f32x16 {
        unsafe { transmute(self.as_m512()) }
    }
}

impl m512Ext for __m512 {
    #[inline]
    fn as_m512(self) -> Self {
        self
    }
}

#[allow(non_camel_case_types)]
#[unstable(feature = "stdsimd_internal", issue = "none")]
pub(crate) trait m512dExt: Sized {
    fn as_m512d(self) -> __m512d;

    #[inline]
    fn as_f64x8(self) -> crate::core_arch::simd::f64x8 {
        unsafe { transmute(self.as_m512d()) }
    }
}

impl m512dExt for __m512d {
    #[inline]
    fn as_m512d(self) -> Self {
        self
    }
}

#[allow(non_camel_case_types)]
#[unstable(feature = "stdsimd_internal", issue = "none")]
pub(crate) trait m128bhExt: Sized {
    fn as_m128bh(self) -> __m128bh;

    #[inline]
    fn as_u16x8(self) -> crate::core_arch::simd::u16x8 {
        unsafe { transmute(self.as_m128bh()) }
    }

    #[inline]
    fn as_i16x8(self) -> crate::core_arch::simd::i16x8 {
        unsafe { transmute(self.as_m128bh()) }
    }

    #[inline]
    fn as_u32x4(self) -> crate::core_arch::simd::u32x4 {
        unsafe { transmute(self.as_m128bh()) }
    }

    #[inline]
    fn as_i32x4(self) -> crate::core_arch::simd::i32x4 {
        unsafe { transmute(self.as_m128bh()) }
    }
}

impl m128bhExt for __m128bh {
    #[inline]
    fn as_m128bh(self) -> Self {
        self
    }
}

#[allow(non_camel_case_types)]
#[unstable(feature = "stdsimd_internal", issue = "none")]
pub(crate) trait m256bhExt: Sized {
    fn as_m256bh(self) -> __m256bh;

    #[inline]
    fn as_u16x16(self) -> crate::core_arch::simd::u16x16 {
        unsafe { transmute(self.as_m256bh()) }
    }

    #[inline]
    fn as_i16x16(self) -> crate::core_arch::simd::i16x16 {
        unsafe { transmute(self.as_m256bh()) }
    }

    #[inline]
    fn as_u32x8(self) -> crate::core_arch::simd::u32x8 {
        unsafe { transmute(self.as_m256bh()) }
    }

    #[inline]
    fn as_i32x8(self) -> crate::core_arch::simd::i32x8 {
        unsafe { transmute(self.as_m256bh()) }
    }
}

impl m256bhExt for __m256bh {
    #[inline]
    fn as_m256bh(self) -> Self {
        self
    }
}

#[allow(non_camel_case_types)]
#[unstable(feature = "stdsimd_internal", issue = "none")]
pub(crate) trait m512bhExt: Sized {
    fn as_m512bh(self) -> __m512bh;

    #[inline]
    fn as_u16x32(self) -> crate::core_arch::simd::u16x32 {
        unsafe { transmute(self.as_m512bh()) }
    }

    #[inline]
    fn as_i16x32(self) -> crate::core_arch::simd::i16x32 {
        unsafe { transmute(self.as_m512bh()) }
    }

    #[inline]
    fn as_u32x16(self) -> crate::core_arch::simd::u32x16 {
        unsafe { transmute(self.as_m512bh()) }
    }

    #[inline]
    fn as_i32x16(self) -> crate::core_arch::simd::i32x16 {
        unsafe { transmute(self.as_m512bh()) }
    }
}

impl m512bhExt for __m512bh {
    #[inline]
    fn as_m512bh(self) -> Self {
        self
    }
}

mod eflags;
pub use self::eflags::*;

mod fxsr;
pub use self::fxsr::*;

mod bswap;
pub use self::bswap::*;

mod rdtsc;
pub use self::rdtsc::*;

mod cpuid;
pub use self::cpuid::*;
mod xsave;
pub use self::xsave::*;

mod sse;
pub use self::sse::*;
mod sse2;
pub use self::sse2::*;
mod sse3;
pub use self::sse3::*;
mod ssse3;
pub use self::ssse3::*;
mod sse41;
pub use self::sse41::*;
mod sse42;
pub use self::sse42::*;
mod avx;
pub use self::avx::*;
mod avx2;
pub use self::avx2::*;
mod fma;
pub use self::fma::*;

mod abm;
pub use self::abm::*;
mod bmi1;
pub use self::bmi1::*;

mod bmi2;
pub use self::bmi2::*;

#[cfg(not(stdarch_intel_sde))]
mod sse4a;
#[cfg(not(stdarch_intel_sde))]
pub use self::sse4a::*;

#[cfg(not(stdarch_intel_sde))]
mod tbm;
#[cfg(not(stdarch_intel_sde))]
pub use self::tbm::*;

mod pclmulqdq;
pub use self::pclmulqdq::*;

mod aes;
pub use self::aes::*;

mod rdrand;
pub use self::rdrand::*;

mod sha;
pub use self::sha::*;

mod adx;
pub use self::adx::*;

#[cfg(test)]
use stdarch_test::assert_instr;

/// 生成陷阱指令 `UD2`
#[cfg_attr(test, assert_instr(ud2))]
#[inline]
pub unsafe fn ud2() -> ! {
    intrinsics::abort()
}

mod avx512f;
pub use self::avx512f::*;

mod avx512bw;
pub use self::avx512bw::*;

mod avx512cd;
pub use self::avx512cd::*;

mod avx512ifma;
pub use self::avx512ifma::*;

mod avx512vbmi;
pub use self::avx512vbmi::*;

mod avx512vbmi2;
pub use self::avx512vbmi2::*;

mod avx512vnni;
pub use self::avx512vnni::*;

mod avx512bitalg;
pub use self::avx512bitalg::*;

mod gfni;
pub use self::gfni::*;

mod avx512vpopcntdq;
pub use self::avx512vpopcntdq::*;

mod vaes;
pub use self::vaes::*;

mod vpclmulqdq;
pub use self::vpclmulqdq::*;

mod bt;
pub use self::bt::*;

mod rtm;
pub use self::rtm::*;

mod f16c;
pub use self::f16c::*;

mod avx512bf16;
pub use self::avx512bf16::*;