improves instruction decoding by avoiding copying, replaces .size()
This commit is contained in:
parent
0d6bf924ed
commit
b1306c3a47
|
@ -85,15 +85,13 @@ void decoder::populate_decoding_tree(decoding_tree_node& parent) {
|
||||||
}
|
}
|
||||||
uint32_t decoder::decode_instr(uint32_t word) { return _decode_instr(this->root, word); }
|
uint32_t decoder::decode_instr(uint32_t word) { return _decode_instr(this->root, word); }
|
||||||
uint32_t decoder::_decode_instr(decoding_tree_node const& node, uint32_t word) {
|
uint32_t decoder::_decode_instr(decoding_tree_node const& node, uint32_t word) {
|
||||||
if(!node.children.size()) {
|
if(!node.instrs.empty()) {
|
||||||
if(node.instrs.size() == 1)
|
for(auto& instr : node.instrs) {
|
||||||
return node.instrs[0].index;
|
|
||||||
for(auto instr : node.instrs) {
|
|
||||||
if((instr.mask & word) == instr.value)
|
if((instr.mask & word) == instr.value)
|
||||||
return instr.index;
|
return instr.index;
|
||||||
}
|
}
|
||||||
} else {
|
} else if(!node.children.empty()) {
|
||||||
for(auto child : node.children) {
|
for(auto& child : node.children) {
|
||||||
if(child.value == (node.submask & word)) {
|
if(child.value == (node.submask & word)) {
|
||||||
return _decode_instr(child, word);
|
return _decode_instr(child, word);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue