xref: /freebsd/contrib/llvm-project/llvm/lib/Transforms/Utils/Utils.cpp (revision 972a253a57b6f144b0e4a3e2080a2a0076ec55a0)
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   initializeCanonicalizeFreezeInLoopsPass(Registry);
32   initializeInstNamerPass(Registry);
33   initializeLCSSAWrapperPassPass(Registry);
34   initializeLibCallsShrinkWrapLegacyPassPass(Registry);
35   initializeLoopSimplifyPass(Registry);
36   initializeLowerGlobalDtorsLegacyPassPass(Registry);
37   initializeLowerInvokeLegacyPassPass(Registry);
38   initializeLowerSwitchLegacyPassPass(Registry);
39   initializePromoteLegacyPassPass(Registry);
40   initializeStripNonLineTableDebugLegacyPassPass(Registry);
41   initializeUnifyFunctionExitNodesLegacyPassPass(Registry);
42   initializeMetaRenamerPass(Registry);
43   initializeStripGCRelocatesLegacyPass(Registry);
44   initializePredicateInfoPrinterLegacyPassPass(Registry);
45   initializeInjectTLIMappingsLegacyPass(Registry);
46   initializeFixIrreduciblePass(Registry);
47   initializeUnifyLoopExitsLegacyPassPass(Registry);
48 }
49 
50 /// LLVMInitializeTransformUtils - C binding for initializeTransformUtilsPasses.
51 void LLVMInitializeTransformUtils(LLVMPassRegistryRef R) {
52   initializeTransformUtils(*unwrap(R));
53 }
54 
55 void LLVMAddLowerSwitchPass(LLVMPassManagerRef PM) {
56   unwrap(PM)->add(createLowerSwitchPass());
57 }
58 
59 void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM) {
60   unwrap(PM)->add(createPromoteMemoryToRegisterPass());
61 }
62 
63 void LLVMAddAddDiscriminatorsPass(LLVMPassManagerRef PM) {
64   unwrap(PM)->add(createAddDiscriminatorsPass());
65 }
66