aboutsummaryrefslogtreecommitdiff
path: root/riscv/triggers.cc
diff options
context:
space:
mode:
authorYenHaoChen <howard25336284@gmail.com>2023-01-04 09:57:04 +0800
committerYenHaoChen <howard25336284@gmail.com>2023-01-04 09:57:04 +0800
commit590a36e487dc9bbb8d2c13bc4fd7e9af40cff9ad (patch)
tree408d0f63512442891f086a57beb4a0d1916c5b37 /riscv/triggers.cc
parent3b3664544262f15e5f6b11b597b32eef954307eb (diff)
downloadriscv-isa-sim-590a36e487dc9bbb8d2c13bc4fd7e9af40cff9ad.zip
riscv-isa-sim-590a36e487dc9bbb8d2c13bc4fd7e9af40cff9ad.tar.gz
riscv-isa-sim-590a36e487dc9bbb8d2c13bc4fd7e9af40cff9ad.tar.bz2
triggers: refactor: create trigger_t::common_match()
Diffstat (limited to 'riscv/triggers.cc')
-rw-r--r--riscv/triggers.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/riscv/triggers.cc b/riscv/triggers.cc
index c292bb5..f451f05 100644
--- a/riscv/triggers.cc
+++ b/riscv/triggers.cc
@@ -54,6 +54,10 @@ void trigger_t::tdata3_write(processor_t * const proc, const reg_t val) noexcept
sselect = (sselect_t)((proc->extension_enabled_const('S') && get_field(val, CSR_TEXTRA_SSELECT(xlen)) <= SSELECT_MAXVAL) ? get_field(val, CSR_TEXTRA_SSELECT(xlen)) : SSELECT_IGNORE);
}
+bool trigger_t::common_match(processor_t * const proc) const noexcept {
+ return mode_match(proc->get_state()) && textra_match(proc);
+}
+
bool trigger_t::mode_match(state_t * const state) const noexcept
{
switch (state->prv) {
@@ -190,8 +194,7 @@ std::optional<match_result_t> mcontrol_common_t::detect_memory_access_match(proc
if ((operation == triggers::OPERATION_EXECUTE && !execute) ||
(operation == triggers::OPERATION_STORE && !store) ||
(operation == triggers::OPERATION_LOAD && !load) ||
- !mode_match(proc->get_state()) ||
- !textra_match(proc)) {
+ !common_match(proc)) {
return std::nullopt;
}
@@ -313,7 +316,7 @@ void itrigger_t::tdata1_write(processor_t * const proc, const reg_t val, const b
std::optional<match_result_t> trap_common_t::detect_trap_match(processor_t * const proc, const trap_t& t) noexcept
{
- if (!mode_match(proc->get_state()) || !textra_match(proc))
+ if (!common_match(proc))
return std::nullopt;
auto xlen = proc->get_xlen();