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
0dba194a
Commit
0dba194a
authored
Nov 30, 2014
by
Anirudh
Browse files
Multiple instances Sautos and SusCFGs
parent
5f09c9d9
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/EntryFunctionContainer.cpp
View file @
0dba194a
...
...
@@ -56,12 +56,14 @@ PROCESS_TYPE EntryFunctionContainer::getProcessType ()
return
_procType
;
}
SuspensionAutomata
::
susCFGVectorType
EntryFunctionContainer
::
getSusCFG
()
{
return
_susCFG
;
SuspensionAutomata
::
susCFGVectorType
EntryFunctionContainer
::
getSusCFG
(
int
numInstance
)
{
//return _susCFG;
return
_instanceSusCFGMap
[
numInstance
];
}
SuspensionAutomata
::
transitionVectorType
EntryFunctionContainer
::
getSusAuto
()
{
return
_susAuto
;
SuspensionAutomata
::
transitionVectorType
EntryFunctionContainer
::
getSusAuto
(
int
numInstance
)
{
//return _susAuto;
return
_instanceSautoMap
[
numInstance
];
}
///////////////////////////////////////////////////////////////////////////////////////////////
void
EntryFunctionContainer
::
setName
(
string
n
)
...
...
@@ -101,9 +103,15 @@ void EntryFunctionContainer::addWaits (FindWait & f)
}
void
EntryFunctionContainer
::
addSusCFGAuto
(
SuspensionAutomata
&
s
)
{
_susCFG
=
s
.
getSusCFG
();
_susAuto
=
s
.
getSauto
();
void
EntryFunctionContainer
::
addSusCFGAuto
(
SuspensionAutomata
&
s
,
int
numInstance
)
{
//_susCFG = s.getSusCFG();
//_susAuto = s.getSauto();
if
(
_instanceSusCFGMap
.
find
(
numInstance
)
==
_instanceSusCFGMap
.
end
()
&&
_instanceSautoMap
.
find
(
numInstance
)
==
_instanceSautoMap
.
end
())
{
_instanceSusCFGMap
.
insert
(
instanceSusCFGPairType
(
numInstance
,
s
.
getSusCFG
()));
_instanceSautoMap
.
insert
(
instanceSautoPairType
(
numInstance
,
s
.
getSauto
()));
}
}
void
EntryFunctionContainer
::
addNotifys
(
FindNotify
&
f
)
{
...
...
@@ -123,20 +131,21 @@ void EntryFunctionContainer::addNotifys( FindNotify& f) {
///////////////////////////////////////////////////////////////////////////////////////////////
void
EntryFunctionContainer
::
dumpSusCFG
(
raw_ostream
&
os
)
{
os
<<
"
\n
#############################################"
;
SuspensionAutomata
::
susCFGVectorType
susCFGVector
=
_susCFG
;
for
(
instanceSusCFGMapType
::
iterator
it
=
_instanceSusCFGMap
.
begin
(),
eit
=
_instanceSusCFGMap
.
end
();
it
!=
eit
;
it
++
)
{
os
<<
"
\n
#############################################"
;
SuspensionAutomata
::
susCFGVectorType
susCFGVector
=
it
->
second
;
for
(
unsigned
int
i
=
0
;
i
<
susCFGVector
.
size
();
i
++
)
{
os
<<
"
\n
Block ID : "
<<
susCFGVector
.
at
(
i
)
->
getBlockID
();
os
<<
"
\n
Is Wait Block : "
<<
susCFGVector
.
at
(
i
)
->
isWaitBlock
();
if
(
susCFGVector
.
at
(
i
)
->
getParentBlockID
())
{
os
<<
"
\n
Parent ID : "
<<
susCFGVector
.
at
(
i
)
->
getParentBlockID
();
SusCFG
*
parentBlock
=
susCFGVector
.
at
(
i
)
->
getParentSusCFGBlock
();
os
<<
"
\n
Parent Block ID : "
<<
parentBlock
->
getBlockID
();
os
<<
"
\n
Size of Children : "
<<
parentBlock
->
getChildBlockList
().
size
();
os
<<
"
\n
Block ID : "
<<
susCFGVector
.
at
(
i
)
->
getBlockID
();
os
<<
"
\n
Is Wait Block : "
<<
susCFGVector
.
at
(
i
)
->
isWaitBlock
();
if
(
susCFGVector
.
at
(
i
)
->
getParentBlockID
())
{
os
<<
"
\n
Parent ID : "
<<
susCFGVector
.
at
(
i
)
->
getParentBlockID
();
SusCFG
*
parentBlock
=
susCFGVector
.
at
(
i
)
->
getParentSusCFGBlock
();
os
<<
"
\n
Parent Block ID : "
<<
parentBlock
->
getBlockID
();
os
<<
"
\n
Size of Children : "
<<
parentBlock
->
getChildBlockList
().
size
();
}
vector
<
SusCFG
*
>
predBlocks
=
susCFGVector
.
at
(
i
)
->
getPredBlocks
();
vector
<
SusCFG
*
>
succBlocks
=
susCFGVector
.
at
(
i
)
->
getSuccBlocks
();
...
...
@@ -153,18 +162,21 @@ void EntryFunctionContainer::dumpSusCFG(raw_ostream & os)
}
}
}
}
}
void
EntryFunctionContainer
::
dumpSauto
(
raw_ostream
&
os
)
{
vector
<
Transition
*
>
transitionVector
=
_susAuto
;
for
(
instanceSautoMapType
::
iterator
it
=
_instanceSautoMap
.
begin
(),
eit
=
_instanceSautoMap
.
end
();
it
!=
eit
;
it
++
)
{
vector
<
Transition
*
>
transitionVector
=
it
->
second
;
os
<<
"
\n
Size of transitionVector : "
<<
transitionVector
.
size
();
for
(
unsigned
int
i
=
0
;
i
<
transitionVector
.
size
();
i
++
)
{
Transition
*
t
=
transitionVector
.
at
(
i
);
t
->
dump
(
os
);
}
}
}
...
...
src/EntryFunctionContainer.h
View file @
0dba194a
...
...
@@ -34,9 +34,15 @@ namespace scpar {
public:
// typedefs
typedef
vector
<
WaitContainer
*
>
waitContainerListType
;
typedef
vector
<
NotifyContainer
*>
notifyContainerListType
;
typedef
vector
<
NotifyContainer
*>
notifyContainerListType
;
EntryFunctionContainer
();
typedef
pair
<
int
,
SuspensionAutomata
::
transitionVectorType
>
instanceSautoPairType
;
typedef
map
<
int
,
SuspensionAutomata
::
transitionVectorType
>
instanceSautoMapType
;
typedef
pair
<
int
,
SuspensionAutomata
::
susCFGVectorType
>
instanceSusCFGPairType
;
typedef
map
<
int
,
SuspensionAutomata
::
susCFGVectorType
>
instanceSusCFGMapType
;
EntryFunctionContainer
();
EntryFunctionContainer
(
string
,
PROCESS_TYPE
,
CXXMethodDecl
*
,
Stmt
*
);
EntryFunctionContainer
(
const
EntryFunctionContainer
&
);
~
EntryFunctionContainer
();
...
...
@@ -48,36 +54,39 @@ namespace scpar {
PROCESS_TYPE
getProcessType
();
waitContainerListType
getWaitCalls
();
notifyContainerListType
getNotifyCalls
();
FindSensitivity
::
senseMapType
getSenseMap
();
SuspensionAutomata
::
susCFGVectorType
getSusCFG
();
SuspensionAutomata
::
transitionVectorType
getSusAuto
();
notifyContainerListType
getNotifyCalls
();
FindSensitivity
::
senseMapType
getSenseMap
();
SuspensionAutomata
::
susCFGVectorType
getSusCFG
(
int
);
SuspensionAutomata
::
transitionVectorType
getSusAuto
(
int
);
instanceSautoMapType
getInstanceSautoMap
();
instanceSusCFGMapType
getInstanceSusCFGMap
();
// Add waits.
void
addSensitivityInfo
(
FindSensitivity
&
);
void
addWaits
(
FindWait
&
);
void
addWaits
(
FindWait
&
);
void
addNotifys
(
FindNotify
&
);
void
addSusCFGAuto
(
SuspensionAutomata
&
);
void
addSusCFGAuto
(
SuspensionAutomata
&
,
int
);
//void setConstructorStmt (Stmt *);
void
setName
(
string
);
void
setProcessType
(
PROCESS_TYPE
);
void
setEntryMethod
(
CXXMethodDecl
*
);
void
dumpSusCFG
(
raw_ostream
&
);
void
dumpSauto
(
raw_ostream
&
);
void
dump
(
raw_ostream
&
,
int
);
void
dumpSauto
(
raw_ostream
&
);
void
dump
(
raw_ostream
&
,
int
);
//private:
string
_entryName
;
PROCESS_TYPE
_procType
;
CXXMethodDecl
*
_entryMethodDecl
;
SuspensionAutomata
::
susCFGVectorType
_susCFG
;
SuspensionAutomata
::
transitionVectorType
_susAuto
;
// Hold all the waits.
waitContainerListType
_waitCalls
;
notifyContainerListType
_notifyCalls
;
notifyContainerListType
_notifyCalls
;
FindSensitivity
::
senseMapType
_senseMap
;
instanceSautoMapType
_instanceSautoMap
;
instanceSusCFGMapType
_instanceSusCFGMap
;
};
}
#endif
src/SCuitable/GlobalSuspensionAutomata.cpp
View file @
0dba194a
...
...
@@ -264,7 +264,7 @@ void GlobalSuspensionAutomata::initialise()
for
(
int
i
=
0
;
i
<
instanceList
.
size
();
i
++
)
{
for
(
int
j
=
0
;
j
<
vef
.
size
();
j
++
)
{
SuspensionAutomata
::
transitionVectorType
sauto
=
vef
.
at
(
j
)
->
getSusAuto
();
vef
.
at
(
j
)
->
getSusAuto
(
i
);
_instanceFunctionSautoMap
.
insert
(
instanceFunctionSautoPairType
(
instanceEntryFunctionPairType
...
...
@@ -573,6 +573,7 @@ void GlobalSuspensionAutomata::dump()
vector
<
Transition
*
>
sauto
=
it
->
second
;
for
(
int
i
=
0
;
i
<
sauto
.
size
();
i
++
)
{
_os
<<
"
\n
Transition : "
<<
sauto
.
at
(
i
);
sauto
.
at
(
i
)
->
dump
(
_os
);
// Scheduled time-stamps for execution
if
(
_transitionTimeMap
.
find
(
sauto
.
at
(
i
))
!=
_transitionTimeMap
.
end
())
{
...
...
src/SuspensionAutomata.cpp
View file @
0dba194a
...
...
@@ -277,11 +277,16 @@ void Transition::dump(raw_ostream & os)
}
////////////////////////////////////////////////////////////////////////////////////////
SuspensionAutomata
::
SuspensionAutomata
(
FindWait
::
waitListType
waitCalls
,
CXXMethodDecl
*
d
,
ASTContext
*
a
,
raw_ostream
&
os
)
:
_d
(
d
),
_a
(
a
),
_os
(
os
),
SuspensionAutomata
::
SuspensionAutomata
(
vector
<
WaitContainer
*>
waitCalls
,
CXXMethodDecl
*
d
,
ASTContext
*
a
,
raw_ostream
&
os
)
:
_d
(
d
),
_a
(
a
),
_os
(
os
),
_cfg
(
NULL
)
{
_waitCalls
=
waitCalls
;
for
(
int
i
=
0
;
i
<
waitCalls
.
size
();
i
++
)
{
WaitContainer
*
wc
=
waitCalls
.
at
(
i
);
_waitCalls
.
push_back
(
wc
->
getASTNode
());
}
//_waitCalls = waitCalls;
}
SuspensionAutomata
::~
SuspensionAutomata
()
...
...
@@ -343,10 +348,7 @@ void SuspensionAutomata::genSusCFG()
PrintingPolicy
Policy
(
LO
);
vector
<
Optional
<
CFGStmt
>
>
pre
;
vector
<
unsigned
int
>
waitBlockIDVector
;
vector
<
const
CFGBlock
*>
CFGBlockVector
;;
typedef
map
<
CFGBlock
*
,
SusCFG
*
>
susCFGBlockMapType
;
...
...
@@ -694,8 +696,6 @@ void SuspensionAutomata::checkInsert(vector<SusCFG*> source, vector<SusCFG*>& ta
void
SuspensionAutomata
::
genSauto
()
{
susCFGVectorType
susCFGVector
=
_susCFGVector
;
susCFGVectorType
waitBlocks
;
for
(
int
i
=
0
;
i
<
susCFGVector
.
size
();
i
++
)
{
...
...
src/SuspensionAutomata.h
View file @
0dba194a
...
...
@@ -8,7 +8,7 @@
#include
"clang/AST/ParentMap.h"
#include
<map>
#include
"Utility.h"
#include
"
Find
Wait.h"
#include
"Wait
Container
.h"
#include
"Automata.h"
namespace
scpar
{
...
...
@@ -127,7 +127,7 @@ namespace scpar {
typedef
pair
<
State
*
,
vector
<
SusCFG
*>
>
stateCommonCodeBlockPairType
;
typedef
map
<
State
*
,
vector
<
SusCFG
*>
>
stateCommonCodeBlockMapType
;
SuspensionAutomata
(
FindWait
::
waitListType
,
CXXMethodDecl
*
,
ASTContext
*
,
SuspensionAutomata
(
vector
<
WaitContainer
*>
,
CXXMethodDecl
*
,
ASTContext
*
,
raw_ostream
&
);
~
SuspensionAutomata
();
void
addRemainingBlocks
(
State
*
,
vector
<
SusCFG
*>&
);
...
...
@@ -154,7 +154,7 @@ namespace scpar {
void
dumpSauto
();
private:
CXXMethodDecl
*
_d
;
FindWait
::
waitListType
_waitCalls
;
vector
<
CallExpr
*>
_waitCalls
;
susCFGSuccIDMapType
susCFGSuccIDMap
;
susCFGStateMapType
susCFGStateMap
;
CFG
*
_cfg
;
...
...
src/SystemCClang.cpp
View file @
0dba194a
...
...
@@ -36,7 +36,8 @@ bool SystemCConsumer::fire()
{
ModuleDecl
*
md
=
new
ModuleDecl
(
mit
->
first
,
mit
->
second
);
vector
<
EntryFunctionContainer
*
>
_entryFunctionContainerVector
;
_os
<<
"
\n
Number of instances in this module : "
<<
md
->
getNumInstances
();
vector
<
EntryFunctionContainer
*
>
_entryFunctionContainerVector
;
FindConstructor
constructor
(
mit
->
second
,
_os
);
md
->
addConstructor
(
constructor
.
returnConstructorStmt
());
...
...
@@ -80,7 +81,7 @@ bool SystemCConsumer::fire()
FindNotify
findNotify
(
ef
->
_entryMethodDecl
,
_os
);
ef
->
addNotifys
(
findNotify
);
/*
SuspensionAutomata suspensionAutomata(findWaits.getWaitCalls(), ef->getEntryMethod(), &_context, llvm::errs());
if (suspensionAutomata.initialize()) {
suspensionAutomata.genSusCFG();
...
...
@@ -89,7 +90,7 @@ bool SystemCConsumer::fire()
//suspensionAutomata.dumpSauto();
ef->addSusCFGAuto(suspensionAutomata);
}
*/
_entryFunctionContainerVector
.
push_back
(
ef
);
}
...
...
@@ -113,7 +114,31 @@ bool SystemCConsumer::fire()
FindNetlist
findNetlist
(
scmain
.
getSCMainFunctionDecl
());
findNetlist
.
dump
();
_systemcModel
->
addNetlist
(
findNetlist
);
// Generate SAUTO
// Placing it here so that unique SAUTO for each instance
Model
::
moduleMapType
moduleMap
=
_systemcModel
->
getModuleDecl
();
for
(
Model
::
moduleMapType
::
iterator
it
=
moduleMap
.
begin
(),
eit
=
moduleMap
.
end
();
it
!=
eit
;
it
++
)
{
ModuleDecl
*
moduleDecl
=
it
->
second
;
int
numInstances
=
moduleDecl
->
getNumInstances
();
for
(
int
i
=
0
;
i
<
numInstances
;
i
++
)
{
vector
<
EntryFunctionContainer
*>
entryFunctionContainer
=
moduleDecl
->
getEntryFunctionContainer
();
for
(
int
j
=
0
;
j
<
entryFunctionContainer
.
size
();
j
++
)
{
SuspensionAutomata
suspensionAutomata
(
entryFunctionContainer
.
at
(
j
)
->
getWaitCalls
(),
entryFunctionContainer
.
at
(
j
)
->
getEntryMethod
(),
&
_context
,
llvm
::
errs
());
if
(
suspensionAutomata
.
initialize
())
{
suspensionAutomata
.
genSusCFG
();
//suspensionAutomata.dumpSusCFG();
suspensionAutomata
.
genSauto
();
//suspensionAutomata.dumpSauto();
entryFunctionContainer
.
at
(
j
)
->
addSusCFGAuto
(
suspensionAutomata
,
i
);
}
}
}
}
_os
<<
"
\n
SystemC model dump
\n
"
;
_systemcModel
->
dump
(
_os
);
return
true
;
...
...
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