Commit bd43b33f authored by Twiga's avatar Twiga
Browse files

Update.

parent be634884
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# Path for where the binaries are for clang # Path for where the binaries are for clang
# SET this. # SET this.
export LLVM_BUILD_DIR=/home/$USER/clang-7.0.0/ export LLVM_BUILD_DIR=/home/$USER/bin/clang-7.0.0/
# Path where SystemC is installed # Path where SystemC is installed
# SET this. # SET this.
......
#include "FindSignals.h" #include "FindSignals.h"
#include "FindTemplateTypes.h" #include "FindTemplateTypes.h"
using namespace scpar; using namespace scpar;
FindSignals::~FindSignals () FindSignals::~FindSignals() {
{
// _os << "[[ Destructor FindSignals ]]\n"; // _os << "[[ Destructor FindSignals ]]\n";
for (FindSignals::signalMapType::iterator sit = _signals->begin (); for (FindSignals::signalMapType::iterator sit = _signals->begin();
sit != _signals->end (); sit++) sit != _signals->end(); sit++) {
{
delete sit->second; delete sit->second;
} }
_signals->clear (); _signals->clear();
delete _signals; delete _signals;
} }
FindSignals::FindSignals (CXXRecordDecl * d, llvm::raw_ostream & os): FindSignals::FindSignals (CXXRecordDecl * d, llvm::raw_ostream & os) :
_os (os) _os(os) {
{ _signals = new FindSignals::signalMapType();
_signals = new FindSignals::signalMapType ();
state = 0; state = 0;
TraverseDecl (d); TraverseDecl(d);
} }
bool FindSignals::VisitFieldDecl( FieldDecl * fd ) {
QualType q = fd->getType();
bool FindSignals::VisitFieldDecl (FieldDecl * fd) if (IdentifierInfo * info = fd->getIdentifier()) {
{
// _os << "####################### FindSignals::VisitFieldDecl\n ";
QualType
q = fd->getType ();
if (IdentifierInfo * info = fd->getIdentifier ())
{
// fname = info->getNameStart(); // fname = info->getNameStart();
// _os << "\n+ Name: " << info->getNameStart(); // _os << "\n+ Name: " << info->getNameStart();
// _os << "\n+ Type: " << q.getAsString(); // _os << "\n+ Type: " << q.getAsString();
// _os << "\n+ also name: " << fd->getNameAsString(); // _os << "\n+ also name: " << fd->getNameAsString();
/// We are going to store these. So use pointers. /// We are going to store these. So use pointers.
const Type * const Type *tp = q.getTypePtr();
tp = q.getTypePtr (); FindTemplateTypes *te = new FindTemplateTypes ();
FindTemplateTypes *
te = new FindTemplateTypes ();
te->Enumerate (tp); te->Enumerate (tp);
// te->printTemplateArguments(_os); // te->printTemplateArguments(_os);
string string tt = te->getTemplateType ();
tt = te->getTemplateType ();
// _os << "OUTPUT ============ " << tt << "\n"; // _os << "OUTPUT ============ " << tt << "\n";
if ((signed) tt.find ("sc_signal") == -1) if ((signed) tt.find ("sc_signal") == -1) {
{ delete te;
delete
te;
return true; return true;
} }
SignalContainer * SignalContainer *sc = new SignalContainer (fd->getNameAsString (), te, fd);
sc = new SignalContainer (fd->getNameAsString (), te, fd);
_signals->insert (FindSignals::
signalPairType (fd->getNameAsString (), sc));
_signals->insert (FindSignals::signalPairType (fd->getNameAsString (), sc));
} }
return true; return true;
} }
FindSignals::signalMapType * FindSignals::getSignals () FindSignals::signalMapType * FindSignals::getSignals() {
{
return _signals; return _signals;
} }
void void FindSignals::dump() {
FindSignals::dump (
)
{
_os << "\n================= Find Signals ================\n"; _os << "\n================= Find Signals ================\n";
for (FindSignals::signalMapType::iterator sit = _signals->begin (); for (FindSignals::signalMapType::iterator sit = _signals->begin();
sit != _signals->end (); sit++) sit != _signals->end (); sit++) {
{
_os << sit->second; _os << sit->second;
sit->second->dump (_os); sit->second->dump (_os);
} }
......
...@@ -12,24 +12,25 @@ namespace scpar { ...@@ -12,24 +12,25 @@ namespace scpar {
using namespace std; using namespace std;
struct SignalContainer { struct SignalContainer {
SignalContainer (string n, FindTemplateTypes * tt, FieldDecl * fd) : SignalContainer( string n, FindTemplateTypes *tt, FieldDecl *fd ) :
_name (n), _name{n},
_template (tt), _template{tt},
_astNode (fd) { _astNode{fd} {
} }
~SignalContainer () { ~SignalContainer () {
// Only thing I create is FindTemplateType. Rest should be deleted by clang. // Only thing I create is FindTemplateType. Rest should be deleted by clang.
llvm::errs () << "[[ Destructor SignalContainer ]]\n"; // llvm::errs () << "[[ Destructor SignalContainer ]]\n";
delete _template; delete _template;
} }
SignalContainer (const SignalContainer & from) { SignalContainer( const SignalContainer &from ) {
_name = from._name; _name = from._name;
_template = new FindTemplateTypes (*(from._template)); _template = new FindTemplateTypes (*(from._template));
_astNode = from._astNode; _astNode = from._astNode;
} }
void dump (raw_ostream & os ) { void dump ( llvm::raw_ostream &os ) {
os << "[SignalContainer " << _name << " FindTemplateType " << _template os << "[SignalContainer " << _name << " FindTemplateType " << _template
<< " FieldDecl " << _astNode << "\n"; << " FieldDecl " << _astNode << "\n";
_template->printTemplateArguments (os); _template->printTemplateArguments (os);
...@@ -37,16 +38,16 @@ namespace scpar { ...@@ -37,16 +38,16 @@ namespace scpar {
} }
FindTemplateTypes *getTemplateTypes() { FindTemplateTypes *getTemplateTypes() {
assert (!(_template == NULL)); assert (!(_template == nullptr ));
return _template; return _template;
} }
FieldDecl *getASTNode() { FieldDecl *getASTNode() {
assert (!(_astNode == NULL)); assert (!(_astNode == nullptr ));
return _astNode; return _astNode;
} }
string getName () { string getName() {
return _name; return _name;
} }
...@@ -62,17 +63,16 @@ namespace scpar { ...@@ -62,17 +63,16 @@ namespace scpar {
typedef pair < string, SignalContainer* > signalPairType; typedef pair < string, SignalContainer* > signalPairType;
typedef map < string, SignalContainer * > signalMapType; typedef map < string, SignalContainer * > signalMapType;
FindSignals(CXXRecordDecl *, llvm::raw_ostream & ); FindSignals(CXXRecordDecl *, llvm::raw_ostream & );
virtual ~FindSignals(); virtual ~FindSignals();
virtual bool VisitFieldDecl (FieldDecl *); virtual bool VisitFieldDecl( FieldDecl * );
// virtual bool VisitMemberExpr(MemberExpr* ) ;
signalMapType *getSignals(); signalMapType *getSignals();
void dump(); void dump();
private: private:
llvm::raw_ostream & _os; llvm::raw_ostream &_os;
int state; int state;
signalMapType *_signals; signalMapType *_signals;
}; };
......
...@@ -101,8 +101,7 @@ void Model::updateModuleDecl() { ...@@ -101,8 +101,7 @@ void Model::updateModuleDecl() {
} }
} }
void Model::addSCModules(SCModules * m) void Model::addSCModules(SCModules * m) {
{
SCModules::moduleMapType mods = m->getSystemCModulesMap(); SCModules::moduleMapType mods = m->getSystemCModulesMap();
for (SCModules::moduleMapType::iterator mit = mods.begin(); for (SCModules::moduleMapType::iterator mit = mods.begin();
...@@ -111,8 +110,7 @@ void Model::addSCModules(SCModules * m) ...@@ -111,8 +110,7 @@ void Model::addSCModules(SCModules * m)
} }
} }
Model::moduleMapType Model::getModuleDecl() Model::moduleMapType Model::getModuleDecl() {
{
return modules_; return modules_;
} }
...@@ -125,8 +123,7 @@ Model::moduleInstanceMapType Model::getModuleInstanceMap() { ...@@ -125,8 +123,7 @@ Model::moduleInstanceMapType Model::getModuleInstanceMap() {
return module_instance_map_; return module_instance_map_;
} }
Model::eventMapType Model::getEventMapType() Model::eventMapType Model::getEventMapType() {
{
return event_map_; return event_map_;
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "EntryFunctionContainer.h" #include "EntryFunctionContainer.h"
#include "FindNetlist.h" #include "FindNetlist.h"
#include "SCuitable/FindGPUMacro.h" #include "SCuitable/FindGPUMacro.h"
namespace scpar { namespace scpar {
using namespace clang; using namespace clang;
using namespace std; using namespace std;
......
...@@ -207,8 +207,8 @@ void SystemCConsumer::HandleTranslationUnit(ASTContext & context) { ...@@ -207,8 +207,8 @@ 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()),
_ci(ci),
_context(ci.getASTContext()), _context(ci.getASTContext()),
_ci(ci),
_systemcModel(nullptr) { _systemcModel(nullptr) {
} }
......
...@@ -76,7 +76,7 @@ namespace scpar { ...@@ -76,7 +76,7 @@ namespace scpar {
ASTContext & _context; ASTContext & _context;
private: private:
CompilerInstance & _ci; CompilerInstance &_ci;
//ASTContext& _context; //ASTContext& _context;
Model *_systemcModel; Model *_systemcModel;
......
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