pub struct MemorySizeInfo { /* private fields */ }
Expand description

MemorySize information

Implementations§

Gets the MemorySize value

Examples
use iced_x86::*;
let info = MemorySize::Packed256_UInt16.info();
assert_eq!(info.memory_size(), MemorySize::Packed256_UInt16);

Gets the size in bytes of the memory location or 0 if it’s not accessed or unknown

Examples
use iced_x86::*;
let info = MemorySize::UInt32.info();
assert_eq!(info.size(), 4);
let info = MemorySize::Packed256_UInt16.info();
assert_eq!(info.size(), 32);
let info = MemorySize::Broadcast512_UInt64.info();
assert_eq!(info.size(), 8);
Examples found in repository?
src/memory_size.rs (line 1098)
1097
1098
1099
	pub fn size(self) -> usize {
		self.info().size()
	}

Gets the size in bytes of the packed element. If it’s not a packed data type, it’s equal to size().

Examples
use iced_x86::*;
let info = MemorySize::UInt32.info();
assert_eq!(info.element_size(), 4);
let info = MemorySize::Packed256_UInt16.info();
assert_eq!(info.element_size(), 2);
let info = MemorySize::Broadcast512_UInt64.info();
assert_eq!(info.element_size(), 8);
Examples found in repository?
src/memory_size.rs (line 1116)
1115
1116
1117
	pub fn element_size(self) -> usize {
		self.info().element_size()
	}

Gets the element type if it’s packed data or the type itself if it’s not packed data

Examples
use iced_x86::*;
let info = MemorySize::UInt32.info();
assert_eq!(info.element_type(), MemorySize::UInt32);
let info = MemorySize::Packed256_UInt16.info();
assert_eq!(info.element_type(), MemorySize::UInt16);
let info = MemorySize::Broadcast512_UInt64.info();
assert_eq!(info.element_type(), MemorySize::UInt64);
Examples found in repository?
src/memory_size.rs (line 293)
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
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
		pub fn element_type_info(&self) -> &'static Self {
			self.element_type().info()
		}

		/// `true` if it's signed data (signed integer or a floating point value)
		///
		/// # Examples
		///
		/// ```
		/// use iced_x86::*;
		/// let info = MemorySize::UInt32.info();
		/// assert!(!info.is_signed());
		/// let info = MemorySize::Int32.info();
		/// assert!(info.is_signed());
		/// let info = MemorySize::Float64.info();
		/// assert!(info.is_signed());
		/// ```
		#[must_use]
		#[inline]
		pub const fn is_signed(&self) -> bool {
			self.is_signed
		}

		/// `true` if it's a broadcast memory type
		///
		/// # Examples
		///
		/// ```
		/// use iced_x86::*;
		/// let info = MemorySize::UInt32.info();
		/// assert!(!info.is_broadcast());
		/// let info = MemorySize::Packed256_UInt16.info();
		/// assert!(!info.is_broadcast());
		/// let info = MemorySize::Broadcast512_UInt64.info();
		/// assert!(info.is_broadcast());
		/// ```
		#[must_use]
		#[inline]
		pub const fn is_broadcast(&self) -> bool {
			self.is_broadcast
		}

		/// `true` if this is a packed data type, eg. [`MemorySize::Packed128_Float32`]. See also [`element_count()`]
		///
		/// [`MemorySize::Packed128_Float32`]: #variant.Packed128_Float32
		/// [`element_count()`]: #method.element_count
		///
		/// # Examples
		///
		/// ```
		/// use iced_x86::*;
		/// let info = MemorySize::UInt32.info();
		/// assert!(!info.is_packed());
		/// let info = MemorySize::Packed256_UInt16.info();
		/// assert!(info.is_packed());
		/// let info = MemorySize::Broadcast512_UInt64.info();
		/// assert!(!info.is_packed());
		/// ```
		#[must_use]
		#[inline]
		pub const fn is_packed(&self) -> bool {
			self.element_size < self.size
		}

		/// Gets the number of elements in the packed data type or `1` if it's not packed data ([`is_packed()`])
		///
		/// [`is_packed()`]: #method.is_packed
		///
		/// # Examples
		///
		/// ```
		/// use iced_x86::*;
		/// let info = MemorySize::UInt32.info();
		/// assert_eq!(info.element_count(), 1);
		/// let info = MemorySize::Packed256_UInt16.info();
		/// assert_eq!(info.element_count(), 16);
		/// let info = MemorySize::Broadcast512_UInt64.info();
		/// assert_eq!(info.element_count(), 1);
		/// ```
		#[must_use]
		#[inline]
		pub const fn element_count(&self) -> usize {
			// element_size can be 0 so we don't divide by it if es == s
			if self.element_size == self.size {
				1
			} else {
				self.size as usize / self.element_size as usize
			}
		}
	}
}

// GENERATOR-BEGIN: MemorySize
// ⚠️This was generated by GENERATOR!🦹‍♂️
/// Size of a memory reference
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[cfg_attr(not(feature = "exhaustive_enums"), non_exhaustive)]
#[allow(non_camel_case_types)]
pub enum MemorySize {
	/// Unknown size or the instruction doesn't reference any memory (eg. `LEA`)
	Unknown = 0,
	/// Memory location contains a `u8`
	UInt8 = 1,
	/// Memory location contains a `u16`
	UInt16 = 2,
	/// Memory location contains a `u32`
	UInt32 = 3,
	/// Memory location contains a `u52`
	UInt52 = 4,
	/// Memory location contains a `u64`
	UInt64 = 5,
	/// Memory location contains a `u128`
	UInt128 = 6,
	/// Memory location contains a `u256`
	UInt256 = 7,
	/// Memory location contains a `u512`
	UInt512 = 8,
	/// Memory location contains a `i8`
	Int8 = 9,
	/// Memory location contains a `i16`
	Int16 = 10,
	/// Memory location contains a `i32`
	Int32 = 11,
	/// Memory location contains a `i64`
	Int64 = 12,
	/// Memory location contains a `i128`
	Int128 = 13,
	/// Memory location contains a `i256`
	Int256 = 14,
	/// Memory location contains a `i512`
	Int512 = 15,
	/// Memory location contains a seg:ptr pair, `u16` (offset) + `u16` (segment/selector)
	SegPtr16 = 16,
	/// Memory location contains a seg:ptr pair, `u32` (offset) + `u16` (segment/selector)
	SegPtr32 = 17,
	/// Memory location contains a seg:ptr pair, `u64` (offset) + `u16` (segment/selector)
	SegPtr64 = 18,
	/// Memory location contains a 16-bit offset (`JMP/CALL WORD PTR [mem]`)
	WordOffset = 19,
	/// Memory location contains a 32-bit offset (`JMP/CALL DWORD PTR [mem]`)
	DwordOffset = 20,
	/// Memory location contains a 64-bit offset (`JMP/CALL QWORD PTR [mem]`)
	QwordOffset = 21,
	/// Memory location contains two `u16`s (16-bit `BOUND`)
	Bound16_WordWord = 22,
	/// Memory location contains two `u32`s (32-bit `BOUND`)
	Bound32_DwordDword = 23,
	/// 32-bit `BNDMOV`, 2 x `u32`
	Bnd32 = 24,
	/// 64-bit `BNDMOV`, 2 x `u64`
	Bnd64 = 25,
	/// Memory location contains a 16-bit limit and a 32-bit address (eg. `LGDTW`, `LGDTD`)
	Fword6 = 26,
	/// Memory location contains a 16-bit limit and a 64-bit address (eg. `LGDTQ`)
	Fword10 = 27,
	/// Memory location contains a `f16`
	Float16 = 28,
	/// Memory location contains a `f32`
	Float32 = 29,
	/// Memory location contains a `f64`
	Float64 = 30,
	/// Memory location contains a `f80`
	Float80 = 31,
	/// Memory location contains a `f128`
	Float128 = 32,
	/// Memory location contains a `bfloat16`
	BFloat16 = 33,
	/// Memory location contains a 14-byte FPU environment (16-bit `FLDENV`/`FSTENV`)
	FpuEnv14 = 34,
	/// Memory location contains a 28-byte FPU environment (32/64-bit `FLDENV`/`FSTENV`)
	FpuEnv28 = 35,
	/// Memory location contains a 94-byte FPU environment (16-bit `FSAVE`/`FRSTOR`)
	FpuState94 = 36,
	/// Memory location contains a 108-byte FPU environment (32/64-bit `FSAVE`/`FRSTOR`)
	FpuState108 = 37,
	/// Memory location contains 512-bytes of `FXSAVE`/`FXRSTOR` data
	Fxsave_512Byte = 38,
	/// Memory location contains 512-bytes of `FXSAVE64`/`FXRSTOR64` data
	Fxsave64_512Byte = 39,
	/// 32-bit `XSAVE` area
	Xsave = 40,
	/// 64-bit `XSAVE` area
	Xsave64 = 41,
	/// Memory location contains a 10-byte `bcd` value (`FBLD`/`FBSTP`)
	Bcd = 42,
	/// 64-bit location: TILECFG (`LDTILECFG`/`STTILECFG`)
	Tilecfg = 43,
	/// Tile data
	Tile = 44,
	/// 80-bit segment descriptor and selector: 0-7 = descriptor, 8-9 = selector
	SegmentDescSelector = 45,
	/// 384-bit AES 128 handle (Key Locker)
	KLHandleAes128 = 46,
	/// 512-bit AES 256 handle (Key Locker)
	KLHandleAes256 = 47,
	/// 16-bit location: 2 x `u8`
	Packed16_UInt8 = 48,
	/// 16-bit location: 2 x `i8`
	Packed16_Int8 = 49,
	/// 32-bit location: 4 x `u8`
	Packed32_UInt8 = 50,
	/// 32-bit location: 4 x `i8`
	Packed32_Int8 = 51,
	/// 32-bit location: 2 x `u16`
	Packed32_UInt16 = 52,
	/// 32-bit location: 2 x `i16`
	Packed32_Int16 = 53,
	/// 32-bit location: 2 x `f16`
	Packed32_Float16 = 54,
	/// 32-bit location: 2 x `bfloat16`
	Packed32_BFloat16 = 55,
	/// 64-bit location: 8 x `u8`
	Packed64_UInt8 = 56,
	/// 64-bit location: 8 x `i8`
	Packed64_Int8 = 57,
	/// 64-bit location: 4 x `u16`
	Packed64_UInt16 = 58,
	/// 64-bit location: 4 x `i16`
	Packed64_Int16 = 59,
	/// 64-bit location: 2 x `u32`
	Packed64_UInt32 = 60,
	/// 64-bit location: 2 x `i32`
	Packed64_Int32 = 61,
	/// 64-bit location: 4 x `f16`
	Packed64_Float16 = 62,
	/// 64-bit location: 2 x `f32`
	Packed64_Float32 = 63,
	/// 128-bit location: 16 x `u8`
	Packed128_UInt8 = 64,
	/// 128-bit location: 16 x `i8`
	Packed128_Int8 = 65,
	/// 128-bit location: 8 x `u16`
	Packed128_UInt16 = 66,
	/// 128-bit location: 8 x `i16`
	Packed128_Int16 = 67,
	/// 128-bit location: 4 x `u32`
	Packed128_UInt32 = 68,
	/// 128-bit location: 4 x `i32`
	Packed128_Int32 = 69,
	/// 128-bit location: 2 x `u52`
	Packed128_UInt52 = 70,
	/// 128-bit location: 2 x `u64`
	Packed128_UInt64 = 71,
	/// 128-bit location: 2 x `i64`
	Packed128_Int64 = 72,
	/// 128-bit location: 8 x `f16`
	Packed128_Float16 = 73,
	/// 128-bit location: 4 x `f32`
	Packed128_Float32 = 74,
	/// 128-bit location: 2 x `f64`
	Packed128_Float64 = 75,
	/// 128-bit location: 8 x `bfloat16`
	Packed128_BFloat16 = 76,
	/// 128-bit location: 4 x (2 x `f16`)
	Packed128_2xFloat16 = 77,
	/// 128-bit location: 4 x (2 x `bfloat16`)
	Packed128_2xBFloat16 = 78,
	/// 256-bit location: 32 x `u8`
	Packed256_UInt8 = 79,
	/// 256-bit location: 32 x `i8`
	Packed256_Int8 = 80,
	/// 256-bit location: 16 x `u16`
	Packed256_UInt16 = 81,
	/// 256-bit location: 16 x `i16`
	Packed256_Int16 = 82,
	/// 256-bit location: 8 x `u32`
	Packed256_UInt32 = 83,
	/// 256-bit location: 8 x `i32`
	Packed256_Int32 = 84,
	/// 256-bit location: 4 x `u52`
	Packed256_UInt52 = 85,
	/// 256-bit location: 4 x `u64`
	Packed256_UInt64 = 86,
	/// 256-bit location: 4 x `i64`
	Packed256_Int64 = 87,
	/// 256-bit location: 2 x `u128`
	Packed256_UInt128 = 88,
	/// 256-bit location: 2 x `i128`
	Packed256_Int128 = 89,
	/// 256-bit location: 16 x `f16`
	Packed256_Float16 = 90,
	/// 256-bit location: 8 x `f32`
	Packed256_Float32 = 91,
	/// 256-bit location: 4 x `f64`
	Packed256_Float64 = 92,
	/// 256-bit location: 2 x `f128`
	Packed256_Float128 = 93,
	/// 256-bit location: 16 x `bfloat16`
	Packed256_BFloat16 = 94,
	/// 256-bit location: 8 x (2 x `f16`)
	Packed256_2xFloat16 = 95,
	/// 256-bit location: 8 x (2 x `bfloat16`)
	Packed256_2xBFloat16 = 96,
	/// 512-bit location: 64 x `u8`
	Packed512_UInt8 = 97,
	/// 512-bit location: 64 x `i8`
	Packed512_Int8 = 98,
	/// 512-bit location: 32 x `u16`
	Packed512_UInt16 = 99,
	/// 512-bit location: 32 x `i16`
	Packed512_Int16 = 100,
	/// 512-bit location: 16 x `u32`
	Packed512_UInt32 = 101,
	/// 512-bit location: 16 x `i32`
	Packed512_Int32 = 102,
	/// 512-bit location: 8 x `u52`
	Packed512_UInt52 = 103,
	/// 512-bit location: 8 x `u64`
	Packed512_UInt64 = 104,
	/// 512-bit location: 8 x `i64`
	Packed512_Int64 = 105,
	/// 256-bit location: 4 x `u128`
	Packed512_UInt128 = 106,
	/// 512-bit location: 32 x `f16`
	Packed512_Float16 = 107,
	/// 512-bit location: 16 x `f32`
	Packed512_Float32 = 108,
	/// 512-bit location: 8 x `f64`
	Packed512_Float64 = 109,
	/// 512-bit location: 16 x (2 x `f16`)
	Packed512_2xFloat16 = 110,
	/// 512-bit location: 16 x (2 x `bfloat16`)
	Packed512_2xBFloat16 = 111,
	/// Broadcast `f16` to 32-bits
	Broadcast32_Float16 = 112,
	/// Broadcast `u32` to 64-bits
	Broadcast64_UInt32 = 113,
	/// Broadcast `i32` to 64-bits
	Broadcast64_Int32 = 114,
	/// Broadcast `f16` to 64-bits
	Broadcast64_Float16 = 115,
	/// Broadcast `f32` to 64-bits
	Broadcast64_Float32 = 116,
	/// Broadcast `i16` to 128-bits
	Broadcast128_Int16 = 117,
	/// Broadcast `u16` to 128-bits
	Broadcast128_UInt16 = 118,
	/// Broadcast `u32` to 128-bits
	Broadcast128_UInt32 = 119,
	/// Broadcast `i32` to 128-bits
	Broadcast128_Int32 = 120,
	/// Broadcast `u52` to 128-bits
	Broadcast128_UInt52 = 121,
	/// Broadcast `u64` to 128-bits
	Broadcast128_UInt64 = 122,
	/// Broadcast `i64` to 128-bits
	Broadcast128_Int64 = 123,
	/// Broadcast `f16` to 128-bits
	Broadcast128_Float16 = 124,
	/// Broadcast `f32` to 128-bits
	Broadcast128_Float32 = 125,
	/// Broadcast `f64` to 128-bits
	Broadcast128_Float64 = 126,
	/// Broadcast 2 x `i16` to 128-bits
	Broadcast128_2xInt16 = 127,
	/// Broadcast 2 x `i32` to 128-bits
	Broadcast128_2xInt32 = 128,
	/// Broadcast 2 x `u32` to 128-bits
	Broadcast128_2xUInt32 = 129,
	/// Broadcast 2 x `f16` to 128-bits
	Broadcast128_2xFloat16 = 130,
	/// Broadcast 2 x `bfloat16` to 128-bits
	Broadcast128_2xBFloat16 = 131,
	/// Broadcast `i16` to 256-bits
	Broadcast256_Int16 = 132,
	/// Broadcast `u16` to 256-bits
	Broadcast256_UInt16 = 133,
	/// Broadcast `u32` to 256-bits
	Broadcast256_UInt32 = 134,
	/// Broadcast `i32` to 256-bits
	Broadcast256_Int32 = 135,
	/// Broadcast `u52` to 256-bits
	Broadcast256_UInt52 = 136,
	/// Broadcast `u64` to 256-bits
	Broadcast256_UInt64 = 137,
	/// Broadcast `i64` to 256-bits
	Broadcast256_Int64 = 138,
	/// Broadcast `f16` to 256-bits
	Broadcast256_Float16 = 139,
	/// Broadcast `f32` to 256-bits
	Broadcast256_Float32 = 140,
	/// Broadcast `f64` to 256-bits
	Broadcast256_Float64 = 141,
	/// Broadcast 2 x `i16` to 256-bits
	Broadcast256_2xInt16 = 142,
	/// Broadcast 2 x `i32` to 256-bits
	Broadcast256_2xInt32 = 143,
	/// Broadcast 2 x `u32` to 256-bits
	Broadcast256_2xUInt32 = 144,
	/// Broadcast 2 x `f16` to 256-bits
	Broadcast256_2xFloat16 = 145,
	/// Broadcast 2 x `bfloat16` to 256-bits
	Broadcast256_2xBFloat16 = 146,
	/// Broadcast `i16` to 512-bits
	Broadcast512_Int16 = 147,
	/// Broadcast `u16` to 512-bits
	Broadcast512_UInt16 = 148,
	/// Broadcast `u32` to 512-bits
	Broadcast512_UInt32 = 149,
	/// Broadcast `i32` to 512-bits
	Broadcast512_Int32 = 150,
	/// Broadcast `u52` to 512-bits
	Broadcast512_UInt52 = 151,
	/// Broadcast `u64` to 512-bits
	Broadcast512_UInt64 = 152,
	/// Broadcast `i64` to 512-bits
	Broadcast512_Int64 = 153,
	/// Broadcast `f16` to 512-bits
	Broadcast512_Float16 = 154,
	/// Broadcast `f32` to 512-bits
	Broadcast512_Float32 = 155,
	/// Broadcast `f64` to 512-bits
	Broadcast512_Float64 = 156,
	/// Broadcast 2 x `f16` to 512-bits
	Broadcast512_2xFloat16 = 157,
	/// Broadcast 2 x `i16` to 512-bits
	Broadcast512_2xInt16 = 158,
	/// Broadcast 2 x `u32` to 512-bits
	Broadcast512_2xUInt32 = 159,
	/// Broadcast 2 x `i32` to 512-bits
	Broadcast512_2xInt32 = 160,
	/// Broadcast 2 x `bfloat16` to 512-bits
	Broadcast512_2xBFloat16 = 161,
}
#[rustfmt::skip]
static GEN_DEBUG_MEMORY_SIZE: [&str; 162] = [
	"Unknown",
	"UInt8",
	"UInt16",
	"UInt32",
	"UInt52",
	"UInt64",
	"UInt128",
	"UInt256",
	"UInt512",
	"Int8",
	"Int16",
	"Int32",
	"Int64",
	"Int128",
	"Int256",
	"Int512",
	"SegPtr16",
	"SegPtr32",
	"SegPtr64",
	"WordOffset",
	"DwordOffset",
	"QwordOffset",
	"Bound16_WordWord",
	"Bound32_DwordDword",
	"Bnd32",
	"Bnd64",
	"Fword6",
	"Fword10",
	"Float16",
	"Float32",
	"Float64",
	"Float80",
	"Float128",
	"BFloat16",
	"FpuEnv14",
	"FpuEnv28",
	"FpuState94",
	"FpuState108",
	"Fxsave_512Byte",
	"Fxsave64_512Byte",
	"Xsave",
	"Xsave64",
	"Bcd",
	"Tilecfg",
	"Tile",
	"SegmentDescSelector",
	"KLHandleAes128",
	"KLHandleAes256",
	"Packed16_UInt8",
	"Packed16_Int8",
	"Packed32_UInt8",
	"Packed32_Int8",
	"Packed32_UInt16",
	"Packed32_Int16",
	"Packed32_Float16",
	"Packed32_BFloat16",
	"Packed64_UInt8",
	"Packed64_Int8",
	"Packed64_UInt16",
	"Packed64_Int16",
	"Packed64_UInt32",
	"Packed64_Int32",
	"Packed64_Float16",
	"Packed64_Float32",
	"Packed128_UInt8",
	"Packed128_Int8",
	"Packed128_UInt16",
	"Packed128_Int16",
	"Packed128_UInt32",
	"Packed128_Int32",
	"Packed128_UInt52",
	"Packed128_UInt64",
	"Packed128_Int64",
	"Packed128_Float16",
	"Packed128_Float32",
	"Packed128_Float64",
	"Packed128_BFloat16",
	"Packed128_2xFloat16",
	"Packed128_2xBFloat16",
	"Packed256_UInt8",
	"Packed256_Int8",
	"Packed256_UInt16",
	"Packed256_Int16",
	"Packed256_UInt32",
	"Packed256_Int32",
	"Packed256_UInt52",
	"Packed256_UInt64",
	"Packed256_Int64",
	"Packed256_UInt128",
	"Packed256_Int128",
	"Packed256_Float16",
	"Packed256_Float32",
	"Packed256_Float64",
	"Packed256_Float128",
	"Packed256_BFloat16",
	"Packed256_2xFloat16",
	"Packed256_2xBFloat16",
	"Packed512_UInt8",
	"Packed512_Int8",
	"Packed512_UInt16",
	"Packed512_Int16",
	"Packed512_UInt32",
	"Packed512_Int32",
	"Packed512_UInt52",
	"Packed512_UInt64",
	"Packed512_Int64",
	"Packed512_UInt128",
	"Packed512_Float16",
	"Packed512_Float32",
	"Packed512_Float64",
	"Packed512_2xFloat16",
	"Packed512_2xBFloat16",
	"Broadcast32_Float16",
	"Broadcast64_UInt32",
	"Broadcast64_Int32",
	"Broadcast64_Float16",
	"Broadcast64_Float32",
	"Broadcast128_Int16",
	"Broadcast128_UInt16",
	"Broadcast128_UInt32",
	"Broadcast128_Int32",
	"Broadcast128_UInt52",
	"Broadcast128_UInt64",
	"Broadcast128_Int64",
	"Broadcast128_Float16",
	"Broadcast128_Float32",
	"Broadcast128_Float64",
	"Broadcast128_2xInt16",
	"Broadcast128_2xInt32",
	"Broadcast128_2xUInt32",
	"Broadcast128_2xFloat16",
	"Broadcast128_2xBFloat16",
	"Broadcast256_Int16",
	"Broadcast256_UInt16",
	"Broadcast256_UInt32",
	"Broadcast256_Int32",
	"Broadcast256_UInt52",
	"Broadcast256_UInt64",
	"Broadcast256_Int64",
	"Broadcast256_Float16",
	"Broadcast256_Float32",
	"Broadcast256_Float64",
	"Broadcast256_2xInt16",
	"Broadcast256_2xInt32",
	"Broadcast256_2xUInt32",
	"Broadcast256_2xFloat16",
	"Broadcast256_2xBFloat16",
	"Broadcast512_Int16",
	"Broadcast512_UInt16",
	"Broadcast512_UInt32",
	"Broadcast512_Int32",
	"Broadcast512_UInt52",
	"Broadcast512_UInt64",
	"Broadcast512_Int64",
	"Broadcast512_Float16",
	"Broadcast512_Float32",
	"Broadcast512_Float64",
	"Broadcast512_2xFloat16",
	"Broadcast512_2xInt16",
	"Broadcast512_2xUInt32",
	"Broadcast512_2xInt32",
	"Broadcast512_2xBFloat16",
];
impl fmt::Debug for MemorySize {
	#[inline]
	fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
		write!(f, "{}", GEN_DEBUG_MEMORY_SIZE[*self as usize])
	}
}
impl Default for MemorySize {
	#[must_use]
	#[inline]
	fn default() -> Self {
		MemorySize::Unknown
	}
}
#[allow(non_camel_case_types)]
#[allow(dead_code)]
pub(crate) type MemorySizeUnderlyingType = u8;
#[rustfmt::skip]
impl MemorySize {
	/// Iterates over all `MemorySize` enum values
	#[inline]
	pub fn values() -> impl Iterator<Item = MemorySize> + DoubleEndedIterator + ExactSizeIterator + FusedIterator {
		// SAFETY: all values 0-max are valid enum values
		(0..IcedConstants::MEMORY_SIZE_ENUM_COUNT).map(|x| unsafe { mem::transmute::<u8, MemorySize>(x as u8) })
	}
}
#[test]
#[rustfmt::skip]
fn test_memorysize_values() {
	let mut iter = MemorySize::values();
	assert_eq!(iter.size_hint(), (IcedConstants::MEMORY_SIZE_ENUM_COUNT, Some(IcedConstants::MEMORY_SIZE_ENUM_COUNT)));
	assert_eq!(iter.len(), IcedConstants::MEMORY_SIZE_ENUM_COUNT);
	assert!(iter.next().is_some());
	assert_eq!(iter.size_hint(), (IcedConstants::MEMORY_SIZE_ENUM_COUNT - 1, Some(IcedConstants::MEMORY_SIZE_ENUM_COUNT - 1)));
	assert_eq!(iter.len(), IcedConstants::MEMORY_SIZE_ENUM_COUNT - 1);

	let values: Vec<MemorySize> = MemorySize::values().collect();
	assert_eq!(values.len(), IcedConstants::MEMORY_SIZE_ENUM_COUNT);
	for (i, value) in values.into_iter().enumerate() {
		assert_eq!(i, value as usize);
	}

	let values1: Vec<MemorySize> = MemorySize::values().collect();
	let mut values2: Vec<MemorySize> = MemorySize::values().rev().collect();
	values2.reverse();
	assert_eq!(values1, values2);
}
#[rustfmt::skip]
impl TryFrom<usize> for MemorySize {
	type Error = IcedError;
	#[inline]
	fn try_from(value: usize) -> Result<Self, Self::Error> {
		if value < IcedConstants::MEMORY_SIZE_ENUM_COUNT {
			// SAFETY: all values 0-max are valid enum values
			Ok(unsafe { mem::transmute(value as u8) })
		} else {
			Err(IcedError::new("Invalid MemorySize value"))
		}
	}
}
#[test]
#[rustfmt::skip]
fn test_memorysize_try_from_usize() {
	for value in MemorySize::values() {
		let converted = <MemorySize as TryFrom<usize>>::try_from(value as usize).unwrap();
		assert_eq!(converted, value);
	}
	assert!(<MemorySize as TryFrom<usize>>::try_from(IcedConstants::MEMORY_SIZE_ENUM_COUNT).is_err());
	assert!(<MemorySize as TryFrom<usize>>::try_from(core::usize::MAX).is_err());
}
#[cfg(feature = "serde")]
#[rustfmt::skip]
#[allow(clippy::zero_sized_map_values)]
const _: () = {
	use alloc::string::String;
	use core::marker::PhantomData;
	#[cfg(not(feature = "std"))]
	use hashbrown::HashMap;
	use lazy_static::lazy_static;
	use serde::de::{self, VariantAccess};
	use serde::{Deserialize, Deserializer, Serialize, Serializer};
	#[cfg(feature = "std")]
	use std::collections::HashMap;
	lazy_static! {
		static ref NAME_TO_ENUM: HashMap<&'static [u8], EnumType> = GEN_DEBUG_MEMORY_SIZE.iter().map(|&s| s.as_bytes()).zip(EnumType::values()).collect();
	}
	type EnumType = MemorySize;
	impl Serialize for EnumType {
		#[inline]
		fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
		where
			S: Serializer,
		{
			serializer.serialize_unit_variant("MemorySize", *self as u32, GEN_DEBUG_MEMORY_SIZE[*self as usize])
		}
	}
	impl<'de> Deserialize<'de> for EnumType {
		#[inline]
		fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
		where
			D: Deserializer<'de>,
		{
			#[repr(transparent)]
			struct EnumValue(EnumType);
			struct EnumValueVisitor;
			impl<'de> de::Visitor<'de> for EnumValueVisitor {
				type Value = EnumValue;
				#[inline]
				fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
					formatter.write_str("variant identifier")
				}
				#[inline]
				fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
				where
					E: de::Error,
				{
					if let Ok(v) = <usize as TryFrom<_>>::try_from(v) {
						if let Ok(value) = <EnumType as TryFrom<_>>::try_from(v) {
							return Ok(EnumValue(value));
						}
					}
					Err(de::Error::invalid_value(de::Unexpected::Unsigned(v), &"a valid MemorySize variant value"))
				}
				#[inline]
				fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
				where
					E: de::Error,
				{
					EnumValueVisitor::deserialize_name(v.as_bytes())
				}
				#[inline]
				fn visit_bytes<E>(self, v: &[u8]) -> Result<Self::Value, E>
				where
					E: de::Error,
				{
					EnumValueVisitor::deserialize_name(v)
				}
			}
			impl EnumValueVisitor {
				#[inline]
				fn deserialize_name<E>(v: &[u8]) -> Result<EnumValue, E>
				where
					E: de::Error,
				{
					if let Some(&value) = NAME_TO_ENUM.get(v) {
						Ok(EnumValue(value))
					} else {
						Err(de::Error::unknown_variant(&String::from_utf8_lossy(v), &["MemorySize enum variants"][..]))
					}
				}
			}
			impl<'de> Deserialize<'de> for EnumValue {
				#[inline]
				fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
				where
					D: Deserializer<'de>,
				{
					deserializer.deserialize_identifier(EnumValueVisitor)
				}
			}
			struct Visitor<'de> {
				marker: PhantomData<EnumType>,
				lifetime: PhantomData<&'de ()>,
			}
			impl<'de> de::Visitor<'de> for Visitor<'de> {
				type Value = EnumType;
				#[inline]
				fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
					formatter.write_str("enum MemorySize")
				}
				#[inline]
				fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
				where
					A: de::EnumAccess<'de>,
				{
					let (field, variant): (EnumValue, _) = data.variant()?;
					match variant.unit_variant() {
						Ok(_) => Ok(field.0),
						Err(err) => Err(err),
					}
				}
			}
			deserializer.deserialize_enum("MemorySize", &GEN_DEBUG_MEMORY_SIZE[..], Visitor { marker: PhantomData::<EnumType>, lifetime: PhantomData })
		}
	}
};
// GENERATOR-END: MemorySize

#[cfg(any(feature = "instr_info", feature = "encoder"))]
impl MemorySize {
	/// Gets the memory size info
	///
	/// # Examples
	///
	/// ```
	/// use iced_x86::*;
	/// let info = MemorySize::Packed256_UInt16.info();
	/// assert_eq!(info.size(), 32);
	/// ```
	#[must_use]
	#[inline]
	pub fn info(self) -> &'static MemorySizeInfo {
		&MEMORY_SIZE_INFOS[self as usize]
	}

	/// Gets the size in bytes of the memory location or 0 if it's not accessed by the instruction or unknown or variable sized
	///
	/// # Examples
	///
	/// ```
	/// use iced_x86::*;
	/// assert_eq!(MemorySize::UInt32.size(), 4);
	/// assert_eq!(MemorySize::Packed256_UInt16.size(), 32);
	/// assert_eq!(MemorySize::Broadcast512_UInt64.size(), 8);
	/// ```
	#[must_use]
	#[inline]
	pub fn size(self) -> usize {
		self.info().size()
	}

	/// Gets the size in bytes of the packed element. If it's not a packed data type, it's equal to [`size()`].
	///
	/// [`size()`]: #method.size
	///
	/// # Examples
	///
	/// ```
	/// use iced_x86::*;
	/// assert_eq!(MemorySize::UInt32.element_size(), 4);
	/// assert_eq!(MemorySize::Packed256_UInt16.element_size(), 2);
	/// assert_eq!(MemorySize::Broadcast512_UInt64.element_size(), 8);
	/// ```
	#[must_use]
	#[inline]
	pub fn element_size(self) -> usize {
		self.info().element_size()
	}

	/// Gets the element type if it's packed data or `self` if it's not packed data
	///
	/// # Examples
	///
	/// ```
	/// use iced_x86::*;
	/// assert_eq!(MemorySize::UInt32.element_type(), MemorySize::UInt32);
	/// assert_eq!(MemorySize::Packed256_UInt16.element_type(), MemorySize::UInt16);
	/// assert_eq!(MemorySize::Broadcast512_UInt64.element_type(), MemorySize::UInt64);
	/// ```
	#[must_use]
	#[inline]
	pub fn element_type(self) -> Self {
		self.info().element_type()
	}

	/// Gets the element type info if it's packed data or `self` if it's not packed data
	///
	/// # Examples
	///
	/// ```
	/// use iced_x86::*;
	/// assert_eq!(MemorySize::UInt32.element_type_info().memory_size(), MemorySize::UInt32);
	/// assert_eq!(MemorySize::Packed256_UInt16.element_type_info().memory_size(), MemorySize::UInt16);
	/// assert_eq!(MemorySize::Broadcast512_UInt64.element_type_info().memory_size(), MemorySize::UInt64);
	/// ```
	#[must_use]
	#[inline]
	pub fn element_type_info(self) -> &'static MemorySizeInfo {
		self.info().element_type().info()
	}

Gets the element type if it’s packed data or the type itself if it’s not packed data

Examples
use iced_x86::*;
let info = MemorySize::UInt32.info().element_type_info();
assert_eq!(info.memory_size(), MemorySize::UInt32);
let info = MemorySize::Packed256_UInt16.info().element_type_info();
assert_eq!(info.memory_size(), MemorySize::UInt16);
let info = MemorySize::Broadcast512_UInt64.info().element_type_info();
assert_eq!(info.memory_size(), MemorySize::UInt64);

true if it’s signed data (signed integer or a floating point value)

Examples
use iced_x86::*;
let info = MemorySize::UInt32.info();
assert!(!info.is_signed());
let info = MemorySize::Int32.info();
assert!(info.is_signed());
let info = MemorySize::Float64.info();
assert!(info.is_signed());
Examples found in repository?
src/memory_size.rs (line 1164)
1163
1164
1165
	pub fn is_signed(self) -> bool {
		self.info().is_signed()
	}

true if it’s a broadcast memory type

Examples
use iced_x86::*;
let info = MemorySize::UInt32.info();
assert!(!info.is_broadcast());
let info = MemorySize::Packed256_UInt16.info();
assert!(!info.is_broadcast());
let info = MemorySize::Broadcast512_UInt64.info();
assert!(info.is_broadcast());

true if this is a packed data type, eg. MemorySize::Packed128_Float32. See also element_count()

Examples
use iced_x86::*;
let info = MemorySize::UInt32.info();
assert!(!info.is_packed());
let info = MemorySize::Packed256_UInt16.info();
assert!(info.is_packed());
let info = MemorySize::Broadcast512_UInt64.info();
assert!(!info.is_packed());
Examples found in repository?
src/memory_size.rs (line 1182)
1181
1182
1183
	pub fn is_packed(self) -> bool {
		self.info().is_packed()
	}

Gets the number of elements in the packed data type or 1 if it’s not packed data (is_packed())

Examples
use iced_x86::*;
let info = MemorySize::UInt32.info();
assert_eq!(info.element_count(), 1);
let info = MemorySize::Packed256_UInt16.info();
assert_eq!(info.element_count(), 16);
let info = MemorySize::Broadcast512_UInt64.info();
assert_eq!(info.element_count(), 1);
Examples found in repository?
src/memory_size.rs (line 1200)
1199
1200
1201
	pub fn element_count(self) -> usize {
		self.info().element_count()
	}

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.