xref: /freebsd/contrib/llvm-project/llvm/lib/Transforms/Utils/Utils.cpp (revision 3e8eb5c7f4909209c042403ddee340b2ee7003a5)
1 //===-- Utils.cpp - TransformUtils Infrastructure -------------------------===//
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 file defines the common initialization infrastructure for the
10 // TransformUtils library.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "llvm/Transforms/Utils.h"
15 #include "llvm-c/Initialization.h"
16 #include "llvm-c/Transforms/Utils.h"
17 #include "llvm/IR/LegacyPassManager.h"
18 #include "llvm/InitializePasses.h"
19 #include "llvm/Pass.h"
20 #include "llvm/PassRegistry.h"
21 
22 using namespace llvm;
23 
24 /// initializeTransformUtils - Initialize all passes in the TransformUtils
25 /// library.
26 void llvm::initializeTransformUtils(PassRegistry &Registry) {
27   initializeAddDiscriminatorsLegacyPassPass(Registry);
28   initializeAssumeSimplifyPassLegacyPassPass(Registry);
29   initializeAssumeBuilderPassLegacyPassPass(Registry);
30   initializeBreakCriticalEdgesPass(Registry);
31   initializeCanonicalizeAliasesLegacyPassPass(Registry);
32   initializeCanonicalizeFreezeInLoopsPass(Registry);
33   initializeInstNamerPass(Registry);
34   initializeLCSSAWrapperPassPass(Registry);
35   initializeLibCallsShrinkWrapLegacyPassPass(Registry);
36   initializeLoopSimplifyPass(Registry);
37   initializeLowerInvokeLegacyPassPass(Registry);
38   initializeLowerSwitchLegacyPassPass(Registry);
39   initializeNameAnonGlobalLegacyPassPass(Registry);
40   initializePromoteLegacyPassPass(Registry);
41   initializeStripNonLineTableDebugLegacyPassPass(Registry);
42   initializeUnifyFunctionExitNodesLegacyPassPass(Registry);
43   initializeMetaRenamerPass(Registry);
44   initializeStripGCRelocatesLegacyPass(Registry);
45   initializePredicateInfoPrinterLegacyPassPass(Registry);
46   initializeInjectTLIMappingsLegacyPass(Registry);
47   initializeFixIrreduciblePass(Registry);
48   initializeUnifyLoopExitsLegacyPassPass(Registry);
49 }
50 
51 /// LLVMInitializeTransformUtils - C binding for initializeTransformUtilsPasses.
52 void LLVMInitializeTransformUtils(LLVMPassRegistryRef R) {
53   initializeTransformUtils(*unwrap(R));
54 }
55 
56 void LLVMAddLowerSwitchPass(LLVMPassManagerRef PM) {
57   unwrap(PM)->add(createLowerSwitchPass());
58 }
59 
60 void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM) {
61   unwrap(PM)->add(createPromoteMemoryToRegisterPass());
62 }
63 
64 void LLVMAddAddDiscriminatorsPass(LLVMPassManagerRef PM) {
65   unwrap(PM)->add(createAddDiscriminatorsPass());
66 }
67