| 1 | //===- llvm/Codegen/LinkAllCodegenComponents.h ------------------*- C++ -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This header file pulls in all codegen related passes for tools like lli and |
| 10 | // llc that need this functionality. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef LLVM_CODEGEN_LINKALLCODEGENCOMPONENTS_H |
| 15 | #define LLVM_CODEGEN_LINKALLCODEGENCOMPONENTS_H |
| 16 | |
| 17 | #include "llvm/CodeGen/Passes.h" |
| 18 | #include "llvm/CodeGen/SchedulerRegistry.h" |
| 19 | #include "llvm/Support/AlwaysTrue.h" |
| 20 | #include "llvm/Target/TargetMachine.h" |
| 21 | |
| 22 | namespace { |
| 23 | struct ForceCodegenLinking { |
| 24 | ForceCodegenLinking() { |
| 25 | // We must reference the passes in such a way that compilers will not |
| 26 | // delete it all as dead code, even with whole program optimization, |
| 27 | // yet is effectively a NO-OP. This is so that globals in the translation |
| 28 | // units where these functions are defined are forced to be initialized, |
| 29 | // populating various registries. |
| 30 | if (llvm::getNonFoldableAlwaysTrue()) |
| 31 | return; |
| 32 | |
| 33 | (void) llvm::createFastRegisterAllocator(); |
| 34 | (void) llvm::createBasicRegisterAllocator(); |
| 35 | (void) llvm::createGreedyRegisterAllocator(); |
| 36 | (void) llvm::createDefaultPBQPRegisterAllocator(); |
| 37 | |
| 38 | (void)llvm::createBURRListDAGScheduler(IS: nullptr, |
| 39 | OptLevel: llvm::CodeGenOptLevel::Default); |
| 40 | (void)llvm::createSourceListDAGScheduler(IS: nullptr, |
| 41 | OptLevel: llvm::CodeGenOptLevel::Default); |
| 42 | (void)llvm::createHybridListDAGScheduler(IS: nullptr, |
| 43 | llvm::CodeGenOptLevel::Default); |
| 44 | (void)llvm::createFastDAGScheduler(IS: nullptr, |
| 45 | OptLevel: llvm::CodeGenOptLevel::Default); |
| 46 | (void)llvm::createDefaultScheduler(IS: nullptr, |
| 47 | OptLevel: llvm::CodeGenOptLevel::Default); |
| 48 | (void)llvm::createVLIWDAGScheduler(IS: nullptr, |
| 49 | OptLevel: llvm::CodeGenOptLevel::Default); |
| 50 | } |
| 51 | } ForceCodegenLinking; // Force link by creating a global definition. |
| 52 | } |
| 53 | |
| 54 | #endif |
| 55 | |