Skip to content

Commit b795b2e

Browse files
committed
Fixups for Insn.hxx generation and hard defintions
Signed-off-by: Luke Quinn <[email protected]>
1 parent 43cce55 commit b795b2e

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

backends/cpp_hart_gen/cpp/include/udb/hart.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ namespace udb {
170170
virtual void set_xreg(unsigned num, uint64_t value) = 0;
171171

172172
virtual CsrBase* csr(unsigned address) = 0;
173-
174173
virtual const CsrBase* csr(unsigned address) const = 0;
175174

175+
virtual CsrBase* csr(const std::string &address) = 0;
176+
virtual const CsrBase* csr(const std::string &address) const = 0;
177+
176178
virtual void printState(FILE* out = stdout) const = 0;
177179

178180
virtual bool implemented_Q_(const ExtensionName& ext) = 0;

backends/cpp_hart_gen/templates/hart.hxx.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ namespace udb {
123123
// return it->second;
124124
}
125125

126+
const <%= name_of(:params, cfg_arch) %>& params() const {
127+
return m_params;
128+
}
129+
126130
private:
127131
XReg m_pc;
128132
XReg m_next_pc;

backends/cpp_hart_gen/templates/inst.hxx.erb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <udb/bits.hpp>
44
#include <type_traits>
55
#include <udb/util.hpp>
6+
#include <udb/inst.hpp>
67

78
<%- ilist = cfg_arch.fully_configured? ? cfg_arch.transitive_implemented_instructions : cfg_arch.instructions -%>
89

@@ -70,6 +71,13 @@ namespace udb {
7071
#define __UDB_FUNC_CALL m_parent->
7172
#define __UDB_CSR_BY_ADDR(addr) m_parent->csr(addr)
7273
#define __UDB_CSR_BY_NAME(csr_name) m_parent->m_csrs.csr_name
74+
#define __UDB_ENCODING this->encoding()
75+
#define __UDB_RUNTIME_PARAM(field) m_parent->params().field
76+
#define __UDB_STRUCT(type) struct <%= cfg_arch.name %>type_Struct
77+
#define __UDB_SET_PC(new_pc) m_parent->set_next_pc(new_pc)
78+
#define __UDB_PC m_parent->pc()
79+
#define __UDB_MUTABLE_GLOBAL(x) m_parent->x
80+
#define __UDB_CONSTEXPR_FUNC_CALL
7381

7482

7583
void execute() override {
@@ -102,6 +110,13 @@ namespace udb {
102110
#undef __UDB__FUNC__CALL
103111
#undef __UDB_CSR_BY_ADDR
104112
#undef __UDB_CSR_BY_NAME
113+
#undef __UDB_ENCODING
114+
#undef __UDB_RUNTIME_PARAM
115+
#undef __UDB_STRUCT
116+
#undef __UDB_PC
117+
#undef __UDB_CONSTEXPR_FUNC_CALL
118+
#undef __UDB_SET_PC
119+
105120

106121
private:
107122
<%= name_of(:hart, cfg_arch) %> * const m_parent;

0 commit comments

Comments
 (0)