Convert more code to use new style casts
Eliminate old style casts from value.h

llvm-svn: 696
diff --git a/llvm/lib/Transforms/IPO/InlineSimple.cpp b/llvm/lib/Transforms/IPO/InlineSimple.cpp
index 27ef66e..8bc0a77 100644
--- a/llvm/lib/Transforms/IPO/InlineSimple.cpp
+++ b/llvm/lib/Transforms/IPO/InlineSimple.cpp
@@ -40,7 +40,7 @@
   for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) {
     const Value *Op = I->getOperand(op);
     Value *V = ValueMap[Op];
-    if (!V && (Op->isMethod() || Op->isConstant()))
+    if (!V && (isa<Method>(Op) || isa<ConstPoolVal>(Op)))
       continue;  // Methods and constants don't get relocated
 
     if (!V) {
diff --git a/llvm/lib/Transforms/Scalar/ConstantProp.cpp b/llvm/lib/Transforms/Scalar/ConstantProp.cpp
index 8b87916..d43f693 100644
--- a/llvm/lib/Transforms/Scalar/ConstantProp.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstantProp.cpp
@@ -88,9 +88,9 @@
     BasicBlock *Dest1 = cast<BasicBlock>(BI->getOperand(0));
     BasicBlock *Dest2 = cast<BasicBlock>(BI->getOperand(1));
 
-    if (BI->getCondition()->isConstant()) {    // Are we branching on constant?
+    if (ConstPoolBool *Cond = dyn_cast<ConstPoolBool>(BI->getCondition())) {
+      // Are we branching on constant?
       // YES.  Change to unconditional branch...
-      ConstPoolBool *Cond = (ConstPoolBool*)BI->getCondition();
       BasicBlock *Destination = Cond->getValue() ? Dest1 : Dest2;
       BasicBlock *OldDest     = Cond->getValue() ? Dest2 : Dest1;
 
@@ -137,14 +137,14 @@
 ConstantFoldInstruction(Method *M, Method::inst_iterator &II) {
   Instruction *Inst = *II;
   if (Inst->isBinaryOp()) {
-    ConstPoolVal *D1 = Inst->getOperand(0)->castConstant();
-    ConstPoolVal *D2 = Inst->getOperand(1)->castConstant();
+    ConstPoolVal *D1 = dyn_cast<ConstPoolVal>(Inst->getOperand(0));
+    ConstPoolVal *D2 = dyn_cast<ConstPoolVal>(Inst->getOperand(1));
 
     if (D1 && D2)
       return ConstantFoldBinaryInst(M, II, (BinaryOperator*)Inst, D1, D2);
 
   } else if (Inst->isUnaryOp()) {
-    ConstPoolVal *D = Inst->getOperand(0)->castConstant();
+    ConstPoolVal *D = dyn_cast<ConstPoolVal>(Inst->getOperand(0));
     if (D) return ConstantFoldUnaryInst(M, II, (UnaryOperator*)Inst, D);
   } else if (Inst->isTerminator()) {
     return opt::ConstantFoldTerminator((TerminatorInst*)Inst);
diff --git a/llvm/lib/Transforms/Scalar/InductionVars.cpp b/llvm/lib/Transforms/Scalar/InductionVars.cpp
index 6815ccb..f2dcb45 100644
--- a/llvm/lib/Transforms/Scalar/InductionVars.cpp
+++ b/llvm/lib/Transforms/Scalar/InductionVars.cpp
@@ -36,9 +36,9 @@
 // an interval invariant computation.
 //
 static bool isLoopInvariant(cfg::Interval *Int, Value *V) {
-  assert(V->isConstant() || V->isInstruction() || V->isMethodArgument());
+  assert(isa<ConstPoolVal>(V) || isa<Instruction>(V) || isa<MethodArgument>(V));
 
-  if (!V->isInstruction())
+  if (!isa<Instruction>(V))
     return true;  // Constants and arguments are always loop invariant
 
   BasicBlock *ValueBlock = ((Instruction*)V)->getParent();
@@ -132,7 +132,7 @@
 static inline bool isSimpleInductionVar(PHINode *PN) {
   assert(PN->getNumIncomingValues() == 2 && "Must have cannonical PHI node!");
   Value *Initializer = PN->getIncomingValue(0);
-  if (!Initializer->isConstant()) return false;
+  if (!isa<ConstPoolVal>(Initializer)) return false;
 
   if (Initializer->getType()->isSigned()) {  // Signed constant value...
     if (((ConstPoolSInt*)Initializer)->getValue() != 0) return false;
@@ -143,18 +143,18 @@
   }
 
   Value *StepExpr = PN->getIncomingValue(1);
-  if (!StepExpr->isInstruction() ||
+  if (!isa<Instruction>(StepExpr) ||
       ((Instruction*)StepExpr)->getOpcode() != Instruction::Add)
     return false;
 
   BinaryOperator *I = (BinaryOperator*)StepExpr;
-  assert(I->getOperand(0)->isInstruction() && 
+  assert(isa<Instruction>(I->getOperand(0)) && 
       ((Instruction*)I->getOperand(0))->isPHINode() &&
 	 "PHI node should be first operand of ADD instruction!");
 
   // Get the right hand side of the ADD node.  See if it is a constant 1.
   Value *StepSize = I->getOperand(1);
-  if (!StepSize->isConstant()) return false;
+  if (!isa<ConstPoolVal>(StepSize)) return false;
 
   if (StepSize->getType()->isSigned()) {  // Signed constant value...
     if (((ConstPoolSInt*)StepSize)->getValue() != 1) return false;
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp
index 78b6c3d..91e002d 100644
--- a/llvm/lib/Transforms/Scalar/SCCP.cpp
+++ b/llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -146,9 +146,9 @@
     map<Value*, InstVal>::iterator I = ValueState.find(V);
     if (I != ValueState.end()) return I->second;  // Common case, in the map
       
-    if (ConstPoolVal *CPV = V->castConstant()) {  // Constants are constant
+    if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V)) {//Constants are constant
       ValueState[CPV].markConstant(CPV);
-    } else if (V->isMethodArgument()) {           // MethodArgs are overdefined
+    } else if (isa<MethodArgument>(V)) {          // MethodArgs are overdefined
       ValueState[V].markOverdefined();
     } 
     // All others are underdefined by default...