75 const auto TM =
AppM->get_tree_manager();
76 const auto FB =
AppM->CGetFunctionBehavior(function_id);
77 const auto BH = FB->CGetBehavioralHelper();
78 const auto fname = BH->GetMangledFunctionName();
82 const auto HLSMgr = GetPointer<const HLS_manager>(
AppM);
85 const auto func_arch = HLSMgr->module_arch->GetArchitecture(fname);
88 THROW_ASSERT(func_arch,
"Expected interface architecture for function " + fname);
89 const auto parm_original_typename = [&]() -> std::vector<std::string> {
90 std::vector<std::string> parm_ot(func_arch->parms.size(),
"");
91 for(
auto& [parm, attrs] : func_arch->parms)
93 const auto idx = std::strtoul(attrs.at(FunctionArchitecture::parm_index).c_str(),
nullptr, 10);
94 parm_ot[idx] = attrs.at(FunctionArchitecture::parm_original_typename);
98 const std::regex param_match(
"[^,(]+\\s(\\w+)\\s*([,)]\\s?)");
100 auto it = fdecl.cbegin();
101 std::string if_fdecl;
103 while(std::regex_search(it, fdecl.cend(),
match, param_match))
105 THROW_ASSERT(param_idx < parm_original_typename.size(),
"Too many parameters matched.");
106 it += match.position() + match.length();
107 if_fdecl += match.prefix();
108 if_fdecl += parm_original_typename.at(param_idx++) +
" ";
109 if_fdecl += match[1];
110 if_fdecl += match[2];
112 THROW_ASSERT(param_idx == parm_original_typename.size(),
"Expected to match all parameter declarations.");
121 boost::replace_all(fdecl,
" main(",
" _main(");
Data structure representing the entire HLS information.
Definition of the class representing a generic C application.
score match(base b1, base b2)
void declareFunction(const unsigned int function_id) override
Write the declaration of a function.
Class to print indented code.
Simple class to print single instruction.
~HLSInstructionWriter() override
Destructor.
Standard functor that returns the name of a variable.
void Append(const std::string &str)
Append a string to the output.
Classes specification of the tree_node data structures.
This file collects some utility functions and macros.
const application_managerConstRef AppM
The application manager.
This file collects some utility functions.
const IndentedOutputStreamRef indented_output_stream
The indented output stream.
Class specification of the tree_reindex support class.
static std::string PrintType(const tree_managerConstRef &TM, const tree_nodeConstRef &type, bool global=false, bool print_qualifiers=false, bool print_storage=false, const tree_nodeConstRef &var=nullptr, const var_pp_functorConstRef &vppf=var_pp_functorConstRef(), const std::string &prefix="", const std::string &tail="")
Print a type and its variable in case var is not zero.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
this class is used to manage the command-line or XML options.
This file contains the routines necessary to create a C executable program.
HLSInstructionWriter(const application_managerConstRef app_man, const IndentedOutputStreamRef indented_output_stream, const ParameterConstRef parameters)
Constructor.
refcount< const var_pp_functor > var_pp_functorConstRef
Class specification of the manager of the tree structures extracted from the raw file.
A brief description of the C++ Header File.
#define THROW_ASSERT(cond, str_expr)
helper function used to check an assert and if needed to throw an error in a standard way ...