Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
caesr-pub
systemc-clang
Commits
054dc72e
Commit
054dc72e
authored
Dec 22, 2018
by
rmrf
Browse files
Cleanup code.
parent
9a814f4b
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/FindSCMain.cpp
View file @
054dc72e
...
...
@@ -2,39 +2,39 @@
using
namespace
scpar
;
FindSCMain
::
FindSCMain
(
TranslationUnitDecl
*
tuDecl
,
llvm
::
raw_ostream
&
os
)
:
os_
{
os
},
sc_main_function_declaration_
{
nullptr
}
{
assert
(
!
(
tuDecl
==
nullptr
));
TraverseDecl
(
tuDecl
);
}
FindSCMain
::
FindSCMain
(
TranslationUnitDecl
*
tuDecl
,
llvm
::
raw_ostream
&
os
)
:
os_
{
os
},
sc_main_function_declaration_
{
nullptr
}
{
assert
(
!
(
tuDecl
==
nullptr
));
TraverseDecl
(
tuDecl
);
}
FindSCMain
::~
FindSCMain
()
{
sc_main_function_declaration_
=
nullptr
;
sc_main_function_declaration_
=
nullptr
;
}
bool
FindSCMain
::
VisitFunctionDecl
(
FunctionDecl
*
function_declaration
)
{
/// Find sc_main.
/// There are three conditions to satisfy this:
/// 1. Must have sc_main in its name.
/// 2. Must have a body
/// 3. Must *not* be a first declaration. (This is becuase systemc.h includes a null definition of sc_main.
if
((
function_declaration
->
getNameInfo
().
getAsString
()
!=
"sc_main"
)
||
(
!
function_declaration
->
hasBody
())
||
(
function_declaration
->
isMain
()))
{
return
true
;
}
sc_main_function_declaration_
=
function_declaration
;
return
true
;
/// Find sc_main.
/// There are three conditions to satisfy this:
/// 1. Must have sc_main in its name.
/// 2. Must have a body
/// 3. Must *not* be a first declaration. (This is becuase systemc.h includes a null definition of sc_main.
if
((
function_declaration
->
getNameInfo
().
getAsString
()
!=
"sc_main"
)
||
(
!
function_declaration
->
hasBody
())
||
(
function_declaration
->
isMain
()))
{
return
true
;
}
sc_main_function_declaration_
=
function_declaration
;
return
true
;
}
FunctionDecl
*
FindSCMain
::
getSCMainFunctionDecl
()
const
{
assert
(
sc_main_function_declaration_
!=
nullptr
);
assert
(
sc_main_function_declaration_
!=
nullptr
);
return
sc_main_function_declaration_
;
return
sc_main_function_declaration_
;
}
bool
FindSCMain
::
isSCMainFound
()
const
{
return
(
sc_main_function_declaration_
!=
nullptr
);
return
(
sc_main_function_declaration_
!=
nullptr
);
}
src/FindSimTime.cpp
View file @
054dc72e
#include
"FindSimTime.h"
using
namespace
scpar
;
FindSimTime
::
FindSimTime
(
FunctionDecl
*
tuDecl
,
llvm
::
raw_ostream
&
os
)
:
_
os
(
os
)
,
_sigInst
(
NULL
),
_callexpr
(
NULL
)
{
assert
(
!
(
tuDecl
==
NULL
));
FindSimTime
::
FindSimTime
(
FunctionDecl
*
tuDecl
,
llvm
::
raw_ostream
&
os
)
:
os
_
(
os
)
{
// _sigInst{nullptr},
// call_expr_{nullptr} {
TraverseDecl
(
tuDecl
);
assert
(
!
(
tuDecl
==
nullptr
));
TraverseDecl
(
tuDecl
);
}
FindSimTime
::~
FindSimTime
()
{
_simTime
.
clear
();
FindSimTime
::~
FindSimTime
()
{
simulation_time_
.
clear
();
}
bool
FindSimTime
::
VisitCallExpr
(
CallExpr
*
c
)
{
if
(
c
->
getDirectCallee
()
->
getNameInfo
().
getAsString
()
!=
"sc_start"
)
{
bool
FindSimTime
::
VisitCallExpr
(
CallExpr
*
c
)
{
if
(
c
->
getDirectCallee
()
->
getNameInfo
().
getAsString
()
!=
"sc_start"
)
{
return
true
;
}
// _os << "Found sc_start";
if
(
c
->
getNumArgs
()
>
0
)
{
// _os <<"\n Simulation time is :" << getArgumentName(c->getArg(0));
if
(
c
->
getNumArgs
()
>
1
)
{
// _os << " " << getArgumentName(c->getArg(1));
_simTime
.
insert
(
simulationTimePairType
// os_ << "Found sc_start";
if
(
c
->
getNumArgs
()
>
0
)
{
// os_ <<"\n Simulation time is :" << getArgumentName(c->getArg(0));
if
(
c
->
getNumArgs
()
>
1
)
{
// os_ << " " << getArgumentName(c->getArg(1));
simulation_time_
.
insert
(
simulationTimePairType
(
getArgumentName
(
c
->
getArg
(
0
)),
getArgumentName
(
c
->
getArg
(
1
))));
}
...
...
@@ -38,27 +34,25 @@ bool FindSimTime::VisitCallExpr (CallExpr * c)
}
/*
string FindSimTime::getArgumentName (Expr * arg)
{
string FindSimTime::getArgumentName (Expr * arg)
{
if (arg == NULL)
return string ("NULL");
return string ("NULL");
clang::LangOptions LangOpts;
LangOpts.CPlusPlus = true;
clang::PrintingPolicy Policy (LangOpts);
string
TypeS;
TypeS;
llvm::raw_string_ostream s (TypeS);
arg->printPretty (s, 0, Policy);
//
_
os << ", argument: " << s.str() << "\n";
// os
_
<< ", argument: " << s.str() << "\n";
return s.str ();
}
}
*/
FindSimTime
::
simulationTimeMapType
FindSimTime
::
returnSimTime
()
{
return
_simTime
;
FindSimTime
::
simulationTimeMapType
FindSimTime
::
returnSimTime
()
{
return
simulation_time_
;
}
src/FindSimTime.h
View file @
054dc72e
...
...
@@ -12,23 +12,25 @@ namespace scpar {
using
namespace
clang
;
using
namespace
std
;
class
FindSimTime
:
public
RecursiveASTVisitor
<
FindSimTime
>
,
public
Utility
{
class
FindSimTime
:
public
RecursiveASTVisitor
<
FindSimTime
>
,
public
Utility
{
public:
typedef
pair
<
string
,
string
>
simulationTimePairType
;
typedef
map
<
string
,
string
>
simulationTimeMapType
;
typedef
pair
<
string
,
string
>
simulationTimePairType
;
typedef
map
<
string
,
string
>
simulationTimeMapType
;
FindSimTime
(
FunctionDecl
*
,
llvm
::
raw_ostream
&
);
FindSimTime
(
FunctionDecl
*
,
llvm
::
raw_ostream
&
);
virtual
~
FindSimTime
();
virtual
bool
VisitCallExpr
(
CallExpr
*
C
);
virtual
bool
VisitCallExpr
(
CallExpr
*
c
);
simulationTimeMapType
returnSimTime
();
simulationTimeMapType
returnSimTime
();
private:
llvm
::
raw_ostream
&
_
os
;
FunctionDecl
*
_sigInst
;
simulationTimeMapType
_
sim
T
ime
;
CallExpr
*
_
callexpr
;
llvm
::
raw_ostream
&
os
_
;
//
FunctionDecl *_sigInst;
simulationTimeMapType
sim
ulation_t
ime
_
;
//
CallExpr *call
_
expr
_
;
};
}
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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