aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Transforms/Scalar')
-rw-r--r--lib/Transforms/Scalar/ConstantProp.cpp24
-rw-r--r--lib/Transforms/Scalar/DCE.cpp6
-rw-r--r--lib/Transforms/Scalar/InductionVars.cpp20
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp46
-rw-r--r--lib/Transforms/Scalar/SymbolStripping.cpp2
5 files changed, 49 insertions, 49 deletions
diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp
index bf2886871f..4fb3254853 100644
--- a/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/lib/Transforms/Scalar/ConstantProp.cpp
@@ -29,12 +29,12 @@
#include "llvm/iTerminators.h"
#include "llvm/iPHINode.h"
#include "llvm/iOther.h"
-#include "llvm/ConstPoolVals.h"
+#include "llvm/ConstantVals.h"
inline static bool
ConstantFoldUnaryInst(BasicBlock *BB, BasicBlock::iterator &II,
- UnaryOperator *Op, ConstPoolVal *D) {
- ConstPoolVal *ReplaceWith =
+ UnaryOperator *Op, Constant *D) {
+ Constant *ReplaceWith =
opt::ConstantFoldUnaryInstruction(Op->getOpcode(), D);
if (!ReplaceWith) return false; // Nothing new to change...
@@ -56,8 +56,8 @@ ConstantFoldUnaryInst(BasicBlock *BB, BasicBlock::iterator &II,
inline static bool
ConstantFoldCast(BasicBlock *BB, BasicBlock::iterator &II,
- CastInst *CI, ConstPoolVal *D) {
- ConstPoolVal *ReplaceWith =
+ CastInst *CI, Constant *D) {
+ Constant *ReplaceWith =
opt::ConstantFoldCastInstruction(D, CI->getType());
if (!ReplaceWith) return false; // Nothing new to change...
@@ -80,8 +80,8 @@ ConstantFoldCast(BasicBlock *BB, BasicBlock::iterator &II,
inline static bool
ConstantFoldBinaryInst(BasicBlock *BB, BasicBlock::iterator &II,
BinaryOperator *Op,
- ConstPoolVal *D1, ConstPoolVal *D2) {
- ConstPoolVal *ReplaceWith =
+ Constant *D1, Constant *D2) {
+ Constant *ReplaceWith =
opt::ConstantFoldBinaryInstruction(Op->getOpcode(), D1, D2);
if (!ReplaceWith) return false; // Nothing new to change...
@@ -111,7 +111,7 @@ bool opt::ConstantFoldTerminator(TerminatorInst *T) {
BasicBlock *Dest1 = cast<BasicBlock>(BI->getOperand(0));
BasicBlock *Dest2 = cast<BasicBlock>(BI->getOperand(1));
- if (ConstPoolBool *Cond = dyn_cast<ConstPoolBool>(BI->getCondition())) {
+ if (ConstantBool *Cond = dyn_cast<ConstantBool>(BI->getCondition())) {
// Are we branching on constant?
// YES. Change to unconditional branch...
BasicBlock *Destination = Cond->getValue() ? Dest1 : Dest2;
@@ -160,18 +160,18 @@ bool opt::ConstantPropogation::doConstantPropogation(BasicBlock *BB,
BasicBlock::iterator &II) {
Instruction *Inst = *II;
if (BinaryOperator *BInst = dyn_cast<BinaryOperator>(Inst)) {
- ConstPoolVal *D1 = dyn_cast<ConstPoolVal>(Inst->getOperand(0));
- ConstPoolVal *D2 = dyn_cast<ConstPoolVal>(Inst->getOperand(1));
+ Constant *D1 = dyn_cast<Constant>(Inst->getOperand(0));
+ Constant *D2 = dyn_cast<Constant>(Inst->getOperand(1));
if (D1 && D2)
return ConstantFoldBinaryInst(BB, II, cast<BinaryOperator>(Inst), D1, D2);
} else if (CastInst *CI = dyn_cast<CastInst>(Inst)) {
- ConstPoolVal *D = dyn_cast<ConstPoolVal>(CI->getOperand(0));
+ Constant *D = dyn_cast<Constant>(CI->getOperand(0));
if (D) return ConstantFoldCast(BB, II, CI, D);
} else if (UnaryOperator *UInst = dyn_cast<UnaryOperator>(Inst)) {
- ConstPoolVal *D = dyn_cast<ConstPoolVal>(UInst->getOperand(0));
+ Constant *D = dyn_cast<Constant>(UInst->getOperand(0));
if (D) return ConstantFoldUnaryInst(BB, II, UInst, D);
} else if (TerminatorInst *TInst = dyn_cast<TerminatorInst>(Inst)) {
return opt::ConstantFoldTerminator(TInst);
diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp
index e1bda22b8b..6c4e3d2a20 100644
--- a/lib/Transforms/Scalar/DCE.cpp
+++ b/lib/Transforms/Scalar/DCE.cpp
@@ -96,7 +96,7 @@ static bool RemoveSingularPHIs(BasicBlock *BB) {
}
static void ReplaceUsesWithConstant(Instruction *I) {
- ConstPoolVal *CPV = ConstPoolVal::getNullConstant(I->getType());
+ Constant *CPV = Constant::getNullConstant(I->getType());
// Make all users of this instruction reference the constant instead
I->replaceAllUsesWith(CPV);
@@ -166,7 +166,7 @@ bool opt::SimplifyCFG(Method::iterator &BBIt) {
// Remove basic blocks that have no predecessors... which are unreachable.
if (BB->pred_begin() == BB->pred_end() &&
- !BB->hasConstantPoolReferences()) {
+ !BB->hasConstantReferences()) {
//cerr << "Removing BB: \n" << BB;
// Loop through all of our successors and make sure they know that one
@@ -225,7 +225,7 @@ bool opt::SimplifyCFG(Method::iterator &BBIt) {
// and if there is only one successor of the predecessor.
BasicBlock::pred_iterator PI(BB->pred_begin());
if (PI != BB->pred_end() && *PI != BB && // Not empty? Not same BB?
- ++PI == BB->pred_end() && !BB->hasConstantPoolReferences()) {
+ ++PI == BB->pred_end() && !BB->hasConstantReferences()) {
BasicBlock *Pred = *BB->pred_begin();
TerminatorInst *Term = Pred->getTerminator();
assert(Term != 0 && "malformed basic block without terminator!");
diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp
index 7dfae486d2..d4b7bc5010 100644
--- a/lib/Transforms/Scalar/InductionVars.cpp
+++ b/lib/Transforms/Scalar/InductionVars.cpp
@@ -20,7 +20,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Optimizations/InductionVars.h"
-#include "llvm/ConstPoolVals.h"
+#include "llvm/ConstantVals.h"
#include "llvm/Analysis/IntervalPartition.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/SymbolTable.h"
@@ -36,7 +36,7 @@ using namespace opt;
// an interval invariant computation.
//
static bool isLoopInvariant(cfg::Interval *Int, Value *V) {
- assert(isa<ConstPoolVal>(V) || isa<Instruction>(V) || isa<MethodArgument>(V));
+ assert(isa<Constant>(V) || isa<Instruction>(V) || isa<MethodArgument>(V));
if (!isa<Instruction>(V))
return true; // Constants and arguments are always loop invariant
@@ -132,12 +132,12 @@ static inline bool isLinearInductionVariable(cfg::Interval *Int, Value *V,
static inline bool isSimpleInductionVar(PHINode *PN) {
assert(PN->getNumIncomingValues() == 2 && "Must have cannonical PHI node!");
Value *Initializer = PN->getIncomingValue(0);
- if (!isa<ConstPoolVal>(Initializer)) return false;
+ if (!isa<Constant>(Initializer)) return false;
if (Initializer->getType()->isSigned()) { // Signed constant value...
- if (((ConstPoolSInt*)Initializer)->getValue() != 0) return false;
+ if (((ConstantSInt*)Initializer)->getValue() != 0) return false;
} else if (Initializer->getType()->isUnsigned()) { // Unsigned constant value
- if (((ConstPoolUInt*)Initializer)->getValue() != 0) return false;
+ if (((ConstantUInt*)Initializer)->getValue() != 0) return false;
} else {
return false; // Not signed or unsigned? Must be FP type or something
}
@@ -153,12 +153,12 @@ static inline bool isSimpleInductionVar(PHINode *PN) {
// Get the right hand side of the ADD node. See if it is a constant 1.
Value *StepSize = I->getOperand(1);
- if (!isa<ConstPoolVal>(StepSize)) return false;
+ if (!isa<Constant>(StepSize)) return false;
if (StepSize->getType()->isSigned()) { // Signed constant value...
- if (((ConstPoolSInt*)StepSize)->getValue() != 1) return false;
+ if (((ConstantSInt*)StepSize)->getValue() != 1) return false;
} else if (StepSize->getType()->isUnsigned()) { // Unsigned constant value
- if (((ConstPoolUInt*)StepSize)->getValue() != 1) return false;
+ if (((ConstantUInt*)StepSize)->getValue() != 1) return false;
} else {
return false; // Not signed or unsigned? Must be FP type or something
}
@@ -189,8 +189,8 @@ static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) {
// Create the neccesary instructions...
PHINode *PN = new PHINode(Type::UIntTy, PHIName);
- ConstPoolVal *One = ConstPoolUInt::get(Type::UIntTy, 1);
- ConstPoolVal *Zero = ConstPoolUInt::get(Type::UIntTy, 0);
+ Constant *One = ConstantUInt::get(Type::UIntTy, 1);
+ Constant *Zero = ConstantUInt::get(Type::UIntTy, 0);
BinaryOperator *AddNode = BinaryOperator::create(Instruction::Add,
PN, One, AddName);
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 3c699c16e0..26a52d61bf 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -19,7 +19,7 @@
#include "llvm/Optimizations/ConstantHandling.h"
#include "llvm/Method.h"
#include "llvm/BasicBlock.h"
-#include "llvm/ConstPoolVals.h"
+#include "llvm/ConstantVals.h"
#include "llvm/InstrTypes.h"
#include "llvm/iPHINode.h"
#include "llvm/iMemory.h"
@@ -38,28 +38,28 @@
//
class InstVal {
enum {
- Undefined, // This instruction has no known value
- Constant, // This instruction has a constant value
+ undefined, // This instruction has no known value
+ constant, // This instruction has a constant value
// Range, // This instruction is known to fall within a range
- Overdefined // This instruction has an unknown value
- } LatticeValue; // The current lattice position
- ConstPoolVal *ConstantVal; // If Constant value, the current value
+ overdefined // This instruction has an unknown value
+ } LatticeValue; // The current lattice position
+ Constant *ConstantVal; // If Constant value, the current value
public:
- inline InstVal() : LatticeValue(Undefined), ConstantVal(0) {}
+ inline InstVal() : LatticeValue(undefined), ConstantVal(0) {}
// markOverdefined - Return true if this is a new status to be in...
inline bool markOverdefined() {
- if (LatticeValue != Overdefined) {
- LatticeValue = Overdefined;
+ if (LatticeValue != overdefined) {
+ LatticeValue = overdefined;
return true;
}
return false;
}
// markConstant - Return true if this is a new status for us...
- inline bool markConstant(ConstPoolVal *V) {
- if (LatticeValue != Constant) {
- LatticeValue = Constant;
+ inline bool markConstant(Constant *V) {
+ if (LatticeValue != constant) {
+ LatticeValue = constant;
ConstantVal = V;
return true;
} else {
@@ -68,11 +68,11 @@ public:
return false;
}
- inline bool isUndefined() const { return LatticeValue == Undefined; }
- inline bool isConstant() const { return LatticeValue == Constant; }
- inline bool isOverdefined() const { return LatticeValue == Overdefined; }
+ inline bool isUndefined() const { return LatticeValue == undefined; }
+ inline bool isConstant() const { return LatticeValue == constant; }
+ inline bool isOverdefined() const { return LatticeValue == overdefined; }
- inline ConstPoolVal *getConstant() const { return ConstantVal; }
+ inline Constant *getConstant() const { return ConstantVal; }
};
@@ -113,7 +113,7 @@ private:
// is not already a constant, add it to the instruction work list so that
// the users of the instruction are updated later.
//
- inline bool markConstant(Instruction *I, ConstPoolVal *V) {
+ inline bool markConstant(Instruction *I, Constant *V) {
//cerr << "markConstant: " << V << " = " << I;
if (ValueState[I].markConstant(V)) {
InstWorkList.push_back(I);
@@ -147,7 +147,7 @@ private:
map<Value*, InstVal>::iterator I = ValueState.find(V);
if (I != ValueState.end()) return I->second; // Common case, in the map
- if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V)) {//Constants are constant
+ if (Constant *CPV = dyn_cast<Constant>(V)) { // Constants are constant
ValueState[CPV].markConstant(CPV);
} else if (isa<MethodArgument>(V)) { // MethodArgs are overdefined
ValueState[V].markOverdefined();
@@ -246,7 +246,7 @@ bool SCCP::doSCCP() {
Instruction *Inst = *II;
InstVal &IV = ValueState[Inst];
if (IV.isConstant()) {
- ConstPoolVal *Const = IV.getConstant();
+ Constant *Const = IV.getConstant();
// cerr << "Constant: " << Inst << " is: " << Const;
// Replaces all of the uses of a variable with uses of the constant.
@@ -393,7 +393,7 @@ void SCCP::UpdateInstruction(Instruction *I) {
markExecutable(BI->getSuccessor(1));
} else if (BCValue.isConstant()) {
// Constant condition variables mean the branch can only go a single way.
- ConstPoolBool *CPB = cast<ConstPoolBool>(BCValue.getConstant());
+ ConstantBool *CPB = cast<ConstantBool>(BCValue.getConstant());
if (CPB->getValue()) // If the branch condition is TRUE...
markExecutable(BI->getSuccessor(0));
else // Else if the br cond is FALSE...
@@ -409,7 +409,7 @@ void SCCP::UpdateInstruction(Instruction *I) {
for(unsigned i = 0; BasicBlock *Succ = SI->getSuccessor(i); ++i)
markExecutable(Succ);
} else if (SCValue.isConstant()) {
- ConstPoolVal *CPV = SCValue.getConstant();
+ Constant *CPV = SCValue.getConstant();
// Make sure to skip the "default value" which isn't a value
for (unsigned i = 1, E = SI->getNumSuccessors(); i != E; ++i) {
if (SI->getSuccessorValue(i) == CPV) {// Found the right branch...
@@ -443,7 +443,7 @@ void SCCP::UpdateInstruction(Instruction *I) {
if (VState.isOverdefined()) { // Inherit overdefinedness of operand
markOverdefined(I);
} else if (VState.isConstant()) { // Propogate constant value
- ConstPoolVal *Result = isa<CastInst>(I)
+ Constant *Result = isa<CastInst>(I)
? opt::ConstantFoldCastInstruction(VState.getConstant(), I->getType())
: opt::ConstantFoldUnaryInstruction(I->getOpcode(),
VState.getConstant());
@@ -470,7 +470,7 @@ void SCCP::UpdateInstruction(Instruction *I) {
if (V1State.isOverdefined() || V2State.isOverdefined()) {
markOverdefined(I);
} else if (V1State.isConstant() && V2State.isConstant()) {
- ConstPoolVal *Result =
+ Constant *Result =
opt::ConstantFoldBinaryInstruction(I->getOpcode(),
V1State.getConstant(),
V2State.getConstant());
diff --git a/lib/Transforms/Scalar/SymbolStripping.cpp b/lib/Transforms/Scalar/SymbolStripping.cpp
index 06cf025221..bb4f01c90b 100644
--- a/lib/Transforms/Scalar/SymbolStripping.cpp
+++ b/lib/Transforms/Scalar/SymbolStripping.cpp
@@ -29,7 +29,7 @@ static bool StripSymbolTable(SymbolTable *SymTab) {
SymbolTable::type_iterator B;
while ((B = Plane.begin()) != Plane.end()) { // Found nonempty type plane!
Value *V = B->second;
- if (isa<ConstPoolVal>(V) || isa<Type>(V))
+ if (isa<Constant>(V) || isa<Type>(V))
SymTab->type_remove(B);
else
V->setName("", SymTab); // Set name to "", removing from symbol table!