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