Add a comment to describe why vector shuffles are legalized to custom DAG nodes.
[oota-llvm.git] / lib / VMCore / Instructions.cpp
index 08b439630749547da07e72a520b5ede7549c6331..902d806f23eb90d5d36343d6d62aebd5b2b7fad6 100644 (file)
@@ -187,7 +187,7 @@ Value *PHINode::removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty) {
   // If the PHI node is dead, because it has zero entries, nuke it now.
   if (NumOps == 2 && DeletePHIIfEmpty) {
     // If anyone is using this PHI, make them use a dummy value instead...
-    replaceAllUsesWith(getType()->getContext().getUndef(getType()));
+    replaceAllUsesWith(UndefValue::get(getType()));
     eraseFromParent();
   }
   return Removed;
@@ -231,8 +231,7 @@ Value *PHINode::hasConstantValue(bool AllowNonDominatingInstruction) const {
     if (getIncomingValue(0) != this)   // not  X = phi X
       return getIncomingValue(0);
     else
-      return
-        getType()->getContext().getUndef(getType());  // Self cycle is dead.
+      return UndefValue::get(getType());  // Self cycle is dead.
   }
       
   // Otherwise if all of the incoming values are the same for the PHI, replace
@@ -254,7 +253,7 @@ Value *PHINode::hasConstantValue(bool AllowNonDominatingInstruction) const {
   // that only has entries for itself.  In this case, there is no entry into the
   // loop, so kill the PHI.
   //
-  if (InVal == 0) InVal = getType()->getContext().getUndef(getType());
+  if (InVal == 0) InVal = UndefValue::get(getType());
   
   // If we have a PHI node like phi(X, undef, X), where X is defined by some
   // instruction, we cannot always return X as the result of the PHI node.  Only
@@ -1573,8 +1572,7 @@ BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
   return Res;
 }
 
-BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
-                                          Value *Op, const Twine &Name,
+BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const Twine &Name,
                                           Instruction *InsertBefore) {
   Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
   return new BinaryOperator(Instruction::Sub,
@@ -1582,8 +1580,7 @@ BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
                             Op->getType(), Name, InsertBefore);
 }
 
-BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context, 
-                                          Value *Op, const Twine &Name,
+BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const Twine &Name,
                                           BasicBlock *InsertAtEnd) {
   Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
   return new BinaryOperator(Instruction::Sub,
@@ -1591,8 +1588,7 @@ BinaryOperator *BinaryOperator::CreateNeg(LLVMContext &Context,
                             Op->getType(), Name, InsertAtEnd);
 }
 
-BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
-                                           Value *Op, const Twine &Name,
+BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const Twine &Name,
                                            Instruction *InsertBefore) {
   Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
   return new BinaryOperator(Instruction::FSub,
@@ -1600,8 +1596,7 @@ BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
                             Op->getType(), Name, InsertBefore);
 }
 
-BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
-                                           Value *Op, const Twine &Name,
+BinaryOperator *BinaryOperator::CreateFNeg(Value *Op, const Twine &Name,
                                            BasicBlock *InsertAtEnd) {
   Value *zero = ConstantFP::getZeroValueForNegation(Op->getType());
   return new BinaryOperator(Instruction::FSub,
@@ -1609,33 +1604,31 @@ BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
                             Op->getType(), Name, InsertAtEnd);
 }
 
-BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
-                                          Value *Op, const Twine &Name,
+BinaryOperator *BinaryOperator::CreateNot(Value *Op, const Twine &Name,
                                           Instruction *InsertBefore) {
   Constant *C;
   if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
-    C = Context.getAllOnesValue(PTy->getElementType());
+    C = Constant::getAllOnesValue(PTy->getElementType());
     C = ConstantVector::get(
                               std::vector<Constant*>(PTy->getNumElements(), C));
   } else {
-    C = Context.getAllOnesValue(Op->getType());
+    C = Constant::getAllOnesValue(Op->getType());
   }
   
   return new BinaryOperator(Instruction::Xor, Op, C,
                             Op->getType(), Name, InsertBefore);
 }
 
-BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
-                                          Value *Op, const Twine &Name,
+BinaryOperator *BinaryOperator::CreateNot(Value *Op, const Twine &Name,
                                           BasicBlock *InsertAtEnd) {
   Constant *AllOnes;
   if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
     // Create a vector of all ones values.
-    Constant *Elt = Context.getAllOnesValue(PTy->getElementType());
+    Constant *Elt = Constant::getAllOnesValue(PTy->getElementType());
     AllOnes = ConstantVector::get(
                             std::vector<Constant*>(PTy->getNumElements(), Elt));
   } else {
-    AllOnes = Context.getAllOnesValue(Op->getType());
+    AllOnes = Constant::getAllOnesValue(Op->getType());
   }
   
   return new BinaryOperator(Instruction::Xor, Op, AllOnes,