systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
ModuleInstance.h
Go to the documentation of this file.
1#ifndef _MODULE_INSTANCE_H_
2#define _MODULE_INSTANCE_H_
3
4/* clang-format off */
5#include <map>
6#include <string>
7
8/* clang-format on */
9
10#include "FindConstructor.h"
11#include "FindEntryFunctions.h"
12#include "FindTLMInterfaces.h"
13#include "InterfaceDecl.h"
14#include "PortBinding.h"
15#include "PortDecl.h"
16#include "ProcessDecl.h"
17#include "SignalDecl.h"
18
19#include "ModuleInstanceType.h"
20
21namespace clang {
22
23 class CXXRecordDecl;
24 class CXXConstructorDecl;
25 class Stmt;
26 class FieldDecl;
27 class Decl;
28};
29
30
31namespace systemc_clang {
32using namespace sc_ast_matchers;
33
35//
36
38 public:
39 typedef std::pair<std::string, SignalDecl *> signalPairType;
40 typedef std::map<std::string, SignalDecl *> signalMapType;
41
42 typedef std::pair<std::string, InterfaceDecl *> interfacePairType;
43 typedef std::map<std::string, InterfaceDecl *> interfaceMapType;
44
45 // Maps the name of the process with a pointer to a structure that holds
46 // information about the process.
47 typedef std::pair<std::string, ProcessDecl *> processPairType;
48 typedef std::map<std::string, ProcessDecl *> processMapType;
49
50 typedef std::pair<std::string, std::string> moduleProcessPairType;
51
52 typedef std::pair<std::string, std::string> portSignalPairType;
53 typedef std::map<std::string, std::string> portSignalMapType;
54
55 // Why is this a not a Type?
56 typedef std::vector<std::string> instanceName;
57
58 // string: name of bound port, PortBinding*: structure with more info.
59 typedef std::pair<std::string, PortBinding *> portBindingPairType;
60 typedef std::map<std::string, PortBinding *> portBindingMapType;
61
62 // PortType
63 typedef std::vector<std::tuple<std::string, PortDecl *> > PortType;
64 typedef std::vector<std::tuple<std::string, PortDecl *> > portMapType;
65
66 public:
69
71 ModuleInstance(const std::string &, const clang::CXXRecordDecl *);
73 const std::tuple<const std::string &, clang::CXXRecordDecl *> &);
74
75 // Copy constructor.
76 ModuleInstance(const ModuleInstance &from);
77
78 // Assignment operator.
80 virtual ~ModuleInstance();
81
82 void addPorts(const PortType &found_ports, const std::string &port_type);
83
85 void addConstructor(clang::Stmt *);
90 void addInstances(const std::vector<std::string> &);
91
92 void addPortBinding(const std::string &port_name, PortBinding *pb);
93 void addSignalBinding(std::map<std::string, std::string>);
95
96 void addNestedModule(ModuleInstance *submodule);
97
99 void setInstanceName(const std::string &);
100 void setInstanceDecl(Decl *);
101 void setModuleName(const std::string &);
102 void setTemplateParameters(const vector<std::string> &);
103 void setTemplateArgs(const vector<std::string> &);
104 const std::vector<std::string> &getTemplateParameters() const;
105
106 std::string getName() const;
107 std::string getInstanceName() const;
108
109 const clang::CXXRecordDecl *getModuleClassDecl();
110 clang::FieldDecl *getInstanceFieldDecl();
111 clang::VarDecl *getInstanceVarDecl();
112 const clang::Decl *getInstanceDecl();
114
116
118 const portMapType &getOPorts();
119 const portMapType &getIPorts();
120 const portMapType &getIOPorts();
121 const portMapType &getOtherVars();
125
126 const std::vector<ModuleInstance *> &getBaseInstances();
128
130
131 const clang::Stmt *getConstructorStmt() const;
132 const clang::CXXConstructorDecl *getConstructorDecl() const;
133
137 const std::vector<std::string> &getInstanceList();
138 const std::vector<EntryFunctionContainer *> &getEntryFunctionContainer();
139 int getNumInstances() const;
140 const signalMapType &getSignals() const;
141
142 const std::vector<ModuleInstance *> &getNestedModuleInstances() const;
143
144 void dumpPorts(llvm::raw_ostream &);
145 std::string dumpPortBinding();
146 void dumpInterfaces(llvm::raw_ostream &, int);
147 void dumpProcesses(llvm::raw_ostream &, int);
148 void dumpSignals(llvm::raw_ostream &, int);
149 void dump(llvm::raw_ostream &);
150 void dumpInstances(llvm::raw_ostream &, int);
151 void dumpSignalBinding(llvm::raw_ostream &, int);
152 void dump_base_instances(llvm::raw_ostream &os);
153
154 void clearOnlyGlobal();
155
156 std::string dump_json();
157
158 private:
159 std::string module_name_;
160 std::string instance_name_;
162
163 std::vector<ModuleInstance *> base_instances_;
164
165 // Declaration
166 clang::CXXRecordDecl *class_decl_;
167 // Constructor statement
168 clang::Stmt *constructor_stmt_;
169 clang::CXXConstructorDecl *constructor_decl_;
170 // Instance fieldDecl or varDecl
171 clang::Decl *instance_decl_;
172
178
181
183
188
189 std::vector<std::string> instance_list_;
191 std::vector<EntryFunctionContainer *> vef_;
192
194 std::vector<ModuleInstance *> nested_modules_;
195
197 std::vector<std::string> template_parameters_;
198 std::vector<std::string> template_args_;
199
200
201};
202} // namespace systemc_clang
203#endif
std::vector< EntryFunctionContainer * > entryFunctionVectorType
Typedefs.
std::map< string, FindTemplateTypes * > interfaceType
Forward declarations.
void addConstructor(FindConstructor *)
std::pair< std::string, InterfaceDecl * > interfacePairType
std::vector< std::string > template_parameters_
Class template parameters.
const portMapType & getOtherVars()
std::pair< std::string, std::string > portSignalPairType
void addInputInterfaces(FindTLMInterfaces::interfaceType)
void addNestedModule(ModuleInstance *submodule)
void addInstances(const std::vector< std::string > &)
std::pair< std::string, ProcessDecl * > processPairType
void setInstanceName(const std::string &)
const std::vector< std::string > & getTemplateParameters() const
void addConstructor(clang::Stmt *)
ModuleInstance & operator=(const ModuleInstance &from)
portSignalMapType port_signal_map_
const clang::CXXRecordDecl * getModuleClassDecl()
void dumpSignals(llvm::raw_ostream &, int)
void addBaseInstance(ModuleInstance *)
clang::FieldDecl * getInstanceFieldDecl()
std::vector< ModuleInstance * > base_instances_
void setTemplateArgs(const vector< std::string > &)
void dumpPorts(llvm::raw_ostream &)
std::vector< std::tuple< std::string, PortDecl * > > portMapType
const portMapType & getIOPorts()
const portMapType & getOPorts()
void addPortBinding(const std::string &port_name, PortBinding *pb)
std::map< std::string, PortBinding * > portBindingMapType
const clang::Stmt * getConstructorStmt() const
clang::CXXRecordDecl * class_decl_
void dumpInterfaces(llvm::raw_ostream &, int)
const std::vector< ModuleInstance * > & getNestedModuleInstances() const
void setTemplateParameters(const vector< std::string > &)
void addProcess(FindEntryFunctions::entryFunctionVectorType *)
const portMapType & getOutputStreamPorts()
void addInputOutputInterfaces(FindTLMInterfaces::interfaceType)
std::map< std::string, InterfaceDecl * > interfaceMapType
void addOutputInterfaces(FindTLMInterfaces::interfaceType)
std::vector< std::tuple< std::string, PortDecl * > > PortType
portBindingMapType port_bindings_
std::map< std::string, SignalDecl * > signalMapType
std::vector< ModuleInstance * > nested_modules_
Nested modules.
const portMapType & getInputStreamPorts()
const portBindingMapType & getPortBindings()
void dump(llvm::raw_ostream &)
std::map< std::string, std::string > portSignalMapType
const interfaceMapType & getOInterfaces()
void setModuleName(const std::string &)
const interfaceMapType & getIInterfaces()
ModuleInstanceType getInstanceInfo()
std::string getInstanceName() const
void dump_base_instances(llvm::raw_ostream &os)
const clang::Decl * getInstanceDecl()
void dumpSignalBinding(llvm::raw_ostream &, int)
const clang::CXXConstructorDecl * getConstructorDecl() const
std::pair< std::string, SignalDecl * > signalPairType
void dumpProcesses(llvm::raw_ostream &, int)
const std::vector< ModuleInstance * > & getBaseInstances()
std::pair< std::string, std::string > moduleProcessPairType
const std::vector< std::string > & getInstanceList()
std::map< std::string, ProcessDecl * > processMapType
std::vector< std::string > instance_list_
void setInstanceInfo(const sc_ast_matchers::ModuleInstanceType &info)
void addSignalBinding(std::map< std::string, std::string >)
std::vector< std::string > template_args_
clang::CXXConstructorDecl * constructor_decl_
clang::VarDecl * getInstanceVarDecl()
std::pair< std::string, PortBinding * > portBindingPairType
std::vector< EntryFunctionContainer * > vef_
std::vector< std::string > instanceName
ModuleInstance()
Default constructor.
const interfaceMapType & getIOInterfaces()
void dumpInstances(llvm::raw_ostream &, int)
const processMapType & getProcessMap()
ModuleInstanceType instance_info_
const portMapType & getSubmodules()
const std::vector< EntryFunctionContainer * > & getEntryFunctionContainer()
void addPorts(const PortType &found_ports, const std::string &port_type)
const portMapType & getIPorts()
const signalMapType & getSignals() const
Clang forward declarations.
Definition FindArgument.h:6