return ConstantInt::get(Ty, 0);
case Type::FloatTyID:
case Type::DoubleTyID:
+ case Type::X86_FP80TyID:
+ case Type::PPC_FP128TyID:
+ case Type::FP128TyID:
return ConstantFP::get(Ty, 0.0);
case Type::PointerTyID:
return ConstantPointerNull::get(cast<PointerType>(Ty));
}
}
+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) {
return 0;
}
-/// @returns the value for an packed integer constant of the given type that
+/// @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 packed integer type!");
+ assert(Elts[0] && "Not a vector integer type!");
return cast<ConstantVector>(ConstantVector::get(Elts));
}
ConstantFP *&Slot = (*FloatConstants)[std::make_pair(IntVal, Ty)];
if (Slot) return Slot;
return Slot = new ConstantFP(Ty, (float)V);
- } else {
- assert(Ty == Type::DoubleTy);
+ } else if (Ty == Type::DoubleTy) {
uint64_t IntVal = DoubleToBits(V);
ConstantFP *&Slot = (*DoubleConstants)[std::make_pair(IntVal, Ty)];
if (Slot) return Slot;
return Slot = new ConstantFP(Ty, V);
+ // FIXME: Make long double constants work.
+ } else if (Ty == Type::X86_FP80Ty ||
+ Ty == Type::PPC_FP128Ty || Ty == Type::FP128Ty) {
+ assert(0 && "Long double constants not handled yet.");
+ } else {
+ assert(0 && "Unknown FP Type!");
}
}
assert((C->getType() == T->getElementType() ||
(T->isAbstract() &&
C->getType()->getTypeID() == T->getElementType()->getTypeID())) &&
- "Initializer for packed element doesn't match packed element type!");
+ "Initializer for vector element doesn't match vector element type!");
OL->init(C, this);
}
}
default:
return false; // These can't be represented as floating point!
- // TODO: Figure out how to test if a double can be cast to a float!
+ // TODO: Figure out how to test if we can use a shorter type instead!
case Type::FloatTyID:
case Type::DoubleTyID:
- return true; // This is the largest type...
+ case Type::X86_FP80TyID:
+ case Type::PPC_FP128TyID:
+ case Type::FP128TyID:
+ return true;
}
}
Constant *ConstantVector::get(const VectorType *Ty,
const std::vector<Constant*> &V) {
- // If this is an all-zero packed, return a ConstantAggregateZero object
+ // If this is an all-zero vector, return a ConstantAggregateZero object
if (!V.empty()) {
Constant *C = V[0];
if (!C->isNullValue())
destroyConstantImpl();
}
-/// This function will return true iff every element in this packed constant
+/// This function will return true iff every element in this vector constant
/// is set to all ones.
/// @returns true iff this constant's emements are all set to all ones.
/// @brief Determine if the value is all ones.