diff options
| author | Florian Hahn <flo@fhahn.com> | 2019-11-12 14:06:12 +0000 |
|---|---|---|
| committer | Florian Hahn <flo@fhahn.com> | 2019-11-12 14:14:48 +0000 |
| commit | 7d0b1d77b3d4d47df477519fd1bf099b3df6f899 (patch) | |
| tree | ca900ee5b656d7e131ddcb29a2b763ec9fe4dac4 /llvm/tools | |
| parent | a6c40f56aed1556a80867209b6846f7eedc4dc78 (diff) | |
| download | bcm5719-llvm-7d0b1d77b3d4d47df477519fd1bf099b3df6f899.tar.gz bcm5719-llvm-7d0b1d77b3d4d47df477519fd1bf099b3df6f899.zip | |
[Examples] Add IRTransformations directory to examples.
This patch adds a new IRTransformations directory to llvm/examples/. This is
intended to serve as a new home for example transformations/analysis
code used by various tutorials.
If LLVM_BUILD_EXAMPLES is enabled, the ExamplesIRTransforms library is
linked into the opt binary and the example passes become available.
To start off with, it contains the CFG simplifications used in the IR
part of the 'Getting Started With LLVM: Basics' tutorial at the US LLVM
Developers Meeting 2019.
Reviewers: paquette, jfb, meikeb, lhames, kbarton
Reviewed By: paquette
Differential Revision: https://reviews.llvm.org/D69416
Diffstat (limited to 'llvm/tools')
| -rw-r--r-- | llvm/tools/opt/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | llvm/tools/opt/opt.cpp | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/llvm/tools/opt/CMakeLists.txt b/llvm/tools/opt/CMakeLists.txt index 4ea9baf447a..90730e324c7 100644 --- a/llvm/tools/opt/CMakeLists.txt +++ b/llvm/tools/opt/CMakeLists.txt @@ -42,3 +42,7 @@ export_executable_symbols(opt) if(WITH_POLLY AND LINK_POLLY_INTO_TOOLS) target_link_libraries(opt PRIVATE Polly) endif(WITH_POLLY AND LINK_POLLY_INTO_TOOLS) + +if(LLVM_BUILD_EXAMPLES) + target_link_libraries(opt PRIVATE ExampleIRTransforms) +endif(LLVM_BUILD_EXAMPLES) diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index 1dc5dd448f3..1ad6079f67b 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -476,6 +476,10 @@ static TargetMachine* GetTargetMachine(Triple TheTriple, StringRef CPUStr, getCodeModel(), GetCodeGenOptLevel()); } +#ifdef BUILD_EXAMPLES +void initializeExampleIRTransforms(llvm::PassRegistry &Registry); +#endif + #ifdef LINK_POLLY_INTO_TOOLS namespace polly { void initializePollyPasses(llvm::PassRegistry &Registry); @@ -557,6 +561,10 @@ int main(int argc, char **argv) { initializeWriteBitcodePassPass(Registry); initializeHardwareLoopsPass(Registry); +#ifdef BUILD_EXAMPLES + initializeExampleIRTransforms(Registry); +#endif + #ifdef LINK_POLLY_INTO_TOOLS polly::initializePollyPasses(Registry); #endif |

