mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-04 01:11:44 +00:00
[Constant] add undef element query for vector constants; NFC
This is likely to be used in D48987 and similar patches, so adding it as an NFC preliminary step. llvm-svn: 336442
This commit is contained in:
parent
5aeee587fd
commit
8e3ee5bc36
@ -87,6 +87,10 @@ public:
|
||||
/// floating-point constant with all NaN elements.
|
||||
bool isNaN() const;
|
||||
|
||||
/// Return true if this is a vector constant that includes any undefined
|
||||
/// elements.
|
||||
bool containsUndefElement() const;
|
||||
|
||||
/// Return true if evaluation of this constant could trap. This is true for
|
||||
/// things like constant expressions that could divide by zero.
|
||||
bool canTrap() const;
|
||||
|
@ -254,6 +254,16 @@ bool Constant::isNaN() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Constant::containsUndefElement() const {
|
||||
if (!getType()->isVectorTy())
|
||||
return false;
|
||||
for (unsigned i = 0, e = getType()->getVectorNumElements(); i != e; ++i)
|
||||
if (isa<UndefValue>(getAggregateElement(i)))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Constructor to create a '0' constant of arbitrary type.
|
||||
Constant *Constant::getNullValue(Type *Ty) {
|
||||
switch (Ty->getTypeID()) {
|
||||
|
Loading…
Reference in New Issue
Block a user