aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Support
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2012-01-26 21:37:55 +0000
committerChris Lattner <sabre@nondot.org>2012-01-26 21:37:55 +0000
commit6b0dc92043ab1f63d78b8796098575e1d777b701 (patch)
tree2ff62b3e597697a2569a0f9940de2f12c32a7168 /include/llvm/Support
parent5b676ce7932cf60d4fd6d101323d8d54b8395804 (diff)
downloadexternal_llvm-6b0dc92043ab1f63d78b8796098575e1d777b701.zip
external_llvm-6b0dc92043ab1f63d78b8796098575e1d777b701.tar.gz
external_llvm-6b0dc92043ab1f63d78b8796098575e1d777b701.tar.bz2
progress making the world safe to ConstantDataVector. While
we're at it, allow PatternMatch's "neg" pattern to match integer vector negations, and enhance ComputeNumSigned bits to handle shl of vectors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149082 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support')
-rw-r--r--include/llvm/Support/PatternMatch.h37
1 files changed, 29 insertions, 8 deletions
diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h
index d68c265..221fa8b 100644
--- a/include/llvm/Support/PatternMatch.h
+++ b/include/llvm/Support/PatternMatch.h
@@ -98,12 +98,19 @@ struct apint_match {
Res = &CI->getValue();
return true;
}
+ // FIXME: Remove this.
if (ConstantVector *CV = dyn_cast<ConstantVector>(V))
if (ConstantInt *CI =
dyn_cast_or_null<ConstantInt>(CV->getSplatValue())) {
Res = &CI->getValue();
return true;
}
+ if (ConstantDataVector *CV = dyn_cast<ConstantDataVector>(V))
+ if (ConstantInt *CI =
+ dyn_cast_or_null<ConstantInt>(CV->getSplatValue())) {
+ Res = &CI->getValue();
+ return true;
+ }
return false;
}
};
@@ -144,9 +151,13 @@ struct cst_pred_ty : public Predicate {
bool match(ITy *V) {
if (const ConstantInt *CI = dyn_cast<ConstantInt>(V))
return this->isValue(CI->getValue());
+ // FIXME: Remove this.
if (const ConstantVector *CV = dyn_cast<ConstantVector>(V))
if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(CV->getSplatValue()))
return this->isValue(CI->getValue());
+ if (const ConstantDataVector *CV = dyn_cast<ConstantDataVector>(V))
+ if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(CV->getSplatValue()))
+ return this->isValue(CI->getValue());
return false;
}
};
@@ -164,12 +175,22 @@ struct api_pred_ty : public Predicate {
Res = &CI->getValue();
return true;
}
+
+ // FIXME: remove.
if (const ConstantVector *CV = dyn_cast<ConstantVector>(V))
if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(CV->getSplatValue()))
if (this->isValue(CI->getValue())) {
Res = &CI->getValue();
return true;
}
+
+ if (const ConstantDataVector *CV = dyn_cast<ConstantDataVector>(V))
+ if (ConstantInt *CI = dyn_cast_or_null<ConstantInt>(CV->getSplatValue()))
+ if (this->isValue(CI->getValue())) {
+ Res = &CI->getValue();
+ return true;
+ }
+
return false;
}
};
@@ -611,11 +632,11 @@ struct not_match {
}
private:
bool matchIfNot(Value *LHS, Value *RHS) {
- if (ConstantInt *CI = dyn_cast<ConstantInt>(RHS))
- return CI->isAllOnesValue() && L.match(LHS);
- if (ConstantVector *CV = dyn_cast<ConstantVector>(RHS))
- return CV->isAllOnesValue() && L.match(LHS);
- return false;
+ return (isa<ConstantInt>(RHS) || isa<ConstantDataVector>(RHS) ||
+ // FIXME: Remove CV.
+ isa<ConstantVector>(RHS)) &&
+ cast<Constant>(RHS)->isAllOnesValue() &&
+ L.match(LHS);
}
};
@@ -638,9 +659,9 @@ struct neg_match {
}
private:
bool matchIfNeg(Value *LHS, Value *RHS) {
- if (ConstantInt *C = dyn_cast<ConstantInt>(LHS))
- return C->isZero() && L.match(RHS);
- return false;
+ return ((isa<ConstantInt>(LHS) && cast<ConstantInt>(LHS)->isZero()) ||
+ isa<ConstantAggregateZero>(LHS)) &&
+ L.match(RHS);
}
};