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
use std::{
mem::MaybeUninit,
ops::{Deref, DerefMut},
ptr::NonNull,
};
use crate::hook::custom::{
place::{Place, Ref, ResolvePlace, TrivialPlace, UnalignedRef},
x86_64::Context,
};
#[doc(hidden)]
#[repr(transparent)]
pub struct Gpr<T, const N: usize>(NonNull<T>);
#[doc(hidden)]
#[repr(transparent)]
pub struct Flag<const N: usize>(NonNull<u32>);
#[doc(hidden)]
#[repr(transparent)]
pub struct St<const N: usize>(NonNull<[u8; 10]>);
#[doc(hidden)]
#[repr(transparent)]
pub struct Xmm<const N: usize>(NonNull<[u8; 16]>);
#[doc(hidden)]
#[repr(transparent)]
pub struct Ymm<const N: usize>(NonNull<Context>);
#[doc(hidden)]
#[repr(transparent)]
pub struct Zmm<const N: usize>(NonNull<Context>);
#[doc(hidden)]
#[repr(transparent)]
pub struct Kmask<const N: usize>(NonNull<u64>);
#[allow(non_camel_case_types)]
type r80 = [u8; 10];
#[allow(non_camel_case_types)]
type r128 = [u8; 16];
#[allow(non_camel_case_types)]
type r256 = [u8; 32];
#[allow(non_camel_case_types)]
type r512 = [u8; 64];
impl<T, U, const N: usize> Place<T> for Gpr<U, N>
where
U: Place<T>,
{
#[inline]
unsafe fn read(&self) -> T {
unsafe { self.0.as_ref().read() }
}
#[inline]
unsafe fn write(&mut self, value: T) {
unsafe {
self.0.as_mut().write(value);
}
}
}
impl<T, const N: usize> ResolvePlace<Context> for Gpr<T, N> {
const UNIQUE: Option<usize> = Some(N);
#[inline]
fn resolve(src: &Context) -> Self {
const {
assert!(size_of::<T>() <= size_of::<u64>(), "must fit in register");
assert!(N < 16, "register must be defined");
}
unsafe {
let regs = &raw mut (*src.legacy).regs;
Self(NonNull::new_unchecked(
regs.cast::<u64>().add(N).cast::<T>(),
))
}
}
}
impl<T, const N: usize> Deref for Gpr<T, N>
where
T: TrivialPlace,
{
type Target = T;
#[inline]
fn deref(&self) -> &Self::Target {
unsafe { self.0.as_ref() }
}
}
impl<T, const N: usize> DerefMut for Gpr<T, N>
where
T: TrivialPlace,
{
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe {
if const { size_of::<T>() == 4 } {
// Emulate clearing the upper 32 bits.
self.0.cast::<u32>().add(1).write(0);
}
self.0.as_mut()
}
}
}
impl<const N: usize> Place<bool> for Flag<N> {
#[inline]
unsafe fn read(&self) -> bool {
let eflags = unsafe { self.0.read() };
(eflags & Self::MASK) != 0
}
#[inline]
unsafe fn write(&mut self, value: bool) {
let eflags = unsafe { self.0.as_mut() };
*eflags = (*eflags & !Self::MASK) | (value as u32) << N;
}
}
impl<const N: usize> ResolvePlace<Context> for Flag<N> {
#[inline]
fn resolve(src: &Context) -> Self {
unsafe {
let eflags = &raw mut (*src.legacy).eflags;
Self(NonNull::new_unchecked(eflags))
}
}
}
impl<const N: usize> Flag<N> {
const MASK: u32 = 1 << N;
}
impl<const N: usize> Place<r80> for St<N> {
#[inline]
unsafe fn read(&self) -> r80 {
unsafe { self.0.read() }
}
#[inline]
unsafe fn write(&mut self, value: r80) {
unsafe {
*self.0.as_mut() = value;
}
}
}
impl<const N: usize> ResolvePlace<Context> for St<N> {
#[inline]
fn resolve(src: &Context) -> Self {
const {
assert!(N < 8, "register must be defined");
}
unsafe {
let x87 = &raw mut (*src.legacy).xsave.legacy.x87_regs;
Self(NonNull::new_unchecked(x87.cast::<r128>().add(N).cast()))
}
}
}
impl<const N: usize> Place<r128> for Xmm<N> {
#[inline]
unsafe fn read(&self) -> r128 {
unsafe { self.0.read() }
}
#[inline]
unsafe fn write(&mut self, value: r128) {
unsafe {
*self.0.as_mut() = value;
}
}
}
impl<const N: usize> ResolvePlace<Context> for Xmm<N> {
const UNIQUE: Option<usize> = Some(N + 16);
#[inline]
fn resolve(src: &Context) -> Self {
const {
assert!(N < 16, "register must be defined");
}
unsafe {
let xmm = &raw mut (*src.legacy).xsave.legacy.xmm_regs;
Self(NonNull::new_unchecked(xmm.cast::<r128>().add(N)))
}
}
}
impl<const N: usize> Deref for Xmm<N> {
type Target = r128;
#[inline]
fn deref(&self) -> &Self::Target {
unsafe { self.0.as_ref() }
}
}
impl<const N: usize> DerefMut for Xmm<N> {
#[inline]
fn deref_mut(&mut self) -> &mut Self::Target {
unsafe { self.0.as_mut() }
}
}
impl<const N: usize> Place<r256> for Ymm<N> {
#[inline]
unsafe fn read(&self) -> r256 {
unsafe {
let context = self.0.as_ref();
let lo = &raw const (*context.legacy).xsave.legacy.xmm_regs;
debug_assert!(!context.avx.is_null(), "AVX instruction set is undefined");
let hi = &raw const (*context.avx).ymm_h_regs;
let mut ymm = MaybeUninit::<r256>::uninit();
*ymm.as_mut_ptr().cast::<r128>() = *lo.cast::<r128>().add(N);
*ymm.as_mut_ptr().cast::<r128>().add(1) = *hi.cast::<r128>().add(N);
ymm.assume_init()
}
}
#[inline]
unsafe fn write(&mut self, value: r256) {
unsafe {
let context = self.0.as_ref();
let lo = &raw mut (*context.legacy).xsave.legacy.xmm_regs;
debug_assert!(!context.avx.is_null(), "AVX instruction set is undefined");
let hi = &raw mut (*context.avx).ymm_h_regs;
*lo.cast::<r128>().add(N) = *value.as_ptr().cast::<r128>();
*hi.cast::<r128>().add(N) = *value.as_ptr().cast::<r128>().add(1);
}
}
}
impl<const N: usize> ResolvePlace<Context> for Ymm<N> {
const UNIQUE: Option<usize> = Some(N + 16);
#[inline]
fn resolve(src: &Context) -> Self {
const {
assert!(N < 16, "register must be defined");
}
Self(NonNull::from_ref(src))
}
}
impl<const N: usize> Place<r512> for Zmm<N> {
#[inline]
unsafe fn read(&self) -> r512 {
unsafe {
let context = self.0.as_ref();
debug_assert!(
!context.avx512.is_null(),
"AVX512 instruction set is undefined"
);
if const { N >= 16 } {
let zmm_hi = &raw const (*context.avx512).zmm_16_31.zmm_regs;
*zmm_hi.cast::<r512>().add(N - 16)
} else {
let lo = &raw const (*context.legacy).xsave.legacy.xmm_regs;
let hi_ymm = &raw const (*context.avx).ymm_h_regs;
let hi_zmm = &raw const (*context.avx512).zmm_0_15h.zmm_h_regs;
let mut zmm = MaybeUninit::<r512>::uninit();
*zmm.as_mut_ptr().cast::<r128>() = *lo.cast::<r128>().add(N);
*zmm.as_mut_ptr().cast::<r128>().add(1) = *hi_ymm.cast::<r128>().add(N);
*zmm.as_mut_ptr().cast::<r256>().add(1) = *hi_zmm.cast::<r256>().add(N);
zmm.assume_init()
}
}
}
#[inline]
unsafe fn write(&mut self, value: r512) {
unsafe {
let context = self.0.as_ref();
debug_assert!(
!context.avx512.is_null(),
"AVX512 instruction set is undefined"
);
if const { N >= 16 } {
let zmm_hi = &raw mut (*context.avx512).zmm_16_31.zmm_regs;
*zmm_hi.cast::<r512>().add(N - 16) = value;
} else {
let lo = &raw mut (*context.legacy).xsave.legacy.xmm_regs;
let hi_ymm = &raw mut (*context.avx).ymm_h_regs;
let hi_zmm = &raw mut (*context.avx512).zmm_0_15h.zmm_h_regs;
*lo.cast::<r128>().add(N) = *value.as_ptr().cast::<r128>();
*hi_ymm.cast::<r128>().add(N) = *value.as_ptr().cast::<r128>().add(1);
*hi_zmm.cast::<r256>().add(1) = *value.as_ptr().cast::<r256>().add(1);
}
}
}
}
impl<const N: usize> ResolvePlace<Context> for Zmm<N> {
const UNIQUE: Option<usize> = if N < 16 { Some(N + 16) } else { None };
#[inline]
fn resolve(src: &Context) -> Self {
const {
assert!(N < 32, "register must be defined");
}
Self(NonNull::from_ref(src))
}
}
impl<const N: usize> Place<u64> for Kmask<N> {
#[inline]
unsafe fn read(&self) -> u64 {
unsafe { self.0.read() }
}
#[inline]
unsafe fn write(&mut self, value: u64) {
unsafe {
*self.0.as_mut() = value;
}
}
}
impl<const N: usize> ResolvePlace<Context> for Kmask<N> {
#[inline]
fn resolve(src: &Context) -> Self {
const {
assert!(N < 8, "register must be defined");
}
debug_assert!(!src.avx512.is_null(), "AVX512 instruction set is undefined");
unsafe {
let kmask = &raw mut (*src.avx512).kmasks.k_regs;
Self(NonNull::new_unchecked(kmask.cast::<u64>().add(N)))
}
}
}
pub(super) mod defs {
pub use super::*;
/// Stack (base is RSP) variable (alias for [`Rsp<Ref<T, OFFSET>>`]).
pub type Stack<T, const OFFSET: isize = 0> = Rsp<Ref<T, OFFSET>>;
/// Stack (base is RSP) unaligned variable (alias for [`Rsp<UnalignedRef<T, OFFSET>>`]).
pub type UnalignedStack<T, const OFFSET: isize = 0> = Rsp<UnalignedRef<T, OFFSET>>;
/// Frame (base is RBP) variable (alias for [`Rbp<Ref<T, OFFSET>>`]).
pub type Frame<T, const OFFSET: isize = 0> = Rbp<Ref<T, OFFSET>>;
/// Frame (base is RBP) unaligned variable (alias for [`Rbp<UnalignedRef<T, OFFSET>>`]).
pub type UnalignedFrame<T, const OFFSET: isize = 0> = Rbp<UnalignedRef<T, OFFSET>>;
/// 64-bit general purpose register RAX.
pub type Rax<T = u64> = Gpr<T, 0>;
/// 64-bit general purpose register RCX.
pub type Rcx<T = u64> = Gpr<T, 1>;
/// 64-bit general purpose register RDX.
pub type Rdx<T = u64> = Gpr<T, 2>;
/// 64-bit general purpose register RBX.
pub type Rbx<T = u64> = Gpr<T, 3>;
/// 64-bit general purpose register RSP.
pub type Rsp<T = u64> = Gpr<T, 4>;
/// 64-bit general purpose register RBP.
pub type Rbp<T = u64> = Gpr<T, 5>;
/// 64-bit general purpose register RSI.
pub type Rsi<T = u64> = Gpr<T, 6>;
/// 64-bit general purpose register RDI.
pub type Rdi<T = u64> = Gpr<T, 7>;
/// 64-bit general purpose register R8.
pub type R8<T = u64> = Gpr<T, 8>;
/// 64-bit general purpose register R9.
pub type R9<T = u64> = Gpr<T, 9>;
/// 64-bit general purpose register R10.
pub type R10<T = u64> = Gpr<T, 10>;
/// 64-bit general purpose register R11.
pub type R11<T = u64> = Gpr<T, 11>;
/// 64-bit general purpose register R12.
pub type R12<T = u64> = Gpr<T, 12>;
/// 64-bit general purpose register R13.
pub type R13<T = u64> = Gpr<T, 13>;
/// 64-bit general purpose register R14.
pub type R14<T = u64> = Gpr<T, 14>;
/// 64-bit general purpose register R15.
pub type R15<T = u64> = Gpr<T, 15>;
/// Lower 32-bits of [`Rax`] (as a [`u32`] alias).
pub type Eax = Rax<u32>;
/// Lower 32-bits of [`Rcx`] (as a [`u32`] alias).
pub type Ecx = Rcx<u32>;
/// Lower 32-bits of [`Rdx`] (as a [`u32`] alias).
pub type Edx = Rdx<u32>;
/// Lower 32-bits of [`Rbx`] (as a [`u32`] alias).
pub type Ebx = Rbx<u32>;
/// Lower 32-bits of [`Rsp`] (as a [`u32`] alias).
pub type Esp = Rsp<u32>;
/// Lower 32-bits of [`Rbp`] (as a [`u32`] alias).
pub type Ebp = Rbp<u32>;
/// Lower 32-bits of [`Rsi`] (as a [`u32`] alias).
pub type Esi = Rsi<u32>;
/// Lower 32-bits of [`Rdi`] (as a [`u32`] alias).
pub type Edi = Rdi<u32>;
/// Lower 32-bits of [`R8`] (as a [`u32`] alias).
pub type R8d = R8<u32>;
/// Lower 32-bits of [`R9`] (as a [`u32`] alias).
pub type R9d = R9<u32>;
/// Lower 32-bits of [`R10`] (as a [`u32`] alias).
pub type R10d = R10<u32>;
/// Lower 32-bits of [`R11`] (as a [`u32`] alias).
pub type R11d = R11<u32>;
/// Lower 32-bits of [`R12`] (as a [`u32`] alias).
pub type R12d = R12<u32>;
/// Lower 32-bits of [`R13`] (as a [`u32`] alias).
pub type R13d = R13<u32>;
/// Lower 32-bits of [`R14`] (as a [`u32`] alias).
pub type R14d = R14<u32>;
/// Lower 32-bits of [`R15`] (as a [`u32`] alias).
pub type R15d = R15<u32>;
/// Lowest 16-bits of [`Rax`] (as a [`u16`] alias).
pub type Ax = Rax<u16>;
/// Lowest 16-bits of [`Rcx`] (as a [`u16`] alias).
pub type Cx = Rcx<u16>;
/// Lowest 16-bits of [`Rdx`] (as a [`u16`] alias).
pub type Dx = Rdx<u16>;
/// Lowest 16-bits of [`Rbx`] (as a [`u16`] alias).
pub type Bx = Rbx<u16>;
/// Lowest 16-bits of [`Rsp`] (as a [`u16`] alias).
pub type Sp = Rsp<u16>;
/// Lowest 16-bits of [`Rbp`] (as a [`u16`] alias).
pub type Bp = Rbp<u16>;
/// Lowest 16-bits of [`Rsi`] (as a [`u16`] alias).
pub type Si = Rsi<u16>;
/// Lowest 16-bits of [`Rdi`] (as a [`u16`] alias).
pub type Di = Rdi<u16>;
/// Lowest 16-bits of [`R8`] (as a [`u16`] alias).
pub type R8w = R8<u16>;
/// Lowest 16-bits of [`R9`] (as a [`u16`] alias).
pub type R9w = R9<u16>;
/// Lowest 16-bits of [`R10`] (as a [`u16`] alias).
pub type R10w = R10<u16>;
/// Lowest 16-bits of [`R11`] (as a [`u16`] alias).
pub type R11w = R11<u16>;
/// Lowest 16-bits of [`R12`] (as a [`u16`] alias).
pub type R12w = R12<u16>;
/// Lowest 16-bits of [`R13`] (as a [`u16`] alias).
pub type R13w = R13<u16>;
/// Lowest 16-bits of [`R14`] (as a [`u16`] alias).
pub type R14w = R14<u16>;
/// Lowest 16-bits of [`R15`] (as a [`u16`] alias).
pub type R15w = R15<u16>;
/// Lowest 8-bits of [`Rax`] (as a [`u8`] alias).
pub type Al = Rax<u8>;
/// Lowest 8-bits of [`Rcx`] (as a [`u8`] alias).
pub type Cl = Rcx<u8>;
/// Lowest 8-bits of [`Rdx`] (as a [`u8`] alias).
pub type Dl = Rdx<u8>;
/// Lowest 8-bits of [`Rbx`] (as a [`u8`] alias).
pub type Bl = Rbx<u8>;
/// Lowest 8-bits of [`Rsp`] (as a [`u8`] alias).
pub type Spl = Rsp<u8>;
/// Lowest 8-bits of [`Rbp`] (as a [`u8`] alias).
pub type Bpl = Rbp<u8>;
/// Lowest 8-bits of [`Rsi`] (as a [`u8`] alias).
pub type Sil = Rsi<u8>;
/// Lowest 8-bits of [`Rdi`] (as a [`u8`] alias).
pub type Dil = Rdi<u8>;
/// Lowest 8-bits of [`R8`] (as a [`u8`] alias).
pub type R8b = R8<u8>;
/// Lowest 8-bits of [`R9`] (as a [`u8`] alias).
pub type R9b = R9<u8>;
/// Lowest 8-bits of [`R10`] (as a [`u8`] alias).
pub type R10b = R10<u8>;
/// Lowest 8-bits of [`R11`] (as a [`u8`] alias).
pub type R11b = R11<u8>;
/// Lowest 8-bits of [`R12`] (as a [`u8`] alias).
pub type R12b = R12<u8>;
/// Lowest 8-bits of [`R13`] (as a [`u8`] alias).
pub type R13b = R13<u8>;
/// Lowest 8-bits of [`R14`] (as a [`u8`] alias).
pub type R14b = R14<u8>;
/// Lowest 8-bits of [`R15`] (as a [`u8`] alias).
pub type R15b = R15<u8>;
/// The carry flag (EFLAGS bit 0).
pub type CF = Flag<0>;
/// The parity flag (EFLAGS bit 2).
pub type PF = Flag<2>;
/// The zero flag (EFLAGS bit 6).
pub type ZF = Flag<6>;
/// The sign flag (EFLAGS bit 7).
pub type SF = Flag<7>;
/// The overflow flag (EFLAGS bit 11).
pub type OF = Flag<11>;
/// 80-bit x87 floating point register ST0.
pub type St0 = St<0>;
/// 80-bit x87 floating point register ST1.
pub type St1 = St<1>;
/// 80-bit x87 floating point register ST2.
pub type St2 = St<2>;
/// 80-bit x87 floating point register ST3.
pub type St3 = St<3>;
/// 80-bit x87 floating point register ST4.
pub type St4 = St<4>;
/// 80-bit x87 floating point register ST5.
pub type St5 = St<5>;
/// 80-bit x87 floating point register ST6.
pub type St6 = St<6>;
/// 80-bit x87 floating point register ST7.
pub type St7 = St<7>;
/// 128-bit SSE register XMM0 (lower half of [`Ymm0`]).
pub type Xmm0 = Xmm<0>;
/// 128-bit SSE register XMM1 (lower half of [`Ymm1`]).
pub type Xmm1 = Xmm<1>;
/// 128-bit SSE register XMM2 (lower half of [`Ymm2`]).
pub type Xmm2 = Xmm<2>;
/// 128-bit SSE register XMM3 (lower half of [`Ymm3`]).
pub type Xmm3 = Xmm<3>;
/// 128-bit SSE register XMM4 (lower half of [`Ymm4`]).
pub type Xmm4 = Xmm<4>;
/// 128-bit SSE register XMM5 (lower half of [`Ymm5`]).
pub type Xmm5 = Xmm<5>;
/// 128-bit SSE register XMM6 (lower half of [`Ymm6`]).
pub type Xmm6 = Xmm<6>;
/// 128-bit SSE register XMM7 (lower half of [`Ymm7`]).
pub type Xmm7 = Xmm<7>;
/// 128-bit SSE register XMM8 (lower half of [`Ymm8`]).
pub type Xmm8 = Xmm<8>;
/// 128-bit SSE register XMM9 (lower half of [`Ymm9`]).
pub type Xmm9 = Xmm<9>;
/// 128-bit SSE register XMM10 (lower half of [`Ymm10`]).
pub type Xmm10 = Xmm<10>;
/// 128-bit SSE register XMM11 (lower half of [`Ymm11`]).
pub type Xmm11 = Xmm<11>;
/// 128-bit SSE register XMM12 (lower half of [`Ymm12`]).
pub type Xmm12 = Xmm<12>;
/// 128-bit SSE register XMM13 (lower half of [`Ymm13`]).
pub type Xmm13 = Xmm<13>;
/// 128-bit SSE register XMM14 (lower half of [`Ymm14`]).
pub type Xmm14 = Xmm<14>;
/// 128-bit SSE register XMM15 (lower half of [`Ymm15`]).
pub type Xmm15 = Xmm<15>;
/// 256-bit AVX register YMM0 (lower half of [`Zmm0`]).
pub type Ymm0 = Ymm<0>;
/// 256-bit AVX register YMM1 (lower half of [`Zmm1`]).
pub type Ymm1 = Ymm<1>;
/// 256-bit AVX register YMM2 (lower half of [`Zmm2`]).
pub type Ymm2 = Ymm<2>;
/// 256-bit AVX register YMM3 (lower half of [`Zmm3`]).
pub type Ymm3 = Ymm<3>;
/// 256-bit AVX register YMM4 (lower half of [`Zmm4`]).
pub type Ymm4 = Ymm<4>;
/// 256-bit AVX register YMM5 (lower half of [`Zmm5`]).
pub type Ymm5 = Ymm<5>;
/// 256-bit AVX register YMM6 (lower half of [`Zmm6`]).
pub type Ymm6 = Ymm<6>;
/// 256-bit AVX register YMM7 (lower half of [`Zmm7`]).
pub type Ymm7 = Ymm<7>;
/// 256-bit AVX register YMM8 (lower half of [`Zmm8`]).
pub type Ymm8 = Ymm<8>;
/// 256-bit AVX register YMM9 (lower half of [`Zmm9`]).
pub type Ymm9 = Ymm<9>;
/// 256-bit AVX register YMM10 (lower half of [`Zmm10`]).
pub type Ymm10 = Ymm<10>;
/// 256-bit AVX register YMM11 (lower half of [`Zmm11`]).
pub type Ymm11 = Ymm<11>;
/// 256-bit AVX register YMM12 (lower half of [`Zmm12`]).
pub type Ymm12 = Ymm<12>;
/// 256-bit AVX register YMM13 (lower half of [`Zmm13`]).
pub type Ymm13 = Ymm<13>;
/// 256-bit AVX register YMM14 (lower half of [`Zmm14`]).
pub type Ymm14 = Ymm<14>;
/// 256-bit AVX register YMM15 (lower half of [`Zmm15`]).
pub type Ymm15 = Ymm<15>;
/// 512-bit AVX-512 register ZMM0.
pub type Zmm0 = Zmm<0>;
/// 512-bit AVX-512 register ZMM1.
pub type Zmm1 = Zmm<1>;
/// 512-bit AVX-512 register ZMM2.
pub type Zmm2 = Zmm<2>;
/// 512-bit AVX-512 register ZMM3.
pub type Zmm3 = Zmm<3>;
/// 512-bit AVX-512 register ZMM4.
pub type Zmm4 = Zmm<4>;
/// 512-bit AVX-512 register ZMM5.
pub type Zmm5 = Zmm<5>;
/// 512-bit AVX-512 register ZMM6.
pub type Zmm6 = Zmm<6>;
/// 512-bit AVX-512 register ZMM7.
pub type Zmm7 = Zmm<7>;
/// 512-bit AVX-512 register ZMM8.
pub type Zmm8 = Zmm<8>;
/// 512-bit AVX-512 register ZMM9.
pub type Zmm9 = Zmm<9>;
/// 512-bit AVX-512 register ZMM10.
pub type Zmm10 = Zmm<10>;
/// 512-bit AVX-512 register ZMM11.
pub type Zmm11 = Zmm<11>;
/// 512-bit AVX-512 register ZMM12.
pub type Zmm12 = Zmm<12>;
/// 512-bit AVX-512 register ZMM13.
pub type Zmm13 = Zmm<13>;
/// 512-bit AVX-512 register ZMM14.
pub type Zmm14 = Zmm<14>;
/// 512-bit AVX-512 register ZMM15.
pub type Zmm15 = Zmm<15>;
/// 512-bit AVX-512 register ZMM16.
pub type Zmm16 = Zmm<16>;
/// 512-bit AVX-512 register ZMM17.
pub type Zmm17 = Zmm<17>;
/// 512-bit AVX-512 register ZMM18.
pub type Zmm18 = Zmm<18>;
/// 512-bit AVX-512 register ZMM19.
pub type Zmm19 = Zmm<19>;
/// 512-bit AVX-512 register ZMM20.
pub type Zmm20 = Zmm<20>;
/// 512-bit AVX-512 register ZMM21.
pub type Zmm21 = Zmm<21>;
/// 512-bit AVX-512 register ZMM22.
pub type Zmm22 = Zmm<22>;
/// 512-bit AVX-512 register ZMM23.
pub type Zmm23 = Zmm<23>;
/// 512-bit AVX-512 register ZMM24.
pub type Zmm24 = Zmm<24>;
/// 512-bit AVX-512 register ZMM25.
pub type Zmm25 = Zmm<25>;
/// 512-bit AVX-512 register ZMM26.
pub type Zmm26 = Zmm<26>;
/// 512-bit AVX-512 register ZMM27.
pub type Zmm27 = Zmm<27>;
/// 512-bit AVX-512 register ZMM28.
pub type Zmm28 = Zmm<28>;
/// 512-bit AVX-512 register ZMM29.
pub type Zmm29 = Zmm<29>;
/// 512-bit AVX-512 register ZMM30.
pub type Zmm30 = Ymm<30>;
/// 512-bit AVX-512 register ZMM31.
pub type Zmm31 = Ymm<31>;
/// 64-bit AVX-512 mask register k0.
pub type Kmask0 = Kmask<0>;
/// 64-bit AVX-512 mask register k1.
pub type Kmask1 = Kmask<1>;
/// 64-bit AVX-512 mask register k2.
pub type Kmask2 = Kmask<2>;
/// 64-bit AVX-512 mask register k3.
pub type Kmask3 = Kmask<3>;
/// 64-bit AVX-512 mask register k4.
pub type Kmask4 = Kmask<4>;
/// 64-bit AVX-512 mask register k5.
pub type Kmask5 = Kmask<5>;
/// 64-bit AVX-512 mask register k6.
pub type Kmask6 = Kmask<6>;
/// 64-bit AVX-512 mask register k7.
pub type Kmask7 = Kmask<7>;
}