1
+ use crate :: instruction:: Format ;
2
+ use crate :: num:: MaskedU8 ;
3
+
4
+ pub type Code = MaskedU8 < 0x7F > ;
5
+
6
+ #[ derive( Debug , Clone , Copy , PartialEq ) ]
7
+ pub enum DualSource {
8
+ Compare
9
+ }
10
+
11
+ impl DualSource {
12
+ pub const MAPPINGS : [ ( Code , DualSource ) ; 1 ] = [ ( Code :: new ( 0 ) , Self :: Compare ) ] ;
13
+ }
14
+
1
15
#[ derive( Debug , Clone , Copy , PartialEq ) ]
2
16
pub enum Destination {
3
17
Unstack
4
18
}
5
19
6
20
impl Destination {
7
- pub const MAPPINGS : [ Destination ; 1 ] = [ Self :: Unstack ] ;
21
+ pub const MAPPINGS : [ ( Code , Destination ) ; 1 ] = [ ( Code :: new ( 1 ) , Self :: Unstack ) ] ;
8
22
}
9
23
10
24
#[ derive( Debug , Clone , Copy , PartialEq ) ]
@@ -13,7 +27,7 @@ pub enum DestinationSource {
13
27
}
14
28
15
29
impl DestinationSource {
16
- pub const MAPPINGS : [ DestinationSource ; 1 ] = [ Self :: CopyRegisterToRegister ] ;
30
+ pub const MAPPINGS : [ ( Code , DestinationSource ) ; 1 ] = [ ( Code :: new ( 2 ) , Self :: CopyRegisterToRegister ) ] ;
17
31
}
18
32
19
33
#[ derive( Debug , Clone , Copy , PartialEq ) ]
@@ -40,38 +54,40 @@ pub enum DestinationDualSource {
40
54
}
41
55
42
56
impl DestinationDualSource {
43
- pub const MAPPINGS : [ DestinationDualSource ; 16 ] = [
44
- Self :: Add , Self :: Subtract , Self :: Multiply , Self :: Divide ,
45
- Self :: AddFloat , Self :: SubtractFloat , Self :: MultiplyFloat , Self :: DivideFloat ,
46
- Self :: AddVector , Self :: SubtractVector , Self :: MultiplyVector , Self :: DivideVector ,
47
- Self :: AddFloatVector , Self :: SubtractFloatVector , Self :: MultiplyFloatVector , Self :: DivideFloatVector ,
57
+ pub const MAPPINGS : [ ( Code , DestinationDualSource ) ; 16 ] = [
58
+ ( Code :: new ( 3 ) , Self :: Add ) , ( Code :: new ( 4 ) , Self :: Subtract ) , ( Code :: new ( 5 ) , Self :: Multiply ) , ( Code :: new ( 6 ) , Self :: Divide ) ,
59
+ ( Code :: new ( 7 ) , Self :: AddFloat ) , ( Code :: new ( 8 ) , Self :: SubtractFloat ) , ( Code :: new ( 9 ) , Self :: MultiplyFloat ) , ( Code :: new ( 10 ) , Self :: DivideFloat ) ,
60
+ ( Code :: new ( 11 ) , Self :: AddVector ) , ( Code :: new ( 12 ) , Self :: SubtractVector ) , ( Code :: new ( 13 ) , Self :: MultiplyVector ) , ( Code :: new ( 14 ) , Self :: DivideVector ) ,
61
+ ( Code :: new ( 15 ) , Self :: AddFloatVector ) , ( Code :: new ( 16 ) , Self :: SubtractFloatVector ) , ( Code :: new ( 17 ) , Self :: MultiplyFloatVector ) , ( Code :: new ( 18 ) , Self :: DivideFloatVector ) ,
48
62
] ;
49
63
}
50
64
51
65
#[ derive( Debug , Clone , Copy , PartialEq ) ]
52
66
pub enum DestinationTripleSource {
53
67
MultiplyAndAdd ,
54
68
AddAndMultiply
69
+
70
+ // todo: Consider neccessity and operation space
55
71
}
56
72
57
73
impl DestinationTripleSource {
58
- pub const MAPPINGS : [ DestinationTripleSource ; 2 ] = [
59
- Self :: MultiplyAndAdd , Self :: AddAndMultiply ,
74
+ pub const MAPPINGS : [ ( Code , DestinationTripleSource ) ; 2 ] = [
75
+ ( Code :: new ( 19 ) , Self :: MultiplyAndAdd ) , ( Code :: new ( 20 ) , Self :: AddAndMultiply ) ,
60
76
] ;
61
77
}
62
78
63
79
#[ derive( Debug , Clone , Copy , PartialEq ) ]
64
80
pub enum DualDestinationDualSource {
65
81
DivideWithRemainder ,
66
- DivideFloatingWithRemainder ,
82
+ DivideFloatWithRemainder ,
67
83
DivideVectorWithRemainder ,
68
84
DivideFloatVectorWithRemainder
69
85
}
70
86
71
87
impl DualDestinationDualSource {
72
- pub const MAPPINGS : [ DualDestinationDualSource ; 4 ] = [
73
- Self :: DivideWithRemainder , Self :: DivideFloatingWithRemainder ,
74
- Self :: DivideVectorWithRemainder , Self :: DivideFloatVectorWithRemainder ,
88
+ pub const MAPPINGS : [ ( Code , DualDestinationDualSource ) ; 4 ] = [
89
+ ( Code :: new ( 21 ) , Self :: DivideWithRemainder ) , ( Code :: new ( 22 ) , Self :: DivideFloatingWithRemainder ) ,
90
+ ( Code :: new ( 23 ) , Self :: DivideVectorWithRemainder ) , ( Code :: new ( 24 ) , Self :: DivideFloatVectorWithRemainder ) ,
75
91
] ;
76
92
}
77
93
@@ -83,8 +99,8 @@ pub enum Memory {
83
99
}
84
100
85
101
impl Memory {
86
- pub const MAPPINGS : [ Memory ; 3 ] = [
87
- Self :: Call , Self :: ReleaseMemory , Self :: Branch ,
102
+ pub const MAPPINGS : [ ( Code , Memory ) ; 3 ] = [
103
+ ( Code :: new ( 25 ) , Self :: Call ) , ( Code :: new ( 26 ) , Self :: ReleaseMemory ) , ( Code :: new ( 27 ) , Self :: Branch ) ,
88
104
] ;
89
105
}
90
106
@@ -102,11 +118,11 @@ pub enum SourceMemory {
102
118
}
103
119
104
120
impl SourceMemory {
105
- pub const MAPPINGS : [ SourceMemory ; 8 ] = [
106
- Self :: CopyMemoryByteToRegister , Self :: CopyMemoryWordToRegister ,
107
- Self :: CopyMemoryDwordToRegister , Self :: CopyMemoryQwordToRegister ,
108
- Self :: AcquireMemoryByte , Self :: AcquireMemoryWord ,
109
- Self :: AcquireMemoryDword , Self :: AcquireMemoryQword ,
121
+ pub const MAPPINGS : [ ( Code , SourceMemory ) ; 8 ] = [
122
+ ( Code :: new ( 28 ) , Self :: CopyMemoryByteToRegister ) , ( Code :: new ( 29 ) , Self :: CopyMemoryWordToRegister ) ,
123
+ ( Code :: new ( 30 ) , Self :: CopyMemoryDwordToRegister ) , ( Code :: new ( 31 ) , Self :: CopyMemoryQwordToRegister ) ,
124
+ ( Code :: new ( 32 ) , Self :: AcquireMemoryByte ) , ( Code :: new ( 33 ) , Self :: AcquireMemoryWord ) ,
125
+ ( Code :: new ( 34 ) , Self :: AcquireMemoryDword ) , ( Code :: new ( 35 ) , Self :: AcquireMemoryQword ) ,
110
126
] ;
111
127
}
112
128
@@ -119,8 +135,64 @@ pub enum DestinationMemory {
119
135
}
120
136
121
137
impl DestinationMemory {
122
- pub const MAPPINGS : [ DestinationMemory ; 4 ] = [
123
- Self :: CopyRegisterByteToMemory , Self :: CopyRegisterWordToMemory ,
124
- Self :: CopyRegisterDwordToMemory , Self :: CopyRegisterQwordToMemory ,
138
+ pub const MAPPINGS : [ ( Code , DestinationMemory ) ; 4 ] = [
139
+ ( Code :: new ( 36 ) , Self :: CopyRegisterByteToMemory ) , ( Code :: new ( 37 ) , Self :: CopyRegisterWordToMemory ) ,
140
+ ( Code :: new ( 38 ) , Self :: CopyRegisterDwordToMemory ) , ( Code :: new ( 39 ) , Self :: CopyRegisterQwordToMemory ) ,
125
141
] ;
126
142
}
143
+
144
+ #[ derive( Debug , Clone , Copy , PartialEq ) ]
145
+ pub struct Entry < ' a > {
146
+ pub format : Format ,
147
+ pub name : & ' a str
148
+ }
149
+
150
+ pub const MAPPINGS : [ Entry ; 47 ] = [
151
+ Entry { format : Format :: WaitForInterrupt , name : "wait_for_interrupt" } ,
152
+ Entry { format : Format :: LoadImmediate , name : "load_immediate" } ,
153
+ Entry { format : Format :: LoadVectorComponents , name : "load_vector_components" } ,
154
+ Entry { format : Format :: ExtractVectorComponents , name : "extract_vector_components" } ,
155
+ Entry { format : Format :: FlagVectorComponents , name : "flag_vector_components" } ,
156
+ Entry { format : Format :: MapVector , name : "map_vector" } ,
157
+ Entry { format : Format :: Branch , name : "branch" } ,
158
+ Entry { format : Format :: DualSource , name : "compare" } ,
159
+ Entry { format : Format :: Destination , name : "unstack" } ,
160
+ Entry { format : Format :: DestinationSource , name : "copy_register_to_register" } ,
161
+ Entry { format : Format :: DestinationDualSource , name : "add" } ,
162
+ Entry { format : Format :: DestinationDualSource , name : "subtract" } ,
163
+ Entry { format : Format :: DestinationDualSource , name : "multiply" } ,
164
+ Entry { format : Format :: DestinationDualSource , name : "divide" } ,
165
+ Entry { format : Format :: DestinationDualSource , name : "add_float" } ,
166
+ Entry { format : Format :: DestinationDualSource , name : "subtract_float" } ,
167
+ Entry { format : Format :: DestinationDualSource , name : "multiply_float" } ,
168
+ Entry { format : Format :: DestinationDualSource , name : "divide_float" } ,
169
+ Entry { format : Format :: DestinationDualSource , name : "add_vector" } ,
170
+ Entry { format : Format :: DestinationDualSource , name : "subtract_vector" } ,
171
+ Entry { format : Format :: DestinationDualSource , name : "multiply_vector" } ,
172
+ Entry { format : Format :: DestinationDualSource , name : "divide_vector" } ,
173
+ Entry { format : Format :: DestinationDualSource , name : "add_float_vector" } ,
174
+ Entry { format : Format :: DestinationDualSource , name : "subtract_float_vector" } ,
175
+ Entry { format : Format :: DestinationDualSource , name : "multiply_float_vector" } ,
176
+ Entry { format : Format :: DestinationDualSource , name : "divide_float_vector" } ,
177
+ Entry { format : Format :: DestinationTripleSource , name : "multiply_and_add" } ,
178
+ Entry { format : Format :: DestinationTripleSource , name : "add_and_multiply" } ,
179
+ Entry { format : Format :: DualDestinationDualSource , name : "divide_with_remainder" } ,
180
+ Entry { format : Format :: DualDestinationDualSource , name : "divide_float_with_remainder" } ,
181
+ Entry { format : Format :: DualDestinationDualSource , name : "divide_vector_with_remainder" } ,
182
+ Entry { format : Format :: DualDestinationDualSource , name : "divide_float_vector_with_remainder" } ,
183
+ Entry { format : Format :: Memory , name : "call" } ,
184
+ Entry { format : Format :: Memory , name : "release_memory" } ,
185
+ Entry { format : Format :: Memory , name : "branch" } ,
186
+ Entry { format : Format :: SourceMemory , name : "copy_memory_byte_to_register" } ,
187
+ Entry { format : Format :: SourceMemory , name : "copy_memory_word_to_register" } ,
188
+ Entry { format : Format :: SourceMemory , name : "copy_memory_dword_to_register" } ,
189
+ Entry { format : Format :: SourceMemory , name : "copy_memory_qword_to_register" } ,
190
+ Entry { format : Format :: SourceMemory , name : "aquire_memory_byte" } ,
191
+ Entry { format : Format :: SourceMemory , name : "aquire_memory_word" } ,
192
+ Entry { format : Format :: SourceMemory , name : "aquire_memory_dword" } ,
193
+ Entry { format : Format :: SourceMemory , name : "aquire_memory_qword" } ,
194
+ Entry { format : Format :: DestinationMemory , name : "copy_register_byte_to_memory" } ,
195
+ Entry { format : Format :: DestinationMemory , name : "copy_register_word_to_memory" } ,
196
+ Entry { format : Format :: DestinationMemory , name : "copy_register_dword_to_memory" } ,
197
+ Entry { format : Format :: DestinationMemory , name : "copy_register_qword_to_memory" }
198
+ ] ;
0 commit comments