Make it illegal to call getDependency* on non-memory instructions
[oota-llvm.git] / include / llvm / Analysis / ScalarEvolutionExpander.h
index daff373348b89b0da904aa8a5ff9f8a302de6155..7ecf5332edd8839ff9ec0116e89d8d38787022ae 100644 (file)
@@ -75,11 +75,7 @@ namespace llvm {
     /// expandCodeFor - Insert code to directly compute the specified SCEV
     /// expression into the program.  The inserted code is inserted into the
     /// specified block.
-    Value *expandCodeFor(SCEVHandle SH, Instruction *IP) {
-      // Expand the code for this SCEV.
-      this->InsertPt = IP;
-      return expand(SH);
-    }
+    Value *expandCodeFor(SCEVHandle SH, Instruction *IP);
 
     /// InsertCastOfTo - Insert a cast of V to the specified type, doing what
     /// we can to share the casts.
@@ -88,7 +84,7 @@ namespace llvm {
     /// InsertBinop - Insert the specified binary operator, doing a small amount
     /// of work to avoid inserting an obviously redundant operation.
     static Value *InsertBinop(Instruction::BinaryOps Opcode, Value *LHS,
-                              Value *RHS, Instruction *&InsertPt);
+                              Value *RHS, Instruction *InsertPt);
   protected:
     Value *expand(SCEV *S);
     
@@ -96,38 +92,19 @@ namespace llvm {
       return S->getValue();
     }
 
-    Value *visitTruncateExpr(SCEVTruncateExpr *S) {
-      Value *V = expand(S->getOperand());
-      return CastInst::CreateTruncOrBitCast(V, S->getType(), "tmp.", InsertPt);
-    }
-
-    Value *visitZeroExtendExpr(SCEVZeroExtendExpr *S) {
-      Value *V = expand(S->getOperand());
-      return CastInst::CreateZExtOrBitCast(V, S->getType(), "tmp.", InsertPt);
-    }
+    Value *visitTruncateExpr(SCEVTruncateExpr *S);
 
-    Value *visitSignExtendExpr(SCEVSignExtendExpr *S) {
-      Value *V = expand(S->getOperand());
-      return CastInst::CreateSExtOrBitCast(V, S->getType(), "tmp.", InsertPt);
-    }
+    Value *visitZeroExtendExpr(SCEVZeroExtendExpr *S);
 
-    Value *visitAddExpr(SCEVAddExpr *S) {
-      Value *V = expand(S->getOperand(S->getNumOperands()-1));
+    Value *visitSignExtendExpr(SCEVSignExtendExpr *S);
 
-      // Emit a bunch of add instructions
-      for (int i = S->getNumOperands()-2; i >= 0; --i)
-        V = InsertBinop(Instruction::Add, V, expand(S->getOperand(i)),
-                        InsertPt);
-      return V;
-    }
+    Value *visitAddExpr(SCEVAddExpr *S);
 
     Value *visitMulExpr(SCEVMulExpr *S);
 
-    Value *visitUDivExpr(SCEVUDivExpr *S) {
-      Value *LHS = expand(S->getLHS());
-      Value *RHS = expand(S->getRHS());
-      return InsertBinop(Instruction::UDiv, LHS, RHS, InsertPt);
-    }
+    Value *visitUDivExpr(SCEVUDivExpr *S);
+
+    Value *visitSDivExpr(SCEVSDivExpr *S);
 
     Value *visitAddRecExpr(SCEVAddRecExpr *S);