Gordon Henriksen | 41ba154 | 2008-03-16 16:32:40 +0000 | [diff] [blame] | 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 | // |
Owen Anderson | 1a3d233 | 2010-10-07 17:55:47 +0000 | [diff] [blame] | 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. |
Gordon Henriksen | 41ba154 | 2008-03-16 16:32:40 +0000 | [diff] [blame] | 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #include "llvm-c/Transforms/Scalar.h" |
Owen Anderson | 1a3d233 | 2010-10-07 17:55:47 +0000 | [diff] [blame] | 17 | #include "llvm-c/Initialization.h" |
| 18 | #include "llvm/InitializePasses.h" |
Gordon Henriksen | 41ba154 | 2008-03-16 16:32:40 +0000 | [diff] [blame] | 19 | #include "llvm/PassManager.h" |
Nate Begeman | 47a53a6 | 2010-03-11 23:06:07 +0000 | [diff] [blame] | 20 | #include "llvm/Analysis/Verifier.h" |
| 21 | #include "llvm/Target/TargetData.h" |
Gordon Henriksen | 41ba154 | 2008-03-16 16:32:40 +0000 | [diff] [blame] | 22 | #include "llvm/Transforms/Scalar.h" |
| 23 | |
| 24 | using namespace llvm; |
| 25 | |
Owen Anderson | 1a3d233 | 2010-10-07 17:55:47 +0000 | [diff] [blame] | 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 | initializeGEPSplitterPass(Registry); |
| 38 | initializeGVNPass(Registry); |
| 39 | initializeIndVarSimplifyPass(Registry); |
| 40 | initializeJumpThreadingPass(Registry); |
| 41 | initializeLICMPass(Registry); |
| 42 | initializeLoopDeletionPass(Registry); |
Owen Anderson | 1a3d233 | 2010-10-07 17:55:47 +0000 | [diff] [blame] | 43 | initializeLoopRotatePass(Registry); |
| 44 | initializeLoopStrengthReducePass(Registry); |
| 45 | initializeLoopUnrollPass(Registry); |
| 46 | initializeLoopUnswitchPass(Registry); |
Chris Lattner | b0db161 | 2010-12-26 19:32:44 +0000 | [diff] [blame^] | 47 | initializeLoopIdiomRecognizePass(Registry); |
Owen Anderson | 1a3d233 | 2010-10-07 17:55:47 +0000 | [diff] [blame] | 48 | initializeLowerAtomicPass(Registry); |
| 49 | initializeMemCpyOptPass(Registry); |
| 50 | initializeReassociatePass(Registry); |
| 51 | initializeRegToMemPass(Registry); |
| 52 | initializeSCCPPass(Registry); |
| 53 | initializeIPSCCPPass(Registry); |
| 54 | initializeSROAPass(Registry); |
| 55 | initializeCFGSimplifyPassPass(Registry); |
| 56 | initializeSimplifyHalfPowrLibCallsPass(Registry); |
| 57 | initializeSimplifyLibCallsPass(Registry); |
| 58 | initializeSinkingPass(Registry); |
| 59 | initializeTailDupPass(Registry); |
| 60 | initializeTailCallElimPass(Registry); |
| 61 | } |
| 62 | |
| 63 | void LLVMInitializeScalarOpts(LLVMPassRegistryRef R) { |
| 64 | initializeScalarOpts(*unwrap(R)); |
| 65 | } |
| 66 | |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 67 | void LLVMAddAggressiveDCEPass(LLVMPassManagerRef PM) { |
| 68 | unwrap(PM)->add(createAggressiveDCEPass()); |
Gordon Henriksen | 41ba154 | 2008-03-16 16:32:40 +0000 | [diff] [blame] | 69 | } |
| 70 | |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 71 | void LLVMAddCFGSimplificationPass(LLVMPassManagerRef PM) { |
| 72 | unwrap(PM)->add(createCFGSimplificationPass()); |
Gordon Henriksen | 41ba154 | 2008-03-16 16:32:40 +0000 | [diff] [blame] | 73 | } |
| 74 | |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 75 | void LLVMAddDeadStoreEliminationPass(LLVMPassManagerRef PM) { |
| 76 | unwrap(PM)->add(createDeadStoreEliminationPass()); |
Gordon Henriksen | 41ba154 | 2008-03-16 16:32:40 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | void LLVMAddGVNPass(LLVMPassManagerRef PM) { |
| 80 | unwrap(PM)->add(createGVNPass()); |
| 81 | } |
| 82 | |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 83 | void LLVMAddIndVarSimplifyPass(LLVMPassManagerRef PM) { |
| 84 | unwrap(PM)->add(createIndVarSimplifyPass()); |
| 85 | } |
| 86 | |
| 87 | void LLVMAddInstructionCombiningPass(LLVMPassManagerRef PM) { |
| 88 | unwrap(PM)->add(createInstructionCombiningPass()); |
| 89 | } |
| 90 | |
| 91 | void LLVMAddJumpThreadingPass(LLVMPassManagerRef PM) { |
| 92 | unwrap(PM)->add(createJumpThreadingPass()); |
| 93 | } |
| 94 | |
| 95 | void LLVMAddLICMPass(LLVMPassManagerRef PM) { |
| 96 | unwrap(PM)->add(createLICMPass()); |
| 97 | } |
| 98 | |
| 99 | void LLVMAddLoopDeletionPass(LLVMPassManagerRef PM) { |
| 100 | unwrap(PM)->add(createLoopDeletionPass()); |
| 101 | } |
| 102 | |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 103 | void LLVMAddLoopRotatePass(LLVMPassManagerRef PM) { |
| 104 | unwrap(PM)->add(createLoopRotatePass()); |
| 105 | } |
| 106 | |
| 107 | void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM) { |
| 108 | unwrap(PM)->add(createLoopUnrollPass()); |
| 109 | } |
| 110 | |
| 111 | void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM) { |
| 112 | unwrap(PM)->add(createLoopUnswitchPass()); |
| 113 | } |
| 114 | |
| 115 | void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM) { |
| 116 | unwrap(PM)->add(createMemCpyOptPass()); |
| 117 | } |
| 118 | |
| 119 | void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM) { |
| 120 | unwrap(PM)->add(createPromoteMemoryToRegisterPass()); |
| 121 | } |
| 122 | |
| 123 | void LLVMAddReassociatePass(LLVMPassManagerRef PM) { |
| 124 | unwrap(PM)->add(createReassociatePass()); |
| 125 | } |
| 126 | |
| 127 | void LLVMAddSCCPPass(LLVMPassManagerRef PM) { |
| 128 | unwrap(PM)->add(createSCCPPass()); |
| 129 | } |
| 130 | |
| 131 | void LLVMAddScalarReplAggregatesPass(LLVMPassManagerRef PM) { |
| 132 | unwrap(PM)->add(createScalarReplAggregatesPass()); |
| 133 | } |
| 134 | |
Nate Begeman | 47a53a6 | 2010-03-11 23:06:07 +0000 | [diff] [blame] | 135 | void LLVMAddScalarReplAggregatesPassWithThreshold(LLVMPassManagerRef PM, |
| 136 | int Threshold) { |
| 137 | unwrap(PM)->add(createScalarReplAggregatesPass(Threshold)); |
| 138 | } |
| 139 | |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 140 | void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM) { |
| 141 | unwrap(PM)->add(createSimplifyLibCallsPass()); |
| 142 | } |
| 143 | |
| 144 | void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM) { |
| 145 | unwrap(PM)->add(createTailCallEliminationPass()); |
| 146 | } |
| 147 | |
| 148 | void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM) { |
| 149 | unwrap(PM)->add(createConstantPropagationPass()); |
| 150 | } |
| 151 | |
| 152 | void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM) { |
| 153 | unwrap(PM)->add(createDemoteRegisterToMemoryPass()); |
Gordon Henriksen | 41ba154 | 2008-03-16 16:32:40 +0000 | [diff] [blame] | 154 | } |
Nate Begeman | 47a53a6 | 2010-03-11 23:06:07 +0000 | [diff] [blame] | 155 | |
| 156 | void LLVMAddVerifierPass(LLVMPassManagerRef PM) { |
| 157 | unwrap(PM)->add(createVerifierPass()); |
| 158 | } |