Scalar.cpp revision 226633
175374Sbp//===-- Scalar.cpp --------------------------------------------------------===// 275374Sbp// 375374Sbp// The LLVM Compiler Infrastructure 475374Sbp// 575374Sbp// This file is distributed under the University of Illinois Open Source 675374Sbp// License. See LICENSE.TXT for details. 775374Sbp// 875374Sbp//===----------------------------------------------------------------------===// 975374Sbp// 1075374Sbp// This file implements common infrastructure for libLLVMScalarOpts.a, which 1175374Sbp// implements several scalar transformations over the LLVM intermediate 1275374Sbp// representation, including the C bindings for that library. 1375374Sbp// 1475374Sbp//===----------------------------------------------------------------------===// 1575374Sbp 1675374Sbp#include "llvm-c/Transforms/Scalar.h" 1775374Sbp#include "llvm-c/Initialization.h" 1875374Sbp#include "llvm/InitializePasses.h" 1975374Sbp#include "llvm/PassManager.h" 2075374Sbp#include "llvm/Analysis/Passes.h" 2175374Sbp#include "llvm/Analysis/Verifier.h" 2275374Sbp#include "llvm/Target/TargetData.h" 2375374Sbp#include "llvm/Transforms/Scalar.h" 2475374Sbp 2575374Sbpusing namespace llvm; 2675374Sbp 2775374Sbp/// initializeScalarOptsPasses - Initialize all passes linked into the 2875374Sbp/// ScalarOpts library. 2975374Sbpvoid llvm::initializeScalarOpts(PassRegistry &Registry) { 3075374Sbp initializeADCEPass(Registry); 3175374Sbp initializeBlockPlacementPass(Registry); 3275374Sbp initializeCodeGenPreparePass(Registry); 3375374Sbp initializeConstantPropagationPass(Registry); 3475374Sbp initializeCorrelatedValuePropagationPass(Registry); 3575374Sbp initializeDCEPass(Registry); 3675374Sbp initializeDeadInstEliminationPass(Registry); 3775374Sbp initializeDSEPass(Registry); 3875374Sbp initializeGVNPass(Registry); 3975374Sbp initializeEarlyCSEPass(Registry); 4075374Sbp initializeIndVarSimplifyPass(Registry); 4175374Sbp initializeJumpThreadingPass(Registry); 4275374Sbp initializeLICMPass(Registry); 4375374Sbp initializeLoopDeletionPass(Registry); 4475374Sbp initializeLoopInstSimplifyPass(Registry); 4575374Sbp initializeLoopRotatePass(Registry); 4675374Sbp initializeLoopStrengthReducePass(Registry); 4775374Sbp initializeLoopUnrollPass(Registry); 4875374Sbp initializeLoopUnswitchPass(Registry); 4975374Sbp initializeLoopIdiomRecognizePass(Registry); 5075374Sbp initializeLowerAtomicPass(Registry); 5175374Sbp initializeLowerExpectIntrinsicPass(Registry); 5275374Sbp initializeMemCpyOptPass(Registry); 5375374Sbp initializeObjCARCAliasAnalysisPass(Registry); 5475374Sbp initializeObjCARCExpandPass(Registry); 5575374Sbp initializeObjCARCContractPass(Registry); 5675374Sbp initializeObjCARCOptPass(Registry); 5775374Sbp initializeReassociatePass(Registry); 5875374Sbp initializeRegToMemPass(Registry); 5975374Sbp initializeSCCPPass(Registry); 6075374Sbp initializeIPSCCPPass(Registry); 6175374Sbp initializeSROA_DTPass(Registry); 6275374Sbp initializeSROA_SSAUpPass(Registry); 6375374Sbp initializeCFGSimplifyPassPass(Registry); 6475374Sbp initializeSimplifyLibCallsPass(Registry); 6575374Sbp initializeSinkingPass(Registry); 6675374Sbp initializeTailCallElimPass(Registry); 6775374Sbp} 6875374Sbp 6975374Sbpvoid LLVMInitializeScalarOpts(LLVMPassRegistryRef R) { 7075374Sbp initializeScalarOpts(*unwrap(R)); 7175374Sbp} 7275374Sbp 7375374Sbpvoid LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM) { 7475374Sbp unwrap(PM)->add(createAggressiveDCEPass()); 7575374Sbp} 7675374Sbp 7775374Sbpvoid LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM) { 7875374Sbp unwrap(PM)->add(createCFGSimplificationPass()); 7975374Sbp} 8075374Sbp 8175374Sbpvoid LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM) { 8275374Sbp unwrap(PM)->add(createDeadStoreEliminationPass()); 8375374Sbp} 8475374Sbp 8575374Sbpvoid LLVMAddGVNPass(LLVMPassManagerRef PM) { 8675374Sbp unwrap(PM)->add(createGVNPass()); 8775374Sbp} 8875374Sbp 8975374Sbpvoid LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM) { 9075374Sbp unwrap(PM)->add(createIndVarSimplifyPass()); 9175374Sbp} 9275374Sbp 9375374Sbpvoid LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM) { 9475374Sbp unwrap(PM)->add(createInstructionCombiningPass()); 9575374Sbp} 9675374Sbp 9775374Sbpvoid LLVMAddJumpThreadingPass(LLVMPassManagerRef PM) { 9875374Sbp unwrap(PM)->add(createJumpThreadingPass()); 9975374Sbp} 10075374Sbp 10175374Sbpvoid LLVMAddLICMPass(LLVMPassManagerRef PM) { 10275374Sbp unwrap(PM)->add(createLICMPass()); 10375374Sbp} 10475374Sbp 10575374Sbpvoid LLVMAddLoopDeletionPass(LLVMPassManagerRef PM) { 10675374Sbp unwrap(PM)->add(createLoopDeletionPass()); 10775374Sbp} 10875374Sbp 10975374Sbpvoid LLVMAddLoopIdiomPass(LLVMPassManagerRef PM) { 11075374Sbp unwrap(PM)->add(createLoopIdiomPass()); 11175374Sbp} 11275374Sbp 11375374Sbpvoid LLVMAddLoopRotatePass(LLVMPassManagerRef PM) { 11475374Sbp unwrap(PM)->add(createLoopRotatePass()); 11575374Sbp} 11675374Sbp 11775374Sbpvoid LLVMAddLoopUnrollPass(LLVMPassManagerRef PM) { 11875374Sbp unwrap(PM)->add(createLoopUnrollPass()); 11975374Sbp} 12075374Sbp 12175374Sbpvoid LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM) { 12275374Sbp unwrap(PM)->add(createLoopUnswitchPass()); 12375374Sbp} 12475374Sbp 12575374Sbpvoid LLVMAddMemCpyOptPass(LLVMPassManagerRef PM) { 12675374Sbp unwrap(PM)->add(createMemCpyOptPass()); 12775374Sbp} 12875374Sbp 12975374Sbpvoid LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM) { 13075374Sbp unwrap(PM)->add(createPromoteMemoryToRegisterPass()); 13175374Sbp} 13275374Sbp 13375374Sbpvoid LLVMAddReassociatePass(LLVMPassManagerRef PM) { 13475374Sbp unwrap(PM)->add(createReassociatePass()); 13575374Sbp} 13675374Sbp 13775374Sbpvoid LLVMAddSCCPPass(LLVMPassManagerRef PM) { 13875374Sbp unwrap(PM)->add(createSCCPPass()); 13975374Sbp} 14075374Sbp 14175374Sbpvoid LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM) { 14275374Sbp unwrap(PM)->add(createScalarReplAggregatesPass()); 14375374Sbp} 14475374Sbp 14575374Sbpvoid LLVMAddScalarReplAggregatesPassSSA(LLVMPassManagerRef PM) { 14675374Sbp unwrap(PM)->add(createScalarReplAggregatesPass(-1, false)); 14775374Sbp} 14875374Sbp 14975374Sbpvoid LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM, 15075374Sbp int Threshold) { 15175374Sbp unwrap(PM)->add(createScalarReplAggregatesPass(Threshold)); 15275374Sbp} 15375374Sbp 15475374Sbpvoid LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM) { 15575374Sbp unwrap(PM)->add(createSimplifyLibCallsPass()); 15675374Sbp} 15775374Sbp 15875374Sbpvoid LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM) { 15975374Sbp unwrap(PM)->add(createTailCallEliminationPass()); 16075374Sbp} 16175374Sbp 16275374Sbpvoid LLVMAddConstantPropagationPass(LLVMPassManagerRef PM) { 16375374Sbp unwrap(PM)->add(createConstantPropagationPass()); 16475374Sbp} 16575374Sbp 16675374Sbpvoid LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM) { 16775374Sbp unwrap(PM)->add(createDemoteRegisterToMemoryPass()); 16875374Sbp} 16975374Sbp 17075374Sbpvoid LLVMAddVerifierPass(LLVMPassManagerRef PM) { 17175374Sbp unwrap(PM)->add(createVerifierPass()); 17275374Sbp} 17396755Strhodes 17496755Strhodesvoid LLVMAddCorrelatedValuePropagationPass(LLVMPassManagerRef PM) { 17575374Sbp unwrap(PM)->add(createCorrelatedValuePropagationPass()); 17675374Sbp} 17796755Strhodes 17875374Sbpvoid LLVMAddEarlyCSEPass(LLVMPassManagerRef PM) { 17975374Sbp unwrap(PM)->add(createEarlyCSEPass()); 18075374Sbp} 18175374Sbp 18275374Sbpvoid LLVMAddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM) { 18375374Sbp unwrap(PM)->add(createTypeBasedAliasAnalysisPass()); 18475374Sbp} 18575374Sbp 18675374Sbpvoid LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM) { 18775374Sbp unwrap(PM)->add(createBasicAliasAnalysisPass()); 18875374Sbp} 18975374Sbp 19075374Sbpvoid LLVMAddLowerExpectIntrinsicPass(LLVMPassManagerRef PM) { 19175374Sbp unwrap(PM)->add(createLowerExpectIntrinsicPass()); 19275374Sbp} 19375374Sbp