1
1
use proc_bitfield:: { bitfield, ConvRaw } ;
2
+ use crate :: instruction:: mnemonic:: Operation ;
2
3
use crate :: num:: MaskedU8 ;
3
4
4
5
pub mod memory;
@@ -15,11 +16,11 @@ bitfield! {
15
16
16
17
#[ derive( Debug , Clone , Copy , PartialEq , Default ) ]
17
18
#[ repr( u8 ) ]
18
- pub enum Scale {
19
+ pub enum Scale {
19
20
#[ default]
20
- X8 ,
21
- X16 ,
22
- X32 ,
21
+ X8 ,
22
+ X16 ,
23
+ X32 ,
23
24
X64
24
25
}
25
26
@@ -44,7 +45,7 @@ impl From<Scale> for u8 {
44
45
#[ derive( Debug , Clone , Copy , PartialEq ) ]
45
46
#[ repr( u8 ) ]
46
47
pub enum Instruction {
47
- Mnemonic ( mnemonic:: Format ) ,
48
+ Mnemonic ( mnemonic:: Operation ) ,
48
49
49
50
LoadImmediate ( register:: LoadImmediateOperation ) ,
50
51
BuildVector ( register:: BuildVectorOperation ) ,
@@ -108,14 +109,17 @@ impl Instruction {
108
109
Self :: BINARY_CODE => Self :: Binary ( binary:: Operation :: from ( encoded) ) ,
109
110
Self :: REGROUP_BINARY_CODE => Self :: RegroupBinary ( binary:: RegroupingBinaryOperation :: from ( encoded) ) ,
110
111
Self :: REGROUP_QUATERNARY_CODE => Self :: RegroupQuaternary ( binary:: RegroupingQuaternaryOperation :: from ( encoded) ) ,
111
-
112
- _ => unimplemented ! ( )
112
+ _ => Self :: Mnemonic ( mnemonic:: Format :: from ( 0 ) . operation ( ) )
113
113
}
114
114
}
115
115
116
116
pub fn encode ( self ) -> u32 {
117
117
let ( opcode, operands) = match self {
118
- Instruction :: Mnemonic ( op) => ( Self :: MNEMONIC_CODE , u32:: from ( op) ) ,
118
+ Instruction :: Mnemonic ( op) => {
119
+ let mut inner = mnemonic:: Format :: from ( 0 ) ;
120
+ inner. set_operation ( op) ;
121
+ ( Self :: MNEMONIC_CODE , u32:: from ( inner) )
122
+ } ,
119
123
Instruction :: LoadImmediate ( op) => ( Self :: LOAD_IMMEDIATE_CODE , u32:: from ( op) ) ,
120
124
Instruction :: BuildVector ( op) => ( Self :: BUILD_VECTOR_CODE , u32:: from ( op) ) ,
121
125
Instruction :: UnBuildVector ( op) => ( Self :: UNBUILD_VECTOR_CODE , u32:: from ( op) ) ,
0 commit comments