5#include "llvm/Support/raw_ostream.h"
9#include <unordered_map>
11#include <unordered_set>
35 etype(hModinitblock), \
36 etype(hPortbindings), \
37 etype(hPortbinding), \
43 etype(hPortsigvarlist), \
54 etype(hTypeTemplateParam), \
62 etype(hFieldaccess), \
64 etype(hVarInitList), \
78 etype(hSwitchDefault), \
86 etype(hThreadFunction), \
87 etype(hBuiltinFunction), \
88 etype(hFunctionRetType), \
89 etype(hFunctionParams), \
90 etype(hFunctionParamI), \
91 etype(hFunctionParamIO), \
92 etype(hFunctionParamRef), \
139 vector<hNodep>::iterator it;
166 return hdlop_pn[
static_cast<int>(opc)];
181 for (
int i = 0; i < n; i++) {
188 void print(llvm::raw_ostream & modelout=llvm::outs(),
unsigned int indnt=2) {
189 modelout.indent(indnt);
192 modelout <<
" NONAME";
195 modelout <<
" NOLIST\n";
200 child->print(modelout, indnt+2);
202 modelout.indent(indnt+2);
203 modelout <<
"<null child>\n";
205 modelout.indent(indnt);
212 print(llvm::outs(), 2);
213 LLVM_DEBUG(
print(llvm::dbgs(), 2));
245 "concat",
"wait",
"range",
"bit",
"or_reduce",
"xor_reduce",
"nor_reduce",
"xnor_reduce",
"and_reduce",
"nand_reduce"};
248 for (
int i=0; i <
numstr; i++)
259 std::replace(nm.begin(), nm.end(),
' ',
'_');
260 std::replace(nm.begin(), nm.end(),
':',
'_');
261 nm.erase(std::remove_if(nm.begin(), nm.end(),
262 [](
char c){ return c!=
'_' && !isalnum(c) ;}), nm.end());
268 std::vector<llvm::StringRef> sc_dt{
"sc_dt",
"sc_core"};
393 if ((typ != NULL) && (
types_seen.count(typ) > 0)) {
398 std::vector<llvm::StringRef> scdt{
"sc_dt"};
400 int found = tstring.find_last_of(
" ");
401 for (
int i=0; i <
numstr; i++) {
407 if ((typ != NULL) && (tmpisnamespace != ret)) {
408 LLVM_DEBUG(llvm::dbgs() <<
"isSCBuiltinType: '" << tstring <<
"' (" << tmpisnamespace <<
409 ", " << ret <<
")\n");
411 if (ret && (typ != NULL)) {
413 LLVM_DEBUG(llvm::dbgs() <<
"types_seen insert " << typ <<
"size = " <<
types_seen.size() <<
"\n");
424 size_t found = tstring.find(
"typename");
425 if (found == string::npos)
return false;
426 else if (found == (
size_t) 0)
return true;
431 string sc_macro_strings [] = {
"sc_min",
"sc_max",
"sc_abs"};
432 for (
string str : sc_macro_strings) {
433 if (str_in.find(str) != string::npos)
return true;
438 inline bool isSCType(
const string &tstring,
const clang::Type *typ = NULL) {
443 string strings[] = {
"sc_in",
"sc_rvd",
"sc_out",
"sc_inout",
"sc_buffer",
444 "sc_signal",
"sc_subref",
"sc_process_handle",
"sc_simcontext",
"sc_dt"};
446 if ((typ != NULL) && (
types_seen.count(typ) > 0)) {
450 bool foundsctype =
false;
452 for (
string onestring : strings) {
453 if (tstring.find(onestring)!=string::npos) {
457 LLVM_DEBUG(llvm::dbgs() <<
"types_seen insert " << typ <<
" size = " <<
types_seen.size() <<
"\n");
461 else foundsctype =
false;
464 std::vector<llvm::StringRef> scdt{
"sc_dt"};
466 if (tmpsctype != foundsctype)
467 LLVM_DEBUG(llvm::dbgs() <<
"isSCType: '" << tstring <<
"' (" << tmpsctype <<
", " << foundsctype <<
")\n");
473 static inline bool isposint(
const std::string &str) {
476 return !str.empty() && str.find_first_not_of(
"0123456789") == string::npos;
495 const static std::string gvar_prefix{
"_scclang_global_"};
496 const static std::string lvar_prefix{
"_local_"};
497 const static std::string tvar_prefix{
"_thread_"};
547 names_t names = {old_name, newn, hnp,
false};
569 mapentry.second.referenced =
false;
581 void print(llvm::raw_ostream & modelout=llvm::outs(),
unsigned int indnt=2) {
583 modelout << entry.first <<
" " <<entry.second.newn <<
"\n";
617 void print(llvm::raw_ostream & modelout=llvm::outs(),
unsigned int indnt=2) {
619 modelout <<
"Methodobjtypemap follows\n";
621 modelout << entry.first <<
" " <<entry.second <<
"\n";
623 modelout <<
"Methodobjtypemap end\n";
string printopc(hdlopsEnum opc)
void set(hdlopsEnum h, string s="")
std::vector< hNodep > child_list
const string hdlop_pn[hLast+1]
hNode(string s, hdlopsEnum h)
hdlopsEnum str2hdlopenum(string st)
void print(llvm::raw_ostream &modelout=llvm::outs(), unsigned int indnt=2)
void print(llvm::raw_ostream &modelout=llvm::outs(), unsigned int indnt=2)
method_object_map_t methodobjtypemap
void insertall(hfunc_name_map_t newmap)
void set_prefix(string prfx)
name_serve(string prefx=lvar_prefix)
void add_entry(T declp, string old_name, hNodep hnp)
bool is_referenced(T declp)
void set_prefix(string prefix)
std::map< T, names_t >::iterator end()
newname_map_t(string prefix=lvar_prefix)
string find_entry_newn(T declp, bool set_ref=false)
std::map< T, names_t > hdecl_name_map
std::map< T, names_t >::iterator begin()
void print(llvm::raw_ostream &modelout=llvm::outs(), unsigned int indnt=2)
void insertall(newname_map_t< T > newmap)
std::unordered_set< const Type * > types_seen
bool isSCFunc(const string &tstring)
bool checkNamespace(const FunctionDecl *fd)
const string scbuiltintype[numstr]
bool isSCMacro(const std::string &str_in)
bool isTypename(const string &tstring)
bool isSCBuiltinType(const string &tstring, const Type *typ=NULL)
bool isSCType(const string &tstring, const clang::Type *typ=NULL)
static bool isposint(const std::string &str)
const set< std::string > sc_built_in_funcs
static void make_ident(string &nm)
newname_map_t< NamedDecl * > hdecl_name_map_t
std::unordered_map< string, hNodep > resetvar_map_t
newname_map_t< FunctionDecl * > hsimplefunc_name_map_t
std::unordered_map< const CXXMethodDecl *, const Type * > method_object_map_t
newname_map_t< ModuleInstance * > hmodinst_name_map_t
std::unordered_map< const CXXMethodDecl *, const CXXMethodDecl * > overridden_method_map_t
bool is_sigvar(hNodep hnp)
bool isInNamespace(const clang::ValueDecl *fd, const std::vector< llvm::StringRef > &names)
std::string to_string(T *pointer)