Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
S
systemc-clang
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
caesr-pub
systemc-clang
Commits
52d34b6b
Commit
52d34b6b
authored
Dec 27, 2018
by
Hiren Patel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'code-cleanup' into 'master'
Code cleanup See merge request !10
parents
361d99c1
9bd7b4c0
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
75 additions
and
99 deletions
+75
-99
paths.sh
paths.sh
+1
-1
src/FindPorts.cpp
src/FindPorts.cpp
+3
-2
src/FindSignals.cpp
src/FindSignals.cpp
+25
-48
src/FindSignals.h
src/FindSignals.h
+14
-14
src/FindTemplateTypes.h
src/FindTemplateTypes.h
+26
-26
src/Model.cpp
src/Model.cpp
+3
-6
src/Model.h
src/Model.h
+1
-0
src/SystemCClang.cpp
src/SystemCClang.cpp
+1
-1
src/SystemCClang.h
src/SystemCClang.h
+1
-1
No files found.
paths.sh
View file @
52d34b6b
...
...
@@ -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.
...
...
src/FindPorts.cpp
View file @
52d34b6b
...
...
@@ -29,7 +29,7 @@ bool FindPorts::VisitFieldDecl( FieldDecl *fd ) {
// 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.
...
...
@@ -41,7 +41,8 @@ bool FindPorts::VisitFieldDecl( FieldDecl *fd ) {
/// 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
auto
args
{
te
->
getTemplateArgumentsType
()
};
FindTemplateTypes
::
argVectorType
::
iterator
ait
{
args
.
begin
()
};
if
(
args
.
size
()
==
0
)
{
return
true
;
...
...
src/FindSignals.cpp
View file @
52d34b6b
#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
->
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
);
}
...
...
src/FindSignals.h
View file @
52d34b6b
...
...
@@ -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
;
};
...
...
src/FindTemplateTypes.h
View file @
52d34b6b
...
...
@@ -20,34 +20,34 @@ namespace scpar {
class
FindTemplateTypes
:
public
RecursiveASTVisitor
<
FindTemplateTypes
>
{
public:
/// Typedefs
typedef
vector
<
pair
<
string
,
const
Type
*>
>
type_vector_t
;
typedef
vector
<
pair
<
string
,
const
Type
*>
>
argVectorType
;
typedef
vector
<
pair
<
string
,
const
Type
*>
>
type_vector_t
;
typedef
vector
<
pair
<
string
,
const
Type
*>
>
argVectorType
;
// Constructor
FindTemplateTypes
()
{
}
/// Copy constructor
FindTemplateTypes
(
const
FindTemplateTypes
&
rhs
)
{
copy
(
rhs
.
_templateTypes
.
begin
(),
rhs
.
_templateTypes
.
end
(),
back_inserter
(
_templateTypes
)
);
copy
(
rhs
.
template_types_
.
begin
(),
rhs
.
template_types_
.
end
(),
back_inserter
(
template_types_
)
);
}
FindTemplateTypes
(
const
FindTemplateTypes
*
rhs
)
{
copy
(
rhs
->
_templateTypes
.
begin
(),
rhs
->
_templateTypes
.
end
(),
back_inserter
(
_templateTypes
)
);
copy
(
rhs
->
template_types_
.
begin
(),
rhs
->
template_types_
.
end
(),
back_inserter
(
template_types_
)
);
}
string
getTemplateType
()
{
string
s
{};
// type_vector_t::iterator
for
(
auto
mit
=
_templateTypes
.
begin
();
mit
!=
_templateTypes
.
end
();
++
mit
)
{
//for ( auto const &mit:
_templateTypes
) {
if
(
mit
!=
_templateTypes
.
begin
()
)
{
for
(
auto
mit
=
template_types_
.
begin
();
mit
!=
template_types_
.
end
();
++
mit
)
{
//for ( auto const &mit:
template_types_
) {
if
(
mit
!=
template_types_
.
begin
()
)
{
s
+=
"<"
;
}
s
+=
mit
->
first
;
if
(
mit
!=
_templateTypes
.
begin
()
)
{
if
(
mit
!=
template_types_
.
begin
()
)
{
s
+=
">"
;
}
}
...
...
@@ -55,20 +55,20 @@ namespace scpar {
}
type_vector_t
Enumerate
(
const
Type
*
type
)
{
_templateTypes
.
clear
();
template_types_
.
clear
();
if
(
!
type
)
{
return
_templateTypes
;
return
template_types_
;
}
TraverseType
(
QualType
(
type
,
0
)
);
return
_templateTypes
;
TraverseType
(
QualType
(
type
,
0
)
);
return
template_types_
;
}
bool
VisitType
(
Type
*
type
)
{
QualType
q
{
type
->
getCanonicalTypeInternal
()};
// cout << "\n###### Type: " << q.getAsString() << " \n" ;
if
(
type
->
isBuiltinType
()
)
{
_templateTypes
.
push_back
(
pair
<
string
,
const
Type
*
>
(
q
.
getAsString
(),
type
)
);
if
(
type
->
isBuiltinType
()
)
{
template_types_
.
push_back
(
pair
<
string
,
const
Type
*
>
(
q
.
getAsString
(),
type
)
);
return
true
;
}
...
...
@@ -76,7 +76,7 @@ namespace scpar {
if
(
p_cxx_record
!=
nullptr
)
{
IdentifierInfo
*
info
{
p_cxx_record
->
getIdentifier
()};
if
(
info
!=
nullptr
)
{
_templateTypes
.
push_back
(
pair
<
string
,
const
Type
*
>
(
info
->
getNameStart
(),
type
)
);
template_types_
.
push_back
(
pair
<
string
,
const
Type
*
>
(
info
->
getNameStart
(),
type
)
);
}
}
return
true
;
...
...
@@ -86,21 +86,21 @@ namespace scpar {
//_os << "\n####### IntegerLiteral: " << l->getValue().toString(10,true) << "\n";
//_os << "== type ptr: " << l->getType().getTypePtr() << "\n";
//_os << "== type name: " << l->getType().getAsString() << "\n";
_templateTypes
.
push_back
(
pair
<
string
,
const
Type
*
>
(
l
->
getValue
().
toString
(
10
,
true
),
template_types_
.
push_back
(
pair
<
string
,
const
Type
*>
(
l
->
getValue
().
toString
(
10
,
true
),
l
->
getType
().
getTypePtr
()));
return
true
;
}
type_vector_t
getTemplateArgumentsType
()
{
return
_templateTypes
;
return
template_types_
;
}
void
printTemplateArguments
(
llvm
::
raw_ostream
&
os
,
int
tabn
=
0
)
{
vector
<
string
>
template_arguments
;
//{ getTemplateArguments() };
// type_vector_t::iterator
// for (auto mit =
_templateTypes.begin(); mit != _templateTypes
.end(); mit++) {
for
(
auto
const
&
mit
:
_templateTypes
)
{
// for (auto mit =
template_types_.begin(); mit != template_types_
.end(); mit++) {
for
(
auto
const
&
mit
:
template_types_
)
{
for
(
auto
i
{
0
};
i
<
tabn
;
++
i
)
{
os
<<
" "
;
}
...
...
@@ -119,8 +119,8 @@ namespace scpar {
vector
<
string
>
getTemplateArguments
()
{
vector
<
string
>
template_arguments
;
// type_vector_t::iterator
// for ( auto mit =
_templateTypes.begin(); mit != _templateTypes
.end(); ++mit ) {
for
(
auto
const
&
mit
:
_templateTypes
)
{
// for ( auto mit =
template_types_.begin(); mit != template_types_
.end(); ++mit ) {
for
(
auto
const
&
mit
:
template_types_
)
{
if
(
mit
.
first
==
"sc_in"
||
mit
.
first
==
"sc_out"
||
mit
.
first
==
"sc_inout"
)
{
break
;
}
...
...
@@ -130,11 +130,11 @@ namespace scpar {
}
size_t
size
()
{
return
_templateTypes
.
size
();
return
template_types_
.
size
();
}
private:
type_vector_t
_templateTypes
;
type_vector_t
template_types_
;
};
}
...
...
src/Model.cpp
View file @
52d34b6b
...
...
@@ -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_
;
}
...
...
src/Model.h
View file @
52d34b6b
...
...
@@ -13,6 +13,7 @@
#include "EntryFunctionContainer.h"
#include "FindNetlist.h"
#include "SCuitable/FindGPUMacro.h"
namespace
scpar
{
using
namespace
clang
;
using
namespace
std
;
...
...
src/SystemCClang.cpp
View file @
52d34b6b
...
...
@@ -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
)
{
}
...
...
src/SystemCClang.h
View file @
52d34b6b
...
...
@@ -76,7 +76,7 @@ namespace scpar {
ASTContext
&
_context
;
private:
CompilerInstance
&
_ci
;
CompilerInstance
&
_ci
;
//ASTContext& _context;
Model
*
_systemcModel
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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