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
d439b174
Commit
d439b174
authored
Dec 06, 2014
by
Anirudh
Browse files
Utility functions
parent
2e1e7b4e
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
94 additions
and
40 deletions
+94
-40
src/CMakeLists.txt
src/CMakeLists.txt
+1
-1
src/FindSimTime.cpp
src/FindSimTime.cpp
+2
-0
src/FindSimTime.h
src/FindSimTime.h
+7
-12
src/SCuitable/GlobalSuspensionAutomata.cpp
src/SCuitable/GlobalSuspensionAutomata.cpp
+13
-16
src/SCuitable/GlobalSuspensionAutomata.h
src/SCuitable/GlobalSuspensionAutomata.h
+3
-3
src/SuspensionAutomata.cpp
src/SuspensionAutomata.cpp
+2
-1
src/SuspensionAutomata.h
src/SuspensionAutomata.h
+2
-2
src/Utility.h
src/Utility.h
+64
-5
No files found.
src/CMakeLists.txt
View file @
d439b174
...
...
@@ -24,7 +24,7 @@ add_library (libsystemc-clang
####################################
#From here the files are for the reflection database
####################################
Utility.cpp
#
Utility.cpp
EntryFunctionContainer.cpp
WaitContainer.cpp
NotifyContainer.cpp
...
...
src/FindSimTime.cpp
View file @
d439b174
...
...
@@ -37,6 +37,7 @@ bool FindSimTime::VisitCallExpr (CallExpr * c)
return
true
;
}
/*
string FindSimTime::getArgumentName (Expr * arg)
{
if (arg == NULL)
...
...
@@ -55,6 +56,7 @@ string FindSimTime::getArgumentName (Expr * arg)
// _os << ", argument: " << s.str() << "\n";
return s.str ();
}
*/
FindSimTime
::
simulationTimeMapType
FindSimTime
::
returnSimTime
()
{
...
...
src/FindSimTime.h
View file @
d439b174
...
...
@@ -6,28 +6,23 @@
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/PrettyPrinter.h"
#include <map>
#include "Utility.h"
namespace
scpar
{
using
namespace
clang
;
using
namespace
std
;
class
FindSimTime
:
public
RecursiveASTVisitor
<
FindSimTime
>
{
class
FindSimTime
:
public
RecursiveASTVisitor
<
FindSimTime
>
,
public
Utility
{
public:
typedef
pair
<
string
,
string
>
simulationTimePairType
;
typedef
map
<
string
,
string
>
simulationTimeMapType
;
FindSimTime
(
FunctionDecl
*
,
llvm
::
raw_ostream
&
);
~
FindSimTime
(
);
virtual
bool
VisitCallExpr
(
CallExpr
*
C
);
string
getArgumentName
(
Expr
*
arg
);
simulationTimeMapType
returnSimTime
(
);
FindSimTime
(
FunctionDecl
*
,
llvm
::
raw_ostream
&
);
~
FindSimTime
();
virtual
bool
VisitCallExpr
(
CallExpr
*
C
);
simulationTimeMapType
returnSimTime
();
private:
llvm
::
raw_ostream
&
_os
;
...
...
src/SCuitable/GlobalSuspensionAutomata.cpp
View file @
d439b174
...
...
@@ -6,26 +6,13 @@ GlobalSuspensionAutomata::GlobalSuspensionAutomata(Model * systemCmodel,
ASTContext
*
a
)
:
_systemcModel
(
systemCmodel
),
_os
(
os
),
_a
(
a
)
{
u
=
new
Utility
();
}
GlobalSuspensionAutomata
::~
GlobalSuspensionAutomata
()
{
}
// ANI : Needs to be a template class
bool
GlobalSuspensionAutomata
::
notInVector
(
vector
<
SusCFG
*>
vec
,
SusCFG
*
cand
){
for
(
int
i
=
0
;
i
<
vec
.
size
();
i
++
)
{
if
(
vec
.
at
(
i
)
==
cand
)
{
return
0
;
}
}
return
1
;
}
void
GlobalSuspensionAutomata
::
initializeGpuMap
()
{
// GPU map algorithm.
...
...
@@ -80,7 +67,7 @@ void GlobalSuspensionAutomata::initializeGpuMap() {
for
(
int
k
=
0
;
k
<
bCodeBlocks
.
size
();
k
++
)
{
if
(
_susCFGBlockGPUMacroMap
.
find
(
bCodeBlocks
.
at
(
k
))
!=
_susCFGBlockGPUMacroMap
.
end
())
{
// DP segment found
if
(
notInVector
(
tmpVec
,
bCodeBlocks
.
at
(
k
)))
{
if
(
!
isElementPresent
(
tmpVec
,
bCodeBlocks
.
at
(
k
)))
{
susCFGBlockList
.
push_back
(
bCodeBlocks
.
at
(
k
));
}
}
...
...
@@ -96,7 +83,17 @@ void GlobalSuspensionAutomata::initializeGpuMap() {
// Actual gpu map algo starts here....
// use _commonTimeDPMap and for each timePair with more than one DP segment, do pseudo-knapsacking algo
for
(
commonTimeDPMapType
::
iterator
cit
=
_commonTimeDPMap
.
begin
(),
cite
=
_commonTimeDPMap
.
end
();
cit
!=
cite
;
cit
++
)
{
_os
<<
"
\n
Time : "
<<
cit
->
first
.
first
<<
" "
<<
cit
->
first
.
second
<<
"
\n
"
;
for
(
int
i
=
0
;
i
<
cit
->
second
.
size
();
i
++
)
{
_os
<<
" "
<<
cit
->
second
.
at
(
i
)
<<
" "
<<
cit
->
second
.
at
(
i
)
->
getBlockID
();
}
}
for
(
commonTimeDPMapType
::
iterator
cit
=
_commonTimeDPMap
.
begin
(),
cite
=
_commonTimeDPMap
.
end
();
cit
!=
cite
;
cit
++
)
{
...
...
src/SCuitable/GlobalSuspensionAutomata.h
View file @
d439b174
...
...
@@ -3,11 +3,12 @@
#include "Model.h"
#include "FindGPUMacro.h"
#include "Utility.h"
namespace
scpar
{
using
namespace
clang
;
using
namespace
std
;
class
GlobalSuspensionAutomata
{
class
GlobalSuspensionAutomata
:
public
Utility
{
public:
GlobalSuspensionAutomata
(
Model
*
,
raw_ostream
&
,
ASTContext
*
);
~
GlobalSuspensionAutomata
();
...
...
@@ -42,7 +43,6 @@ namespace scpar {
typedef
pair
<
timePairType
,
vector
<
SusCFG
*>
>
commonTimeDPPairType
;
typedef
map
<
timePairType
,
vector
<
SusCFG
*>
>
commonTimeDPMapType
;
bool
notInVector
(
vector
<
SusCFG
*>
,
SusCFG
*
);
bool
updateTransitionTime
(
Transition
*
);
void
updateEventNotificationTime
(
Transition
*
);
void
getTransportType
();
...
...
@@ -86,7 +86,7 @@ namespace scpar {
entryFunctionMacroMapType
_entryFunctionGPUMacroMap
;
susCFGBlockGPUMacroMapType
_susCFGBlockGPUMacroMap
;
commonTimeDPMapType
_commonTimeDPMap
;
Utility
*
u
;
};
}
#endif
src/SuspensionAutomata.cpp
View file @
d439b174
...
...
@@ -884,7 +884,7 @@ bool SuspensionAutomata::isTimedWait(Stmt * stmt)
}
return
false
;
}
/*
string SuspensionAutomata::getArgumentName(Expr * arg)
{
if (arg == NULL)
...
...
@@ -902,6 +902,7 @@ string SuspensionAutomata::getArgumentName(Expr * arg)
// _os << ", argument: " << s.str() << "\n";
return s.str();
}
*/
bool
SuspensionAutomata
::
isDeltaWait
(
Stmt
*
stmt
)
{
...
...
src/SuspensionAutomata.h
View file @
d439b174
...
...
@@ -115,7 +115,7 @@ namespace scpar {
//////////////////////////////////////////////////////////////////////////////
class
SuspensionAutomata
{
class
SuspensionAutomata
:
public
Utility
{
public:
typedef
vector
<
SusCFG
*
>
susCFGVectorType
;
...
...
@@ -147,7 +147,7 @@ namespace scpar {
bool
isEventWait
(
Stmt
*
stmt
);
float
getTime
(
Stmt
*
stmt
);
string
getEvent
(
Stmt
*
stmt
);
string
getArgumentName
(
Expr
*
arg
);
//
string getArgumentName(Expr * arg);
void
addEvent
(
string
);
void
addSimTime
(
float
);
susCFGVectorType
getSusCFG
();
...
...
src/Utility.h
View file @
d439b174
...
...
@@ -24,18 +24,77 @@ namespace scpar {
using
namespace
std
;
class
Utility
{
public:
Utility
(
);
Utility
(){
}
/*
void tabit (llvm::raw_ostream &, int tabn);
string strip (string, string);
template < typename vec > vec removeDuplicate (vec);
template < typename vec, typename element > bool isElementPresent (vec, element);
template < typename element > string getArgumentName (element *);
*/
void
tabit
(
raw_ostream
&
os
,
int
tabn
)
{
for
(
int
i
=
0
;
i
<
tabn
;
i
++
)
{
os
<<
" "
;
}
}
template
<
typename
vec
>
vec
removeDuplicate
(
vec
);
string
strip
(
string
s
,
string
sub
)
{
// sub has "struct "
size_t
pos
=
s
.
find
(
sub
);
template
<
typename
vec
,
typename
element
>
bool
isElementPresent
(
vec
,
element
);
if
(
pos
==
string
::
npos
)
{
return
s
;
}
template
<
typename
element
>
string
getArgumentName
(
element
*
);
return
s
.
erase
(
pos
,
sub
.
length
());
}
template
<
typename
vec
>
vec
removeDuplicate
(
vec
vecInput
)
{
for
(
unsigned
int
i
=
0
;
i
<
vecInput
.
size
();
i
++
)
{
for
(
unsigned
int
j
=
0
;
j
<
vecInput
.
size
();
j
++
)
{
if
(
i
!=
j
&&
vecInput
.
at
(
i
)
==
vecInput
.
at
(
j
))
{
vecInput
.
erase
(
vecInput
.
begin
()
+
j
);
}
}
}
return
vecInput
;
}
template
<
typename
vec
,
typename
element
>
bool
isElementPresent
(
vec
vecInput
,
element
elemInput
)
{
for
(
unsigned
int
i
=
0
;
i
<
vecInput
.
size
();
i
++
)
{
if
(
elemInput
==
vecInput
.
at
(
i
))
{
return
true
;
}
}
return
false
;
}
template
<
typename
expressionArg
>
string
getArgumentName
(
expressionArg
*
exp
)
{
if
(
exp
==
NULL
)
{
return
string
(
"NULL"
);
}
clang
::
LangOptions
LangOpts
;
LangOpts
.
CPlusPlus
=
true
;
clang
::
PrintingPolicy
Policy
(
LangOpts
);
string
TypeS
;
llvm
::
raw_string_ostream
s
(
TypeS
);
exp
->
printPretty
(
s
,
0
,
Policy
);
return
s
.
str
();
}
};
}
#endif
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