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
177bb1ac
Commit
177bb1ac
authored
Dec 18, 2018
by
rmrf
Browse files
Clean up code format.
parent
23d5e154
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/FindArgument.cpp
View file @
177bb1ac
...
...
@@ -2,50 +2,40 @@
using
namespace
scpar
;
FindArgument
::
FindArgument
(
Expr
*
e
)
:
_e
(
e
)
{
TraverseStmt
(
e
)
;
FindArgument
::
FindArgument
(
Expr
*
e
)
:
expression_
(
e
)
{
TraverseStmt
(
expression_
);
}
FindArgument
::~
FindArgument
()
{
_
e
=
nullptr
;
e
xpression_
=
nullptr
;
}
bool
FindArgument
::
VisitMemberExpr
(
MemberExpr
*
me
)
{
_argumentName
=
me
->
getMemberNameInfo
().
getAsString
();
bool
FindArgument
::
VisitMemberExpr
(
MemberExpr
*
member_expr
)
{
argument_name_
=
member_expr
->
getMemberNameInfo
().
getAsString
();
return
true
;
}
bool
FindArgument
::
VisitDeclRefExpr
(
DeclRefExpr
*
de
)
{
_argumentName
=
de
->
getFoundDecl
()
->
getNameAsString
();
bool
FindArgument
::
VisitDeclRefExpr
(
DeclRefExpr
*
declaration_ref
)
{
argument_name_
=
declaration_ref
->
getFoundDecl
()
->
getNameAsString
();
return
true
;
}
bool
FindArgument
::
VisitIntegerLiteral
(
IntegerLiteral
*
il
)
{
_argumentName
=
il
->
getValue
().
toString
(
10
,
false
);
bool
FindArgument
::
VisitIntegerLiteral
(
IntegerLiteral
*
integer_literal
)
{
argument_name_
=
integer_literal
->
getValue
().
toString
(
10
,
false
);
return
true
;
}
bool
FindArgument
::
VisitCXXBoolLiteralExpr
(
CXXBoolLiteralExpr
*
bl
)
{
if
(
bl
->
getValue
()
==
false
)
{
_argumentName
=
"false"
;
bool
FindArgument
::
VisitCXXBoolLiteralExpr
(
CXXBoolLiteralExpr
*
boolean_expr
)
{
if
(
boolean_expr
->
getValue
()
==
false
)
{
argument_name_
=
"false"
;
}
else
{
_argumentName
=
"true"
;
else
{
argument_name_
=
"true"
;
}
return
true
;
}
string
FindArgument
::
getArgumentName
()
{
return
_argumentName
;
string
FindArgument
::
getArgumentName
()
{
return
argument_name_
;
}
src/FindArgument.h
View file @
177bb1ac
...
...
@@ -12,19 +12,17 @@ namespace scpar {
class
FindArgument
:
public
RecursiveASTVisitor
<
FindArgument
>
{
public:
FindArgument
(
Expr
*
ce
);
FindArgument
(
Expr
*
);
virtual
~
FindArgument
();
virtual
bool
VisitMemberExpr
(
MemberExpr
*
me
);
virtual
bool
VisitDeclRefExpr
(
DeclRefExpr
*
de
);
virtual
bool
VisitIntegerLiteral
(
IntegerLiteral
*
il
);
virtual
bool
VisitCXXBoolLiteralExpr
(
CXXBoolLiteralExpr
*
bl
);
string
getArgumentName
(
);
string
getArgumentName
();
private:
Expr
*
_
e
;
string
_
argument
N
ame
;
Expr
*
e
xpression_
;
string
argument
_n
ame
_
;
};
}
#endif
src/FindConstructor.h
View file @
177bb1ac
...
...
@@ -2,12 +2,14 @@
#define _FIND_CONSTRUCTOR_H_
#include
<vector>
#include
<map>
#include
<string>
#include
"clang/AST/DeclCXX.h"
#include
"llvm/Support/raw_ostream.h"
#include
"clang/AST/RecursiveASTVisitor.h"
#include
"EntryFunctionContainer.h"
#include
<map>
namespace
scpar
{
using
namespace
clang
;
...
...
src/FindPorts.cpp
View file @
177bb1ac
...
...
@@ -2,145 +2,110 @@
#include
"FindTemplateTypes.h"
using
namespace
scpar
;
FindPorts
::
FindPorts
(
CXXRecordDecl
*
d
,
llvm
::
raw_ostream
&
os
)
:
_os
(
os
)
//, _reflectionContainer(container)
{
TraverseDecl
(
d
);
FindPorts
::
FindPorts
(
CXXRecordDecl
*
d
,
llvm
::
raw_ostream
&
os
)
:
os_
{
os
}
{
TraverseDecl
(
d
);
}
FindPorts
::
portType
FindPorts
::
getInputPorts
()
{
FindPorts
::
PortType
FindPorts
::
getInputPorts
()
const
{
return
_inPorts
;
}
FindPorts
::
portType
FindPorts
::
getOutputPorts
()
{
FindPorts
::
PortType
FindPorts
::
getOutputPorts
()
const
{
return
_outPorts
;
}
FindPorts
::
portType
FindPorts
::
getInputOutputPorts
()
{
FindPorts
::
PortType
FindPorts
::
getInputOutputPorts
()
const
{
return
_inoutPorts
;
}
bool
FindPorts
::
VisitFieldDecl
(
FieldDecl
*
fd
)
{
// _os << "####################### VisitFieldDecl\n ";
QualType
q
=
fd
->
getType
();
string
fname
;
if
(
IdentifierInfo
*
info
=
fd
->
getIdentifier
())
{
fname
=
info
->
getNameStart
();
// _os << "\n+ Name: " << info->getNameStart();
// _os << "\n+ Type: " << q.getAsString();
}
//
bool
FindPorts
::
VisitFieldDecl
(
FieldDecl
*
fd
)
{
// os_ << "####################### VisitFieldDecl\n ";
QualType
q
=
fd
->
getType
();
string
fname
;
if
(
IdentifierInfo
*
info
=
fd
->
getIdentifier
())
{
fname
=
info
->
getNameStart
();
// os_ << "\n+ Name: " << info->getNameStart();
// os_ << "\n+ Type: " << q.getAsString();
}
//
/// FIXME: We have to delete these somewhere. Who is responsible of doing this?
/// 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
->
Enumerate
(
tp
);
//te->printTemplateArguments();
/// Check if we have sc_in/sc_out/sc_inout ports.
/// The vector is organized such that the first element is the port type.
FindTemplateTypes
::
argVectorType
args
=
te
->
getTemplateArgumentsType
();
FindTemplateTypes
::
argVectorType
::
iterator
ait
=
args
.
begin
();
if
(
args
.
size
()
==
0
)
{
return
true
;
}
if
(
ait
->
first
==
"sc_in"
)
{
// _os << "\n+ sc_in";
_inPorts
.
insert
(
kvType
(
fname
,
te
));
}
else
if
(
ait
->
first
==
"sc_out"
)
{
// _os << "\n+ sc_out";
_outPorts
.
insert
(
kvType
(
fname
,
te
));
}
else
if
(
ait
->
first
==
"sc_inout"
)
{
// _os << "\n+ sc_inout";
_inoutPorts
.
insert
(
kvType
(
fname
,
te
));
}
else
{
/// This is sometype we don't know about.
}
FindTemplateTypes
::
argVectorType
args
{
te
->
getTemplateArgumentsType
()
};
FindTemplateTypes
::
argVectorType
::
iterator
ait
{
args
.
begin
()
};
if
(
args
.
size
()
==
0
)
{
return
true
;
}
if
(
ait
->
first
==
"sc_in"
)
{
// os_ << "\n+ sc_in";
_inPorts
.
insert
(
kvType
(
fname
,
te
)
);
}
else
if
(
ait
->
first
==
"sc_out"
)
{
// os_ << "\n+ sc_out";
_outPorts
.
insert
(
kvType
(
fname
,
te
)
);
}
else
if
(
ait
->
first
==
"sc_inout"
)
{
// os_ << "\n+ sc_inout";
_inoutPorts
.
insert
(
kvType
(
fname
,
te
)
);
}
else
{
/// This is sometype we don't know about.
}
return
true
;
}
void
FindPorts
::
dump
(
)
{
_os
<<
"
\n
================= Find Ports ================
\n
"
;
_os
<<
"
\n
:> Number of input Ports: "
<<
_inPorts
.
size
();
for
(
portType
::
iterator
mit
=
_inPorts
.
begin
(),
mitend
=
_inPorts
.
end
();
mit
!=
mitend
;
mit
++
)
{
_os
<<
"
\n
:>> "
<<
mit
->
first
;
(
mit
->
second
)
->
printTemplateArguments
(
_os
);
}
_os
<<
"
\n\n
:> Number of output Ports: "
<<
_outPorts
.
size
();
for
(
portType
::
iterator
mit
=
_outPorts
.
begin
(),
mitend
=
_outPorts
.
end
();
mit
!=
mitend
;
mit
++
)
{
_os
<<
"
\n
:>> "
<<
mit
->
first
;
(
mit
->
second
)
->
printTemplateArguments
(
_os
);
}
_os
<<
"
\n\n
:> Number of inout Ports: "
<<
_inoutPorts
.
size
();
for
(
portType
::
iterator
mit
=
_inoutPorts
.
begin
(),
mitend
=
_inoutPorts
.
end
();
mit
!=
mitend
;
mit
++
)
{
_os
<<
"
\n
:>> "
<<
mit
->
first
;
(
mit
->
second
)
->
printTemplateArguments
(
_os
);
}
_os
<<
"
\n
================= END Find Ports ================
\n\n
"
;
void
FindPorts
::
dump
()
{
os_
<<
"
\n
================= Find Ports ================
\n
"
;
os_
<<
"
\n
:> Number of input Ports: "
<<
_inPorts
.
size
();
for
(
PortType
::
iterator
mit
=
_inPorts
.
begin
(),
mitend
=
_inPorts
.
end
();
mit
!=
mitend
;
mit
++
)
{
os_
<<
"
\n
:>> "
<<
mit
->
first
;
(
mit
->
second
)
->
printTemplateArguments
(
os_
);
}
os_
<<
"
\n\n
:> Number of output Ports: "
<<
_outPorts
.
size
();
for
(
PortType
::
iterator
mit
=
_outPorts
.
begin
(),
mitend
=
_outPorts
.
end
();
mit
!=
mitend
;
mit
++
)
{
os_
<<
"
\n
:>> "
<<
mit
->
first
;
(
mit
->
second
)
->
printTemplateArguments
(
os_
);
}
os_
<<
"
\n\n
:> Number of inout Ports: "
<<
_inoutPorts
.
size
();
for
(
PortType
::
iterator
mit
=
_inoutPorts
.
begin
(),
mitend
=
_inoutPorts
.
end
();
mit
!=
mitend
;
mit
++
)
{
os_
<<
"
\n
:>> "
<<
mit
->
first
;
(
mit
->
second
)
->
printTemplateArguments
(
os_
);
}
os_
<<
"
\n
================= END Find Ports ================
\n\n
"
;
}
FindPorts
::~
FindPorts
()
{
// _os << "[[ Destructor FindPorts ]]\n";
for
(
portType
::
iterator
mit
=
_inPorts
.
begin
(),
mitend
=
_inPorts
.
end
();
mit
!=
mitend
;
mit
++
)
{
delete
mit
->
second
;
}
FindPorts
::~
FindPorts
()
{
// os_ << "[[ Destructor FindPorts ]]\n";
for
(
PortType
::
iterator
mit
=
_inPorts
.
begin
(),
mitend
=
_inPorts
.
end
();
mit
!=
mitend
;
mit
++
)
{
// for ( auto mit : _inPorts ) {
delete
mit
->
second
;
}
_inPorts
.
clear
();
for
(
portType
::
iterator
mit
=
_outPorts
.
begin
(),
mitend
=
_outPorts
.
end
();
mit
!=
mitend
;
mit
++
)
{
// _os << "\n:>> " << mit->first;
delete
mit
->
second
;
}
_outPorts
.
clear
();
// _os << "\n\n:> Number of inout Ports: " << _inoutPorts.size();
for
(
portType
::
iterator
mit
=
_inoutPorts
.
begin
(),
mitend
=
_inoutPorts
.
end
();
mit
!=
mitend
;
mit
++
)
{
// _os << "\n:>> " << mit->first;
delete
mit
->
second
;
}
_inoutPorts
.
clear
();
for
(
PortType
::
iterator
mit
=
_outPorts
.
begin
(),
mitend
=
_outPorts
.
end
();
mit
!=
mitend
;
mit
++
)
{
// for ( auto mit : _outPorts ) {
// os_ << "\n:>> " << mit->first;
delete
mit
->
second
;
}
_outPorts
.
clear
();
// os_ << "\n\n:> Number of inout Ports: " << _inoutPorts.size();
for
(
PortType
::
iterator
mit
=
_inoutPorts
.
begin
(),
mitend
=
_inoutPorts
.
end
();
mit
!=
mitend
;
mit
++
)
{
// for ( auto mit : _inoutPorts ) {
// os_ << "\n:>> " << mit->first;
delete
mit
->
second
;
}
_inoutPorts
.
clear
();
}
src/FindPorts.h
View file @
177bb1ac
...
...
@@ -11,27 +11,27 @@ namespace scpar {
using
namespace
clang
;
using
namespace
std
;
class
FindPorts
:
public
RecursiveASTVisitor
<
FindPorts
>
{
class
FindPorts
:
public
RecursiveASTVisitor
<
FindPorts
>
{
public:
/// typedefs
typedef
map
<
string
,
FindTemplateTypes
*
>
p
ortType
;
typedef
map
<
string
,
FindTemplateTypes
*
>
P
ortType
;
typedef
pair
<
string
,
FindTemplateTypes
*
>
kvType
;
FindPorts
(
CXXRecordDecl
*
,
llvm
::
raw_ostream
&
);
FindPorts
(
CXXRecordDecl
*
,
llvm
::
raw_ostream
&
);
virtual
~
FindPorts
();
virtual
bool
VisitFieldDecl
(
FieldDecl
*
);
virtual
bool
VisitFieldDecl
(
FieldDecl
*
);
p
ortType
getInputPorts
();
p
ortType
getOutputPorts
();
p
ortType
getInputOutputPorts
();
void
dump
();
P
ortType
getInputPorts
()
const
;
P
ortType
getOutputPorts
()
const
;
P
ortType
getInputOutputPorts
()
const
;
void
dump
();
private:
llvm
::
raw_ostream
&
_
os
;
p
ortType
_inPorts
;
p
ortType
_outPorts
;
p
ortType
_inoutPorts
;
llvm
::
raw_ostream
&
os
_
;
P
ortType
_inPorts
;
P
ortType
_outPorts
;
P
ortType
_inoutPorts
;
};
...
...
src/ModuleDecl.cpp
View file @
177bb1ac
...
...
@@ -66,7 +66,7 @@ void ModuleDecl::addSignals( FindSignals::signalMapType *signal_map ) {
}
}
void
ModuleDecl
::
addInputPorts
(
FindPorts
::
p
ortType
p
)
{
void
ModuleDecl
::
addInputPorts
(
FindPorts
::
P
ortType
p
)
{
for
(
auto
mit
:
p
)
{
string
name
=
mit
.
first
;
FindTemplateTypes
*
template_type
=
new
FindTemplateTypes
(
mit
.
second
);
...
...
@@ -76,7 +76,7 @@ void ModuleDecl::addInputPorts( FindPorts::portType p ) {
}
}
void
ModuleDecl
::
addOutputPorts
(
FindPorts
::
p
ortType
p
)
{
void
ModuleDecl
::
addOutputPorts
(
FindPorts
::
P
ortType
p
)
{
for
(
auto
mit
:
p
)
{
string
n
=
mit
.
first
;
FindTemplateTypes
*
tt
=
new
FindTemplateTypes
(
mit
.
second
);
...
...
@@ -86,7 +86,7 @@ void ModuleDecl::addOutputPorts(FindPorts::portType p) {
}
}
void
ModuleDecl
::
addInputOutputPorts
(
FindPorts
::
p
ortType
p
)
{
void
ModuleDecl
::
addInputOutputPorts
(
FindPorts
::
P
ortType
p
)
{
for
(
auto
mit
:
p
)
{
_ioports
.
insert
(
portPairType
(
mit
.
first
,
new
PortDecl
(
mit
.
first
,
mit
.
second
)
)
);
}
...
...
src/ModuleDecl.h
View file @
177bb1ac
...
...
@@ -47,13 +47,13 @@ namespace scpar {
~
ModuleDecl
();
void
addSignals
(
FindSignals
::
signalMapType
*
);
void
addInputPorts
(
FindPorts
::
p
ortType
);
void
addOutputPorts
(
FindPorts
::
p
ortType
);
void
addInputOutputPorts
(
FindPorts
::
p
ortType
);
void
addInputInterfaces
(
FindTLMInterfaces
::
interfaceType
);
void
addOutputInterfaces
(
FindTLMInterfaces
::
interfaceType
);
void
addInputOutputInterfaces
(
FindTLMInterfaces
::
interfaceType
);
void
addSignals
(
FindSignals
::
signalMapType
*
);
void
addInputPorts
(
FindPorts
::
P
ortType
);
void
addOutputPorts
(
FindPorts
::
P
ortType
);
void
addInputOutputPorts
(
FindPorts
::
P
ortType
);
void
addInputInterfaces
(
FindTLMInterfaces
::
interfaceType
);
void
addOutputInterfaces
(
FindTLMInterfaces
::
interfaceType
);
void
addInputOutputInterfaces
(
FindTLMInterfaces
::
interfaceType
);
void
addProcess
(
FindEntryFunctions
::
entryFunctionVectorType
*
);
void
addInstances
(
vector
<
string
>
);
void
addSignalBinding
(
map
<
string
,
string
>
);
...
...
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