Move more functionality over to LLVMContext.
[oota-llvm.git] / lib / VMCore / LLVMContext.cpp
index a8a8928cdfe605bf2949bbe26ef2230eccb7de8e..a7df2affe3123632300e4bc1674fb710ac7ec9cb 100644 (file)
@@ -64,7 +64,14 @@ Constant* LLVMContext::getNullValue(const Type* Ty) {
 }
 
 Constant* LLVMContext::getAllOnesValue(const Type* Ty) {
-  return Constant::getAllOnesValue(Ty);
+  if (const IntegerType* ITy = dyn_cast<IntegerType>(Ty))
+    return getConstantInt(APInt::getAllOnesValue(ITy->getBitWidth()));
+  
+  std::vector<Constant*> Elts;
+  const VectorType* VTy = cast<VectorType>(Ty);
+  Elts.resize(VTy->getNumElements(), getAllOnesValue(VTy->getElementType()));
+  assert(Elts[0] && "Not a vector integer type!");
+  return cast<ConstantVector>(getConstantVector(Elts));
 }
 
 // UndefValue accessors.
@@ -105,11 +112,6 @@ Constant* LLVMContext::getConstantInt(const Type* Ty, const APInt& V) {
   return ConstantInt::get(Ty, V);
 }
 
-ConstantInt* LLVMContext::getConstantIntAllOnesValue(const Type* Ty) {
-  return ConstantInt::getAllOnesValue(Ty);
-}
-
-
 // ConstantPointerNull accessors.
 ConstantPointerNull* LLVMContext::getConstantPointerNull(const PointerType* T) {
   return ConstantPointerNull::get(T);
@@ -285,7 +287,9 @@ Constant* LLVMContext::getConstantExprFNeg(Constant* C) {
 }
 
 Constant* LLVMContext::getConstantExprNot(Constant* C) {
-  return ConstantExpr::getNot(C);
+  assert(C->getType()->isIntOrIntVector() &&
+         "Cannot NOT a nonintegral value!");
+  return getConstantExpr(Instruction::Xor, C, getAllOnesValue(C->getType()));
 }
 
 Constant* LLVMContext::getConstantExprAdd(Constant* C1, Constant* C2) {
@@ -464,11 +468,6 @@ Constant* LLVMContext::getConstantVector(Constant* const* Vals,
   return ConstantVector::get(Vals, NumVals);
 }
 
-ConstantVector* LLVMContext::getConstantVectorAllOnesValue(
-                                                         const VectorType* Ty) {
-  return ConstantVector::getAllOnesValue(Ty);
-}
-
 // MDNode accessors
 MDNode* LLVMContext::getMDNode(Value* const* Vals, unsigned NumVals) {
   return MDNode::get(Vals, NumVals);