1 //===-- Scalar.cpp --------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 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. 13 // 14 //===----------------------------------------------------------------------===// 15 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/Passes.h" 21 #include "llvm/Analysis/Verifier.h" 22 #include "llvm/Target/TargetData.h" 23 #include "llvm/Transforms/Scalar.h" 24 25 using namespace llvm; 26 27 /// initializeScalarOptsPasses - Initialize all passes linked into the 28 /// ScalarOpts library. initializeScalarOpts(PassRegistry & Registry)29void llvm::initializeScalarOpts(PassRegistry &Registry) { 30 initializeADCEPass(Registry); 31 initializeBlockPlacementPass(Registry); 32 initializeCodeGenPreparePass(Registry); 33 initializeConstantPropagationPass(Registry); 34 initializeCorrelatedValuePropagationPass(Registry); 35 initializeDCEPass(Registry); 36 initializeDeadInstEliminationPass(Registry); 37 initializeDSEPass(Registry); 38 initializeGVNPass(Registry); 39 initializeEarlyCSEPass(Registry); 40 initializeIndVarSimplifyPass(Registry); 41 initializeJumpThreadingPass(Registry); 42 initializeLICMPass(Registry); 43 initializeLoopDeletionPass(Registry); 44 initializeLoopInstSimplifyPass(Registry); 45 initializeLoopRotatePass(Registry); 46 initializeLoopStrengthReducePass(Registry); 47 initializeLoopUnrollPass(Registry); 48 initializeLoopUnswitchPass(Registry); 49 initializeLoopIdiomRecognizePass(Registry); 50 initializeLowerAtomicPass(Registry); 51 initializeLowerExpectIntrinsicPass(Registry); 52 initializeMemCpyOptPass(Registry); 53 initializeObjCARCAliasAnalysisPass(Registry); 54 initializeObjCARCAPElimPass(Registry); 55 initializeObjCARCExpandPass(Registry); 56 initializeObjCARCContractPass(Registry); 57 initializeObjCARCOptPass(Registry); 58 initializeReassociatePass(Registry); 59 initializeRegToMemPass(Registry); 60 initializeSCCPPass(Registry); 61 initializeIPSCCPPass(Registry); 62 initializeSROA_DTPass(Registry); 63 initializeSROA_SSAUpPass(Registry); 64 initializeCFGSimplifyPassPass(Registry); 65 initializeSimplifyLibCallsPass(Registry); 66 initializeSinkingPass(Registry); 67 initializeTailCallElimPass(Registry); 68 } 69 LLVMInitializeScalarOpts(LLVMPassRegistryRef R)70void LLVMInitializeScalarOpts(LLVMPassRegistryRef R) { 71 initializeScalarOpts(*unwrap(R)); 72 } 73 LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM)74void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM) { 75 unwrap(PM)->add(createAggressiveDCEPass()); 76 } 77 LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM)78void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM) { 79 unwrap(PM)->add(createCFGSimplificationPass()); 80 } 81 LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM)82void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM) { 83 unwrap(PM)->add(createDeadStoreEliminationPass()); 84 } 85 LLVMAddGVNPass(LLVMPassManagerRef PM)86void LLVMAddGVNPass(LLVMPassManagerRef PM) { 87 unwrap(PM)->add(createGVNPass()); 88 } 89 LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM)90void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM) { 91 unwrap(PM)->add(createIndVarSimplifyPass()); 92 } 93 LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM)94void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM) { 95 unwrap(PM)->add(createInstructionCombiningPass()); 96 } 97 LLVMAddJumpThreadingPass(LLVMPassManagerRef PM)98void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM) { 99 unwrap(PM)->add(createJumpThreadingPass()); 100 } 101 LLVMAddLICMPass(LLVMPassManagerRef PM)102void LLVMAddLICMPass(LLVMPassManagerRef PM) { 103 unwrap(PM)->add(createLICMPass()); 104 } 105 LLVMAddLoopDeletionPass(LLVMPassManagerRef PM)106void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM) { 107 unwrap(PM)->add(createLoopDeletionPass()); 108 } 109 LLVMAddLoopIdiomPass(LLVMPassManagerRef PM)110void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM) { 111 unwrap(PM)->add(createLoopIdiomPass()); 112 } 113 LLVMAddLoopRotatePass(LLVMPassManagerRef PM)114void LLVMAddLoopRotatePass(LLVMPassManagerRef PM) { 115 unwrap(PM)->add(createLoopRotatePass()); 116 } 117 LLVMAddLoopUnrollPass(LLVMPassManagerRef PM)118void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM) { 119 unwrap(PM)->add(createLoopUnrollPass()); 120 } 121 LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM)122void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM) { 123 unwrap(PM)->add(createLoopUnswitchPass()); 124 } 125 LLVMAddMemCpyOptPass(LLVMPassManagerRef PM)126void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM) { 127 unwrap(PM)->add(createMemCpyOptPass()); 128 } 129 LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM)130void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM) { 131 unwrap(PM)->add(createPromoteMemoryToRegisterPass()); 132 } 133 LLVMAddReassociatePass(LLVMPassManagerRef PM)134void LLVMAddReassociatePass(LLVMPassManagerRef PM) { 135 unwrap(PM)->add(createReassociatePass()); 136 } 137 LLVMAddSCCPPass(LLVMPassManagerRef PM)138void LLVMAddSCCPPass(LLVMPassManagerRef PM) { 139 unwrap(PM)->add(createSCCPPass()); 140 } 141 LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM)142void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM) { 143 unwrap(PM)->add(createScalarReplAggregatesPass()); 144 } 145 LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM)146void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM) { 147 unwrap(PM)->add(createScalarReplAggregatesPass(-1, false)); 148 } 149 LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM,int Threshold)150void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM, 151 int Threshold) { 152 unwrap(PM)->add(createScalarReplAggregatesPass(Threshold)); 153 } 154 LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM)155void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM) { 156 unwrap(PM)->add(createSimplifyLibCallsPass()); 157 } 158 LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM)159void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM) { 160 unwrap(PM)->add(createTailCallEliminationPass()); 161 } 162 LLVMAddConstantPropagationPass(LLVMPassManagerRef PM)163void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM) { 164 unwrap(PM)->add(createConstantPropagationPass()); 165 } 166 LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM)167void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM) { 168 unwrap(PM)->add(createDemoteRegisterToMemoryPass()); 169 } 170 LLVMAddVerifierPass(LLVMPassManagerRef PM)171void LLVMAddVerifierPass(LLVMPassManagerRef PM) { 172 unwrap(PM)->add(createVerifierPass()); 173 } 174 LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM)175void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM) { 176 unwrap(PM)->add(createCorrelatedValuePropagationPass()); 177 } 178 LLVMAddEarlyCSEPass(LLVMPassManagerRef PM)179void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM) { 180 unwrap(PM)->add(createEarlyCSEPass()); 181 } 182 LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM)183void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM) { 184 unwrap(PM)->add(createTypeBasedAliasAnalysisPass()); 185 } 186 LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM)187void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM) { 188 unwrap(PM)->add(createBasicAliasAnalysisPass()); 189 } 190 LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM)191void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM) { 192 unwrap(PM)->add(createLowerExpectIntrinsicPass()); 193 } 194