Commit c779d140 authored by Hiren Patel's avatar Hiren Patel
Browse files

Merge branch 'sauto-compile-fix' into 'master'

Re-include sauto files and fix compilation.

See merge request !14
parents 968d09de 9a1cca63
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
project(systemc-clang) project(systemc-clang)
# Use C++ standard version to c++17 # Use C++ standard version to c++17
set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD 17)
# Always keep it on # Always keep it on
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
......
...@@ -90,13 +90,10 @@ void EntryFunctionContainer::addWaits (FindWait & f) ...@@ -90,13 +90,10 @@ void EntryFunctionContainer::addWaits (FindWait & f)
{ {
FindWait::waitListType wcalls = f.getWaitCalls (); FindWait::waitListType wcalls = f.getWaitCalls ();
for (FindWait::waitListType::iterator it = wcalls.begin (), eit = for (FindWait::waitListType::iterator it = wcalls.begin (), eit =
wcalls.end (); it != eit; it++) wcalls.end (); it != eit; it++) {
{
// 'it' points to CXXMembercallExpr type. // 'it' points to CXXMembercallExpr type.
WaitContainer * WaitContainer * wc { new WaitContainer (f.getEntryMethod (), (*it)->getASTNode() ) };
wc = new WaitContainer (f.getEntryMethod (), *it); _waitCalls.push_back(wc);
_waitCalls.push_back (wc);
} }
//_processWaitEventMap = f.getProcessWaitEventMap(); //_processWaitEventMap = f.getProcessWaitEventMap();
......
...@@ -29,7 +29,7 @@ bool FindWait::VisitCallExpr ( CallExpr *e ) { ...@@ -29,7 +29,7 @@ bool FindWait::VisitCallExpr ( CallExpr *e ) {
clang::PrintingPolicy Policy (LangOpts); clang::PrintingPolicy Policy (LangOpts);
if (e->getDirectCallee()->getNameInfo().getAsString() == string("wait")) { if (e->getDirectCallee()->getNameInfo().getAsString() == string("wait")) {
wait_calls_list_.push_back (e); wait_calls_list_.push_back( new WaitContainer(entry_method_decl_, e) );
} }
return true; return true;
} }
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "clang/AST/RecursiveASTVisitor.h" #include "clang/AST/RecursiveASTVisitor.h"
#include <map> #include <map>
#include "WaitContainer.h"
namespace scpar { namespace scpar {
using namespace clang; using namespace clang;
...@@ -13,7 +15,7 @@ namespace scpar { ...@@ -13,7 +15,7 @@ namespace scpar {
class FindWait:public RecursiveASTVisitor < FindWait > { class FindWait:public RecursiveASTVisitor < FindWait > {
public: public:
typedef vector < CallExpr * > waitListType; typedef vector < WaitContainer * > waitListType;
typedef pair < CXXMethodDecl *,vector < string > >processWaitEventPairType; typedef pair < CXXMethodDecl *,vector < string > >processWaitEventPairType;
typedef map < CXXMethodDecl *, vector < string > >processWaitEventMapType; typedef map < CXXMethodDecl *, vector < string > >processWaitEventMapType;
......
...@@ -53,7 +53,7 @@ void SusCFG::addChildBlockList(SusCFG * block) ...@@ -53,7 +53,7 @@ void SusCFG::addChildBlockList(SusCFG * block)
void SusCFG::addChildBlockList(vector < SusCFG * >blockList) void SusCFG::addChildBlockList(vector < SusCFG * >blockList)
{ {
for (unsigned int i = 0; i < blockList.size(); i++) { for (size_t i = 0; i < blockList.size(); i++) {
_childBlockList.push_back(blockList.at(i)); _childBlockList.push_back(blockList.at(i));
} }
} }
...@@ -249,9 +249,8 @@ void Transition::addCodeBlocks(SusCFG * susCFG) ...@@ -249,9 +249,8 @@ void Transition::addCodeBlocks(SusCFG * susCFG)
_codeBlockVector.push_back(susCFG); _codeBlockVector.push_back(susCFG);
} }
void Transition::addCodeBlocks(vector < SusCFG * >susCFG) void Transition::addCodeBlocks(vector < SusCFG * >susCFG) {
{ for (size_t i = 0; i < susCFG.size(); i++) {
for (unsigned int i = 0; i < susCFG.size(); i++) {
_codeBlockVector.push_back(susCFG.at(i)); _codeBlockVector.push_back(susCFG.at(i));
} }
} }
...@@ -282,7 +281,7 @@ void Transition::dump(raw_ostream & os) ...@@ -282,7 +281,7 @@ void Transition::dump(raw_ostream & os)
getBlockID(); getBlockID();
os << "\n Final State : " << _finalState->returnSusCFGBlock()->getBlockID(); os << "\n Final State : " << _finalState->returnSusCFGBlock()->getBlockID();
os << "\n Transition Blocks : "; os << "\n Transition Blocks : ";
for (unsigned int i = 0; i < _codeBlockVector.size(); i++) { for ( size_t i{0}; i < _codeBlockVector.size(); i++) {
os << _codeBlockVector.at(i)->getBlockID() << " "; os << _codeBlockVector.at(i)->getBlockID() << " ";
} }
} }
...@@ -291,7 +290,7 @@ void Transition::dump(raw_ostream & os) ...@@ -291,7 +290,7 @@ void Transition::dump(raw_ostream & os)
SuspensionAutomata::SuspensionAutomata(vector<WaitContainer*> 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)
{ {
for (int i = 0; i<waitCalls.size(); i++) { for (size_t i{0}; i<waitCalls.size(); i++) {
WaitContainer *wc = waitCalls.at(i); WaitContainer *wc = waitCalls.at(i);
_waitCalls.push_back(wc->getASTNode()); _waitCalls.push_back(wc->getASTNode());
} }
...@@ -305,7 +304,6 @@ SuspensionAutomata::~SuspensionAutomata() ...@@ -305,7 +304,6 @@ SuspensionAutomata::~SuspensionAutomata()
bool SuspensionAutomata::initialize() bool SuspensionAutomata::initialize()
{ {
const CFG::BuildOptions & b = CFG::BuildOptions(); const CFG::BuildOptions & b = CFG::BuildOptions();
_cfg = CFG::buildCFG(cast < Decl > (_d), _d->getBody(), _a, b); _cfg = CFG::buildCFG(cast < Decl > (_d), _d->getBody(), _a, b);
if (_cfg != NULL) { if (_cfg != NULL) {
...@@ -327,7 +325,7 @@ bool SuspensionAutomata::isWaitCall(const CFGStmt * cs) ...@@ -327,7 +325,7 @@ bool SuspensionAutomata::isWaitCall(const CFGStmt * cs)
if (!m) { if (!m) {
return f; return f;
} }
for (int i = 0; i < _waitCalls.size(); i++) { for (size_t i{0}; i < _waitCalls.size(); i++) {
CallExpr *ce = _waitCalls.at(i); CallExpr *ce = _waitCalls.at(i);
if (m == ce) { if (m == ce) {
f = true; f = true;
...@@ -365,7 +363,7 @@ void SuspensionAutomata::genSusCFG() ...@@ -365,7 +363,7 @@ void SuspensionAutomata::genSusCFG()
susCFGBlockMapType susCFGBlockMap; susCFGBlockMapType susCFGBlockMap;
bool isFirstCFGBlockID = false; // bool isFirstCFGBlockID = false;
for (CFG::iterator it = _cfg->end() - 1, eit = _cfg->begin(); it != eit; --it) { for (CFG::iterator it = _cfg->end() - 1, eit = _cfg->begin(); it != eit; --it) {
...@@ -391,7 +389,7 @@ void SuspensionAutomata::genSusCFG() ...@@ -391,7 +389,7 @@ void SuspensionAutomata::genSusCFG()
_os << "Dump CFG Block\n"; _os << "Dump CFG Block\n";
b->dump(_cfg, LO, false); b->dump(_cfg, LO, false);
*/ */
unsigned int prevCFGBlockID; // unsigned int prevCFGBlockID;
for (CFGBlock::const_iterator bit = b->begin(), bite = b->end(); for (CFGBlock::const_iterator bit = b->begin(), bite = b->end();
bit != bite; bit++) { bit != bite; bit++) {
...@@ -434,10 +432,9 @@ void SuspensionAutomata::genSusCFG() ...@@ -434,10 +432,9 @@ void SuspensionAutomata::genSusCFG()
CFGBlock *prev = NULL; CFGBlock *prev = NULL;
SusCFG *prevBlock = NULL; SusCFG *prevBlock = NULL;
for (unsigned int i = 0; i < splitBlocksVector.size(); i++) { for (size_t i = 0; i < splitBlocksVector.size(); i++) {
CFGBlock *current = splitBlocksVector.at(i); CFGBlock *current = splitBlocksVector.at(i);
SusCFG *splitBlock = SusCFG *splitBlock = new SusCFG(const_cast < CFGBlock * >(splitBlocksVector.at(i)));
new SusCFG(const_cast < CFGBlock * >(splitBlocksVector.at(i)));
currBlock->addChildBlockList(splitBlock); currBlock->addChildBlockList(splitBlock);
if (current->getLabel()) { if (current->getLabel()) {
splitBlock->setWaitBlock(); splitBlock->setWaitBlock();
...@@ -446,7 +443,7 @@ void SuspensionAutomata::genSusCFG() ...@@ -446,7 +443,7 @@ void SuspensionAutomata::genSusCFG()
if (pre.size() != 0) { if (pre.size() != 0) {
// add trailing statements to post block wait stmt // add trailing statements to post block wait stmt
CFGBlock *newCFGBlock = _cfg->createBlock(); CFGBlock *newCFGBlock = _cfg->createBlock();
for (unsigned int j = 0; j < pre.size(); j++) { for (size_t j = 0; j < pre.size(); j++) {
newCFGBlock->appendStmt(const_cast < Stmt * >(pre.at(j)->getStmt()), newCFGBlock->appendStmt(const_cast < Stmt * >(pre.at(j)->getStmt()),
_cfg->getBumpVectorContext()); _cfg->getBumpVectorContext());
} }
...@@ -573,7 +570,7 @@ void SuspensionAutomata::genSusCFG() ...@@ -573,7 +570,7 @@ void SuspensionAutomata::genSusCFG()
} }
void SuspensionAutomata::addRemainingBlocks(State *initialState, vector<SusCFG*>& transitionBlocks){ void SuspensionAutomata::addRemainingBlocks(State *initialState, vector<SusCFG*>& transitionBlocks){
bool duplicate = false; // bool duplicate = false;
if (_stateCommonCodeBlockMap.find(initialState) != _stateCommonCodeBlockMap.end()) { if (_stateCommonCodeBlockMap.find(initialState) != _stateCommonCodeBlockMap.end()) {
stateCommonCodeBlockMapType::iterator stateFound = _stateCommonCodeBlockMap.find(initialState); stateCommonCodeBlockMapType::iterator stateFound = _stateCommonCodeBlockMap.find(initialState);
checkInsert(stateFound->second, transitionBlocks); checkInsert(stateFound->second, transitionBlocks);
...@@ -593,11 +590,10 @@ vector<SusCFG*> SuspensionAutomata::modifDFS(SusCFG * block, State *initialState ...@@ -593,11 +590,10 @@ vector<SusCFG*> SuspensionAutomata::modifDFS(SusCFG * block, State *initialState
traversedBlocks.pop_front(); traversedBlocks.pop_front();
if (currentBlock->isWaitBlock()) { if (currentBlock->isWaitBlock()) {
float timeInNs; float timeInNs{};
string eventName; string eventName{};
isWaitEncounter = true; isWaitEncounter = true;
susCFGStateMapType::iterator stateFound = susCFGStateMapType::iterator stateFound = susCFGStateMap.find(currentBlock);
susCFGStateMap.find(currentBlock);
State *finalState = stateFound->second; State *finalState = stateFound->second;
if (isTimedWait(currentBlock->getWaitStmt())) { if (isTimedWait(currentBlock->getWaitStmt())) {
...@@ -688,10 +684,10 @@ vector<SusCFG*> SuspensionAutomata::modifDFS(SusCFG * block, State *initialState ...@@ -688,10 +684,10 @@ vector<SusCFG*> SuspensionAutomata::modifDFS(SusCFG * block, State *initialState
} }
void SuspensionAutomata::checkInsert(vector<SusCFG*> source, vector<SusCFG*>& target) { void SuspensionAutomata::checkInsert(vector<SusCFG*> source, vector<SusCFG*>& target) {
bool duplicate; bool duplicate{false};
for (int i = 0; i<source.size(); i++) { for (size_t i = 0; i<source.size(); i++) {
duplicate = false; duplicate = false;
for (int j = 0; j<target.size(); j++) { for (size_t j = 0; j<target.size(); j++) {
if (source.at(i) == target.at(j)) { if (source.at(i) == target.at(j)) {
duplicate = true; duplicate = true;
break; break;
...@@ -707,7 +703,7 @@ void SuspensionAutomata::genSauto() ...@@ -707,7 +703,7 @@ void SuspensionAutomata::genSauto()
{ {
susCFGVectorType susCFGVector = _susCFGVector; susCFGVectorType susCFGVector = _susCFGVector;
susCFGVectorType waitBlocks; susCFGVectorType waitBlocks;
for (int i = 0; i < susCFGVector.size(); i++) { for (size_t i = 0; i < susCFGVector.size(); i++) {
if (susCFGVector.at(i)->isWaitBlock() || i == 0) { if (susCFGVector.at(i)->isWaitBlock() || i == 0) {
waitBlocks.push_back(susCFGVector.at(i)); waitBlocks.push_back(susCFGVector.at(i));
State *state = new State(susCFGVector.at(i), false, false, false, false); State *state = new State(susCFGVector.at(i), false, false, false, false);
...@@ -720,7 +716,7 @@ void SuspensionAutomata::genSauto() ...@@ -720,7 +716,7 @@ void SuspensionAutomata::genSauto()
} }
} }
for (int i = 0; i < waitBlocks.size(); i++) { for (size_t i = 0; i < waitBlocks.size(); i++) {
SusCFG *waitBlock = waitBlocks.at(i); SusCFG *waitBlock = waitBlocks.at(i);
...@@ -730,7 +726,7 @@ void SuspensionAutomata::genSauto() ...@@ -730,7 +726,7 @@ void SuspensionAutomata::genSauto()
State *initialState = stateFound->second; State *initialState = stateFound->second;
vector<SusCFG*> backTrackCodeBlocks; vector<SusCFG*> backTrackCodeBlocks;
SusCFG* lastBlock; //SusCFG* lastBlock;
susCFGSuccIDMap.clear(); // For each new initial state, start fresh... susCFGSuccIDMap.clear(); // For each new initial state, start fresh...
// Left child.. do the same for the right child // Left child.. do the same for the right child
do { do {
...@@ -746,7 +742,7 @@ void SuspensionAutomata::genSauto() ...@@ -746,7 +742,7 @@ void SuspensionAutomata::genSauto()
//_os <<"\n Transition Blocks : "; //_os <<"\n Transition Blocks : ";
backTrackCodeBlocks.clear(); backTrackCodeBlocks.clear();
for (int j = 0; j<transitionCodeBlocks.size(); j++) { for (size_t j = 0; j<transitionCodeBlocks.size(); j++) {
backTrackCodeBlocks.push_back(transitionCodeBlocks.at(j)); backTrackCodeBlocks.push_back(transitionCodeBlocks.at(j));
//_os <<" "<<transitionCodeBlocks.at(j)->getBlockID();; //_os <<" "<<transitionCodeBlocks.at(j)->getBlockID();;
} }
...@@ -823,7 +819,7 @@ bool is_found(Node n1, Node n2) ...@@ -823,7 +819,7 @@ bool is_found(Node n1, Node n2)
template <template <typename, typename> class Container, typename Node, typename Allocator> template <template <typename, typename> class Container, typename Node, typename Allocator>
bool generic_isFound(Container<Node, Allocator> &container, Node node) bool generic_isFound(Container<Node, Allocator> &container, Node node)
{ {
bool foundBlock = false; // bool foundBlock = false;
typename Container<Node, Allocator>::iterator itr = std::find_if( typename Container<Node, Allocator>::iterator itr = std::find_if(
container.begin(), container.begin(),
...@@ -850,7 +846,7 @@ bool SuspensionAutomata::isFound(vector < Transition * >visitedState, ...@@ -850,7 +846,7 @@ bool SuspensionAutomata::isFound(vector < Transition * >visitedState,
float SuspensionAutomata::getTime(Stmt * stmt) float SuspensionAutomata::getTime(Stmt * stmt)
{ {
float factor; float factor{};
if (CXXMemberCallExpr * ce = dyn_cast < CXXMemberCallExpr > (stmt)) { if (CXXMemberCallExpr * ce = dyn_cast < CXXMemberCallExpr > (stmt)) {
if (getArgumentName(ce->getArg(1)) == "SC_FS") { if (getArgumentName(ce->getArg(1)) == "SC_FS") {
factor = 1000000; factor = 1000000;
...@@ -867,6 +863,7 @@ float SuspensionAutomata::getTime(Stmt * stmt) ...@@ -867,6 +863,7 @@ float SuspensionAutomata::getTime(Stmt * stmt)
} }
return (atof(getArgumentName(ce->getArg(0)).c_str()) * factor); return (atof(getArgumentName(ce->getArg(0)).c_str()) * factor);
} }
return factor;
} }
string SuspensionAutomata::getEvent(Stmt * stmt) string SuspensionAutomata::getEvent(Stmt * stmt)
...@@ -874,6 +871,8 @@ string SuspensionAutomata::getEvent(Stmt * stmt) ...@@ -874,6 +871,8 @@ string SuspensionAutomata::getEvent(Stmt * stmt)
if (CXXMemberCallExpr * ce = dyn_cast < CXXMemberCallExpr > (stmt)) { if (CXXMemberCallExpr * ce = dyn_cast < CXXMemberCallExpr > (stmt)) {
return (getArgumentName(ce->getArg(0))); return (getArgumentName(ce->getArg(0)));
} }
return "Error: NONE";
} }
......
...@@ -111,7 +111,7 @@ bool SystemCConsumer::fire() { ...@@ -111,7 +111,7 @@ bool SystemCConsumer::fire() {
FindNotify findNotify{ ef->_entryMethodDecl, _os }; FindNotify findNotify{ ef->_entryMethodDecl, _os };
ef->addNotifys(findNotify); ef->addNotifys(findNotify);
/* /// Does not compile
SuspensionAutomata suspensionAutomata(findWaits.getWaitCalls(), ef->getEntryMethod(), &_context, llvm::errs()); SuspensionAutomata suspensionAutomata(findWaits.getWaitCalls(), ef->getEntryMethod(), &_context, llvm::errs());
if (suspensionAutomata.initialize()) { if (suspensionAutomata.initialize()) {
suspensionAutomata.genSusCFG(); suspensionAutomata.genSusCFG();
...@@ -120,7 +120,7 @@ bool SystemCConsumer::fire() { ...@@ -120,7 +120,7 @@ bool SystemCConsumer::fire() {
//suspensionAutomata.dumpSauto(); //suspensionAutomata.dumpSauto();
ef->addSusCFGAuto(suspensionAutomata); ef->addSusCFGAuto(suspensionAutomata);
} }
*/
_entryFunctionContainerVector.push_back(ef); _entryFunctionContainerVector.push_back(ef);
} }
moduleDeclVec.push_back(md); moduleDeclVec.push_back(md);
...@@ -142,10 +142,13 @@ bool SystemCConsumer::fire() { ...@@ -142,10 +142,13 @@ bool SystemCConsumer::fire() {
else { else {
_os <<"\n Could not find SCMain"; _os <<"\n Could not find SCMain";
} }
FindNetlist findNetlist(scmain.getSCMainFunctionDecl()); FindNetlist findNetlist(scmain.getSCMainFunctionDecl());
findNetlist.dump(); findNetlist.dump();
_systemcModel->addNetlist(findNetlist); _systemcModel->addNetlist(findNetlist);
*/ */
// Generate SAUTO // Generate SAUTO
// Placing it here so that unique SAUTO for each instance // Placing it here so that unique SAUTO for each instance
//Model::moduleMapType moduleMap = _systemcModel->getModuleDecl(); //Model::moduleMapType moduleMap = _systemcModel->getModuleDecl();
...@@ -162,9 +165,9 @@ bool SystemCConsumer::fire() { ...@@ -162,9 +165,9 @@ bool SystemCConsumer::fire() {
SuspensionAutomata suspensionAutomata(entryFunctionContainer.at(j)->getWaitCalls(), entryFunctionContainer.at(j)->getEntryMethod(), &_context, llvm::errs()); SuspensionAutomata suspensionAutomata(entryFunctionContainer.at(j)->getWaitCalls(), entryFunctionContainer.at(j)->getEntryMethod(), &_context, llvm::errs());
if (suspensionAutomata.initialize()) { if (suspensionAutomata.initialize()) {
suspensionAutomata.genSusCFG(); suspensionAutomata.genSusCFG();
//suspensionAutomata.dumpSusCFG(); suspensionAutomata.dumpSusCFG();
suspensionAutomata.genSauto(); suspensionAutomata.genSauto();
//suspensionAutomata.dumpSauto(); suspensionAutomata.dumpSauto();
entryFunctionContainer.at(j)->addSusCFGAuto(suspensionAutomata); entryFunctionContainer.at(j)->addSusCFGAuto(suspensionAutomata);
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment