Commit 2a6bb79e authored by rmrf's avatar rmrf
Browse files

SAUTO requires a careful inspection and rework.

For the time being, USE_SAUTO is not defined by default. This means that
we do not need to compile the respective files into the libsystemc-clang
library.  The CMakeLists adjust that.

The source code must also use #ifdef and #endif pairs to isolate the
code that generates and dumps the SAUTO.  This has also been added.

The focus as of now is going to be primarily on sc_method processes.
parent 49d75bfe
......@@ -29,12 +29,12 @@ set (LLVM_BUILD_DIR
)
set (CMAKE_CXX_FLAGS
"$ENV{LLVM_CXX_FLAGS} $ENV{CMAKE_CXX_FLAGS} -DUSE_SAUTO=off -Wcovered-switch-default"
"$ENV{LLVM_CXX_FLAGS} $ENV{CMAKE_CXX_FLAGS} -Wcovered-switch-default -g"
)
if (USE_SAUTO)
set (CMAKE_CXX_FLAGS
"-DUSE_SAUTO=on ${CMAKE_CXX_FLAGS}"
"-DUSE_SAUTO ${CMAKE_CXX_FLAGS}"
)
endif(USE_SAUTO)
......
if (USE_SAUTO)
add_library (libsystemc-clang
Automata.cpp
SuspensionAutomata.cpp
SCuitable/GlobalSuspensionAutomata.cpp
SCuitable/FindGPUMacro.cpp
)
endif (USE_SAUTO)
add_library (libsystemc-clang
ModuleDecl.cpp
FindModule.cpp
......@@ -19,11 +28,11 @@ add_library (libsystemc-clang
FindNetlist.cpp
FindArgument.cpp
FindTemplateParameters.cpp
Automata.cpp
SuspensionAutomata.cpp
SCuitable/GlobalSuspensionAutomata.cpp
SCuitable/FindGPUMacro.cpp
####################################
# Automata.cpp
# SuspensionAutomata.cpp
# SCuitable/GlobalSuspensionAutomata.cpp
# SCuitable/FindGPUMacro.cpp
#####################################
#From here the files are for the reflection database
####################################
#Utility.cpp
......
......@@ -80,6 +80,7 @@ void EntryFunctionContainer::addWaits(FindWait &f) {
}
void EntryFunctionContainer::addSusCFGAuto(SuspensionAutomata &s) {
#ifdef USE_SAUTO
_susCFG = s.getSusCFG();
_susAuto = s.getSauto();
......@@ -92,6 +93,7 @@ void EntryFunctionContainer::addSusCFGAuto(SuspensionAutomata &s) {
s.getSauto()));
}
*/
#endif
}
void EntryFunctionContainer::addNotifys(FindNotify &f) {
......@@ -110,6 +112,7 @@ void EntryFunctionContainer::addNotifys(FindNotify &f) {
void EntryFunctionContainer::dumpSusCFG(raw_ostream &os) {
os << "\n#############################################";
#ifdef USE_SAUTO
SuspensionAutomata::susCFGVectorType susCFGVector = _susCFG;
for (unsigned int i = 0; i < susCFGVector.size(); i++) {
......@@ -137,15 +140,18 @@ void EntryFunctionContainer::dumpSusCFG(raw_ostream &os) {
}
}
}
#endif
}
void EntryFunctionContainer::dumpSauto(raw_ostream &os) {
#ifdef USE_SAUTO
vector<Transition *> transitionVector = _susAuto;
os << "\n Size of transitionVector : " << transitionVector.size();
for (unsigned int i = 0; i < transitionVector.size(); i++) {
Transition *t = transitionVector.at(i);
t->dump(os);
}
#endif
}
void EntryFunctionContainer::dump(raw_ostream &os, int tabn) {
......
......@@ -156,11 +156,10 @@ SuspensionAutomata::SuspensionAutomata(vector<WaitContainer *> waitCalls,
raw_ostream &os)
: _d(d), _a(a), _os(os) {
for (int i = 0; i < waitCalls.size(); i++) {
WaitContainer *wc = waitCalls.at(i);
for (std::size_t i {0}; i < waitCalls.size(); i++) {
WaitContainer *wc {waitCalls.at(i)};
_waitCalls.push_back(wc->getASTNode());
}
//_waitCalls = waitCalls;
}
SuspensionAutomata::~SuspensionAutomata() {}
......@@ -187,8 +186,8 @@ bool SuspensionAutomata::isWaitCall(const CFGStmt *cs) {
if (!m) {
return f;
}
for (int i = 0; i < _waitCalls.size(); i++) {
CallExpr *ce = _waitCalls.at(i);
for (std::size_t i {0}; i < _waitCalls.size(); i++) {
CallExpr *ce {_waitCalls.at(i)};
if (m == ce) {
f = true;
}
......@@ -291,7 +290,7 @@ void SuspensionAutomata::genSusCFG() {
CFGBlock *prev = NULL;
SusCFG *prevBlock = NULL;
for (unsigned int i = 0; i < splitBlocksVector.size(); i++) {
for (std::size_t i = 0; i < splitBlocksVector.size(); i++) {
CFGBlock *current = splitBlocksVector.at(i);
SusCFG *splitBlock =
new SusCFG(const_cast<CFGBlock *>(splitBlocksVector.at(i)));
......@@ -303,7 +302,7 @@ void SuspensionAutomata::genSusCFG() {
if (pre.size() != 0) {
// add trailing statements to post block wait stmt
CFGBlock *newCFGBlock = _cfg->createBlock();
for (unsigned int j = 0; j < pre.size(); j++) {
for (std::size_t j{0}; j < pre.size(); j++) {
newCFGBlock->appendStmt(const_cast<Stmt *>(pre.at(j)->getStmt()),
_cfg->getBumpVectorContext());
}
......@@ -408,7 +407,7 @@ void SuspensionAutomata::genSusCFG() {
site = b->succ_end();
sit != site; sit++) {
const CFGBlock *succBlock = *sit;
SusCFG *tmpBlock;
SusCFG *tmpBlock{nullptr};
if (succBlock) {
if (susCFGBlockMap.find(const_cast<CFGBlock *>(succBlock)) ==
......@@ -488,11 +487,16 @@ vector<SusCFG *> SuspensionAutomata::modifDFS(SusCFG *block,
// When adding blocks to traversed blocks, check if the last node prior to
// the wait call has which branch discovered. Also need to check
// terminator block or block 0
//
if (susCFGSuccIDMap.find(currentBlock) == susCFGSuccIDMap.end()) {
// currentBlock is not our concern yet, so insert the 0th successive
// block
//_os <<"\n Current Block : " <<currentBlock->getBlockID()<<" not of
//concern";
//
// TODO: BUG: There is an issue here.
// There exists a getSuccBlocks(), but it happens to be empty.
// This happens when there is a thread that uses a wait(), but no while loop.
if (currentBlock->getSuccBlocks().at(0)->isParentBlock()) {
if (!isFound(
visitedBlocks,
......@@ -571,7 +575,7 @@ vector<SusCFG *> SuspensionAutomata::modifDFS(SusCFG *block,
void SuspensionAutomata::checkInsert(vector<SusCFG *> source,
vector<SusCFG *> &target) {
bool duplicate;
for (int i = 0; i < source.size(); i++) {
for (std::size_t i {0}; i < source.size(); i++) {
duplicate = false;
for (int j = 0; j < target.size(); j++) {
if (source.at(i) == target.at(j)) {
......@@ -588,7 +592,7 @@ void SuspensionAutomata::checkInsert(vector<SusCFG *> source,
void SuspensionAutomata::genSauto() {
susCFGVectorType susCFGVector = _susCFGVector;
susCFGVectorType waitBlocks;
for (int i = 0; i < susCFGVector.size(); i++) {
for (std::size_t i {0}; i < susCFGVector.size(); i++) {
if (susCFGVector.at(i)->isWaitBlock() || i == 0) {
waitBlocks.push_back(susCFGVector.at(i));
State *state = new State(susCFGVector.at(i), false, false, false, false);
......@@ -602,7 +606,7 @@ void SuspensionAutomata::genSauto() {
}
}
for (int i = 0; i < waitBlocks.size(); i++) {
for (std::size_t i {0}; i < waitBlocks.size(); i++) {
SusCFG *waitBlock = waitBlocks.at(i);
......@@ -631,11 +635,11 @@ void SuspensionAutomata::genSauto() {
//_os <<"\n Transition Blocks : ";
backTrackCodeBlocks.clear();
for (int j = 0; j < transitionCodeBlocks.size(); j++) {
for (std::size_t j {0}; j < transitionCodeBlocks.size(); j++) {
backTrackCodeBlocks.push_back(transitionCodeBlocks.at(j));
//_os <<" "<<transitionCodeBlocks.at(j)->getBlockID();;
}
int j;
std::size_t j{};
for (j = backTrackCodeBlocks.size() - 2; j >= 0; j--) {
if (backTrackCodeBlocks.at(j)->getSuccBlocks().size() > 1) {
//_os <<"\n Block : " <<backTrackCodeBlocks.at(j)->getBlockID()<<" has
......@@ -765,9 +769,8 @@ bool SuspensionAutomata::isTimedWait(Stmt *stmt) {
}
return false;
}
/*
string SuspensionAutomata::getArgumentName(Expr * arg)
{
string SuspensionAutomata::getArgumentName(Expr * arg) {
if (arg == NULL)
return string("NULL");
......@@ -783,7 +786,6 @@ string SuspensionAutomata::getArgumentName(Expr * arg)
// _os << ", argument: " << s.str() << "\n";
return s.str();
}
*/
bool SuspensionAutomata::isDeltaWait(Stmt *stmt) {
......
......@@ -148,7 +148,7 @@ public:
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();
......
......@@ -120,17 +120,19 @@ bool SystemCConsumer::fire() {
FindNotify findNotify{ef->_entryMethodDecl, os_};
ef->addNotifys(findNotify);
#ifdef USE_SAUTO
/// Does not compile
SuspensionAutomata suspensionAutomata(findWaits.getWaitCalls(),
ef->getEntryMethod(), &_context,
llvm::errs());
if (suspensionAutomata.initialize()) {
suspensionAutomata.genSusCFG();
// suspensionAutomata.dumpSusCFG();
suspensionAutomata.dumpSusCFG();
suspensionAutomata.genSauto();
// suspensionAutomata.dumpSauto();
suspensionAutomata.dumpSauto();
ef->addSusCFGAuto(suspensionAutomata);
}
#endif
_entryFunctionContainerVector.push_back(ef);
}
......@@ -159,6 +161,8 @@ findNetlist.dump();
_systemcModel->addNetlist(findNetlist);
*/
// Only do this if SAUTO flag is set.
#ifdef USE_SAUTO
// Generate SAUTO
// Placing it here so that unique SAUTO for each instance
// Model::moduleMapType moduleMap = _systemcModel->getModuleDecl();
......@@ -188,7 +192,8 @@ _systemcModel->addNetlist(findNetlist);
}
}
}
}
}
#endif
os_ << "\n";
os_ << "\n## SystemC model\n";
......
#include "systemc.h"
#include <iostream>
SC_MODULE( test ){
sc_in<int> in;
sc_out<int> out;
sc_signal<int> test_signal;
void hello() {
std::cout << "write 1" << std::endl;
out.write(1);
wait();
/*
std::cout << "write 2" << std::endl;
out.write(2);
wait(sc_time(100, SC_NS));
*/
}
SC_CTOR( test ) {
SC_THREAD(hello);
}
};
int sc_main(int argc, char *argv[]) {
sc_signal<int> sig1;
test test_instance("testing");
test_instance.in(sig1);
test_instance.out(sig1);
sc_start();
return 0;
}
Markdown is supported
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