Commit 39c13572 authored by rmrf's avatar rmrf
Browse files

Merge branch 'new-json-dumps'

parents 7ce0bc87 50201a93
---
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
...
cmake_minimum_required(VERSION 2.6)
project(systemc-clang)
# Use C++ standard version to c++17
set(CMAKE_CXX_STANDARD 17)
# Always keep it on
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option (USE_SAUTO
"Use suspension-automata library." OFF
)
set (ROOT_CPP
driver-tooling.cpp
# ToolingTest.cpp
# ToolingTutorial.cpp
)
project(systemc-clang)
# Use C++ standard version to c++17
set(CMAKE_CXX_STANDARD 17)
# Always keep it on
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option (USE_SAUTO
"Use suspension-automata library." OFF
)
set (ROOT_CPP
driver-tooling.cpp
# ToolingTest.cpp
# ToolingTutorial.cpp
)
# set (CLANG_SRC_DIR
# $ENV{CLANG_SRC_DIR}
......@@ -20,108 +20,107 @@ cmake_minimum_required(VERSION 2.6)
# set (LLVM_SRC_DIR
# $ENV{LLVM_SRC_DIR}
# )
set (LLVM_BUILD_DIR
$ENV{LLVM_BUILD_DIR}
)
set (CMAKE_CXX_FLAGS
"$ENV{LLVM_CXX_FLAGS} $ENV{CMAKE_CXX_FLAGS} -DUSE_SAUTO=off"
)
set (LLVM_BUILD_DIR
$ENV{LLVM_BUILD_DIR}
)
set (CMAKE_CXX_FLAGS
"$ENV{LLVM_CXX_FLAGS} $ENV{CMAKE_CXX_FLAGS} -DUSE_SAUTO=off"
)
if (USE_SAUTO)
set (CMAKE_CXX_FLAGS
"-DUSE_SAUTO=on ${CMAKE_CXX_FLAGS}"
)
"-DUSE_SAUTO=on ${CMAKE_CXX_FLAGS}"
)
endif(USE_SAUTO)
set (LLVM_LD_FLAGS
"$ENV{LLVM_LD_FLAGS} -lpthread"
)
set (LLVM_LD_FLAGS
"$ENV{LLVM_LD_FLAGS} -lpthread"
)
set (LLVM_LIBS
$ENV{LLVM_LIBS}
)
set (LLVM_LIBS
$ENV{LLVM_LIBS}
)
#set (LLVM_LD_LIBS LLVMCppBackendCodeGen LLVMCppBackendInfo LLVMTarget LLVMCore LLVMMC LLVMObject LLVMSupport)
#LLVMJIT LLVMX86CodeGen LLVMX86AsmParser LLVMX86Disassembler LLVMExecutionEngine LLVMAsmPrinter LLVMSelectionDAG LLVMX86AsmPrinter LLVMX86Info LLVMMCParser LLVMCodeGen LLVMX86Utils LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMTarget LLVMCore LLVMMC LLVMSupport
set (CLANG_LIBS
clangTooling
clangFrontendTool
clangFrontend
clangDriver
clangSerialization
clangCodeGen
clangParse
clangSema
clangStaticAnalyzerFrontend
clangStaticAnalyzerCheckers
clangStaticAnalyzerCore
clangAnalysis
clangARCMigrate
clangRewriteFrontend
clangRewrite
clangEdit
clangAST
clangLex
clangBasic
clangASTMatchers
)
set (CMAKE_MODULE_LINKER_FLAGS
$ENV{LLVM_LD_FLAGS}
)
set (TARGET
"systemc-clang"
)
include_directories(
"${LLVM_BUILD_DIR}/include"
src
if (USE_SAUTO)
sauto
endif (USE_SAUTO)
)
link_directories(
${LLVM_BUILD_DIR}/lib
)
set (CLANG_LIBS
clangTooling
clangFrontendTool
clangFrontend
clangDriver
clangSerialization
clangCodeGen
clangParse
clangSema
clangStaticAnalyzerFrontend
clangStaticAnalyzerCheckers
clangStaticAnalyzerCore
clangAnalysis
clangARCMigrate
clangRewriteFrontend
clangRewrite
clangEdit
clangAST
clangLex
clangBasic
clangASTMatchers
)
set (CMAKE_MODULE_LINKER_FLAGS
$ENV{LLVM_LD_FLAGS}
)
set (TARGET
"systemc-clang"
)
include_directories(
"${LLVM_BUILD_DIR}/include"
src
if (USE_SAUTO)
sauto
endif (USE_SAUTO)
)
link_directories(
${LLVM_BUILD_DIR}/lib
)
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(src)
if (USE_SAUTO)
add_subdirectory(sauto)
endif (USE_SAUTO)
set( SRC_LIB libsystemc-clang)
set( SRC_LIB libsystemc-clang )
if (USE_SAUTO)
set( SAUTO_LIB libsauto )
endif (USE_SAUTO)
add_executable(
${TARGET}
${ROOT_CPP} )
target_link_libraries(${TARGET} ${SRC_LIB})
target_link_libraries(${TARGET} ${SAUTO_LIB})
foreach (clang_lib ${CLANG_LIBS})
target_link_libraries( ${TARGET} ${clang_lib} )
endforeach()
foreach (ld_flag ${LLVM_LD_FLAGS})
target_link_libraries( ${TARGET} ${ld_flag} )
endforeach()
add_executable(
${TARGET}
${ROOT_CPP} )
foreach (llvm_lib ${LLVM_LIBS})
target_link_libraries( ${TARGET} ${llvm_lib} )
endforeach()
target_link_libraries(${TARGET} ${SRC_LIB})
target_link_libraries(${TARGET} ${SAUTO_LIB})
foreach (clang_lib ${CLANG_LIBS})
target_link_libraries( ${TARGET} ${clang_lib} )
endforeach()
foreach (ld_flag ${LLVM_LD_FLAGS})
target_link_libraries( ${TARGET} ${ld_flag} )
endforeach()
foreach (llvm_lib ${LLVM_LIBS})
target_link_libraries( ${TARGET} ${llvm_lib} )
endforeach()
#######################################################
# Author: Hiren Patel
# Adapted
# Credit: https://gist.github.com/Kocha/1953411
#
########################################################
SYSTEMC ?=
SYSTEMC_HOME ?= $(SYSTEMC)
TARGET_ARCH = linux64
SYSTEMC_INC_DIR = $(SYSTEMC_HOME)/include
SYSTEMC_LIB_DIR = $(SYSTEMC_HOME)/lib-$(TARGET_ARCH)
# LIBTOOL Setting
SHELL = /bin/bash
LIBTOOL_DIR = /usr/bin
LIBTOOL = $(SHELL) $(LIBTOOL_DIR)/libtool
GXX = g++
GCC = gcc
LD = g++
FLAGS = -g -Wall -pedantic -Wno-long-long \
-DSC_INCLUDE_DYNAMIC_PROCESSES -fpermissive \
-I$(SYSTEMC_INC_DIR)
LDFLAGS = -L$(SYSTEMC_LIB_DIR) -lsystemc -lm
TESTS = .
SRCS = $(wildcard $(TESTS)/*.cpp)
OBJS=$(SRCS:.cpp=.o)
TARGETS = $(SRCS:.cpp=.x)
$(TARGETS) : $(OBJS)
$(LIBTOOL) --mode=link --tag=CXX g++ -o $@ $(OBJS) $(LDFLAGS)
.cpp.o:
$(LIBTOOL) --mode=compile g++ -c $(FLAGS) $<
%.o: %.c
$(LIBTOOL) --mode=compile gcc -Wall -c $<
.PHONY: clean
clean:
rm -f $(TESTS)/*.o $(TESTS)/*.lo
rm -rf $(TESTS)/.libs
......@@ -10,7 +10,7 @@ set -x LLVM_BUILD_DIR /home/$USER/bin/clang-7.0.0/
# Path where SystemC is installed
# SET this.
set -x SYSTEMC /home/$USER/code/systemc-2.3.3/systemc/
set -x SYSTEMC /home/$USER/code/systemc-2.3.3/systemc
# Path for the systemc-clang build directory
# SET this.
......@@ -29,7 +29,7 @@ set -x LLVM_CXX_FLAGS (eval $LLVMCONFIG --cxxflags)
# Generate all the flags.
# -fno-aligned-allocation needed for c++17
set -x LLVM_CXX_FLAGS "$LLVM_CXX_FLAGS -fvisibility-inlines-hidden -fno-aligned-allocation"
set -x LLVM_CXX_FLAGS "$LLVM_CXX_FLAGS -fvisibility-inlines-hidden -fno-aligned-allocation -Wsign-compare"
set -x LLVM_LIBS (eval $LLVMCONFIG --libs)
set -x LLVM_LD_FLAGS (eval $LLVMCONFIG --ldflags)
set -x LLVM_LD_FLAGS (echo $LLVM_LD_FLAGS | sed 's/ *$//g')
add_library (libsystemc-clang
ModuleDecl.cpp
FindModule.cpp
SCModules.cpp
FindSCModules.cpp
FindSCMain.cpp
FindPorts.cpp
FindTLMInterfaces.cpp
......@@ -10,17 +10,19 @@ add_library (libsystemc-clang
FindEntryFunctions.cpp
FindSensitivity.cpp
FindWait.cpp
FindNotify.cpp
FindNotify.cpp
FindSignals.cpp
FindSimTime.cpp
FindConstructor.cpp
FindTemplateTypes.cpp
FindConstructor.cpp
SystemCClang.cpp
FindNetlist.cpp
FindArgument.cpp
Automata.cpp
FindTemplateParameters.cpp
Automata.cpp
SuspensionAutomata.cpp
SCuitable/GlobalSuspensionAutomata.cpp
SCuitable/FindGPUMacro.cpp
SCuitable/GlobalSuspensionAutomata.cpp
SCuitable/FindGPUMacro.cpp
####################################
#From here the files are for the reflection database
####################################
......@@ -35,7 +37,7 @@ add_library (libsystemc-clang
InterfaceDecl.cpp
Model.cpp
WaitCalls.cpp
NotifyCalls.cpp
NotifyCalls.cpp
EventContainer.cpp
)
#include "FindGlobalEvents.h"
using namespace scpar;
FindGlobalEvents::FindGlobalEvents(TranslationUnitDecl *d,
llvm::raw_ostream &os)
: _os(os) {
TraverseDecl(d);
FindGlobalEvents::FindGlobalEvents(TranslationUnitDecl * declaration, llvm::raw_ostream &os)
: _os(os) {
TraverseDecl(declaration);
}
FindGlobalEvents::~FindGlobalEvents() {}
bool FindGlobalEvents::VisitVarDecl(VarDecl *vd) {
QualType q = vd->getType();
bool FindGlobalEvents::VisitVarDecl(VarDecl * variable_declaration) {
QualType variable_type { variable_declaration->getType() };
if (q.getAsString() == "class sc_core::sc_event") {
if (IdentifierInfo *info = vd->getIdentifier()) {
if (variable_type.getAsString() == "class sc_core::sc_event") {
if (IdentifierInfo *info = variable_declaration->getIdentifier()) {
_globalEvents.insert(kvType(info->getNameStart(), vd));
_globalEvents.insert( kvType(info->getNameStart(), variable_declaration) );
}
}
return true;
......@@ -34,3 +34,14 @@ void FindGlobalEvents::dump() {
}
_os << "\n ============== END FindGlobalEvents ===============";
}
json FindGlobalEvents::dump_json() {
json globals_j{};
for (auto const &event : _globalEvents) {
globals_j["global_declarations"].emplace_back( event.first ) ;
}
std::cout << globals_j.dump(4) << endl;
return globals_j;
}
#ifndef _FIND_GLOBAL_EVENTS_H_
#define _FIND_GLOBAL_EVENTS_H_
#include "systemc-clang.h"
#include "json.hpp"
#include "clang/AST/Decl.h"
#include "clang/AST/RecursiveASTVisitor.h"
......@@ -11,7 +13,8 @@
namespace scpar {
using namespace clang;
using namespace std;
using json = nlohmann::json;
class FindGlobalEvents : public RecursiveASTVisitor<FindGlobalEvents> {
public:
typedef map<string, VarDecl *> globalEventMapType;
......@@ -26,6 +29,8 @@ public:
vector<string> getEventNames();
void dump();
json dump_json();
private:
llvm::raw_ostream &_os;
......
......@@ -31,8 +31,20 @@ bool FindModule::VisitCXXRecordDecl(CXXRecordDecl *declaration) {
is_systemc_module_ = true;
if (IdentifierInfo *info = declaration_->getIdentifier()) {
module_name_ = info->getNameStart();
// // Check if the class is a templated module class.
// auto template_args{ declaration->getDescribedClassTemplate() };
// if (template_args != nullptr) {
// os_ << module_name_ << ": TEMPLATE ARGS YES \n";
// template_parameters_ = template_args->getTemplateParameters();
// //parms->getParam(0)->dump();
// // parms->getParam(1)->dump();
// }
}
}
}
......@@ -44,6 +56,20 @@ bool FindModule::VisitCXXRecordDecl(CXXRecordDecl *declaration) {
return false;
}
// vector<string> FindModule::getTemplateParameters() const {
// vector<string> parm_list;
// if ( (template_parameters_ == nullptr)
// || (template_parameters_->size() <= 0) ) {
// return parm_list;
// }
// for (auto parm : template_parameters_->asArray() ) {
// parm_list.push_back( parm->getName() );
// os_ << "Parm: " << parm->getName() << "\n";
// }
// return parm_list;
// }
FindModule::~FindModule() { declaration_ = nullptr; }
bool FindModule::isSystemCModule() const { return is_systemc_module_; }
......
......@@ -14,17 +14,20 @@ class FindModule : public RecursiveASTVisitor<FindModule> {
public:
FindModule(CXXRecordDecl *, llvm::raw_ostream &);
virtual bool VisitCXXRecordDecl(CXXRecordDecl *decl);
virtual ~FindModule();
void dump();
string getModuleName() const;
bool isSystemCModule() const;
// vector<string> getTemplateParameters() const;
private:
CXXRecordDecl *declaration_;
llvm::raw_ostream &os_;
bool is_systemc_module_;
string module_name_;
// TemplateParameterList *template_parameters_;
};
} // namespace scpar
#endif
......@@ -21,7 +21,9 @@ bool FindNotify::VisitCallExpr(CallExpr *e) {
LangOpts.CPlusPlus = true;
PrintingPolicy Policy(LangOpts);
if (e->getDirectCallee()->getNameInfo().getAsString() == string("notify") &&
auto direct_callee{ e->getDirectCallee() };
if (direct_callee != nullptr ) {
if (direct_callee->getNameInfo().getAsString() == string("notify") &&
e->getNumArgs() <= 2) { // need a better checking.....
notify_call_list_.push_back(e);
// To get the 'x' from x.f(5) I must use getImplicitObjectArgument.
......@@ -49,6 +51,7 @@ bool FindNotify::VisitCallExpr(CallExpr *e) {
}
*/
}
}
return true;
}
......
......@@ -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";