2001-06-30 04:34:07 +00:00
|
|
|
//===-- ConstantProp.h - Functions for Constant Propogation ------*- C++ -*--=//
|
|
|
|
//
|
|
|
|
// This family of functions are useful for performing constant propogation.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2002-01-30 23:29:35 +00:00
|
|
|
#ifndef LLVM_TRANSFORMS_SCALAR_CONSTANT_PROPOGATION_H
|
|
|
|
#define LLVM_TRANSFORMS_SCALAR_CONSTANT_PROPOGATION_H
|
2001-06-30 04:34:07 +00:00
|
|
|
|
2001-10-18 20:19:09 +00:00
|
|
|
#include "llvm/Pass.h"
|
2002-01-30 23:29:35 +00:00
|
|
|
#include "llvm/BasicBlock.h"
|
2001-06-30 04:34:07 +00:00
|
|
|
class TerminatorInst;
|
|
|
|
|
2002-01-21 07:31:50 +00:00
|
|
|
struct ConstantPropogation : public MethodPass {
|
2001-10-18 01:31:58 +00:00
|
|
|
// doConstantPropogation - Do trivial constant propogation and expression
|
|
|
|
// folding
|
|
|
|
static bool doConstantPropogation(Method *M);
|
|
|
|
|
2001-11-26 18:50:11 +00:00
|
|
|
// doConstantPropogation - Constant prop a specific instruction. Returns true
|
|
|
|
// and potentially moves the iterator if constant propogation was performed.
|
|
|
|
//
|
|
|
|
static bool doConstantPropogation(BasicBlock *BB, BasicBlock::iterator &I);
|
|
|
|
|
2002-01-21 07:31:50 +00:00
|
|
|
inline bool runOnMethod(Method *M) {
|
2001-10-18 01:31:58 +00:00
|
|
|
return doConstantPropogation(M);
|
|
|
|
}
|
|
|
|
};
|
2001-06-30 04:34:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Sparse Conditional Constant Propogation Pass
|
|
|
|
//
|
2002-01-21 07:31:50 +00:00
|
|
|
struct SCCPPass : public MethodPass {
|
2001-10-18 01:31:58 +00:00
|
|
|
static bool doSCCP(Method *M);
|
|
|
|
|
2002-01-21 07:31:50 +00:00
|
|
|
inline bool runOnMethod(Method *M) {
|
2001-10-18 01:31:58 +00:00
|
|
|
return doSCCP(M);
|
|
|
|
}
|
|
|
|
};
|
2001-06-30 04:34:07 +00:00
|
|
|
|
|
|
|
#endif
|