Craig Topper | 126048c | 2012-10-16 02:21:30 +0000 | [diff] [blame^] | 1 | //===-- IPO.cpp -----------------------------------------------------------===// |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 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 | 2c81296 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 10 | // This file implements the common infrastructure (including C bindings) for |
| 11 | // libLLVMIPO.a, which implements several transformations over the LLVM |
| 12 | // intermediate representation. |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
Benjamin Kramer | 613d13b | 2011-08-19 01:36:54 +0000 | [diff] [blame] | 16 | #include "llvm-c/Initialization.h" |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 17 | #include "llvm-c/Transforms/IPO.h" |
Owen Anderson | 2c81296 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 18 | #include "llvm/InitializePasses.h" |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 19 | #include "llvm/PassManager.h" |
| 20 | #include "llvm/Transforms/IPO.h" |
| 21 | |
| 22 | using namespace llvm; |
| 23 | |
Owen Anderson | 2c81296 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 24 | void llvm::initializeIPO(PassRegistry &Registry) { |
| 25 | initializeArgPromotionPass(Registry); |
| 26 | initializeConstantMergePass(Registry); |
| 27 | initializeDAEPass(Registry); |
| 28 | initializeDAHPass(Registry); |
Owen Anderson | 2c81296 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 29 | initializeFunctionAttrsPass(Registry); |
| 30 | initializeGlobalDCEPass(Registry); |
| 31 | initializeGlobalOptPass(Registry); |
| 32 | initializeIPCPPass(Registry); |
| 33 | initializeAlwaysInlinerPass(Registry); |
| 34 | initializeSimpleInlinerPass(Registry); |
| 35 | initializeInternalizePassPass(Registry); |
| 36 | initializeLoopExtractorPass(Registry); |
| 37 | initializeBlockExtractorPassPass(Registry); |
| 38 | initializeSingleLoopExtractorPass(Registry); |
Owen Anderson | 2c81296 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 39 | initializeMergeFunctionsPass(Registry); |
| 40 | initializePartialInlinerPass(Registry); |
Owen Anderson | 2c81296 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 41 | initializePruneEHPass(Registry); |
| 42 | initializeStripDeadPrototypesPassPass(Registry); |
| 43 | initializeStripSymbolsPass(Registry); |
| 44 | initializeStripDebugDeclarePass(Registry); |
| 45 | initializeStripDeadDebugInfoPass(Registry); |
| 46 | initializeStripNonDebugSymbolsPass(Registry); |
Owen Anderson | 2c81296 | 2010-10-07 18:09:59 +0000 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | void LLVMInitializeIPO(LLVMPassRegistryRef R) { |
| 50 | initializeIPO(*unwrap(R)); |
| 51 | } |
| 52 | |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 53 | void LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM) { |
| 54 | unwrap(PM)->add(createArgumentPromotionPass()); |
| 55 | } |
| 56 | |
| 57 | void LLVMAddConstantMergePass(LLVMPassManagerRef PM) { |
| 58 | unwrap(PM)->add(createConstantMergePass()); |
| 59 | } |
| 60 | |
| 61 | void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM) { |
| 62 | unwrap(PM)->add(createDeadArgEliminationPass()); |
| 63 | } |
| 64 | |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 65 | void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM) { |
| 66 | unwrap(PM)->add(createFunctionAttrsPass()); |
| 67 | } |
| 68 | |
| 69 | void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM) { |
| 70 | unwrap(PM)->add(createFunctionInliningPass()); |
| 71 | } |
| 72 | |
Rafael Espindola | 3d72290 | 2011-07-26 15:23:23 +0000 | [diff] [blame] | 73 | void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM) { |
| 74 | unwrap(PM)->add(llvm::createAlwaysInlinerPass()); |
| 75 | } |
| 76 | |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 77 | void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM) { |
| 78 | unwrap(PM)->add(createGlobalDCEPass()); |
| 79 | } |
| 80 | |
| 81 | void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM) { |
| 82 | unwrap(PM)->add(createGlobalOptimizerPass()); |
| 83 | } |
| 84 | |
| 85 | void LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM) { |
| 86 | unwrap(PM)->add(createIPConstantPropagationPass()); |
| 87 | } |
| 88 | |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 89 | void LLVMAddPruneEHPass(LLVMPassManagerRef PM) { |
| 90 | unwrap(PM)->add(createPruneEHPass()); |
| 91 | } |
| 92 | |
Wesley Peck | 16ddd885 | 2010-04-09 20:43:20 +0000 | [diff] [blame] | 93 | void LLVMAddIPSCCPPass(LLVMPassManagerRef PM) { |
| 94 | unwrap(PM)->add(createIPSCCPPass()); |
| 95 | } |
| 96 | |
| 97 | void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) { |
| 98 | unwrap(PM)->add(createInternalizePass(AllButMain != 0)); |
| 99 | } |
| 100 | |
Chris Lattner | 57c0383 | 2009-03-06 16:52:18 +0000 | [diff] [blame] | 101 | void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM) { |
| 102 | unwrap(PM)->add(createStripDeadPrototypesPass()); |
| 103 | } |
| 104 | |
| 105 | void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM) { |
| 106 | unwrap(PM)->add(createStripSymbolsPass()); |
| 107 | } |