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