1- #include < iss/instruction_decoder.h>
2- #include < vector>
31#include < array>
42#include < fstream>
3+ #include < iss/instruction_decoder.h>
4+ #include < vector>
55
66enum class opcode_e {
7- C__LBU = 116 ,
8- C__LHU = 117 ,
9- C__LH = 118 ,
10- C__SB = 119 ,
11- C__SH = 120 ,
7+ C__LBU = 116 ,
8+ C__LHU = 117 ,
9+ C__LH = 118 ,
10+ C__SB = 119 ,
11+ C__SH = 120 ,
1212
1313};
1414struct instruction_descriptor {
@@ -18,29 +18,26 @@ struct instruction_descriptor {
1818 opcode_e op;
1919};
2020
21-
22- const std::array<instruction_descriptor, 2 > instr_descr = {{
23- // {16, 0b1000000000000000, 0b1111110000000011, opcode_e::C__LBU},
24- {16 , 0b1000010000000000 , 0b1111110001000011 , opcode_e::C__LHU },
25- {16 , 0b1000010001000000 , 0b1111110001000011 , opcode_e::C__LH }
26- }};
21+ const std::array<instruction_descriptor, 2 > instr_descr = {{// {16, 0b1000000000000000, 0b1111110000000011, opcode_e::C__LBU},
22+ {16 , 0b1000010000000000 , 0b1111110001000011 , opcode_e::C__LHU },
23+ {16 , 0b1000010001000000 , 0b1111110001000011 , opcode_e::C__LH }}};
2724
2825int main (int argc, char * argv[]) {
2926 iss::decoder instr_decoder ([]() {
30- std::vector<iss::generic_instruction_descriptor> g_instr_descr;
31- g_instr_descr.reserve (instr_descr.size ());
32- for (uint32_t i = 0 ; i < instr_descr.size (); ++i) {
33- iss::generic_instruction_descriptor new_instr_descr {instr_descr[i].value , instr_descr[i].mask , i};
34- g_instr_descr.push_back (new_instr_descr);
27+ std::vector<iss::generic_instruction_descriptor> g_instr_descr;
28+ g_instr_descr.reserve (instr_descr.size ());
29+ for (uint32_t i = 0 ; i < instr_descr.size (); ++i) {
30+ iss::generic_instruction_descriptor new_instr_descr{instr_descr[i].value , instr_descr[i].mask , i};
31+ g_instr_descr.push_back (new_instr_descr);
3532 }
36- return std::move (g_instr_descr);
37- }());
33+ return std::move (g_instr_descr);
34+ }());
3835
3936 std::ofstream json_out{" idecode_tree.json" };
40- json_out<< instr_decoder.print_tree_as_pretty_json ();
37+ json_out << instr_decoder.print_tree_as_pretty_json ();
4138
4239 auto inst_index1 = instr_decoder.decode_instr (0x8440 );
4340 auto inst_index2 = instr_decoder.decode_instr (0x86b0 );
4441
45- return inst_index1== inst_index2? 0 : 1 ;
42+ return inst_index1 == inst_index2 ? 0 : 1 ;
4643}
0 commit comments