1 //===-- Scalar.cpp --------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements common infrastructure for libLLVMScalarOpts.a, which
11 // implements several scalar transformations over the LLVM intermediate
12 // representation, including the C bindings for that library.
14 //===----------------------------------------------------------------------===//
16 #include "llvm-c/Transforms/Scalar.h"
17 #include "llvm-c/Initialization.h"
18 #include "llvm/InitializePasses.h"
19 #include "llvm/PassManager.h"
20 #include "llvm/Analysis/Verifier.h"
21 #include "llvm/Target/TargetData.h"
22 #include "llvm/Transforms/Scalar.h"
26 /// initializeScalarOptsPasses - Initialize all passes linked into the
27 /// ScalarOpts library.
28 void llvm::initializeScalarOpts(PassRegistry
&Registry
) {
29 initializeADCEPass(Registry
);
30 initializeBlockPlacementPass(Registry
);
31 initializeCodeGenPreparePass(Registry
);
32 initializeConstantPropagationPass(Registry
);
33 initializeCorrelatedValuePropagationPass(Registry
);
34 initializeDCEPass(Registry
);
35 initializeDeadInstEliminationPass(Registry
);
36 initializeDSEPass(Registry
);
37 initializeGVNPass(Registry
);
38 initializeEarlyCSEPass(Registry
);
39 initializeIndVarSimplifyPass(Registry
);
40 initializeJumpThreadingPass(Registry
);
41 initializeLICMPass(Registry
);
42 initializeLoopDeletionPass(Registry
);
43 initializeLoopInstSimplifyPass(Registry
);
44 initializeLoopRotatePass(Registry
);
45 initializeLoopStrengthReducePass(Registry
);
46 initializeLoopUnrollPass(Registry
);
47 initializeLoopUnswitchPass(Registry
);
48 initializeLoopIdiomRecognizePass(Registry
);
49 initializeLowerAtomicPass(Registry
);
50 initializeMemCpyOptPass(Registry
);
51 initializeReassociatePass(Registry
);
52 initializeRegToMemPass(Registry
);
53 initializeSCCPPass(Registry
);
54 initializeIPSCCPPass(Registry
);
55 initializeSROA_DTPass(Registry
);
56 initializeSROA_SSAUpPass(Registry
);
57 initializeCFGSimplifyPassPass(Registry
);
58 initializeSimplifyLibCallsPass(Registry
);
59 initializeSinkingPass(Registry
);
60 initializeTailDupPass(Registry
);
61 initializeTailCallElimPass(Registry
);
64 void LLVMInitializeScalarOpts(LLVMPassRegistryRef R
) {
65 initializeScalarOpts(*unwrap(R
));
68 void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM
) {
69 unwrap(PM
)->add(createAggressiveDCEPass());
72 void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM
) {
73 unwrap(PM
)->add(createCFGSimplificationPass());
76 void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM
) {
77 unwrap(PM
)->add(createDeadStoreEliminationPass());
80 void LLVMAddGVNPass(LLVMPassManagerRef PM
) {
81 unwrap(PM
)->add(createGVNPass());
84 void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM
) {
85 unwrap(PM
)->add(createIndVarSimplifyPass());
88 void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM
) {
89 unwrap(PM
)->add(createInstructionCombiningPass());
92 void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM
) {
93 unwrap(PM
)->add(createJumpThreadingPass());
96 void LLVMAddLICMPass(LLVMPassManagerRef PM
) {
97 unwrap(PM
)->add(createLICMPass());
100 void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM
) {
101 unwrap(PM
)->add(createLoopDeletionPass());
104 void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM
) {
105 unwrap(PM
)->add(createLoopIdiomPass());
108 void LLVMAddLoopRotatePass(LLVMPassManagerRef PM
) {
109 unwrap(PM
)->add(createLoopRotatePass());
112 void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM
) {
113 unwrap(PM
)->add(createLoopUnrollPass());
116 void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM
) {
117 unwrap(PM
)->add(createLoopUnswitchPass());
120 void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM
) {
121 unwrap(PM
)->add(createMemCpyOptPass());
124 void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM
) {
125 unwrap(PM
)->add(createPromoteMemoryToRegisterPass());
128 void LLVMAddReassociatePass(LLVMPassManagerRef PM
) {
129 unwrap(PM
)->add(createReassociatePass());
132 void LLVMAddSCCPPass(LLVMPassManagerRef PM
) {
133 unwrap(PM
)->add(createSCCPPass());
136 void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM
) {
137 unwrap(PM
)->add(createScalarReplAggregatesPass());
140 void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM
) {
141 unwrap(PM
)->add(createScalarReplAggregatesPass(-1, false));
144 void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM
,
146 unwrap(PM
)->add(createScalarReplAggregatesPass(Threshold
));
149 void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM
) {
150 unwrap(PM
)->add(createSimplifyLibCallsPass());
153 void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM
) {
154 unwrap(PM
)->add(createTailCallEliminationPass());
157 void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM
) {
158 unwrap(PM
)->add(createConstantPropagationPass());
161 void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM
) {
162 unwrap(PM
)->add(createDemoteRegisterToMemoryPass());
165 void LLVMAddVerifierPass(LLVMPassManagerRef PM
) {
166 unwrap(PM
)->add(createVerifierPass());
169 void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM
) {
170 unwrap(PM
)->add(createCorrelatedValuePropagationPass());
173 void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM
) {
174 unwrap(PM
)->add(createEarlyCSEPass());