aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Transforms/Scalar/ConstantProp.h
blob: 999e7ffe4d9da2f679c5d73f46fe3731f92a2f03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//===-- ConstantProp.h - Functions for Constant Propogation ------*- C++ -*--=//
//
// This family of functions are useful for performing constant propogation.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_OPT_CONSTANT_PROPOGATION_H
#define LLVM_OPT_CONSTANT_PROPOGATION_H

#include "llvm/Module.h"
class Method;
class TerminatorInst;
class ConstantPool;

namespace opt {

// DoConstantPropogation - Do trivial constant propogation and expression
// folding
bool DoConstantPropogation(Method *M);

static inline bool DoConstantPropogation(Module *M) { 
  return M->reduceApply(DoConstantPropogation); 
}


// ConstantFoldTerminator - If a terminator instruction is predicated on a
// constant value, convert it into an unconditional branch to the constant
// destination.
//
bool ConstantFoldTerminator(TerminatorInst *T);


//===----------------------------------------------------------------------===//
// Constant Pool Merging Pass
//
// This function merges all constants in the specified constant pool that have
// identical types and values.  This is useful for passes that generate lots of
// constants as a side effect of running.
//
bool DoConstantPoolMerging(ConstantPool &CP);
bool DoConstantPoolMerging(Method *M);

static inline bool DoConstantPoolMerging(Module *M) {
  return M->reduceApply(DoConstantPoolMerging) |
         DoConstantPoolMerging(M->getConstantPool());
}

//===----------------------------------------------------------------------===//
// Sparse Conditional Constant Propogation Pass
//

bool DoSCCP(Method *M);
static inline bool DoSCCP(Module *M) {
  return M->reduceApply(DoSCCP);
}

}  // End Namespace opt

#endif