aboutsummaryrefslogtreecommitdiff
path: root/riscv/processor.cc
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2022-05-13 13:58:53 -0700
committerGitHub <noreply@github.com>2022-05-13 13:58:53 -0700
commite94d843e8b2772ec860258f006c8a3126a92a781 (patch)
tree5d1268ac396b42855e332949d30030ad374c4666 /riscv/processor.cc
parent78dfe62633ce4fe6e6a70afae04168e1f102b673 (diff)
parente66e2e2b09c04acf733089658cf32a27708b8d16 (diff)
downloadspike-e94d843e8b2772ec860258f006c8a3126a92a781.zip
spike-e94d843e8b2772ec860258f006c8a3126a92a781.tar.gz
spike-e94d843e8b2772ec860258f006c8a3126a92a781.tar.bz2
Merge pull request #997 from riscv-software-src/simplify-decode_insn
Simplify decode_insn and insn_desc_t
Diffstat (limited to 'riscv/processor.cc')
-rw-r--r--riscv/processor.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/riscv/processor.cc b/riscv/processor.cc
index 661058c..a9003a8 100644
--- a/riscv/processor.cc
+++ b/riscv/processor.cc
@@ -885,11 +885,11 @@ insn_func_t processor_t::decode_insn(insn_t insn)
bool rve = extension_enabled('E');
- if (unlikely(insn.bits() != desc.match || !desc.func(xlen, rve))) {
+ if (unlikely(insn.bits() != desc.match)) {
// fall back to linear search
int cnt = 0;
insn_desc_t* p = &instructions[0];
- while ((insn.bits() & p->mask) != p->match || !desc.func(xlen, rve))
+ while ((insn.bits() & p->mask) != p->match)
p++, cnt++;
desc = *p;
@@ -911,6 +911,8 @@ insn_func_t processor_t::decode_insn(insn_t insn)
void processor_t::register_insn(insn_desc_t desc)
{
+ assert(desc.rv32i && desc.rv64i && desc.rv32e && desc.rv64e);
+
instructions.push_back(desc);
}
@@ -963,14 +965,15 @@ void processor_t::register_base_instructions()
extern reg_t rv64i_##name(processor_t*, insn_t, reg_t); \
extern reg_t rv32e_##name(processor_t*, insn_t, reg_t); \
extern reg_t rv64e_##name(processor_t*, insn_t, reg_t); \
- register_insn((insn_desc_t) { \
- name##_supported, \
- name##_match, \
- name##_mask, \
- rv32i_##name, \
- rv64i_##name, \
- rv32e_##name, \
- rv64e_##name});
+ if (name##_supported) { \
+ register_insn((insn_desc_t) { \
+ name##_match, \
+ name##_mask, \
+ rv32i_##name, \
+ rv64i_##name, \
+ rv32e_##name, \
+ rv64e_##name}); \
+ }
#include "insn_list.h"
#undef DEFINE_INSN