Skip to content

Commit 43cce55

Browse files
author
Derek Hower
committed
Merge remote-tracking branch 'origin/cpp_hart' into cpp_hart
2 parents a98ef57 + 1cf5061 commit 43cce55

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

backends/cpp_hart_gen/lib/gen_cpp.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ class AryElementAccessAst
428428
def gen_cpp(symtab, indent = 0, indent_spaces: 2)
429429
if var.text_value.start_with?("X")
430430
#"#{' '*indent}#{var.gen_cpp(symtab, 0, indent_spaces:)}[#{index.gen_cpp(symtab, 0, indent_spaces:)}]"
431-
"#{' '*indent} __UDB__FUNC__OBJ xregRef(#{index.gen_cpp(symtab, 0, indent_spaces:)})"
431+
"#{' '*indent} __UDB_FUNC_CALL xregRef(#{index.gen_cpp(symtab, 0, indent_spaces:)})"
432432
else
433433
if var.type(symtab).integral?
434434
"#{' '*indent}extract<#{index.gen_cpp(symtab, 0)}, 1, #{var.type(symtab).width}>(#{var.gen_cpp(symtab, 0, indent_spaces:)})"
@@ -461,7 +461,7 @@ class AryElementAssignmentAst
461461
def gen_cpp(symtab, indent = 0, indent_spaces: 2)
462462
if lhs.text_value.start_with?("X")
463463
#"#{' '*indent} #{lhs.gen_cpp(symtab, 0, indent_spaces:)}[#{idx.gen_cpp(symtab, 0, indent_spaces:)}] = #{rhs.gen_cpp(symtab, 0, indent_spaces:)}"
464-
"#{' '*indent} __UDB__FUNC__OBJ xregRef ( #{idx.gen_cpp(symtab, 0, indent_spaces:)} ) = #{rhs.gen_cpp(symtab, 0, indent_spaces:)}"
464+
"#{' '*indent} __UDB_FUNC_CALL xregRef ( #{idx.gen_cpp(symtab, 0, indent_spaces:)} ) = #{rhs.gen_cpp(symtab, 0, indent_spaces:)}"
465465
else
466466
"#{' '*indent}#{lhs.gen_cpp(symtab, 0, indent_spaces:)}[#{idx.gen_cpp(symtab, 0, indent_spaces:)}] = #{rhs.gen_cpp(symtab, 0, indent_spaces:)}"
467467
end

backends/cpp_hart_gen/templates/hart.hxx.erb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,24 @@ namespace udb {
105105
// return it->second;
106106
}
107107

108+
CsrBase* csr(const std::string& address) override {
109+
return nullptr;
110+
// auto it = m_csr_map.find(address);
111+
// if (it == m_csr_map.end()) {
112+
// return nullptr;
113+
// }
114+
// return it->second;
115+
}
116+
117+
const CsrBase* csr(const std::string& address) const override {
118+
return nullptr;
119+
// auto it = m_csr_map.find(address);
120+
// if (it == m_csr_map.end()) {
121+
// return nullptr;
122+
// }
123+
// return it->second;
124+
}
125+
108126
private:
109127
XReg m_pc;
110128
XReg m_next_pc;

backends/cpp_hart_gen/templates/inst.hxx.erb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ namespace udb {
6767
<%- end -%>
6868
<%- end -%>
6969

70-
#define __UDB__FUNC__OBJ m_parent->
70+
#define __UDB_FUNC_CALL m_parent->
71+
#define __UDB_CSR_BY_ADDR(addr) m_parent->csr(addr)
72+
#define __UDB_CSR_BY_NAME(csr_name) m_parent->m_csrs.csr_name
7173

7274

7375
void execute() override {
@@ -97,7 +99,9 @@ namespace udb {
9799
<%- end -%>
98100
}
99101

100-
#undef __UDB__FUNC__OBJ
102+
#undef __UDB__FUNC__CALL
103+
#undef __UDB_CSR_BY_ADDR
104+
#undef __UDB_CSR_BY_NAME
101105

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

0 commit comments

Comments
 (0)