Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
caesr-pub
systemc-clang
Commits
505643f7
Commit
505643f7
authored
Jun 04, 2019
by
rmrf
Browse files
Stage 2: The json dump has the feature to print the template parameters
now.
parent
bcd25d3b
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
56 additions
and
30 deletions
+56
-30
src/CMakeLists.txt
src/CMakeLists.txt
+3
-2
src/FindModule.cpp
src/FindModule.cpp
+23
-23
src/FindModule.h
src/FindModule.h
+2
-2
src/FindSCModules.cpp
src/FindSCModules.cpp
+1
-1
src/FindSCModules.h
src/FindSCModules.h
+0
-1
src/ModuleDecl.cpp
src/ModuleDecl.cpp
+12
-0
src/ModuleDecl.h
src/ModuleDecl.h
+2
-0
src/SystemCClang.cpp
src/SystemCClang.cpp
+11
-1
src/SystemCClang.h
src/SystemCClang.h
+2
-0
No files found.
src/CMakeLists.txt
View file @
505643f7
...
...
@@ -18,6 +18,7 @@ add_library (libsystemc-clang
SystemCClang.cpp
FindNetlist.cpp
FindArgument.cpp
FindTemplateParameters.cpp
Automata.cpp
SuspensionAutomata.cpp
SCuitable/GlobalSuspensionAutomata.cpp
...
...
@@ -36,7 +37,7 @@ add_library (libsystemc-clang
InterfaceDecl.cpp
Model.cpp
WaitCalls.cpp
NotifyCalls.cpp
NotifyCalls.cpp
EventContainer.cpp
)
src/FindModule.cpp
View file @
505643f7
...
...
@@ -9,13 +9,12 @@ using namespace scpar;
string
FindModule
::
getModuleName
()
const
{
return
module_name_
;
}
FindModule
::
FindModule
(
CXXRecordDecl
*
declaration
,
llvm
::
raw_ostream
&
os
)
:
declaration_
{
declaration
},
os_
{
os
},
is_systemc_module_
{
false
}
,
template_parameters_
{
nullptr
}
{
:
declaration_
{
declaration
},
os_
{
os
},
is_systemc_module_
{
false
}
{
if
(
declaration
->
hasDefinition
()
==
true
)
{
TraverseDecl
(
declaration
);
}
}
bool
FindModule
::
VisitCXXRecordDecl
(
CXXRecordDecl
*
declaration
)
{
if
(
declaration_
->
getNumBases
()
<=
0
)
{
return
true
;
...
...
@@ -36,15 +35,16 @@ bool FindModule::VisitCXXRecordDecl(CXXRecordDecl *declaration) {
if
(
IdentifierInfo
*
info
=
declaration_
->
getIdentifier
())
{
module_name_
=
info
->
getNameStart
();
// Check if the class is a templated module class.
auto
template_args
{
declaration
->
getDescribedClassTemplate
()
};
if
(
template_args
!=
nullptr
)
{
os_
<<
module_name_
<<
": TEMPLATE ARGS YES
\n
"
;
template_parameters_
=
template_args
->
getTemplateParameters
();
//parms->getParam(0)->dump();
// parms->getParam(1)->dump();
// // Check if the class is a templated module class.
// auto template_args{ declaration->getDescribedClassTemplate() };
// if (template_args != nullptr) {
// os_ << module_name_ << ": TEMPLATE ARGS YES \n";
// template_parameters_ = template_args->getTemplateParameters();
// //parms->getParam(0)->dump();
// // parms->getParam(1)->dump();
// }
}
}
}
}
...
...
@@ -56,19 +56,19 @@ bool FindModule::VisitCXXRecordDecl(CXXRecordDecl *declaration) {
return
false
;
}
vector
<
string
>
FindModule
::
getTemplateParameters
()
const
{
vector
<
string
>
parm_list
;
if
(
(
template_parameters_
==
nullptr
)
||
(
template_parameters_
->
size
()
<=
0
)
)
{
return
parm_list
;
}
for
(
auto
parm
:
template_parameters_
->
asArray
()
)
{
parm_list
.
push_back
(
parm
->
getName
()
);
os_
<<
"Parm: "
<<
parm
->
getName
()
<<
"
\n
"
;
}
return
parm_list
;
}
//
vector<string> FindModule::getTemplateParameters() const {
//
vector<string> parm_list;
//
if ( (template_parameters_ == nullptr)
//
|| (template_parameters_->size() <= 0) ) {
//
return parm_list;
//
}
//
for (auto parm : template_parameters_->asArray() ) {
//
parm_list.push_back( parm->getName() );
//
os_ << "Parm: " << parm->getName() << "\n";
//
}
//
return parm_list;
//
}
FindModule
::~
FindModule
()
{
declaration_
=
nullptr
;
}
...
...
src/FindModule.h
View file @
505643f7
...
...
@@ -20,14 +20,14 @@ public:
void
dump
();
string
getModuleName
()
const
;
bool
isSystemCModule
()
const
;
vector
<
string
>
getTemplateParameters
()
const
;
//
vector<string> getTemplateParameters() const;
private:
CXXRecordDecl
*
declaration_
;
llvm
::
raw_ostream
&
os_
;
bool
is_systemc_module_
;
string
module_name_
;
TemplateParameterList
*
template_parameters_
;
//
TemplateParameterList *template_parameters_;
};
}
// namespace scpar
#endif
src/FindSCModules.cpp
View file @
505643f7
...
...
@@ -19,7 +19,7 @@ bool FindSCModules::VisitCXXRecordDecl(CXXRecordDecl *cxxDecl) {
}
string
modName
=
mod
.
getModuleName
();
_moduleMap
.
insert
(
modulePairType
(
modName
,
cxxDecl
));
template_parameters_
=
mod
.
getTemplateParameters
();
return
true
;
}
...
...
src/FindSCModules.h
View file @
505643f7
...
...
@@ -25,7 +25,6 @@ public:
private:
llvm
::
raw_ostream
&
_os
;
moduleMapType
_moduleMap
;
vector
<
string
>
template_parameters_
;
};
}
// namespace scpar
#endif
src/ModuleDecl.cpp
View file @
505643f7
...
...
@@ -37,6 +37,13 @@ ModuleDecl::~ModuleDecl() {
_ioports
.
clear
();
}
void
ModuleDecl
::
setTemplateParameters
(
const
vector
<
string
>
&
parm_list
)
{
template_parameters_
=
parm_list
;
}
vector
<
string
>
ModuleDecl
::
getTemplateParameters
()
const
{
return
template_parameters_
;
}
void
ModuleDecl
::
setModuleName
(
const
string
&
name
)
{
module_name_
=
name
;
}
void
ModuleDecl
::
addInstances
(
const
vector
<
string
>
&
instanceList
)
{
...
...
@@ -330,6 +337,11 @@ json ModuleDecl::dump_json() {
json
module_j
;
module_j
[
"module_name"
]
=
module_name_
;
// Template parameters.
std
::
cout
<<
"
\n
TEMPPARM: "
<<
template_parameters_
.
size
()
<<
std
::
endl
;
for
(
const
auto
&
parm
:
template_parameters_
)
{
module_j
[
"template_parameters"
].
push_back
(
parm
);
}
std
::
cout
<<
module_j
.
dump
(
4
);
...
...
src/ModuleDecl.h
View file @
505643f7
...
...
@@ -64,6 +64,8 @@ public:
void
addInstances
(
const
vector
<
string
>
&
);
void
addSignalBinding
(
map
<
string
,
string
>
);
void
setModuleName
(
const
string
&
);
void
setTemplateParameters
(
const
vector
<
string
>
&
);
vector
<
string
>
getTemplateParameters
()
const
;
void
addConstructor
(
Stmt
*
);
string
getName
();
CXXRecordDecl
*
getModuleClassDecl
();
...
...
src/SystemCClang.cpp
View file @
505643f7
...
...
@@ -24,12 +24,13 @@ bool SystemCConsumer::fire() {
// Find the sc_modules
FindSCModules
scmod
{
tu
,
_os
};
FindSCModules
::
moduleMapType
scmodules
{
scmod
.
getSystemCModulesMap
()};
for
(
FindSCModules
::
moduleMapType
::
iterator
mit
=
scmodules
.
begin
(),
mitend
=
scmodules
.
end
();
mit
!=
mitend
;
++
mit
)
{
ModuleDecl
*
md
=
new
ModuleDecl
{
mit
->
first
,
mit
->
second
};
//md->setTemplateParameters( scmod.getTemplateParameters() );
// _os << "SIZE: " << scmod.getTemplateParameters().size() << "\n";
_systemcModel
->
addModuleDecl
(
md
);
}
...
...
@@ -70,6 +71,15 @@ bool SystemCConsumer::fire() {
for
(
unsigned
int
num
{
0
};
num
<
numInstances
;
++
num
)
{
ModuleDecl
*
md
=
new
ModuleDecl
{};
// Find the template arguments for the class.
FindTemplateParameters
tparms
{
mainmd
->
getModuleClassDecl
(),
_os
};
md
->
setTemplateParameters
(
tparms
.
getTemplateParameters
()
);
_os
<<
"@@# "
<<
mainmd
->
getTemplateParameters
().
size
()
<<
"
\n
"
;
md
->
dump_json
();
vector
<
EntryFunctionContainer
*>
_entryFunctionContainerVector
;
FindConstructor
constructor
{
mainmd
->
getModuleClassDecl
(),
_os
};
md
->
addConstructor
(
constructor
.
returnConstructorStmt
());
...
...
src/SystemCClang.h
View file @
505643f7
...
...
@@ -50,6 +50,8 @@ using namespace clang::tooling;
#include "SCuitable/GlobalSuspensionAutomata.h"
#include "SuspensionAutomata.h"
#include "Utility.h"
#include "FindTemplateParameters.h" \
using
namespace
clang
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment