History

Alter register address decoding using a lookup table instead of single function with multiple switch blocks. Reduced scheduler sleep time during tool dispatch setting.

arr committed 10 years ago

Commit 824a71a1 parent fcc75fd7 files · +500 −86Browse files

Showing the changes to src/vm/module_reader.cpp (1 of 7 files). Show all

Unified · Split

src/vm/module_reader.cpp+4−6
@@ -191,16 +191,13 @@ namespace · 190 unmodified lines
191 return dest;191 return dest;
192 }192 }
193 193
194 std::tuple<address_mode_middle_t, address_mode_t, address_mode_t> convert_to_address_mode(uint8_t instr_addr_mode)194 std::tuple<address_mode_middle_t, address_mode_t, address_mode_t> convert_to_address_mode(addr_code_t instr_addr_mode)
195 {195 {
196 // Taken from Dis VM specification196 // See definition of addr_code_t
197 // bit 7 6 5 4 3 2 1 0
198 // m1 m0 s2 s1 s0 d2 d1 d0
199
200 static const auto mid_mask = uint8_t{ 0xc0 };197 static const auto mid_mask = uint8_t{ 0xc0 };
201 static const auto src_mask = uint8_t{ 0x38 };198 static const auto src_mask = uint8_t{ 0x38 };
202 static const auto dest_mask = uint8_t{ 0x07 };199 static const auto dest_mask = uint8_t{ 0x07 };
203 assert((mid_mask | src_mask | dest_mask) == std::numeric_limits<uint8_t>::max());200 assert((mid_mask | src_mask | dest_mask) == std::numeric_limits<addr_code_t>::max());
204 201
205 const auto mid = static_cast<address_mode_middle_t>((instr_addr_mode & mid_mask) >> 6);202 const auto mid = static_cast<address_mode_middle_t>((instr_addr_mode & mid_mask) >> 6);
206 const auto src = static_cast<address_mode_t>((instr_addr_mode & src_mask) >> 3);203 const auto src = static_cast<address_mode_t>((instr_addr_mode & src_mask) >> 3);
@@ -286,6 +283,7 @@ namespace · 79 unmodified lines
286 283
287 instr.opcode = static_cast<opcode_t>(op_and_addrmode[0]);284 instr.opcode = static_cast<opcode_t>(op_and_addrmode[0]);
288 assert(opcode_t::first_opcode <= instr.opcode && instr.opcode <= opcode_t::last_opcode);285 assert(opcode_t::first_opcode <= instr.opcode && instr.opcode <= opcode_t::last_opcode);
286 instr.addr_code = op_and_addrmode[1];
289 287
290 std::tie(instr.middle.mode, instr.source.mode, instr.destination.mode) = convert_to_address_mode(op_and_addrmode[1]);288 std::tie(instr.middle.mode, instr.source.mode, instr.destination.mode) = convert_to_address_mode(op_and_addrmode[1]);
291 289