aboutsummaryrefslogtreecommitdiff
path: root/riscv
diff options
context:
space:
mode:
authorScott Johnson <scott.johnson@arilinc.com>2022-12-01 09:31:21 -0800
committerScott Johnson <scott.johnson@arilinc.com>2022-12-01 09:31:35 -0800
commit849ec1e129e2654cb60dcbc1dfb6ab5b9cc6902b (patch)
tree88ed8d850ad6a897647ddaafd1d7856c9e18703b /riscv
parenta315193ab08abc3aaaa1885370253992c110b6ec (diff)
downloadspike-849ec1e129e2654cb60dcbc1dfb6ab5b9cc6902b.zip
spike-849ec1e129e2654cb60dcbc1dfb6ab5b9cc6902b.tar.gz
spike-849ec1e129e2654cb60dcbc1dfb6ab5b9cc6902b.tar.bz2
Use std::optional for detect_memory_access_match in trigger_t hierarchy
Goal is to remove match_result_t.fire field to eliminate dont-care fields.
Diffstat (limited to 'riscv')
-rw-r--r--riscv/triggers.cc14
-rw-r--r--riscv/triggers.h6
2 files changed, 10 insertions, 10 deletions
diff --git a/riscv/triggers.cc b/riscv/triggers.cc
index 12a06d7..9522aba 100644
--- a/riscv/triggers.cc
+++ b/riscv/triggers.cc
@@ -115,7 +115,7 @@ bool mcontrol_t::simple_match(unsigned xlen, reg_t value) const {
assert(0);
}
-match_result_t mcontrol_t::detect_memory_access_match(processor_t * const proc, operation_t operation, reg_t address, std::optional<reg_t> data) noexcept {
+std::optional<match_result_t> mcontrol_t::detect_memory_access_match(processor_t * const proc, operation_t operation, reg_t address, std::optional<reg_t> data) noexcept {
state_t * const state = proc->get_state();
if ((operation == triggers::OPERATION_EXECUTE && !execute) ||
(operation == triggers::OPERATION_STORE && !store) ||
@@ -124,13 +124,13 @@ match_result_t mcontrol_t::detect_memory_access_match(processor_t * const proc,
(state->prv == PRV_S && !s) ||
(state->prv == PRV_U && !u) ||
(state->v)) {
- return match_result_t(false);
+ return std::nullopt;
}
reg_t value;
if (select) {
if (!data.has_value())
- return match_result_t(false);
+ return std::nullopt;
value = *data;
} else {
value = address;
@@ -149,7 +149,7 @@ match_result_t mcontrol_t::detect_memory_access_match(processor_t * const proc,
hit = true;
return match_result_t(true, timing_t(timing), action);
}
- return match_result_t(false);
+ return std::nullopt;
}
reg_t itrigger_t::tdata1_read(const processor_t * const proc) const noexcept
@@ -351,11 +351,11 @@ std::optional<match_result_t> module_t::detect_memory_access_match(operation_t o
* entire chain did not match. This is allowed by the spec, because the final
* trigger in the chain will never get `hit` set unless the entire chain
* matches. */
- match_result_t result = trigger->detect_memory_access_match(proc, operation, address, data);
- if (result.fire && !trigger->get_chain())
+ auto result = trigger->detect_memory_access_match(proc, operation, address, data);
+ if (result.has_value() && !trigger->get_chain())
return result;
- chain_ok = result.fire || !trigger->get_chain();
+ chain_ok = result.has_value() || !trigger->get_chain();
}
return std::nullopt;
}
diff --git a/riscv/triggers.h b/riscv/triggers.h
index 27f1c0e..365dbe2 100644
--- a/riscv/triggers.h
+++ b/riscv/triggers.h
@@ -67,8 +67,8 @@ public:
virtual bool get_load() const { return false; }
virtual action_t get_action() const { return ACTION_DEBUG_EXCEPTION; }
- virtual match_result_t detect_memory_access_match(processor_t UNUSED * const proc,
- operation_t UNUSED operation, reg_t UNUSED address, std::optional<reg_t> UNUSED data) noexcept { return match_result_t(false); }
+ virtual std::optional<match_result_t> detect_memory_access_match(processor_t UNUSED * const proc,
+ operation_t UNUSED operation, reg_t UNUSED address, std::optional<reg_t> UNUSED data) noexcept { return std::nullopt; }
virtual match_result_t detect_trap_match(processor_t UNUSED * const proc, const trap_t UNUSED & t) noexcept { return match_result_t(false); }
protected:
@@ -152,7 +152,7 @@ public:
virtual bool get_load() const override { return load; }
virtual action_t get_action() const override { return action; }
- virtual match_result_t detect_memory_access_match(processor_t * const proc,
+ virtual std::optional<match_result_t> detect_memory_access_match(processor_t * const proc,
operation_t operation, reg_t address, std::optional<reg_t> data) noexcept override;
private: