Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
caesr-pub
systemc-clang
Commits
6e5991b5
Commit
6e5991b5
authored
Feb 15, 2019
by
rmrf
Browse files
Introduce TemplateType class
parent
e95a4b33
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/FindPorts.cpp
View file @
6e5991b5
...
...
@@ -43,13 +43,14 @@ bool FindPorts::VisitFieldDecl(FieldDecl *fd) {
if
(
args
.
size
()
==
0
)
{
return
true
;
}
if
(
ait
->
first
==
"sc_in"
)
{
string
port_type
{
(
*
ait
)
->
getTypeName
()};
if
(
port_type
==
"sc_in"
)
{
// os_ << "\n+ sc_in";
_inPorts
.
insert
(
kvType
(
fname
,
te
));
}
else
if
(
ait
->
first
==
"sc_out"
)
{
}
else
if
(
port_type
==
"sc_out"
)
{
// os_ << "\n+ sc_out";
_outPorts
.
insert
(
kvType
(
fname
,
te
));
}
else
if
(
ait
->
first
==
"sc_inout"
)
{
}
else
if
(
port_type
==
"sc_inout"
)
{
// os_ << "\n+ sc_inout";
_inoutPorts
.
insert
(
kvType
(
fname
,
te
));
}
else
{
...
...
src/FindSensitivity.cpp
View file @
6e5991b5
...
...
@@ -45,8 +45,9 @@ bool FindSensitivity::VisitMemberExpr(MemberExpr *e) {
return
true
;
/// Is it a port type
if
(
!
(
ait
->
first
==
"sc_in"
||
ait
->
first
==
"sc_out"
||
ait
->
first
==
"sc_inout"
))
{
string
port_type
{
(
*
ait
)
->
getTypeName
()
};
if
(
!
(
port_type
==
"sc_in"
||
port_type
==
"sc_out"
||
port_type
==
"sc_inout"
))
{
return
true
;
}
...
...
src/FindTLMInterfaces.cpp
View file @
6e5991b5
...
...
@@ -33,21 +33,23 @@ bool FindTLMInterfaces::VisitFieldDecl(FieldDecl *fd) {
te
->
Enumerate
(
tp
);
FindTemplateTypes
::
argV
ector
Type
args
=
te
->
getTemplateArgumentsType
();
FindTemplateTypes
::
type_v
ector
_t
args
=
te
->
getTemplateArgumentsType
();
FindTemplateTypes
::
argVectorType
::
iterator
ait
=
args
.
begin
();
if
(
args
.
size
()
==
0
)
{
return
true
;
}
if
(
ait
->
first
==
"sc_fifo_in"
)
{
// There could be more than one type though. Are you only referring to the first one?
string
template_type_name
{
(
*
ait
)
->
getTypeName
()
};
if
(
template_type_name
==
"sc_fifo_in"
)
{
_inInterfaces
.
insert
(
kvType
(
fname
,
te
));
}
else
if
(
ait
->
first
==
"sc_fifo_out"
)
{
else
if
(
template_type_name
==
"sc_fifo_out"
)
{
_outInterfaces
.
insert
(
kvType
(
fname
,
te
));
}
else
if
(
ait
->
first
==
"sc_fifo_inout"
)
{
else
if
(
template_type_name
==
"sc_fifo_inout"
)
{
_inoutInterfaces
.
insert
(
kvType
(
fname
,
te
));
}
...
...
src/FindTemplateTypes.h
View file @
6e5991b5
...
...
@@ -12,34 +12,57 @@
#include
<iostream>
namespace
scpar
{
using
namespace
clang
;
using
namespace
std
;
// This class is going to find the arguments from templates
class
FindTemplateTypes
:
public
RecursiveASTVisitor
<
FindTemplateTypes
>
{
public:
/// Typedefs
typedef
vector
<
pair
<
string
,
const
Type
*>>
type_vector_t
;
typedef
vector
<
pair
<
string
,
const
Type
*>>
argVectorType
;
// Constructor
FindTemplateTypes
();
/// Copy constructor
FindTemplateTypes
(
const
FindTemplateTypes
&
rhs
);
FindTemplateTypes
(
const
FindTemplateTypes
*
rhs
);
string
getTemplateType
();
type_vector_t
Enumerate
(
const
Type
*
type
);
bool
VisitType
(
Type
*
type
);
bool
VisitIntegerLiteral
(
IntegerLiteral
*
l
);
type_vector_t
getTemplateArgumentsType
();
void
printTemplateArguments
(
llvm
::
raw_ostream
&
os
);
vector
<
string
>
getTemplateArguments
();
size_t
size
();
private:
// (string, Type*)
type_vector_t
template_types_
;
};
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
*
);
string
getTypeName
();
const
Type
*
getTypePtr
();
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;
// Constructor
FindTemplateTypes
();
/// Copy constructor
FindTemplateTypes
(
const
FindTemplateTypes
&
rhs
);
FindTemplateTypes
(
const
FindTemplateTypes
*
rhs
);
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.
type_vector_t
template_types_
;
//type_vector_t_new template_types_new_;
};
}
// namespace scpar
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment