diff options
| author | serge_sans_paille <sguelton@redhat.com> | 2019-06-08 17:37:47 +0200 |
|---|---|---|
| committer | serge-sans-paille <sguelton@redhat.com> | 2020-01-02 16:45:31 +0100 |
| commit | 24ab9b537e61b3fe5e6a1019492ff6530d82a3ee (patch) | |
| tree | a44734fd73e2789f7817cf49b5a30f638a1a4a63 /polly/lib | |
| parent | 8d7ecc16291ff415da0d5bfccb6363590a1310ad (diff) | |
| download | bcm5719-llvm-24ab9b537e61b3fe5e6a1019492ff6530d82a3ee.tar.gz bcm5719-llvm-24ab9b537e61b3fe5e6a1019492ff6530d82a3ee.zip | |
Generalize the pass registration mechanism used by Polly to any third-party tool
There's quite a lot of references to Polly in the LLVM CMake codebase. However
the registration pattern used by Polly could be useful to other external
projects: thanks to that mechanism it would be possible to develop LLVM
extension without touching the LLVM code base.
This patch has two effects:
1. Remove all code specific to Polly in the llvm/clang codebase, replaicing it
with a generic mechanism
2. Provide a generic mechanism to register compiler extensions.
A compiler extension is similar to a pass plugin, with the notable difference
that the compiler extension can be configured to be built dynamically (like
plugins) or statically (like regular passes).
As a result, people willing to add extra passes to clang/opt can do it using a
separate code repo, but still have their pass be linked in clang/opt as built-in
passes.
Differential Revision: https://reviews.llvm.org/D61446
Diffstat (limited to 'polly/lib')
| -rw-r--r-- | polly/lib/CMakeLists.txt | 15 | ||||
| -rw-r--r-- | polly/lib/Plugin/Polly.cpp | 20 | ||||
| -rw-r--r-- | polly/lib/Polly.cpp | 29 | ||||
| -rw-r--r-- | polly/lib/Support/RegisterPasses.cpp | 25 |
4 files changed, 49 insertions, 40 deletions
diff --git a/polly/lib/CMakeLists.txt b/polly/lib/CMakeLists.txt index 5bbc4dcf109..e76d6039ad5 100644 --- a/polly/lib/CMakeLists.txt +++ b/polly/lib/CMakeLists.txt @@ -23,7 +23,7 @@ endif () # Use an object-library to add the same files to multiple libs without requiring # the sources them to be recompiled for each of them. -add_library(PollyCore OBJECT +add_llvm_pass_plugin(Polly Analysis/DependenceInfo.cpp Analysis/PolyhedralInfo.cpp Analysis/ScopDetection.cpp @@ -70,13 +70,13 @@ add_library(PollyCore OBJECT Transform/ScopInliner.cpp ${POLLY_HEADER_FILES} ) -set_target_properties(PollyCore PROPERTIES FOLDER "Polly") +set_target_properties(obj.Polly PROPERTIES FOLDER "Polly") +set_target_properties(Polly PROPERTIES FOLDER "Polly") # Create the library that can be linked into LLVM's tools and Polly's unittests. # It depends on all library it needs, such that with # LLVM_POLLY_LINK_INTO_TOOLS=ON, its dependencies like PollyISL are linked as # well. -add_polly_library(Polly $<TARGET_OBJECTS:PollyCore>) target_link_libraries(Polly PUBLIC ${ISL_TARGET} ) @@ -124,6 +124,9 @@ else () LLVMTarget LLVMVectorize ) + + # Polly-ACC requires the NVPTX target to be present in the executable it is linked to + set_property(TARGET bugpoint APPEND PROPERTY LINK_LIBRARIES LLVMTarget) endif () # Create a loadable module Polly.so that can be loaded using @@ -134,8 +137,8 @@ if (MSVC) set_target_properties(LLVMPolly PROPERTIES FOLDER "Polly") else () add_polly_loadable_module(LLVMPolly - Polly.cpp - $<TARGET_OBJECTS:PollyCore> + Plugin/Polly.cpp + $<TARGET_OBJECTS:obj.Polly> ) # Only add the dependencies that are not part of LLVM. The latter are assumed @@ -159,5 +162,5 @@ endif () if (TARGET intrinsics_gen) # Check if we are building as part of an LLVM build - add_dependencies(PollyCore intrinsics_gen) + add_dependencies(obj.Polly intrinsics_gen) endif() diff --git a/polly/lib/Plugin/Polly.cpp b/polly/lib/Plugin/Polly.cpp new file mode 100644 index 00000000000..f567d37c07e --- /dev/null +++ b/polly/lib/Plugin/Polly.cpp @@ -0,0 +1,20 @@ +//===---------- Polly.cpp - Initialize the Polly Module -------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +//===----------------------------------------------------------------------===// + +#include "polly/RegisterPasses.h" +#include "llvm/PassRegistry.h" +#include "llvm/Passes/PassPlugin.h" + +// Pass Plugin Entrypoints + +extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo +llvmGetPassPluginInfo() { + return getPollyPluginInfo(); +} diff --git a/polly/lib/Polly.cpp b/polly/lib/Polly.cpp deleted file mode 100644 index e6bae931fc5..00000000000 --- a/polly/lib/Polly.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===---------- Polly.cpp - Initialize the Polly Module -------------------===// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// -// -//===----------------------------------------------------------------------===// - -#include "polly/RegisterPasses.h" -#include "llvm/PassRegistry.h" - -namespace { - -/// Initialize Polly passes when library is loaded. -/// -/// We use the constructor of a statically declared object to initialize the -/// different Polly passes right after the Polly library is loaded. This ensures -/// that the Polly passes are available e.g. in the 'opt' tool. -class StaticInitializer { -public: - StaticInitializer() { - llvm::PassRegistry &Registry = *llvm::PassRegistry::getPassRegistry(); - polly::initializePollyPasses(Registry); - } -}; -static StaticInitializer InitializeEverything; -} // end of anonymous namespace. diff --git a/polly/lib/Support/RegisterPasses.cpp b/polly/lib/Support/RegisterPasses.cpp index 1d31db5e984..4ceca070b37 100644 --- a/polly/lib/Support/RegisterPasses.cpp +++ b/polly/lib/Support/RegisterPasses.cpp @@ -235,6 +235,23 @@ static cl::opt<bool> EnablePruneUnprofitable( cl::desc("Bail out on unprofitable SCoPs before rescheduling"), cl::Hidden, cl::init(true), cl::cat(PollyCategory)); +namespace { + +/// Initialize Polly passes when library is loaded. +/// +/// We use the constructor of a statically declared object to initialize the +/// different Polly passes right after the Polly library is loaded. This ensures +/// that the Polly passes are available e.g. in the 'opt' tool. +class StaticInitializer { +public: + StaticInitializer() { + llvm::PassRegistry &Registry = *llvm::PassRegistry::getPassRegistry(); + polly::initializePollyPasses(Registry); + } +}; +static StaticInitializer InitializeEverything; +} // end of anonymous namespace. + namespace polly { void initializePollyPasses(PassRegistry &Registry) { initializeCodeGenerationPass(Registry); @@ -690,7 +707,7 @@ parseTopLevelPipeline(ModulePassManager &MPM, return true; } -void RegisterPollyPasses(PassBuilder &PB) { +void registerPollyPasses(PassBuilder &PB) { PB.registerAnalysisRegistrationCallback(registerFunctionAnalyses); PB.registerPipelineParsingCallback(parseFunctionPipeline); PB.registerPipelineParsingCallback(parseScopPipeline); @@ -702,9 +719,7 @@ void RegisterPollyPasses(PassBuilder &PB) { } } // namespace polly -// Plugin Entrypoint: -extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK -llvmGetPassPluginInfo() { +llvm::PassPluginLibraryInfo getPollyPluginInfo() { return {LLVM_PLUGIN_API_VERSION, "Polly", LLVM_VERSION_STRING, - polly::RegisterPollyPasses}; + polly::registerPollyPasses}; } |

