[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Jan 1 08:00:09 PST 2005
Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.118 -> 1.119
---
Log message:
Allow getZeroExtend and getSignExtend to work with boolean inputs.
---
Diffs of the changes: (+13 -5)
Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.118 llvm/lib/VMCore/Constants.cpp:1.119
--- llvm/lib/VMCore/Constants.cpp:1.118 Mon Dec 13 13:48:51 2004
+++ llvm/lib/VMCore/Constants.cpp Sat Jan 1 09:59:57 2005
@@ -1239,18 +1239,26 @@
}
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);
}
More information about the llvm-commits
mailing list