summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-01-01 15:59:57 +0000
committerChris Lattner <sabre@nondot.org>2005-01-01 15:59:57 +0000
commit1ece6f83bae3f3e3a7938078508c91422915d7a4 (patch)
tree0ba4454866809544ac2b47400037ed1fcd3a8f64 /llvm/lib
parent3196de7663a5345358300a4fe44d29a1773a14a1 (diff)
downloadbcm5719-llvm-1ece6f83bae3f3e3a7938078508c91422915d7a4.tar.gz
bcm5719-llvm-1ece6f83bae3f3e3a7938078508c91422915d7a4.zip
Allow getZeroExtend and getSignExtend to work with boolean inputs.
llvm-svn: 19210
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/Constants.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index f09e3b94bb5..b5de2780336 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/lib/VMCore/Constants.cpp
@@ -1239,18 +1239,26 @@ Constant *ConstantExpr::getCast(Constant *C, const Type *Ty) {
}
Constant *ConstantExpr::getSignExtend(Constant *C, const Type *Ty) {
- assert(C->getType()->isInteger() && Ty->isInteger() &&
+ assert(C->getType()->isIntegral() && Ty->isIntegral() &&
C->getType()->getPrimitiveSize() <= Ty->getPrimitiveSize() &&
"This is an illegal sign extension!");
- C = ConstantExpr::getCast(C, C->getType()->getSignedVersion());
- return ConstantExpr::getCast(C, Ty);
+ if (C->getType() != Type::BoolTy) {
+ C = ConstantExpr::getCast(C, C->getType()->getSignedVersion());
+ return ConstantExpr::getCast(C, Ty);
+ } else {
+ if (C == ConstantBool::True)
+ return ConstantIntegral::getAllOnesValue(Ty);
+ else
+ return ConstantIntegral::getNullValue(Ty);
+ }
}
Constant *ConstantExpr::getZeroExtend(Constant *C, const Type *Ty) {
- assert(C->getType()->isInteger() && Ty->isInteger() &&
+ assert(C->getType()->isIntegral() && Ty->isIntegral() &&
C->getType()->getPrimitiveSize() <= Ty->getPrimitiveSize() &&
"This is an illegal zero extension!");
- C = ConstantExpr::getCast(C, C->getType()->getUnsignedVersion());
+ if (C->getType() != Type::BoolTy)
+ C = ConstantExpr::getCast(C, C->getType()->getUnsignedVersion());
return ConstantExpr::getCast(C, Ty);
}
OpenPOWER on IntegriCloud