Skip to content

Commit 05f6a26

Browse files
committed
CPP hart function prototypes
Signed-off-by: Luke Quinn <[email protected]>
1 parent 3113191 commit 05f6a26

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

backends/cpp_hart_gen/tasks.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ namespace :gen do
245245
Rake::Task["#{CPP_HART_GEN_DST}/#{build_name}/include/udb/cfgs/#{config}/csr_container.hxx"].invoke
246246
Rake::Task["#{CPP_HART_GEN_DST}/#{build_name}/include/udb/cfgs/#{config}/structs.hxx"].invoke
247247
Rake::Task["#{CPP_HART_GEN_DST}/#{build_name}/include/udb/cfgs/#{config}/func_prototypes.hxx"].invoke
248+
Rake::Task["#{CPP_HART_GEN_DST}/#{build_name}/src/cfgs/#{config}/func_prototypes.cxx"].invoke
248249
Rake::Task["#{CPP_HART_GEN_DST}/#{build_name}/include/udb/cfgs/#{config}/builtin_funcs.hxx"].invoke
249250

250251
Dir.glob("#{CPP_HART_GEN_SRC}/cpp/include/udb/*.hpp") do |f|
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
// THIS FILE IS AUTOGENERATED
3+
// IT IS NOT STANDALONE. IT IS A FUNCTION LIST FOR THE Hart CLASS
4+
5+
6+
#define __UDB_CONSTEXPR_FUNC_CALL
7+
#define __UDB_CONST_GLOBAL(global_name) <%= name_of(:hart, cfg_arch) %>::global_name
8+
#define __UDB_MUTABLE_GLOBAL(global_name) global_name
9+
#define __UDB_STRUCT(struct_name) <%= cfg_arch.name.camelize %>_ ## struct_name ## _Struct
10+
11+
<%# need to get symtab at function scope -%>
12+
<%- symtab = cfg_arch.symtab.global_clone.push(nil) -%>
13+
<%- cfg_arch.functions.each do |func| -%>
14+
<%- next if func.builtin? || func.generated? -%>
15+
//
16+
// <%= func.description.gsub("\n", "\n// ") %>
17+
<%= func.gen_cpp_prototype(symtab, 0, include_semi: false) %> {
18+
<%- unless func.gen_return_type(symtab) == "void" -%>
19+
static_assert(std::is_default_constructible_v<<%= func.gen_return_type(symtab) %>>, "Return type is not default constructible");
20+
<%= func.gen_return_type(symtab) %> ret;
21+
return ret;
22+
<%- end -%>
23+
}
24+
<%- end -%>
25+
26+
#undef __UDB_CONSTEXPR_FUNC_CALL
27+
#undef __UDB_CONST_GLOBAL
28+
#undef __UDB_MUTABLE_GLOBAL
29+
#undef __UDB_STRUCT
30+
31+
<%- symtab.release -%>

0 commit comments

Comments
 (0)