Commit more code over to new cast style


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@697 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp
index 852c4f2..fd09e9e 100644
--- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp
+++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp
@@ -21,6 +21,7 @@
 #include "llvm/Target/MachineInstrInfo.h"
 #include "llvm/Target/MachineRegInfo.h"
 #include "llvm/Support/StringExtras.h"
+#include "llvm/iOther.h"
 #include <algorithm>
 
 
@@ -540,7 +541,7 @@
   // Phi instructions are the only ones that produce a value but don't get
   // any non-dummy machine instructions.  Return here as an optimization.
   // 
-  if (defVMInstr->isPHINode())
+  if (isa<PHINode>(defVMInstr))
     return;
   
   // Now add the graph edge for the appropriate machine instruction(s).
@@ -642,7 +643,7 @@
 SchedGraph::addNonSSAEdgesForValue(const Instruction* instr,
                                    const TargetMachine& target)
 {
-  if (instr->isPHINode())
+  if (isa<PHINode>(instr))
     return;
 
   MachineCodeForVMInstr& mvec = instr->getMachineInstrVec();
diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
index f5a5247..199ed65 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
@@ -26,6 +26,7 @@
 #include "llvm/Method.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iMemory.h"
+#include "llvm/iOther.h"
 #include "llvm/ConstPoolVals.h"
 #include "llvm/BasicBlock.h"
 #include "llvm/CodeGen/MachineInstr.h"
@@ -57,11 +58,11 @@
 
   // Distinguish special cases of some instructions such as Ret and Br
   // 
-  if (opLabel == Instruction::Ret && ((ReturnInst*)I)->getReturnValue())
+  if (opLabel == Instruction::Ret && cast<ReturnInst>(I)->getReturnValue())
     {
       opLabel = RetValueOp;              	 // ret(value) operation
     }
-  else if (opLabel == Instruction::Br && ! ((BranchInst*)I)->isUnconditional())
+  else if (opLabel ==Instruction::Br && !cast<BranchInst>(I)->isUnconditional())
     {
       opLabel = BrCondOp;		// br(cond) operation
     }
@@ -302,7 +303,7 @@
 	  InstrTreeNode* opTreeNode;
 	  if (isa<Instruction>(operand) && operand->use_size() == 1 &&
 	      cast<Instruction>(operand)->getParent() == instr->getParent() &&
-	      ! instr->isPHINode() &&
+	      !isa<PHINode>(instr) &&
 	      instr->getOpcode() != Instruction::Call)
 	    {
 	      // Recursively create a treeNode for it.
diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp
index b1b5e01..e4ae8a8 100644
--- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp
+++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp
@@ -2010,9 +2010,8 @@
                 // Also, mark the operands of the Call as implicit operands
                 // of the machine instruction.
         {
-        CallInst* callInstr = (CallInst*) subtreeRoot->getInstruction();
+        CallInst *callInstr = cast<CallInst>(subtreeRoot->getInstruction());
         Method* callee = callInstr->getCalledMethod();
-        assert(callInstr->getOpcode() == Instruction::Call); 
         
         Instruction* jmpAddrReg = new TmpInstruction(Instruction::UserOp1,
                                                      callee, NULL);
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp
index 24a5e85..0b4dc98 100644
--- a/lib/Target/TargetData.cpp
+++ b/lib/Target/TargetData.cpp
@@ -147,14 +147,14 @@
 
 unsigned TargetData::getIndexedOffset(const Type *ptrTy,
 				      const vector<ConstPoolVal*> &Idx) const {
-  const PointerType *PtrTy = ptrTy->castPointerType();
+  const PointerType *PtrTy = cast<const PointerType>(ptrTy);
   unsigned Result = 0;
 
   // Get the type pointed to...
   const Type *Ty = PtrTy->getValueType();
 
   for (unsigned CurIDX = 0; CurIDX < Idx.size(); ++CurIDX) {
-    if (const StructType *STy = Ty->dyncastStructType()) {
+    if (const StructType *STy = dyn_cast<const StructType>(Ty)) {
       assert(Idx[CurIDX]->getType() == Type::UByteTy && "Illegal struct idx");
       unsigned FieldNo = ((ConstPoolUInt*)Idx[CurIDX++])->getValue();
 
@@ -168,7 +168,7 @@
       // Update Ty to refer to current element
       Ty = STy->getElementTypes()[FieldNo];
 
-    } else if (const ArrayType *ATy = Ty->dyncastArrayType()) {
+    } else if (const ArrayType *ATy = dyn_cast<const ArrayType>(Ty)) {
       assert(0 && "Loading from arrays not implemented yet!");
     } else {
       assert(0 && "Indexing type that is not struct or array?");