Skip to content

Commit

Permalink
Add some convenience to PreparedCall
Browse files Browse the repository at this point in the history
  • Loading branch information
fwsGonzo committed Jun 19, 2024
1 parent c9bbe33 commit 3cf3240
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/libriscv/prepared_call.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ namespace riscv
return m.cpu.reg(REG_RETVAL);
}

template <typename... Args>
Ret operator()(Args&&... args) const
{
return this->vmcall(std::forward<Args>(args)...);
}

bool prepared(Machine<W>& m) const noexcept {
return m_machine == &m;
}
Expand Down Expand Up @@ -277,6 +283,21 @@ namespace riscv
this->prepare(m, m.address_of(func), imax);
}

PreparedCall() = default;
~PreparedCall() = default;

PreparedCall(Machine<W>& m, address_t call_addr, uint64_t max = UINT64_MAX)
{
this->prepare(m, call_addr, max);
}
PreparedCall(const PreparedCall& other)
: m_machine(other.m_machine), m_max(other.m_max), m_pc(other.m_pc)
{
#if defined(RISCV_BINARY_TRANSLATION)
this->m_mapping = other.m_mapping;
#endif
}

private:
Machine<W>* m_machine = nullptr;
uint64_t m_max = 0;
Expand Down

0 comments on commit 3cf3240

Please sign in to comment.