-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
669 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
Language: Cpp | ||
# BasedOnStyle: Google | ||
AccessModifierOffset: -1 | ||
AlignAfterOpenBracket: Align | ||
AlignConsecutiveAssignments: true | ||
AlignEscapedNewlinesLeft: true | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortBlocksOnASingleLine: false | ||
AllowShortCaseLabelsOnASingleLine: false | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: false | ||
AlwaysBreakAfterDefinitionReturnType: false | ||
AlwaysBreakTemplateDeclarations: true | ||
AlwaysBreakBeforeMultilineStrings: true | ||
BreakBeforeBinaryOperators: None | ||
BreakBeforeTernaryOperators: true | ||
BreakConstructorInitializersBeforeComma: false | ||
BinPackParameters: true | ||
BinPackArguments: true | ||
ColumnLimit: 120 | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
ConstructorInitializerIndentWidth: 4 | ||
DerivePointerAlignment: false | ||
ExperimentalAutoDetectBinPacking: false | ||
IndentCaseLabels: true | ||
IndentWrappedFunctionNames: false | ||
IndentFunctionDeclarationAfterType: false | ||
MaxEmptyLinesToKeep: 1 | ||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
NamespaceIndentation: None | ||
ObjCBlockIndentWidth: 2 | ||
ObjCSpaceAfterProperty: false | ||
ObjCSpaceBeforeProtocolList: false | ||
PenaltyBreakBeforeFirstCallParameter: 1 | ||
PenaltyBreakComment: 300 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 200 | ||
PointerAlignment: Left | ||
SpacesBeforeTrailingComments: 2 | ||
Cpp11BracedListStyle: true | ||
Standard: Cpp11 | ||
IndentWidth: 2 | ||
TabWidth: 2 | ||
UseTab: Never | ||
BreakBeforeBraces: Attach | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
SpacesInAngles: false | ||
SpaceInEmptyParentheses: false | ||
SpacesInCStyleCastParentheses: false | ||
SpaceAfterCStyleCast: false | ||
SpacesInContainerLiterals: true | ||
SpaceBeforeAssignmentOperators: true | ||
ContinuationIndentWidth: 4 | ||
CommentPragmas: '^ IWYU pragma:' | ||
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] | ||
SpaceBeforeParens: ControlStatements | ||
DisableFormat: false | ||
IncludeBlocks: Regroup | ||
IncludeCategories: | ||
- Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
Priority: 2 | ||
- Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
Priority: 3 | ||
- Regex: '<[[:alnum:].]+>' | ||
Priority: 4 | ||
- Regex: '.*' | ||
Priority: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
--- | ||
# Configure clang-tidy for this project. | ||
# Modified from https://github.com/googleapis/google-cloud-cpp/blob/main/.clang-tidy | ||
|
||
# Here is an explanation for why some of the checks are disabled: | ||
# | ||
# -google-readability-namespace-comments: the *_CLIENT_NS is a macro, and | ||
# clang-tidy fails to match it against the initial value. | ||
# | ||
# -modernize-use-trailing-return-type: clang-tidy recommends using | ||
# `auto Foo() -> std::string { return ...; }`, we think the code is less | ||
# readable in this form. | ||
# | ||
# -modernize-return-braced-init-list: We think removing typenames and using | ||
# only braced-init can hurt readability. | ||
# | ||
# -modernize-avoid-c-arrays: We only use C arrays when they seem to be the | ||
# right tool for the job, such as `char foo[] = "hello"`. In these cases, | ||
# avoiding C arrays often makes the code less readable, and std::array is | ||
# not a drop-in replacement because it doesn't deduce the size. | ||
# | ||
# -performance-move-const-arg: This warning requires the developer to | ||
# know/care more about the implementation details of types/functions than | ||
# should be necessary. For example, `A a; F(std::move(a));` will trigger a | ||
# warning IFF `A` is a trivial type (and therefore the move is | ||
# meaningless). It would also warn if `F` accepts by `const&`, which is | ||
# another detail that the caller need not care about. | ||
# | ||
# -readability-redundant-declaration: A friend declaration inside a class | ||
# counts as a declaration, so if we also declare that friend outside the | ||
# class in order to document it as part of the public API, that will | ||
# trigger a redundant declaration warning from this check. | ||
# | ||
# -readability-function-cognitive-complexity: too many false positives with | ||
# clang-tidy-12. We need to disable this check in macros, and that setting | ||
# only appears in clang-tidy-13. | ||
# | ||
# -bugprone-narrowing-conversions: too many false positives around | ||
# `std::size_t` vs. `*::difference_type`. | ||
# | ||
Checks: > | ||
-*, | ||
bugprone-*, | ||
misc-*, | ||
modernize-*, | ||
performance-*, | ||
portability-*, | ||
readability-*, | ||
-google-readability-braces-around-statements, | ||
-google-readability-namespace-comments, | ||
-google-runtime-references, | ||
-misc-non-private-member-variables-in-classes, | ||
-modernize-return-braced-init-list, | ||
-modernize-use-trailing-return-type, | ||
-modernize-avoid-c-arrays, | ||
-performance-move-const-arg, | ||
-readability-braces-around-statements, | ||
-readability-magic-numbers, | ||
-readability-named-parameter, | ||
-readability-redundant-declaration, | ||
-readability-function-cognitive-complexity, | ||
-bugprone-narrowing-conversions | ||
CheckOptions: | ||
- { key: readability-identifier-naming.NamespaceCase, value: lower_case } | ||
- { key: readability-identifier-naming.ClassCase, value: CamelCase } | ||
- { key: readability-identifier-naming.StructCase, value: CamelCase } | ||
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase } | ||
- { key: readability-identifier-naming.FunctionCase, value: aNy_CasE } | ||
- { key: readability-identifier-naming.VariableCase, value: lower_case } | ||
- { key: readability-identifier-naming.ClassMemberCase, value: lower_case } | ||
- { key: readability-identifier-naming.ClassMemberSuffix, value: _ } | ||
- { key: readability-identifier-naming.PrivateMemberSuffix, value: _ } | ||
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: _ } | ||
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase } | ||
- { key: readability-identifier-naming.EnumConstantPrefix, value: k } | ||
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase } | ||
- { key: readability-identifier-naming.ConstexprVariablePrefix, value: k } | ||
- { key: readability-identifier-naming.GlobalConstantCase, value: CamelCase } | ||
- { key: readability-identifier-naming.GlobalConstantPrefix, value: k } | ||
- { key: readability-identifier-naming.MemberConstantCase, value: CamelCase } | ||
- { key: readability-identifier-naming.MemberConstantPrefix, value: k } | ||
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase } | ||
- { key: readability-identifier-naming.StaticConstantPrefix, value: k } | ||
- { key: readability-implicit-bool-conversion.AllowIntegerConditions, value: 1 } | ||
- { key: readability-implicit-bool-conversion.AllowPointerConditions, value: 1 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
cmake_minimum_required(VERSION 3.20) | ||
|
||
project(dimeta | ||
VERSION 0.1 | ||
) | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
set(CMAKE_VERBOSE_MAKEFILE ON) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
list( | ||
APPEND | ||
CMAKE_MODULE_PATH | ||
${CMAKE_CURRENT_SOURCE_DIR}/cmake | ||
) | ||
|
||
include(dimetaToolchain) | ||
|
||
dimeta_target_format( | ||
format-dimeta-sources "Formats project source files" | ||
TARGETS lib/pass/*.cpp | ||
lib/pass/*.h | ||
) | ||
|
||
add_subdirectory(lib) | ||
|
||
enable_testing() | ||
add_subdirectory(test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"version": 2, | ||
"cmakeMinimumRequired": { | ||
"major": 3, | ||
"minor": 20, | ||
"patch": 0 | ||
}, | ||
"configurePresets": [ | ||
{ | ||
"name": "clang-toolchain", | ||
"hidden": true, | ||
"generator": "Unix Makefiles", | ||
"cacheVariables": { | ||
"CMAKE_C_COMPILER": "clang", | ||
"CMAKE_CXX_COMPILER": "clang++" | ||
} | ||
}, | ||
{ | ||
"name": "develop", | ||
"displayName": "Development config (debug)", | ||
"description": "Default develop build options for Clang", | ||
"binaryDir": "${sourceDir}/build", | ||
"inherits": [ | ||
"clang-toolchain" | ||
], | ||
"cacheVariables": { | ||
"CMAKE_BUILD_TYPE": "Debug" | ||
} | ||
}, | ||
{ | ||
"name": "release", | ||
"displayName": "Release config", | ||
"description": "Default release build options for Clang", | ||
"binaryDir": "${sourceDir}/build", | ||
"inherits": [ | ||
"clang-toolchain" | ||
], | ||
"cacheVariables": { | ||
"CMAKE_BUILD_TYPE": "Release" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
include(CMakeDependentOption) | ||
include(CMakePackageConfigHelpers) | ||
include(GNUInstallDirs) | ||
include(FeatureSummary) | ||
set(FETCHCONTENT_UPDATES_DISCONNECTED ON CACHE STRING "" FORCE) | ||
include(FetchContent) | ||
|
||
find_package(LLVM 10 REQUIRED CONFIG) | ||
set_package_properties(LLVM PROPERTIES | ||
URL https://llvm.org/ | ||
TYPE REQUIRED | ||
PURPOSE | ||
"LLVM framework installation required to compile (and apply) TypeART and TyCart." | ||
) | ||
|
||
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}") | ||
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") | ||
include(AddLLVM) | ||
|
||
include(modules/dimeta-llvm) | ||
include(modules/dimeta-llvm-lit) | ||
include(modules/dimeta-format) | ||
include(modules/dimeta-target-util) | ||
|
||
if(NOT CMAKE_BUILD_TYPE) | ||
# set default build type | ||
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE) | ||
message(STATUS "Building as debug (default)") | ||
endif() | ||
|
||
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) | ||
# set default install path | ||
set(CMAKE_INSTALL_PREFIX | ||
"${dimeta_SOURCE_DIR}/install/dimeta" | ||
CACHE PATH "Default install path" FORCE | ||
) | ||
message(STATUS "Installing to (default): ${CMAKE_INSTALL_PREFIX}") | ||
endif() | ||
|
||
dimeta_find_llvm_progs(DIMETA_CLANG_EXEC "clang;clang-13;clang-12;clang-11;clang-10" "clang") | ||
dimeta_find_llvm_progs(DIMETA_CLANGCXX_EXEC "clang++;clang-13;clang-12;clang-11;clang++-10" "clang++") | ||
dimeta_find_llvm_progs(DIMETA_LLC_EXEC "llc;llc-13;llc-12;llc-11;llc-10" "llc") | ||
dimeta_find_llvm_progs(DIMETA_OPT_EXEC "opt;opt-13;opt-12;opt-11;opt-10" "opt") | ||
dimeta_find_llvm_progs(DIMETA_FILECHECK_EXEC "FileCheck;FileCheck-13;FileCheck-12;FileCheck-11;FileCheck-10" "FileCheck") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
function(dimeta_target_format target comment) | ||
macro(filter_dir dir_name_) | ||
foreach (source_file ${ALL_CXX_FILES}) | ||
string(FIND ${source_file} ${dir_name_} EXCLUDE_FOUND) | ||
if (NOT ${EXCLUDE_FOUND} EQUAL -1) | ||
list(REMOVE_ITEM ALL_CXX_FILES ${source_file}) | ||
endif() | ||
endforeach() | ||
endmacro() | ||
|
||
cmake_parse_arguments(ARG "" "" "TARGETS;EXCLUDES;OTHER" ${ARGN}) | ||
|
||
file(GLOB_RECURSE | ||
ALL_CXX_FILES | ||
CONFIGURE_DEPENDS | ||
${ARG_TARGETS} | ||
) | ||
|
||
foreach(exclude ${ARG_EXCLUDES}) | ||
filter_dir(${exclude}) | ||
endforeach() | ||
|
||
find_program(FORMAT_COMMAND | ||
NAMES clang-format clang-format-13 clang-format-12 clang-format-11 clang-format-10) | ||
if(FORMAT_COMMAND) | ||
add_custom_target(${target} | ||
COMMAND ${FORMAT_COMMAND} -i -style=file ${ARG_OTHER} ${ARG_UNPARSED_ARGUMENTS} | ||
${ALL_CXX_FILES} | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} | ||
COMMENT "${comment}" | ||
USES_TERMINAL | ||
) | ||
else() | ||
message(WARNING "Could not find clang-format executable.") | ||
add_custom_target(${target} | ||
COMMAND ${CMAKE_COMMAND} -E echo "${target} does nothing, no clang-format found.") | ||
endif() | ||
endfunction() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
find_package(Python3 QUIET) | ||
|
||
if(LLVM_EXTERNAL_LIT) | ||
message(STATUS "External lit path is used") | ||
get_llvm_lit_path( | ||
lit_base_dir | ||
lit_file_name | ||
ALLOW_EXTERNAL | ||
) | ||
set(PATH_TO_LIT ${lit_file_name}) | ||
if(lit_base_dir) | ||
set(PATH_TO_LIT ${lit_base_dir}/${PATH_TO_LIT}) | ||
endif() | ||
set(LIT_COMMAND_I "${Python3_EXECUTABLE};${PATH_TO_LIT}") | ||
endif() | ||
|
||
if(NOT LIT_COMMAND_I) | ||
find_program(LLVM_LIT_PATH | ||
NAME llvm-lit lit lit.py | ||
HINTS ${LLVM_TOOLS_BINARY_DIR} | ||
PATHS ${LLVM_ROOT_DIR}/bin /usr/bin /usr/local/bin /opt/local/bin /usr/lib | ||
) | ||
|
||
if(LLVM_LIT_PATH) | ||
get_filename_component(path_to_llvm_lit ${LLVM_LIT_PATH} ABSOLUTE CACHE) | ||
set(LIT_COMMAND_I ${path_to_llvm_lit}) | ||
set(LLVM_EXTERNAL_LIT ${LLVM_LIT_PATH}) | ||
else() | ||
message(WARNING "No llvm lit is available") | ||
endif() | ||
endif() | ||
|
||
mark_as_advanced(path_to_llvm_lit) | ||
|
||
message(STATUS "LLVM lit command is set to ${LIT_COMMAND_I}") |
Oops, something went wrong.