Skip to content

Commit

Permalink
Merge branch 'master' into synthesis-test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuanhao-wu committed Dec 12, 2019
2 parents d5ec31a + e44e977 commit 9366164
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 53 deletions.
4 changes: 3 additions & 1 deletion plugins/xlat/Xlat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ void Xlat::xlatsig(ModuleDecl::signalMapType pmap, hNode::hdlopsEnum h_op,
}

void Xlat::xlattype(FindTemplateTypes *tt, hNodep &h_typeinfo) {
// tt->printTemplateArguments(os, 1);
//tt->printTemplateArguments(os_);

scpar::FindTemplateTypes::type_vector_t ttargs =
tt->getTemplateArgumentsType();
for (auto const &targ : ttargs) {
h_typeinfo->child_list.push_back(
new hNode(targ.getTypeName(), hNode::hdlopsEnum::hType));
const Type * tmpptr = targ.getTypePtr();
(targ.getTypePtr())->dump(os_);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/FindTemplateTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TemplateType::~TemplateType() { type_ptr_ = nullptr; }

string TemplateType::getTypeName() const { return type_name_; }

const Type *TemplateType::getTypePtr() { return type_ptr_; }
const Type *TemplateType::getTypePtr() const { return type_ptr_; }

//////////////////////////////////////////////////////////////////////
// FindTemplateTypes
Expand Down
98 changes: 47 additions & 51 deletions src/FindTemplateTypes.h
Original file line number Diff line number Diff line change
@@ -1,73 +1,69 @@
#ifndef _FIND_TEMPLATE_TYPES_H_
#define _FIND_TEMPLATE_TYPES_H_

#include <string>
#include <vector>
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/Type.h"
#include "llvm/Support/raw_ostream.h"
#include <string>
#include <vector>

#include <iostream>

namespace scpar {
using namespace clang;
using namespace std;
using namespace clang;
using namespace std;

// This class holds the name of the type, and a pointer to the
// type object.
class TemplateType {
public:
TemplateType( string, const Type* );
~TemplateType( );
TemplateType( const TemplateType& );
// This class holds the name of the type, and a pointer to the
// type object.
class TemplateType {
public:
TemplateType(string, const Type *);
~TemplateType();
TemplateType(const TemplateType &);

string getTypeName() const;
const Type* getTypePtr();
string getTypeName() const;
const Type *getTypePtr() const;

private:
string type_name_;
const Type * type_ptr_;
};
private:
string type_name_;
const Type *type_ptr_;
};

// This class is going to find the arguments from templates
class FindTemplateTypes : public RecursiveASTVisitor<FindTemplateTypes> {
public:
/// Typedefs
typedef TemplateType TemplateTypePtr;
//typedef vector< TemplateTypePtr > type_vector_t_new;
//typedef vector<pair<string, const Type *>> type_vector_t;
typedef vector< TemplateTypePtr > type_vector_t;
typedef vector< TemplateTypePtr > argVectorType;
//typedef vector<pair<string, const Type *>> argVectorType;
// This class is going to find the arguments from templates
class FindTemplateTypes : public RecursiveASTVisitor<FindTemplateTypes> {
public:
/// Typedefs
typedef TemplateType TemplateTypePtr;
typedef vector<TemplateTypePtr> type_vector_t;
typedef vector<TemplateTypePtr> argVectorType;

// Constructor
FindTemplateTypes();
// Constructor
FindTemplateTypes();

/// Copy constructor
FindTemplateTypes(const FindTemplateTypes &rhs);
FindTemplateTypes(const FindTemplateTypes *rhs);
/// Copy constructor
FindTemplateTypes(const FindTemplateTypes &rhs);
FindTemplateTypes(const FindTemplateTypes *rhs);

~FindTemplateTypes();
string getTemplateType();
bool VisitType(Type *type);
bool VisitIntegerLiteral(IntegerLiteral *l);
type_vector_t Enumerate(const Type *type);
type_vector_t getTemplateArgumentsType();
void printTemplateArguments(llvm::raw_ostream &os);
vector<string> getTemplateArguments();
size_t size();
~FindTemplateTypes();
string getTemplateType();
bool VisitType(Type *type);
bool VisitIntegerLiteral(IntegerLiteral *l);
type_vector_t Enumerate(const Type *type);
type_vector_t getTemplateArgumentsType();
void printTemplateArguments(llvm::raw_ostream &os);
vector<string> getTemplateArguments();
size_t size();

private:
// (string, Type*)
// Classes such as sc_port and sc_in can have nested types within it.
// For example: sc_in< sc_int<16> >
// The general way to handle this would be to have a vector starting from the
// outside type to the inside type.
private:
// (string, Type*)
// Classes such as sc_port and sc_in can have nested types within it.
// For example: sc_in< sc_int<16> >
// The general way to handle this would be to have a vector starting from the
// outside type to the inside type.

type_vector_t template_types_;
//type_vector_t_new template_types_new_;
};
} // namespace scpar
type_vector_t template_types_;
};
} // namespace scpar
#endif
1 change: 1 addition & 0 deletions src/Matchers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ finder.addMatcher( match_non_sc_types, this );
void ModuleDeclarationMatcher::run( const MatchFinder::MatchResult &result ) {

if ( auto decl = const_cast<CXXRecordDecl*>(result.Nodes.getNodeAs<CXXRecordDecl>("sc_module")) ) {

cout << " Found sc_module: " << decl->getIdentifier()->getNameStart() << endl;
std::string name{ decl->getIdentifier()->getNameStart() };
found_declarations_.push_back( std::make_tuple(name, decl) );
Expand Down

0 comments on commit 9366164

Please sign in to comment.