Scalar.cpp revision 218893
1181834Sroberto//===-- Scalar.cpp --------------------------------------------------------===// 2181834Sroberto// 3181834Sroberto// The LLVM Compiler Infrastructure 4181834Sroberto// 5181834Sroberto// This file is distributed under the University of Illinois Open Source 6181834Sroberto// License. See LICENSE.TXT for details. 7181834Sroberto// 8181834Sroberto//===----------------------------------------------------------------------===// 9200576Sroberto// 10181834Sroberto// This file implements common infrastructure for libLLVMScalarOpts.a, which 11181834Sroberto// implements several scalar transformations over the LLVM intermediate 12181834Sroberto// representation, including the C bindings for that library. 13181834Sroberto// 14181834Sroberto//===----------------------------------------------------------------------===// 15181834Sroberto 16181834Sroberto#include "llvm-c/Transforms/Scalar.h" 17181834Sroberto#include "llvm-c/Initialization.h" 18181834Sroberto#include "llvm/InitializePasses.h" 19181834Sroberto#include "llvm/PassManager.h" 20181834Sroberto#include "llvm/Analysis/Verifier.h" 21181834Sroberto#include "llvm/Target/TargetData.h" 22181834Sroberto#include "llvm/Transforms/Scalar.h" 23181834Sroberto 24181834Srobertousing namespace llvm; 25181834Sroberto 26181834Sroberto/// initializeScalarOptsPasses - Initialize all passes linked into the 27181834Sroberto/// ScalarOpts library. 28181834Srobertovoid llvm::initializeScalarOpts(PassRegistry &Registry) { 29181834Sroberto initializeADCEPass(Registry); 30181834Sroberto initializeBlockPlacementPass(Registry); 31181834Sroberto initializeCodeGenPreparePass(Registry); 32181834Sroberto initializeConstantPropagationPass(Registry); 33181834Sroberto initializeCorrelatedValuePropagationPass(Registry); 34181834Sroberto initializeDCEPass(Registry); 35181834Sroberto initializeDeadInstEliminationPass(Registry); 36181834Sroberto initializeDSEPass(Registry); 37181834Sroberto initializeGEPSplitterPass(Registry); 38181834Sroberto initializeGVNPass(Registry); 39181834Sroberto initializeEarlyCSEPass(Registry); 40181834Sroberto initializeIndVarSimplifyPass(Registry); 41181834Sroberto initializeJumpThreadingPass(Registry); 42181834Sroberto initializeLICMPass(Registry); 43181834Sroberto initializeLoopDeletionPass(Registry); 44181834Sroberto initializeLoopInstSimplifyPass(Registry); 45181834Sroberto initializeLoopRotatePass(Registry); 46181834Sroberto initializeLoopStrengthReducePass(Registry); 47181834Sroberto initializeLoopUnrollPass(Registry); 48181834Sroberto initializeLoopUnswitchPass(Registry); 49200576Sroberto initializeLoopIdiomRecognizePass(Registry); 50181834Sroberto initializeLowerAtomicPass(Registry); 51181834Sroberto initializeMemCpyOptPass(Registry); 52181834Sroberto initializeReassociatePass(Registry); 53200576Sroberto initializeRegToMemPass(Registry); 54200576Sroberto initializeSCCPPass(Registry); 55181834Sroberto initializeIPSCCPPass(Registry); 56200576Sroberto initializeSROA_DTPass(Registry); 57200576Sroberto initializeSROA_SSAUpPass(Registry); 58181834Sroberto initializeCFGSimplifyPassPass(Registry); 59181834Sroberto initializeSimplifyHalfPowrLibCallsPass(Registry); 60181834Sroberto initializeSimplifyLibCallsPass(Registry); 61181834Sroberto initializeSinkingPass(Registry); 62181834Sroberto initializeTailDupPass(Registry); 63181834Sroberto initializeTailCallElimPass(Registry); 64181834Sroberto} 65181834Sroberto 66181834Srobertovoid LLVMInitializeScalarOpts(LLVMPassRegistryRef R) { 67181834Sroberto initializeScalarOpts(*unwrap(R)); 68181834Sroberto} 69181834Sroberto 70181834Srobertovoid LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM) { 71181834Sroberto unwrap(PM)->add(createAggressiveDCEPass()); 72200576Sroberto} 73181834Sroberto 74200576Srobertovoid LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM) { 75181834Sroberto unwrap(PM)->add(createCFGSimplificationPass()); 76181834Sroberto} 77181834Sroberto 78181834Srobertovoid LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM) { 79181834Sroberto unwrap(PM)->add(createDeadStoreEliminationPass()); 80181834Sroberto} 81181834Sroberto 82181834Srobertovoid LLVMAddGVNPass(LLVMPassManagerRef PM) { 83181834Sroberto unwrap(PM)->add(createGVNPass()); 84181834Sroberto} 85181834Sroberto 86181834Srobertovoid LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM) { 87181834Sroberto unwrap(PM)->add(createIndVarSimplifyPass()); 88181834Sroberto} 89181834Sroberto 90181834Srobertovoid LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM) { 91181834Sroberto unwrap(PM)->add(createInstructionCombiningPass()); 92181834Sroberto} 93181834Sroberto 94181834Srobertovoid LLVMAddJumpThreadingPass(LLVMPassManagerRef PM) { 95181834Sroberto unwrap(PM)->add(createJumpThreadingPass()); 96181834Sroberto} 97181834Sroberto 98181834Srobertovoid LLVMAddLICMPass(LLVMPassManagerRef PM) { 99181834Sroberto unwrap(PM)->add(createLICMPass()); 100181834Sroberto} 101181834Sroberto 102181834Srobertovoid LLVMAddLoopDeletionPass(LLVMPassManagerRef PM) { 103181834Sroberto unwrap(PM)->add(createLoopDeletionPass()); 104181834Sroberto} 105181834Sroberto 106181834Srobertovoid LLVMAddLoopRotatePass(LLVMPassManagerRef PM) { 107181834Sroberto unwrap(PM)->add(createLoopRotatePass()); 108181834Sroberto} 109181834Sroberto 110181834Srobertovoid LLVMAddLoopUnrollPass(LLVMPassManagerRef PM) { 111181834Sroberto unwrap(PM)->add(createLoopUnrollPass()); 112181834Sroberto} 113181834Sroberto 114181834Srobertovoid LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM) { 115181834Sroberto unwrap(PM)->add(createLoopUnswitchPass()); 116181834Sroberto} 117181834Sroberto 118181834Srobertovoid LLVMAddMemCpyOptPass(LLVMPassManagerRef PM) { 119181834Sroberto unwrap(PM)->add(createMemCpyOptPass()); 120181834Sroberto} 121181834Sroberto 122181834Srobertovoid LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM) { 123181834Sroberto unwrap(PM)->add(createPromoteMemoryToRegisterPass()); 124181834Sroberto} 125181834Sroberto 126181834Srobertovoid LLVMAddReassociatePass(LLVMPassManagerRef PM) { 127181834Sroberto unwrap(PM)->add(createReassociatePass()); 128181834Sroberto} 129181834Sroberto 130181834Srobertovoid LLVMAddSCCPPass(LLVMPassManagerRef PM) { 131181834Sroberto unwrap(PM)->add(createSCCPPass()); 132181834Sroberto} 133181834Sroberto 134181834Srobertovoid LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM) { 135181834Sroberto unwrap(PM)->add(createScalarReplAggregatesPass()); 136181834Sroberto} 137181834Sroberto 138181834Srobertovoid LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM, 139181834Sroberto int Threshold) { 140181834Sroberto unwrap(PM)->add(createScalarReplAggregatesPass(Threshold)); 141181834Sroberto} 142181834Sroberto 143181834Srobertovoid LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM) { 144181834Sroberto unwrap(PM)->add(createSimplifyLibCallsPass()); 145181834Sroberto} 146181834Sroberto 147181834Srobertovoid LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM) { 148181834Sroberto unwrap(PM)->add(createTailCallEliminationPass()); 149181834Sroberto} 150181834Sroberto 151181834Srobertovoid LLVMAddConstantPropagationPass(LLVMPassManagerRef PM) { 152181834Sroberto unwrap(PM)->add(createConstantPropagationPass()); 153181834Sroberto} 154181834Sroberto 155181834Srobertovoid LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM) { 156181834Sroberto unwrap(PM)->add(createDemoteRegisterToMemoryPass()); 157181834Sroberto} 158181834Sroberto 159181834Srobertovoid LLVMAddVerifierPass(LLVMPassManagerRef PM) { 160181834Sroberto unwrap(PM)->add(createVerifierPass()); 161181834Sroberto} 162181834Sroberto