Commit 731af1ee authored by rmrf's avatar rmrf

Working on PortDecl

parent 7e25e8e5
add_library (libsystemc-clang
ModuleDecl.cpp
FindModule.cpp
SCModules.cpp
FindSCModules.cpp
FindSCMain.cpp
FindPorts.cpp
FindTLMInterfaces.cpp
......
#include "SCModules.h"
#include "FindSCModules.h"
#include "FindModule.h"
#include "clang/AST/ASTContext.h"
using namespace scpar;
SCModules::SCModules(TranslationUnitDecl *tuDecl, llvm::raw_ostream &os)
FindSCModules::FindSCModules(TranslationUnitDecl *tuDecl, llvm::raw_ostream &os)
: _os(os) {
assert(!(tuDecl == nullptr));
TraverseDecl(tuDecl);
}
SCModules::~SCModules() {}
FindSCModules::~FindSCModules() {}
bool SCModules::VisitCXXRecordDecl(CXXRecordDecl *cxxDecl) {
bool FindSCModules::VisitCXXRecordDecl(CXXRecordDecl *cxxDecl) {
FindModule mod(cxxDecl, _os);
if (!mod.isSystemCModule()) {
......@@ -22,11 +22,11 @@ bool SCModules::VisitCXXRecordDecl(CXXRecordDecl *cxxDecl) {
return true;
}
SCModules::moduleMapType SCModules::getSystemCModulesMap() {
FindSCModules::moduleMapType FindSCModules::getSystemCModulesMap() {
return _moduleMap;
}
void SCModules::dump() {
void FindSCModules::dump() {
_os << "\n================= SCModules ================";
_os << "\n Print SystemC Module Map";
for (moduleMapType::iterator mit = _moduleMap.begin();
......
#ifndef _SC_MODULES_H_
#define _SC_MODULES_H_
#ifndef _FIND_SC_MODULES_H_
#define _FIND_SC_MODULES_H_
#include "clang/AST/DeclCXX.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "llvm/Support/raw_ostream.h"
......@@ -11,13 +11,13 @@ namespace scpar {
using namespace clang;
using namespace std;
class SCModules : public RecursiveASTVisitor<SCModules> {
class FindSCModules : public RecursiveASTVisitor<FindSCModules> {
public:
typedef map<string, CXXRecordDecl *> moduleMapType;
typedef pair<string, CXXRecordDecl *> modulePairType;
SCModules(TranslationUnitDecl *, llvm::raw_ostream &);
virtual ~SCModules();
FindSCModules(TranslationUnitDecl *, llvm::raw_ostream &);
virtual ~FindSCModules();
virtual bool VisitCXXRecordDecl(CXXRecordDecl *);
moduleMapType getSystemCModulesMap();
void dump();
......
#include "Model.h"
#include "SCModules.h"
//#include "FindSCModules.h"
#include <string>
using namespace scpar;
......@@ -104,10 +104,10 @@ void Model::updateModuleDecl() {
}
}
void Model::addSCModules(SCModules *m) {
SCModules::moduleMapType mods = m->getSystemCModulesMap();
void Model::addSCModules(FindSCModules *m) {
FindSCModules::moduleMapType mods = m->getSystemCModulesMap();
for (SCModules::moduleMapType::iterator mit = mods.begin(); mit != mods.end();
for (FindSCModules::moduleMapType::iterator mit = mods.begin(); mit != mods.end();
mit++) {
addModuleDecl(new ModuleDecl(mit->first, mit->second));
}
......
......@@ -7,7 +7,7 @@
#include "FindNetlist.h"
#include "FindSimTime.h"
#include "ModuleDecl.h"
#include "SCModules.h"
#include "FindSCModules.h"
#include "SCuitable/FindGPUMacro.h"
#include "clang/AST/DeclCXX.h"
#include <map>
......@@ -37,7 +37,7 @@ public:
Model();
~Model();
void addSCModules(SCModules *);
void addSCModules(FindSCModules *);
void addModuleDecl(ModuleDecl *);
void addModuleDeclInstances(ModuleDecl *, vector<ModuleDecl *>);
void addSimulationTime(FindSimTime::simulationTimeMapType);
......
......@@ -10,7 +10,7 @@ ModuleDecl::ModuleDecl() : module_name_{"NONE"},
constructor_stmt_{nullptr} {}
ModuleDecl::ModuleDecl(const string &name, CXXRecordDecl *decl)
: module_name_{name}, class_decl_{decl} {}
: module_name_{name}, class_decl_{decl} {}
ModuleDecl::~ModuleDecl() {
......@@ -84,7 +84,7 @@ void ModuleDecl::addOutputPorts(FindPorts::PortType p) {
void ModuleDecl::addInputOutputPorts(FindPorts::PortType p) {
for (auto mit : p) {
_ioports.insert(
portPairType(mit.first, new PortDecl(mit.first, mit.second)));
portPairType(mit.first, new PortDecl(mit.first, mit.second)));
}
}
......@@ -113,7 +113,7 @@ void ModuleDecl::addInputOutputInterfaces(FindTLMInterfaces::interfaceType p) {
// p.end(); mit != mite; mit++) {
for (auto mit : p) {
_iointerfaces.insert(
interfacePairType(mit.first, new InterfaceDecl(mit.first, mit.second)));
interfacePairType(mit.first, new InterfaceDecl(mit.first, mit.second)));
}
}
......@@ -150,9 +150,9 @@ void ModuleDecl::addProcess(FindEntryFunctions::entryFunctionVectorType *efv) {
break;
}
}
_processes.insert(
processPairType(entryName, new ProcessDecl(entryType, entryName,
ef->_entryMethodDecl, ef)));
process_map_.insert(
processPairType(entryName, new ProcessDecl(entryType, entryName,
ef->_entryMethodDecl, ef)));
}
}
......@@ -164,7 +164,7 @@ vector<EntryFunctionContainer *> ModuleDecl::getEntryFunctionContainer() {
int ModuleDecl::getNumInstances() { return _instanceList.size(); }
ModuleDecl::processMapType ModuleDecl::getProcessMap() { return _processes; }
ModuleDecl::processMapType ModuleDecl::getProcessMap() { return process_map_; }
ModuleDecl::portMapType ModuleDecl::getOPorts() { return _oports; }
......@@ -216,10 +216,10 @@ void ModuleDecl::dumpSignalBinding(raw_ostream &os, int tabn) {
}
void ModuleDecl::dumpProcesses(raw_ostream &os, int tabn) {
if (_processes.size() == 0) {
if ( process_map_.empty() ) {
os << "none \n";
} else {
for (auto pit : _processes) {
for (auto pit : process_map_) {
ProcessDecl *pd = pit.second;
pd->dump( os );
os << "\n";
......
......@@ -20,17 +20,21 @@ using namespace std;
class ModuleDecl {
public:
typedef pair<string, Signal *> signalPairType;
typedef map<string, Signal *> signalMapType;
typedef pair<string, Signal* > signalPairType;
typedef map<string, Signal* > signalMapType;
typedef pair<string, PortDecl *> portPairType;
typedef map<string, PortDecl *> portMapType;
// Maps the name of the port with a pointer to a structure that holds
// information about the port.
typedef pair<string, PortDecl* > portPairType;
typedef map<string, PortDecl* > portMapType;
typedef pair<string, InterfaceDecl *> interfacePairType;
typedef map<string, InterfaceDecl *> interfaceMapType;
typedef pair<string, InterfaceDecl* > interfacePairType;
typedef map<string, InterfaceDecl* > interfaceMapType;
typedef pair<string, ProcessDecl *> processPairType;
typedef map<string, ProcessDecl *> processMapType;
// Maps the name of the process with a pointer to a structure that holds
// information about the process.
typedef pair<string, ProcessDecl* > processPairType;
typedef map<string, ProcessDecl* > processMapType;
typedef pair<string, string> moduleProcessPairType;
......@@ -86,7 +90,7 @@ private:
CXXRecordDecl *class_decl_;
Stmt *constructor_stmt_;
processMapType _processes;
processMapType process_map_;
portMapType _iports;
portMapType _oports;
portMapType _ioports;
......
//#include <string>
#include "PortDecl.h"
#include "FindTemplateTypes.h"
using namespace scpar;
using namespace std;
PortDecl::~PortDecl() {
if (template_type_ != nullptr) {
if ( template_type_ != nullptr ) {
delete template_type_;
template_type_ = nullptr;
}
}
PortDecl::PortDecl() : port_name_{"NONE"}, template_type_{nullptr} {}
PortDecl::PortDecl(const string &name, FindTemplateTypes *tt)
: port_name_{name}, template_type_{tt} {}
: port_name_{name}, template_type_{tt} {}
PortDecl::PortDecl(const PortDecl &from) {
port_name_ = from.port_name_;
......@@ -32,4 +33,15 @@ void PortDecl::dump(llvm::raw_ostream &os, int tabn) {
// << template_type_;
os << "Port name: " << port_name_ << " ";
template_type_->printTemplateArguments(os);
dump_json();
}
json PortDecl::dump_json() {
json port_j;
port_j["module_name"] = getName();
//port_j["template_type"]
return port_j;
}
#ifndef _PORT_DECL_H_
#define _PORT_DECL_H_
#include "systemc-clang.h"
#include "json.hpp"
#include <map>
#include <string>
......@@ -10,6 +13,7 @@
namespace scpar {
using namespace clang;
using namespace std;
using json = nlohmann::json;
class PortDecl {
public:
......@@ -29,6 +33,8 @@ public:
// Print
void dump(raw_ostream &, int tabn = 0);
json dump_json();
private:
string port_name_;
FindTemplateTypes *template_type_;
......
......@@ -16,16 +16,16 @@ bool SystemCConsumer::fire() {
_systemcModel = new Model{};
// Find the sc_modules
SCModules scmod{tu, _os};
FindSCModules scmod{tu, _os};
// ANI : Do we need FindGlobalEvents?
FindGlobalEvents fglobals{tu, _os};
FindGlobalEvents::globalEventMapType eventMap{fglobals.getEventMap()};
_systemcModel->addGlobalEvents(eventMap);
SCModules::moduleMapType scmodules{scmod.getSystemCModulesMap()};
FindSCModules::moduleMapType scmodules{scmod.getSystemCModulesMap()};
for (SCModules::moduleMapType::iterator mit = scmodules.begin(),
for (FindSCModules::moduleMapType::iterator mit = scmodules.begin(),
mitend = scmodules.end();
mit != mitend; ++mit) {
ModuleDecl *md = new ModuleDecl{mit->first, mit->second};
......
......@@ -45,7 +45,7 @@ using namespace clang::tooling;
#include "FindTLMInterfaces.h"
#include "FindWait.h"
#include "Model.h"
#include "SCModules.h"
#include "FindSCModules.h"
#include "SCuitable/FindGPUMacro.h"
#include "SCuitable/GlobalSuspensionAutomata.h"
#include "SuspensionAutomata.h"
......
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