Browse Source
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.
pull/1158/head
Scott Johnson
3 years ago
No known key found for this signature in database
GPG Key ID: 61C1F01D3D1410C9
3 changed files with
9 additions and
9 deletions
-
riscv/mmu.cc
-
riscv/triggers.cc
-
riscv/triggers.h
|
|
|
@ -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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -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 |
|
|
|
|
|
|
|
@ -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; |
|
|
|
|