aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2024-06-10 18:22:05 -0700
committerAndrew Waterman <andrew@sifive.com>2024-06-11 13:51:14 -0700
commitacd43e0191ae9afa8099a00bb9162b134233b01f (patch)
tree0159e25677c8bd7fe923e601ac9bd823def2438e
parentca38d97e7b0ab0b482e50e1381dfb28eab48aefa (diff)
downloadspike-acd43e0191ae9afa8099a00bb9162b134233b01f.zip
spike-acd43e0191ae9afa8099a00bb9162b134233b01f.tar.gz
spike-acd43e0191ae9afa8099a00bb9162b134233b01f.tar.bz2
Preserve the ordering of the instruction list
-rw-r--r--riscv/processor.cc24
1 files changed, 2 insertions, 22 deletions
diff --git a/riscv/processor.cc b/riscv/processor.cc
index a1cec6c..3a9c0d9 100644
--- a/riscv/processor.cc
+++ b/riscv/processor.cc
@@ -1072,24 +1072,6 @@ reg_t illegal_instruction(processor_t UNUSED *p, insn_t insn, reg_t UNUSED pc)
throw trap_illegal_instruction(insn.bits() & 0xffffffffULL);
}
-static insn_desc_t
-propagate_instruction_in_vector(std::vector<insn_desc_t> &instructions,
- std::vector<insn_desc_t>::iterator it) {
- assert(it != instructions.end());
- insn_desc_t desc = *it;
- if (it->mask != 0 && it != instructions.begin() &&
- std::next(it) != instructions.end()) {
- if (it->match != std::prev(it)->match &&
- it->match != std::next(it)->match) {
- // move to front of opcode list to reduce miss penalty
- while (--it >= instructions.begin())
- *std::next(it) = *it;
- instructions[0] = desc;
- }
- }
- return desc;
-}
-
insn_func_t processor_t::decode_insn(insn_t insn)
{
// look up opcode in hash table
@@ -1105,13 +1087,11 @@ insn_func_t processor_t::decode_insn(insn_t insn)
};
auto p = std::find_if(custom_instructions.begin(),
custom_instructions.end(), matching);
- if (p != custom_instructions.end()) {
- desc = propagate_instruction_in_vector(custom_instructions, p);
- } else {
+ if (p == custom_instructions.end()) {
p = std::find_if(instructions.begin(), instructions.end(), matching);
assert(p != instructions.end());
- desc = propagate_instruction_in_vector(instructions, p);
}
+ desc = *p;
opcode_cache[idx] = desc;
opcode_cache[idx].match = insn.bits();
}