aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Constants.cpp31
-rw-r--r--lib/VMCore/Instructions.cpp14
-rw-r--r--lib/VMCore/LLVMContext.cpp23
3 files changed, 19 insertions, 49 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index f8ae2bd..a1b4c93 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -128,31 +128,6 @@ bool Constant::ContainsRelocations(unsigned Kind) const {
return false;
}
-Constant *Constant::getAllOnesValue(const Type *Ty) {
- if (const IntegerType* ITy = dyn_cast<IntegerType>(Ty))
- return ConstantInt::get(APInt::getAllOnesValue(ITy->getBitWidth()));
- return ConstantVector::getAllOnesValue(cast<VectorType>(Ty));
-}
-
-// Static constructor to create an integral constant with all bits set
-ConstantInt *ConstantInt::getAllOnesValue(const Type *Ty) {
- if (const IntegerType* ITy = dyn_cast<IntegerType>(Ty))
- return ConstantInt::get(APInt::getAllOnesValue(ITy->getBitWidth()));
- return 0;
-}
-
-/// @returns the value for a vector integer constant of the given type that
-/// has all its bits set to true.
-/// @brief Get the all ones value
-ConstantVector *ConstantVector::getAllOnesValue(const VectorType *Ty) {
- std::vector<Constant*> Elts;
- Elts.resize(Ty->getNumElements(),
- ConstantInt::getAllOnesValue(Ty->getElementType()));
- assert(Elts[0] && "Not a vector integer type!");
- return cast<ConstantVector>(ConstantVector::get(Elts));
-}
-
-
/// getVectorElements - This method, which is only valid on constant of vector
/// type, returns the elements of the vector in the specified smallvector.
/// This handles breaking down a vector undef into undef elements, etc. For
@@ -797,12 +772,6 @@ const SmallVector<unsigned, 4> &ConstantExpr::getIndices() const {
return cast<InsertValueConstantExpr>(this)->Indices;
}
-Constant *ConstantExpr::getNot(Constant *C) {
- assert(C->getType()->isIntOrIntVector() &&
- "Cannot NOT a nonintegral value!");
- return get(Instruction::Xor, C,
- Constant::getAllOnesValue(C->getType()));
-}
Constant *ConstantExpr::getAdd(Constant *C1, Constant *C2) {
return get(Instruction::Add, C1, C2);
}
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index 74bcc10..7c98d21 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -1669,30 +1669,32 @@ BinaryOperator *BinaryOperator::CreateFNeg(LLVMContext &Context,
Op->getType(), Name, InsertAtEnd);
}
-BinaryOperator *BinaryOperator::CreateNot(Value *Op, const std::string &Name,
+BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
+ Value *Op, const std::string &Name,
Instruction *InsertBefore) {
Constant *C;
if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
- C = ConstantInt::getAllOnesValue(PTy->getElementType());
+ C = Context.getAllOnesValue(PTy->getElementType());
C = ConstantVector::get(std::vector<Constant*>(PTy->getNumElements(), C));
} else {
- C = ConstantInt::getAllOnesValue(Op->getType());
+ C = Context.getAllOnesValue(Op->getType());
}
return new BinaryOperator(Instruction::Xor, Op, C,
Op->getType(), Name, InsertBefore);
}
-BinaryOperator *BinaryOperator::CreateNot(Value *Op, const std::string &Name,
+BinaryOperator *BinaryOperator::CreateNot(LLVMContext &Context,
+ Value *Op, const std::string &Name,
BasicBlock *InsertAtEnd) {
Constant *AllOnes;
if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
// Create a vector of all ones values.
- Constant *Elt = ConstantInt::getAllOnesValue(PTy->getElementType());
+ Constant *Elt = Context.getAllOnesValue(PTy->getElementType());
AllOnes =
ConstantVector::get(std::vector<Constant*>(PTy->getNumElements(), Elt));
} else {
- AllOnes = ConstantInt::getAllOnesValue(Op->getType());
+ AllOnes = Context.getAllOnesValue(Op->getType());
}
return new BinaryOperator(Instruction::Xor, Op, AllOnes,
diff --git a/lib/VMCore/LLVMContext.cpp b/lib/VMCore/LLVMContext.cpp
index a8a8928..a7df2af 100644
--- a/lib/VMCore/LLVMContext.cpp
+++ b/lib/VMCore/LLVMContext.cpp
@@ -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);