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
1fd8cb79
Commit
1fd8cb79
authored
Jul 08, 2019
by
rmrf
Browse files
Merge remote-tracking branch 'origin/new-json-dumps' into new-json-dumps
parents
6034c288
7b929db2
Changes
4
Hide whitespace changes
Inline
Side-by-side
.clang-format
0 → 100644
View file @
1fd8cb79
---
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: true
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 2
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Auto
TabWidth: 8
UseTab: Never
...
src/FindGlobalEvents.cpp
View file @
1fd8cb79
...
...
@@ -38,8 +38,7 @@ void FindGlobalEvents::dump() {
json
FindGlobalEvents
::
dump_json
()
{
json
globals_j
{};
for
(
auto
const
&
event
:
_globalEvents
)
{
for
(
auto
const
&
event
:
_globalEvents
)
{
globals_j
[
"global_declarations"
].
emplace_back
(
event
.
first
)
;
}
std
::
cout
<<
globals_j
.
dump
(
4
)
<<
endl
;
...
...
src/SystemCClang.cpp
View file @
1fd8cb79
...
...
@@ -16,36 +16,36 @@ bool SystemCConsumer::fire() {
_systemcModel
=
new
Model
{}
;
// ANI : Do we need FindGlobalEvents?
FindGlobalEvents
globals
{
tu
,
_
os
};
FindGlobalEvents
globals
{
tu
,
os
_
};
FindGlobalEvents
::
globalEventMapType
eventMap
{
globals
.
getEventMap
()};
globals
.
dump_json
();
_systemcModel
->
addGlobalEvents
(
eventMap
);
// Find the sc_modules
FindSCModules
scmod
{
tu
,
_
os
};
FindSCModules
scmod
{
tu
,
os
_
};
FindSCModules
::
moduleMapType
scmodules
{
scmod
.
getSystemCModulesMap
()};
for
(
FindSCModules
::
moduleMapType
::
iterator
mit
=
scmodules
.
begin
(),
mitend
=
scmodules
.
end
();
mit
!=
mitend
;
++
mit
)
{
ModuleDecl
*
md
=
new
ModuleDecl
{
mit
->
first
,
mit
->
second
};
//md->setTemplateParameters( scmod.getTemplateParameters() );
//
_
os << "SIZE: " << scmod.getTemplateParameters().size() << "\n";
//
md->setTemplateParameters( scmod.getTemplateParameters() );
// os
_
<< "SIZE: " << scmod.getTemplateParameters().size() << "\n";
_systemcModel
->
addModuleDecl
(
md
);
}
////////////////////////////////////////////////////////////////
// Find the sc_main
////////////////////////////////////////////////////////////////
FindSCMain
scmain
{
tu
,
_
os
};
FindSCMain
scmain
{
tu
,
os
_
};
if
(
scmain
.
isSCMainFound
())
{
FunctionDecl
*
fnDecl
{
scmain
.
getSCMainFunctionDecl
()};
FindSimTime
scstart
{
fnDecl
,
_
os
};
FindSimTime
scstart
{
fnDecl
,
os
_
};
_systemcModel
->
addSimulationTime
(
scstart
.
returnSimTime
());
}
else
{
_
os
<<
"
\n
Could not find SCMain"
;
os
_
<<
"
\n
Could not find SCMain"
;
}
////////////////////////////////////////////////////////////////
...
...
@@ -66,57 +66,58 @@ bool SystemCConsumer::fire() {
int
numInstances
{
mainmd
->
getNumInstances
()};
vector
<
ModuleDecl
*>
moduleDeclVec
;
_
os
<<
"
\n
"
;
_
os
<<
"For module: "
<<
mit
->
first
<<
" num instance : "
<<
numInstances
;
os
_
<<
"
\n
"
;
os
_
<<
"For module: "
<<
mit
->
first
<<
" num instance : "
<<
numInstances
;
for
(
unsigned
int
num
{
0
};
num
<
numInstances
;
++
num
)
{
ModuleDecl
*
md
=
new
ModuleDecl
{};
// Find the template arguments for the class.
FindTemplateParameters
tparms
{
mainmd
->
getModuleClassDecl
(),
_
os
};
FindTemplateParameters
tparms
{
mainmd
->
getModuleClassDecl
(),
os
_
};
md
->
setTemplateParameters
(
tparms
.
getTemplateParameters
()
);
_
os
<<
"@@# "
<<
mainmd
->
getTemplateParameters
().
size
()
<<
"
\n
"
;
os
_
<<
"@@# "
<<
mainmd
->
getTemplateParameters
().
size
()
<<
"
\n
"
;
md
->
dump_json
();
vector
<
EntryFunctionContainer
*>
_entryFunctionContainerVector
;
FindConstructor
constructor
{
mainmd
->
getModuleClassDecl
(),
_
os
};
FindConstructor
constructor
{
mainmd
->
getModuleClassDecl
(),
os
_
};
md
->
addConstructor
(
constructor
.
returnConstructorStmt
());
FindPorts
ports
{
mainmd
->
getModuleClassDecl
(),
_
os
};
FindPorts
ports
{
mainmd
->
getModuleClassDecl
(),
os
_
};
md
->
addInputPorts
(
ports
.
getInputPorts
());
md
->
addOutputPorts
(
ports
.
getOutputPorts
());
md
->
addInputOutputPorts
(
ports
.
getInputOutputPorts
());
FindTLMInterfaces
findTLMInterfaces
{
mainmd
->
getModuleClassDecl
(),
_
os
};
FindTLMInterfaces
findTLMInterfaces
{
mainmd
->
getModuleClassDecl
(),
os
_
};
md
->
addInputInterfaces
(
findTLMInterfaces
.
getInputInterfaces
());
md
->
addOutputInterfaces
(
findTLMInterfaces
.
getOutputInterfaces
());
md
->
addInputOutputInterfaces
(
findTLMInterfaces
.
getInputOutputInterfaces
());
FindSignals
signals
{
mainmd
->
getModuleClassDecl
(),
_
os
};
FindSignals
signals
{
mainmd
->
getModuleClassDecl
(),
os
_
};
md
->
addSignals
(
signals
.
getSignals
());
FindEntryFunctions
findEntries
{
mainmd
->
getModuleClassDecl
(),
_
os
};
FindEntryFunctions
findEntries
{
mainmd
->
getModuleClassDecl
(),
os
_
};
FindEntryFunctions
::
entryFunctionVectorType
*
entryFunctions
{
findEntries
.
getEntryFunctions
()};
md
->
addProcess
(
entryFunctions
);
for
(
size_t
i
=
0
;
i
<
entryFunctions
->
size
();
i
++
)
{
EntryFunctionContainer
*
ef
{(
*
entryFunctions
)[
i
]};
FindSensitivity
findSensitivity
{
constructor
.
returnConstructorStmt
(),
_os
};
FindSensitivity
findSensitivity
{
constructor
.
returnConstructorStmt
(),
os_
};
ef
->
addSensitivityInfo
(
findSensitivity
);
if
(
ef
->
getEntryMethod
()
==
nullptr
)
{
_
os
<<
"ERROR"
;
os
_
<<
"ERROR"
;
continue
;
}
FindWait
findWaits
{
ef
->
getEntryMethod
(),
_
os
};
FindWait
findWaits
{
ef
->
getEntryMethod
(),
os
_
};
ef
->
addWaits
(
findWaits
);
FindNotify
findNotify
{
ef
->
_entryMethodDecl
,
_
os
};
FindNotify
findNotify
{
ef
->
_entryMethodDecl
,
os
_
};
ef
->
addNotifys
(
findNotify
);
/// Does not compile
...
...
@@ -139,18 +140,18 @@ bool SystemCConsumer::fire() {
}
/*
FindSCMain scmain(tu,
_
os);
FindSCMain scmain(tu, os
_
);
if (scmain.isSCMainFound())
{
FunctionDecl *fnDecl = scmain.getSCMainFunctionDecl();
FindSimTime scstart(fnDecl,
_
os);
FindSimTime scstart(fnDecl, os
_
);
_systemcModel->addSimulationTime(scstart.returnSimTime());
}
else {
_
os <<"\n Could not find SCMain";
os
_
<<"\n Could not find SCMain";
}
FindNetlist findNetlist(scmain.getSCMainFunctionDecl());
...
...
@@ -189,9 +190,9 @@ _systemcModel->addNetlist(findNetlist);
}
}
_
os
<<
"
\n
"
;
_
os
<<
"
\n
## SystemC model
\n
"
;
_systemcModel
->
dump
(
_
os
);
os
_
<<
"
\n
"
;
os
_
<<
"
\n
## SystemC model
\n
"
;
_systemcModel
->
dump
(
os
_
);
return
true
;
}
...
...
@@ -219,8 +220,11 @@ void SystemCConsumer::HandleTranslationUnit(ASTContext &context) {
}
SystemCConsumer
::
SystemCConsumer
(
CompilerInstance
&
ci
)
:
_os
{
llvm
::
errs
()},
_sm
{
ci
.
getSourceManager
()},
_context
{
ci
.
getASTContext
()},
_ci
{
ci
},
_systemcModel
{
nullptr
}
{}
:
os_
{
llvm
::
errs
()},
_sm
{
ci
.
getSourceManager
()},
_context
{
ci
.
getASTContext
()},
_ci
{
ci
},
_systemcModel
{
nullptr
}
{}
SystemCConsumer
::~
SystemCConsumer
()
{
if
(
_systemcModel
!=
nullptr
)
{
...
...
src/SystemCClang.h
View file @
1fd8cb79
...
...
@@ -60,7 +60,7 @@ namespace scpar {
class
SystemCConsumer
:
public
ASTConsumer
,
public
RecursiveASTVisitor
<
SystemCConsumer
>
{
public:
llvm
::
raw_ostream
&
_
os
;
llvm
::
raw_ostream
&
os
_
;
SourceManager
&
_sm
;
SystemCConsumer
(
CompilerInstance
&
);
...
...
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