Commit ba54bdf4 authored by rmrf's avatar rmrf
Browse files

Clean up code

parent 9bd7b4c0
...@@ -17,39 +17,37 @@ bool SystemCConsumer::postFire() { ...@@ -17,39 +17,37 @@ bool SystemCConsumer::postFire() {
bool SystemCConsumer::fire() { bool SystemCConsumer::fire() {
TranslationUnitDecl *tu = _context.getTranslationUnitDecl(); TranslationUnitDecl *tu{ _context.getTranslationUnitDecl() };
// Reflection database. // Reflection database.
_systemcModel = new Model(); _systemcModel = new Model{};
// Find the sc_modules // Find the sc_modules
SCModules scmod(tu, _os); SCModules scmod{ tu, _os };
// ANI : Do we need FindGlobalEvents? // ANI : Do we need FindGlobalEvents?
FindGlobalEvents fglobals(tu, _os); FindGlobalEvents fglobals{ tu, _os };
FindGlobalEvents::globalEventMapType eventMap = fglobals.getEventMap(); FindGlobalEvents::globalEventMapType eventMap { fglobals.getEventMap() };
_systemcModel->addGlobalEvents(eventMap); _systemcModel->addGlobalEvents(eventMap);
SCModules::moduleMapType scmodules = scmod.getSystemCModulesMap(); SCModules::moduleMapType scmodules{ scmod.getSystemCModulesMap() };
for ( SCModules::moduleMapType::iterator mit = scmodules.begin(), for ( SCModules::moduleMapType::iterator mit = scmodules.begin(),
mitend = scmodules.end(); mit != mitend; ++mit ) { mitend = scmodules.end(); mit != mitend; ++mit ) {
ModuleDecl *md = new ModuleDecl(mit->first, mit->second); ModuleDecl *md = new ModuleDecl{ mit->first, mit->second };
_systemcModel->addModuleDecl(md); _systemcModel->addModuleDecl(md);
} }
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Find the sc_main // Find the sc_main
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
FindSCMain scmain(tu, _os); FindSCMain scmain{ tu, _os };
if ( scmain.isSCMainFound() ) { if ( scmain.isSCMainFound() ) {
FunctionDecl *fnDecl = scmain.getSCMainFunctionDecl(); FunctionDecl *fnDecl{ scmain.getSCMainFunctionDecl() };
FindSimTime scstart(fnDecl, _os); FindSimTime scstart{ fnDecl, _os };
_systemcModel->addSimulationTime(scstart.returnSimTime()); _systemcModel->addSimulationTime( scstart.returnSimTime() );
} else { } else {
_os <<"\n Could not find SCMain"; _os <<"\n Could not find SCMain";
} }
...@@ -57,61 +55,60 @@ bool SystemCConsumer::fire() { ...@@ -57,61 +55,60 @@ bool SystemCConsumer::fire() {
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Find the netlist. // Find the netlist.
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
FindNetlist findNetlist(scmain.getSCMainFunctionDecl()); FindNetlist findNetlist{ scmain.getSCMainFunctionDecl() };
findNetlist.dump(); findNetlist.dump();
_systemcModel->addNetlist(findNetlist); _systemcModel->addNetlist(findNetlist);
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
// Figure out the module map. // Figure out the module map.
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
Model::moduleMapType moduleMap = _systemcModel->getModuleDecl(); Model::moduleMapType moduleMap{ _systemcModel->getModuleDecl() };
for (Model::moduleMapType::iterator mit = moduleMap.begin(), mitend = moduleMap.end(); mit != mitend; mit++) { for (Model::moduleMapType::iterator mit = moduleMap.begin(), mitend = moduleMap.end(); mit != mitend; mit++) {
ModuleDecl *mainmd = mit->second; ModuleDecl *mainmd{ mit->second };
int numInstances = mainmd->getNumInstances(); int numInstances{ mainmd->getNumInstances() };
vector<ModuleDecl*> moduleDeclVec; vector<ModuleDecl*> moduleDeclVec;
_os << "\n"; _os << "\n";
_os <<"For module: " << mit->first <<" num instance : " << numInstances; _os <<"For module: " << mit->first <<" num instance : " << numInstances;
for (unsigned int num {0}; num < numInstances; ++num ) { for (unsigned int num{0}; num < numInstances; ++num ) {
ModuleDecl *md = new ModuleDecl(); ModuleDecl *md = new ModuleDecl{};
vector < EntryFunctionContainer * >_entryFunctionContainerVector; vector <EntryFunctionContainer *> _entryFunctionContainerVector;
FindConstructor constructor(mainmd->getModuleClassDecl(), _os); FindConstructor constructor{ mainmd->getModuleClassDecl(), _os };
md->addConstructor(constructor.returnConstructorStmt()); md->addConstructor(constructor.returnConstructorStmt());
FindPorts ports(mainmd->getModuleClassDecl(), _os); FindPorts ports{ mainmd->getModuleClassDecl(), _os };
md->addInputPorts(ports.getInputPorts()); md->addInputPorts( ports.getInputPorts() );
md->addOutputPorts(ports.getOutputPorts()); md->addOutputPorts( ports.getOutputPorts() );
md->addInputOutputPorts(ports.getInputOutputPorts()); md->addInputOutputPorts( ports.getInputOutputPorts() );
FindTLMInterfaces findTLMInterfaces(mainmd->getModuleClassDecl(), _os); FindTLMInterfaces findTLMInterfaces{ mainmd->getModuleClassDecl(), _os };
md->addInputInterfaces(findTLMInterfaces.getInputInterfaces()); md->addInputInterfaces( findTLMInterfaces.getInputInterfaces() );
md->addOutputInterfaces(findTLMInterfaces.getOutputInterfaces()); md->addOutputInterfaces( findTLMInterfaces.getOutputInterfaces() );
md->addInputOutputInterfaces(findTLMInterfaces.getInputOutputInterfaces()); md->addInputOutputInterfaces( findTLMInterfaces.getInputOutputInterfaces() );
FindSignals signals(mainmd->getModuleClassDecl(), _os); FindSignals signals{ mainmd->getModuleClassDecl(), _os };
md->addSignals(signals.getSignals()); md->addSignals( signals.getSignals() );
FindEntryFunctions findEntries(mainmd->getModuleClassDecl(), _os); FindEntryFunctions findEntries{ mainmd->getModuleClassDecl(), _os };
FindEntryFunctions::entryFunctionVectorType * entryFunctions = findEntries.getEntryFunctions(); FindEntryFunctions::entryFunctionVectorType *entryFunctions{ findEntries.getEntryFunctions() };
md->addProcess(entryFunctions); md->addProcess( entryFunctions );
for (size_t i = 0; i < entryFunctions->size(); i++) { for (size_t i = 0; i < entryFunctions->size(); i++) {
EntryFunctionContainer *ef = (*entryFunctions)[i]; EntryFunctionContainer *ef{ (*entryFunctions)[i] };
FindSensitivity findSensitivity(constructor.returnConstructorStmt(), _os); FindSensitivity findSensitivity{ constructor.returnConstructorStmt(), _os };
ef->addSensitivityInfo(findSensitivity); ef->addSensitivityInfo(findSensitivity);
if (ef->getEntryMethod() == nullptr) { if ( ef->getEntryMethod() == nullptr ) {
_os << "ERROR"; _os << "ERROR";
continue; continue;
} }
FindWait findWaits(ef->getEntryMethod(), _os); FindWait findWaits{ ef->getEntryMethod(), _os };
ef->addWaits(findWaits); ef->addWaits(findWaits);
FindNotify findNotify(ef->_entryMethodDecl, _os); FindNotify findNotify{ ef->_entryMethodDecl, _os };
ef->addNotifys(findNotify); ef->addNotifys(findNotify);
/* /*
...@@ -119,19 +116,18 @@ bool SystemCConsumer::fire() { ...@@ -119,19 +116,18 @@ bool SystemCConsumer::fire() {
if (suspensionAutomata.initialize()) { if (suspensionAutomata.initialize()) {
suspensionAutomata.genSusCFG(); suspensionAutomata.genSusCFG();
//suspensionAutomata.dumpSusCFG(); //suspensionAutomata.dumpSusCFG();
suspensionAutomata.genSauto(); suspensionAutomata.genSauto();
//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);
} }
_systemcModel->addModuleDeclInstances(mainmd, moduleDeclVec); _systemcModel->addModuleDeclInstances(mainmd, moduleDeclVec);
} }
/* /*
FindSCMain scmain(tu, _os); FindSCMain scmain(tu, _os);
...@@ -205,11 +201,11 @@ void SystemCConsumer::HandleTranslationUnit(ASTContext & context) { ...@@ -205,11 +201,11 @@ void SystemCConsumer::HandleTranslationUnit(ASTContext & context) {
} }
SystemCConsumer::SystemCConsumer(CompilerInstance & ci) : SystemCConsumer::SystemCConsumer(CompilerInstance & ci) :
_os(llvm::errs()), _os{ llvm::errs() },
_sm(ci.getSourceManager()), _sm{ ci.getSourceManager() },
_context(ci.getASTContext()), _context{ ci.getASTContext() },
_ci(ci), _ci{ ci },
_systemcModel(nullptr) { _systemcModel{ nullptr } {
} }
......
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