LLVM API Documentation
00001 //===-- Scalar.cpp --------------------------------------------------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements common infrastructure for libLLVMScalarOpts.a, which 00011 // implements several scalar transformations over the LLVM intermediate 00012 // representation, including the C bindings for that library. 00013 // 00014 //===----------------------------------------------------------------------===// 00015 00016 #include "llvm/Transforms/Scalar.h" 00017 #include "llvm-c/Initialization.h" 00018 #include "llvm-c/Transforms/Scalar.h" 00019 #include "llvm/Analysis/Passes.h" 00020 #include "llvm/IR/DataLayout.h" 00021 #include "llvm/IR/Verifier.h" 00022 #include "llvm/InitializePasses.h" 00023 #include "llvm/PassManager.h" 00024 00025 using namespace llvm; 00026 00027 /// initializeScalarOptsPasses - Initialize all passes linked into the 00028 /// ScalarOpts library. 00029 void llvm::initializeScalarOpts(PassRegistry &Registry) { 00030 initializeADCEPass(Registry); 00031 initializeAlignmentFromAssumptionsPass(Registry); 00032 initializeSampleProfileLoaderPass(Registry); 00033 initializeConstantHoistingPass(Registry); 00034 initializeConstantPropagationPass(Registry); 00035 initializeCorrelatedValuePropagationPass(Registry); 00036 initializeDCEPass(Registry); 00037 initializeDeadInstEliminationPass(Registry); 00038 initializeScalarizerPass(Registry); 00039 initializeDSEPass(Registry); 00040 initializeGVNPass(Registry); 00041 initializeEarlyCSEPass(Registry); 00042 initializeFlattenCFGPassPass(Registry); 00043 initializeIndVarSimplifyPass(Registry); 00044 initializeJumpThreadingPass(Registry); 00045 initializeLICMPass(Registry); 00046 initializeLoopDeletionPass(Registry); 00047 initializeLoopInstSimplifyPass(Registry); 00048 initializeLoopRotatePass(Registry); 00049 initializeLoopStrengthReducePass(Registry); 00050 initializeLoopRerollPass(Registry); 00051 initializeLoopUnrollPass(Registry); 00052 initializeLoopUnswitchPass(Registry); 00053 initializeLoopIdiomRecognizePass(Registry); 00054 initializeLowerAtomicPass(Registry); 00055 initializeLowerExpectIntrinsicPass(Registry); 00056 initializeMemCpyOptPass(Registry); 00057 initializeMergedLoadStoreMotionPass(Registry); 00058 initializePartiallyInlineLibCallsPass(Registry); 00059 initializeReassociatePass(Registry); 00060 initializeRegToMemPass(Registry); 00061 initializeSCCPPass(Registry); 00062 initializeIPSCCPPass(Registry); 00063 initializeSROAPass(Registry); 00064 initializeSROA_DTPass(Registry); 00065 initializeSROA_SSAUpPass(Registry); 00066 initializeCFGSimplifyPassPass(Registry); 00067 initializeStructurizeCFGPass(Registry); 00068 initializeSinkingPass(Registry); 00069 initializeTailCallElimPass(Registry); 00070 initializeSeparateConstOffsetFromGEPPass(Registry); 00071 initializeLoadCombinePass(Registry); 00072 } 00073 00074 void LLVMInitializeScalarOpts(LLVMPassRegistryRef R) { 00075 initializeScalarOpts(*unwrap(R)); 00076 } 00077 00078 void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM) { 00079 unwrap(PM)->add(createAggressiveDCEPass()); 00080 } 00081 00082 void LLVMAddAlignmentFromAssumptionsPass(LLVMPassManagerRef PM) { 00083 unwrap(PM)->add(createAlignmentFromAssumptionsPass()); 00084 } 00085 00086 void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM) { 00087 unwrap(PM)->add(createCFGSimplificationPass()); 00088 } 00089 00090 void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM) { 00091 unwrap(PM)->add(createDeadStoreEliminationPass()); 00092 } 00093 00094 void LLVMAddScalarizerPass(LLVMPassManagerRef PM) { 00095 unwrap(PM)->add(createScalarizerPass()); 00096 } 00097 00098 void LLVMAddGVNPass(LLVMPassManagerRef PM) { 00099 unwrap(PM)->add(createGVNPass()); 00100 } 00101 00102 void LLVMAddMergedLoadStoreMotionPass(LLVMPassManagerRef PM) { 00103 unwrap(PM)->add(createMergedLoadStoreMotionPass()); 00104 } 00105 00106 void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM) { 00107 unwrap(PM)->add(createIndVarSimplifyPass()); 00108 } 00109 00110 void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM) { 00111 unwrap(PM)->add(createInstructionCombiningPass()); 00112 } 00113 00114 void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM) { 00115 unwrap(PM)->add(createJumpThreadingPass()); 00116 } 00117 00118 void LLVMAddLICMPass(LLVMPassManagerRef PM) { 00119 unwrap(PM)->add(createLICMPass()); 00120 } 00121 00122 void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM) { 00123 unwrap(PM)->add(createLoopDeletionPass()); 00124 } 00125 00126 void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM) { 00127 unwrap(PM)->add(createLoopIdiomPass()); 00128 } 00129 00130 void LLVMAddLoopRotatePass(LLVMPassManagerRef PM) { 00131 unwrap(PM)->add(createLoopRotatePass()); 00132 } 00133 00134 void LLVMAddLoopRerollPass(LLVMPassManagerRef PM) { 00135 unwrap(PM)->add(createLoopRerollPass()); 00136 } 00137 00138 void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM) { 00139 unwrap(PM)->add(createLoopUnrollPass()); 00140 } 00141 00142 void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM) { 00143 unwrap(PM)->add(createLoopUnswitchPass()); 00144 } 00145 00146 void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM) { 00147 unwrap(PM)->add(createMemCpyOptPass()); 00148 } 00149 00150 void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM) { 00151 unwrap(PM)->add(createPartiallyInlineLibCallsPass()); 00152 } 00153 00154 void LLVMAddLowerSwitchPass(LLVMPassManagerRef PM) { 00155 unwrap(PM)->add(createLowerSwitchPass()); 00156 } 00157 00158 void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM) { 00159 unwrap(PM)->add(createPromoteMemoryToRegisterPass()); 00160 } 00161 00162 void LLVMAddReassociatePass(LLVMPassManagerRef PM) { 00163 unwrap(PM)->add(createReassociatePass()); 00164 } 00165 00166 void LLVMAddSCCPPass(LLVMPassManagerRef PM) { 00167 unwrap(PM)->add(createSCCPPass()); 00168 } 00169 00170 void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM) { 00171 unwrap(PM)->add(createScalarReplAggregatesPass()); 00172 } 00173 00174 void LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM) { 00175 unwrap(PM)->add(createScalarReplAggregatesPass(-1, false)); 00176 } 00177 00178 void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM, 00179 int Threshold) { 00180 unwrap(PM)->add(createScalarReplAggregatesPass(Threshold)); 00181 } 00182 00183 void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM) { 00184 // NOTE: The simplify-libcalls pass has been removed. 00185 } 00186 00187 void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM) { 00188 unwrap(PM)->add(createTailCallEliminationPass()); 00189 } 00190 00191 void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM) { 00192 unwrap(PM)->add(createConstantPropagationPass()); 00193 } 00194 00195 void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM) { 00196 unwrap(PM)->add(createDemoteRegisterToMemoryPass()); 00197 } 00198 00199 void LLVMAddVerifierPass(LLVMPassManagerRef PM) { 00200 unwrap(PM)->add(createVerifierPass()); 00201 // FIXME: should this also add createDebugInfoVerifierPass()? 00202 } 00203 00204 void LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM) { 00205 unwrap(PM)->add(createCorrelatedValuePropagationPass()); 00206 } 00207 00208 void LLVMAddEarlyCSEPass(LLVMPassManagerRef PM) { 00209 unwrap(PM)->add(createEarlyCSEPass()); 00210 } 00211 00212 void LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM) { 00213 unwrap(PM)->add(createTypeBasedAliasAnalysisPass()); 00214 } 00215 00216 void LLVMAddScopedNoAliasAAPass(LLVMPassManagerRef PM) { 00217 unwrap(PM)->add(createScopedNoAliasAAPass()); 00218 } 00219 00220 void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM) { 00221 unwrap(PM)->add(createBasicAliasAnalysisPass()); 00222 } 00223 00224 void LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM) { 00225 unwrap(PM)->add(createLowerExpectIntrinsicPass()); 00226 }