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) cmake_minimum_required(VERSION 2.6)
project(systemc-clang) project(systemc-clang)
# Use C++ standard version to c++17 # Use C++ standard version to c++17
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
# Always keep it on # Always keep it on
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
option (USE_SAUTO option (USE_SAUTO
"Use suspension-automata library." OFF "Use suspension-automata library." OFF
) )
set (ROOT_CPP set (ROOT_CPP
driver-tooling.cpp driver-tooling.cpp
# ToolingTest.cpp # ToolingTest.cpp
# ToolingTutorial.cpp # ToolingTutorial.cpp
) )
# set (CLANG_SRC_DIR # set (CLANG_SRC_DIR
# $ENV{CLANG_SRC_DIR} # $ENV{CLANG_SRC_DIR}
...@@ -20,108 +20,107 @@ cmake_minimum_required(VERSION 2.6) ...@@ -20,108 +20,107 @@ cmake_minimum_required(VERSION 2.6)
# set (LLVM_SRC_DIR # set (LLVM_SRC_DIR
# $ENV{LLVM_SRC_DIR} # $ENV{LLVM_SRC_DIR}
# ) # )
set (LLVM_BUILD_DIR set (LLVM_BUILD_DIR
$ENV{LLVM_BUILD_DIR} $ENV{LLVM_BUILD_DIR}
) )
set (CMAKE_CXX_FLAGS set (CMAKE_CXX_FLAGS
"$ENV{LLVM_CXX_FLAGS} $ENV{CMAKE_CXX_FLAGS} -DUSE_SAUTO=off" "$ENV{LLVM_CXX_FLAGS} $ENV{CMAKE_CXX_FLAGS} -DUSE_SAUTO=off"
) )
if (USE_SAUTO) if (USE_SAUTO)
set (CMAKE_CXX_FLAGS set (CMAKE_CXX_FLAGS
"-DUSE_SAUTO=on ${CMAKE_CXX_FLAGS}" "-DUSE_SAUTO=on ${CMAKE_CXX_FLAGS}"
) )
endif(USE_SAUTO) endif(USE_SAUTO)
set (LLVM_LD_FLAGS set (LLVM_LD_FLAGS
"$ENV{LLVM_LD_FLAGS} -lpthread" "$ENV{LLVM_LD_FLAGS} -lpthread"
) )
set (LLVM_LIBS set (LLVM_LIBS
$ENV{LLVM_LIBS} $ENV{LLVM_LIBS}
) )
#set (LLVM_LD_LIBS LLVMCppBackendCodeGen LLVMCppBackendInfo LLVMTarget LLVMCore LLVMMC LLVMObject LLVMSupport) #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 #LLVMJIT LLVMX86CodeGen LLVMX86AsmParser LLVMX86Disassembler LLVMExecutionEngine LLVMAsmPrinter LLVMSelectionDAG LLVMX86AsmPrinter LLVMX86Info LLVMMCParser LLVMCodeGen LLVMX86Utils LLVMScalarOpts LLVMInstCombine LLVMTransformUtils LLVMipa LLVMAnalysis LLVMTarget LLVMCore LLVMMC LLVMSupport
set (CLANG_LIBS set (CLANG_LIBS
clangTooling clangTooling
clangFrontendTool clangFrontendTool
clangFrontend clangFrontend
clangDriver clangDriver
clangSerialization clangSerialization
clangCodeGen clangCodeGen
clangParse clangParse
clangSema clangSema
clangStaticAnalyzerFrontend clangStaticAnalyzerFrontend
clangStaticAnalyzerCheckers clangStaticAnalyzerCheckers
clangStaticAnalyzerCore clangStaticAnalyzerCore
clangAnalysis clangAnalysis
clangARCMigrate clangARCMigrate
clangRewriteFrontend clangRewriteFrontend
clangRewrite clangRewrite
clangEdit clangEdit
clangAST clangAST
clangLex clangLex
clangBasic clangBasic
clangASTMatchers clangASTMatchers
) )
set (CMAKE_MODULE_LINKER_FLAGS set (CMAKE_MODULE_LINKER_FLAGS
$ENV{LLVM_LD_FLAGS} $ENV{LLVM_LD_FLAGS}
) )
set (TARGET set (TARGET
"systemc-clang" "systemc-clang"
) )
include_directories( include_directories(
"${LLVM_BUILD_DIR}/include" "${LLVM_BUILD_DIR}/include"
src src
if (USE_SAUTO) if (USE_SAUTO)
sauto sauto
endif (USE_SAUTO) endif (USE_SAUTO)
) )
link_directories( link_directories(
${LLVM_BUILD_DIR}/lib ${LLVM_BUILD_DIR}/lib
) )
add_subdirectory(src)
add_subdirectory(tests)
add_subdirectory(src)
if (USE_SAUTO) if (USE_SAUTO)
add_subdirectory(sauto) add_subdirectory(sauto)
endif (USE_SAUTO) endif (USE_SAUTO)
set( SRC_LIB libsystemc-clang) set( SRC_LIB libsystemc-clang )
if (USE_SAUTO) if (USE_SAUTO)
set( SAUTO_LIB libsauto ) set( SAUTO_LIB libsauto )
endif (USE_SAUTO) endif (USE_SAUTO)
add_executable( add_executable(
${TARGET} ${TARGET}
${ROOT_CPP} ) ${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()
foreach (llvm_lib ${LLVM_LIBS}) target_link_libraries(${TARGET} ${SRC_LIB})
target_link_libraries( ${TARGET} ${llvm_lib} ) target_link_libraries(${TARGET} ${SAUTO_LIB})
endforeach()
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/ ...@@ -10,7 +10,7 @@ set -x LLVM_BUILD_DIR /home/$USER/bin/clang-7.0.0/
# Path where SystemC is installed # Path where SystemC is installed
# SET this. # 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 # Path for the systemc-clang build directory
# SET this. # SET this.
...@@ -29,7 +29,7 @@ set -x LLVM_CXX_FLAGS (eval $LLVMCONFIG --cxxflags) ...@@ -29,7 +29,7 @@ set -x LLVM_CXX_FLAGS (eval $LLVMCONFIG --cxxflags)
# Generate all the flags. # Generate all the flags.
# -fno-aligned-allocation needed for c++17 # -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_LIBS (eval $LLVMCONFIG --libs)
set -x LLVM_LD_FLAGS (eval $LLVMCONFIG --ldflags) set -x LLVM_LD_FLAGS (eval $LLVMCONFIG --ldflags)
set -x LLVM_LD_FLAGS (echo $LLVM_LD_FLAGS | sed 's/ *$//g') set -x LLVM_LD_FLAGS (echo $LLVM_LD_FLAGS | sed 's/ *$//g')
add_library (libsystemc-clang add_library (libsystemc-clang
ModuleDecl.cpp ModuleDecl.cpp
FindModule.cpp FindModule.cpp
SCModules.cpp FindSCModules.cpp
FindSCMain.cpp FindSCMain.cpp
FindPorts.cpp FindPorts.cpp
FindTLMInterfaces.cpp FindTLMInterfaces.cpp
...@@ -10,17 +10,19 @@ add_library (libsystemc-clang ...@@ -10,17 +10,19 @@ add_library (libsystemc-clang
FindEntryFunctions.cpp FindEntryFunctions.cpp
FindSensitivity.cpp FindSensitivity.cpp
FindWait.cpp FindWait.cpp
FindNotify.cpp FindNotify.cpp
FindSignals.cpp FindSignals.cpp
FindSimTime.cpp FindSimTime.cpp
FindConstructor.cpp FindTemplateTypes.cpp
FindConstructor.cpp
SystemCClang.cpp SystemCClang.cpp
FindNetlist.cpp FindNetlist.cpp
FindArgument.cpp FindArgument.cpp
Automata.cpp FindTemplateParameters.cpp
Automata.cpp
SuspensionAutomata.cpp SuspensionAutomata.cpp
SCuitable/GlobalSuspensionAutomata.cpp SCuitable/GlobalSuspensionAutomata.cpp
SCuitable/FindGPUMacro.cpp SCuitable/FindGPUMacro.cpp
#################################### ####################################
#From here the files are for the reflection database #From here the files are for the reflection database
#################################### ####################################
...@@ -35,7 +37,7 @@ add_library (libsystemc-clang ...@@ -35,7 +37,7 @@ add_library (libsystemc-clang
InterfaceDecl.cpp InterfaceDecl.cpp
Model.cpp Model.cpp
WaitCalls.cpp WaitCalls.cpp
NotifyCalls.cpp NotifyCalls.cpp
EventContainer.cpp EventContainer.cpp
) )
#include "FindGlobalEvents.h" #include "FindGlobalEvents.h"
using namespace scpar; using namespace scpar;
FindGlobalEvents::FindGlobalEvents(TranslationUnitDecl *d, FindGlobalEvents::FindGlobalEvents(TranslationUnitDecl * declaration, llvm::raw_ostream &os)
llvm::raw_ostream &os) : _os(os) {
: _os(os) {
TraverseDecl(d); TraverseDecl(declaration);
} }
FindGlobalEvents::~FindGlobalEvents() {} FindGlobalEvents::~FindGlobalEvents() {}
bool FindGlobalEvents::VisitVarDecl(VarDecl *vd) { bool FindGlobalEvents::VisitVarDecl(VarDecl * variable_declaration) {
QualType q = vd->getType(); QualType variable_type { variable_declaration->getType() };
if (q.getAsString() == "class sc_core::sc_event") { if (variable_type.getAsString() == "class sc_core::sc_event") {
if (IdentifierInfo *info = vd->getIdentifier()) { if (IdentifierInfo *info = variable_declaration->getIdentifier()) {
_globalEvents.insert(kvType(info->getNameStart(), vd)); _globalEvents.insert( kvType(info->getNameStart(), variable_declaration) );
} }
} }
return true; return true;
...@@ -34,3 +34,14 @@ void FindGlobalEvents::dump() { ...@@ -34,3 +34,14 @@ void FindGlobalEvents::dump() {
} }
_os << "\n ============== END FindGlobalEvents ==============="; _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_ #ifndef _FIND_GLOBAL_EVENTS_H_
#define _FIND_GLOBAL_EVENTS_H_ #define _FIND_GLOBAL_EVENTS_H_
#include "systemc-clang.h"
#include "json.hpp"
#include "clang/AST/Decl.h" #include "clang/AST/Decl.h"
#include "clang/AST/RecursiveASTVisitor.h" #include "clang/AST/RecursiveASTVisitor.h"
...@@ -11,7 +13,8 @@ ...@@ -11,7 +13,8 @@
namespace scpar { namespace scpar {
using namespace clang; using namespace clang;
using namespace std; using namespace std;
using json = nlohmann::json;
class FindGlobalEvents : public RecursiveASTVisitor<FindGlobalEvents> { class FindGlobalEvents : public RecursiveASTVisitor<FindGlobalEvents> {
public: public:
typedef map<string, VarDecl *> globalEventMapType; typedef map<string, VarDecl *> globalEventMapType;
...@@ -26,6 +29,8 @@ public: ...@@ -26,6 +29,8 @@ public:
vector<string> getEventNames(); vector<string> getEventNames();
void dump(); void dump();
json dump_json();
private: private:
llvm::raw_ostream &_os; llvm::raw_ostream &_os;
......
...@@ -31,8 +31,20 @@ bool FindModule::VisitCXXRecordDecl(CXXRecordDecl *declaration) { ...@@ -31,8 +31,20 @@ bool FindModule::VisitCXXRecordDecl(CXXRecordDecl *declaration) {
is_systemc_module_ = true; is_systemc_module_ = true;
if (IdentifierInfo *info = declaration_->getIdentifier()) { if (IdentifierInfo *info = declaration_->getIdentifier()) {
module_name_ = info->getNameStart(); 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) { ...@@ -44,6 +56,20 @@ bool FindModule::VisitCXXRecordDecl(CXXRecordDecl *declaration) {
return false; 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";
// }