• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 //
10 // This file implements the common infrastructure (including C bindings) for
11 // libLLVMIPO.a, which implements several transformations over the LLVM
12 // intermediate representation.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #include "llvm-c/Transforms/IPO.h"
17 #include "llvm/InitializePasses.h"
18 #include "llvm/PassManager.h"
19 #include "llvm/Transforms/IPO.h"
20 
21 using namespace llvm;
22 
initializeIPO(PassRegistry & Registry)23 void llvm::initializeIPO(PassRegistry &Registry) {
24   initializeArgPromotionPass(Registry);
25   initializeConstantMergePass(Registry);
26   initializeDAEPass(Registry);
27   initializeDAHPass(Registry);
28   initializeFunctionAttrsPass(Registry);
29   initializeGlobalDCEPass(Registry);
30   initializeGlobalOptPass(Registry);
31   initializeIPCPPass(Registry);
32   initializeAlwaysInlinerPass(Registry);
33   initializeSimpleInlinerPass(Registry);
34   initializeInternalizePassPass(Registry);
35   initializeLoopExtractorPass(Registry);
36   initializeBlockExtractorPassPass(Registry);
37   initializeSingleLoopExtractorPass(Registry);
38   initializeLowerSetJmpPass(Registry);
39   initializeMergeFunctionsPass(Registry);
40   initializePartialInlinerPass(Registry);
41   initializePruneEHPass(Registry);
42   initializeStripDeadPrototypesPassPass(Registry);
43   initializeStripSymbolsPass(Registry);
44   initializeStripDebugDeclarePass(Registry);
45   initializeStripDeadDebugInfoPass(Registry);
46   initializeStripNonDebugSymbolsPass(Registry);
47 }
48 
LLVMInitializeIPO(LLVMPassRegistryRef R)49 void LLVMInitializeIPO(LLVMPassRegistryRef R) {
50   initializeIPO(*unwrap(R));
51 }
52 
LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM)53 void LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM) {
54   unwrap(PM)->add(createArgumentPromotionPass());
55 }
56 
LLVMAddConstantMergePass(LLVMPassManagerRef PM)57 void LLVMAddConstantMergePass(LLVMPassManagerRef PM) {
58   unwrap(PM)->add(createConstantMergePass());
59 }
60 
LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM)61 void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM) {
62   unwrap(PM)->add(createDeadArgEliminationPass());
63 }
64 
LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM)65 void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM) {
66   unwrap(PM)->add(createFunctionAttrsPass());
67 }
68 
LLVMAddFunctionInliningPass(LLVMPassManagerRef PM)69 void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM) {
70   unwrap(PM)->add(createFunctionInliningPass());
71 }
72 
LLVMAddGlobalDCEPass(LLVMPassManagerRef PM)73 void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM) {
74   unwrap(PM)->add(createGlobalDCEPass());
75 }
76 
LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM)77 void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM) {
78   unwrap(PM)->add(createGlobalOptimizerPass());
79 }
80 
LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM)81 void LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM) {
82   unwrap(PM)->add(createIPConstantPropagationPass());
83 }
84 
LLVMAddLowerSetJmpPass(LLVMPassManagerRef PM)85 void LLVMAddLowerSetJmpPass(LLVMPassManagerRef PM) {
86   unwrap(PM)->add(createLowerSetJmpPass());
87 }
88 
LLVMAddPruneEHPass(LLVMPassManagerRef PM)89 void LLVMAddPruneEHPass(LLVMPassManagerRef PM) {
90   unwrap(PM)->add(createPruneEHPass());
91 }
92 
LLVMAddIPSCCPPass(LLVMPassManagerRef PM)93 void LLVMAddIPSCCPPass(LLVMPassManagerRef PM) {
94   unwrap(PM)->add(createIPSCCPPass());
95 }
96 
LLVMAddInternalizePass(LLVMPassManagerRef PM,unsigned AllButMain)97 void LLVMAddInternalizePass(LLVMPassManagerRef PM, unsigned AllButMain) {
98   unwrap(PM)->add(createInternalizePass(AllButMain != 0));
99 }
100 
101 
LLVMAddRaiseAllocationsPass(LLVMPassManagerRef PM)102 void LLVMAddRaiseAllocationsPass(LLVMPassManagerRef PM) {
103   // FIXME: Remove in LLVM 3.0.
104 }
105 
LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM)106 void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM) {
107   unwrap(PM)->add(createStripDeadPrototypesPass());
108 }
109 
LLVMAddStripSymbolsPass(LLVMPassManagerRef PM)110 void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM) {
111   unwrap(PM)->add(createStripSymbolsPass());
112 }
113