Commit bd43b33f authored by Twiga's avatar Twiga

Update.

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