diff options
author | Scott Johnson <scott.johnson@arilinc.com> | 2022-12-01 09:21:58 -0800 |
---|---|---|
committer | Scott Johnson <scott.johnson@arilinc.com> | 2022-12-01 09:22:01 -0800 |
commit | a315193ab08abc3aaaa1885370253992c110b6ec (patch) | |
tree | a6f44ec1d0f9d93fa335fd20fe6815e162350870 | |
parent | 024533d921eadd44149a7361d3d94217593ef2a0 (diff) | |
download | riscv-isa-sim-a315193ab08abc3aaaa1885370253992c110b6ec.zip riscv-isa-sim-a315193ab08abc3aaaa1885370253992c110b6ec.tar.gz riscv-isa-sim-a315193ab08abc3aaaa1885370253992c110b6ec.tar.bz2 |
Convert triggers::module_t::detect_memory_access_match to std::optional
Goal is to remove match_result_t.fire field to eliminate dont-care
fields when fire=false.
-rw-r--r-- | riscv/mmu.cc | 10 | ||||
-rw-r--r-- | riscv/triggers.cc | 6 | ||||
-rw-r--r-- | riscv/triggers.h | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/riscv/mmu.cc b/riscv/mmu.cc index e4fba3d..1d15b91 100644 --- a/riscv/mmu.cc +++ b/riscv/mmu.cc @@ -157,18 +157,18 @@ void mmu_t::check_triggers(triggers::operation_t operation, reg_t address, std:: if (matched_trigger || !proc) return; - triggers::match_result_t match = proc->TM.detect_memory_access_match(operation, address, data); + auto match = proc->TM.detect_memory_access_match(operation, address, data); - if (match.fire) - switch (match.timing) { + if (match.has_value()) + switch (match->timing) { case triggers::TIMING_BEFORE: - throw triggers::matched_t(operation, address, match.action); + throw triggers::matched_t(operation, address, match->action); case triggers::TIMING_AFTER: // We want to take this exception on the next instruction. We check // whether to do so in the I$ refill path, so flush the I$. flush_icache(); - matched_trigger = new triggers::matched_t(operation, address, match.action); + matched_trigger = new triggers::matched_t(operation, address, match->action); } } diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 7f3817e..12a06d7 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -331,11 +331,11 @@ bool module_t::tdata2_write(processor_t * const proc, unsigned index, const reg_ return true; } -match_result_t module_t::detect_memory_access_match(operation_t operation, reg_t address, std::optional<reg_t> data) noexcept +std::optional<match_result_t> module_t::detect_memory_access_match(operation_t operation, reg_t address, std::optional<reg_t> data) noexcept { state_t * const state = proc->get_state(); if (state->debug_mode) - return match_result_t(false); + return std::nullopt; bool chain_ok = true; @@ -357,7 +357,7 @@ match_result_t module_t::detect_memory_access_match(operation_t operation, reg_t chain_ok = result.fire || !trigger->get_chain(); } - return match_result_t(false); + return std::nullopt; } match_result_t module_t::detect_trap_match(const trap_t& t) noexcept diff --git a/riscv/triggers.h b/riscv/triggers.h index 0b58798..27f1c0e 100644 --- a/riscv/triggers.h +++ b/riscv/triggers.h @@ -186,7 +186,7 @@ public: unsigned count() const { return triggers.size(); } - match_result_t detect_memory_access_match(operation_t operation, reg_t address, std::optional<reg_t> data) noexcept; + std::optional<match_result_t> detect_memory_access_match(operation_t operation, reg_t address, std::optional<reg_t> data) noexcept; match_result_t detect_trap_match(const trap_t& t) noexcept; processor_t *proc; |