comparison tools/binding/llvm-opt.cpp @ 1273:1ba61de8796b

Committing LLVM binding for D as it currently exists in the SVN repository.
author Frits van Bommel <fvbommel wxs.nl>
date Mon, 27 Apr 2009 22:33:17 +0200
parents
children
comparison
equal deleted inserted replaced
1272:dd4766851b37 1273:1ba61de8796b
1 // Optimizer functionality for the LLVM D binding.
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 #include "llvm/PassManager.h"
7 #include "llvm/LinkAllPasses.h"
8 #include "llvm/Analysis/LoopPass.h"
9 #include "llvm/Target/TargetData.h"
10 #include "llvm-c/Core.h"
11
12 using namespace llvm;
13
14 extern "C" {
15
16 void LLVMOptimizeModule(LLVMModuleRef M, int doinline)
17 {
18 Module* m = unwrap(M);
19
20 PassManager pm;
21 pm.add(new TargetData(m));
22
23 //pm.add(createStripDeadPrototypesPass());
24 pm.add(createGlobalDCEPass());
25
26 pm.add(createRaiseAllocationsPass());
27 pm.add(createCFGSimplificationPass());
28 pm.add(createPromoteMemoryToRegisterPass());
29 pm.add(createGlobalOptimizerPass());
30 pm.add(createGlobalDCEPass());
31
32 pm.add(createIPConstantPropagationPass());
33 pm.add(createDeadArgEliminationPass());
34 pm.add(createInstructionCombiningPass());
35 pm.add(createCFGSimplificationPass());
36 pm.add(createPruneEHPass());
37
38 if (doinline)
39 pm.add(createFunctionInliningPass());
40
41 pm.add(createArgumentPromotionPass());
42 pm.add(createTailDuplicationPass());
43 pm.add(createInstructionCombiningPass());
44 pm.add(createCFGSimplificationPass());
45 pm.add(createScalarReplAggregatesPass());
46 pm.add(createInstructionCombiningPass());
47 pm.add(createCondPropagationPass());
48
49 pm.add(createTailCallEliminationPass());
50 pm.add(createCFGSimplificationPass());
51 pm.add(createReassociatePass());
52 pm.add(createLoopRotatePass());
53 pm.add(createLICMPass());
54 pm.add(createLoopUnswitchPass());
55 pm.add(createInstructionCombiningPass());
56 pm.add(createIndVarSimplifyPass());
57 pm.add(createLoopUnrollPass());
58 pm.add(createInstructionCombiningPass());
59 pm.add(createGVNPass());
60 pm.add(createSCCPPass());
61
62 pm.add(createInstructionCombiningPass());
63 pm.add(createCondPropagationPass());
64
65 pm.add(createDeadStoreEliminationPass());
66 pm.add(createAggressiveDCEPass());
67 pm.add(createCFGSimplificationPass());
68 pm.add(createSimplifyLibCallsPass());
69 pm.add(createDeadTypeEliminationPass());
70 pm.add(createConstantMergePass());
71
72 pm.run(*m);
73 }
74
75 }