[llvm-commits] CVS: llvm/lib/VMCore/Constants.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Apr 4 18:21:21 PDT 2004
Changes in directory llvm/lib/VMCore:
Constants.cpp updated: 1.86 -> 1.87
---
Log message:
Add ConstantExpr::get(Sign|Zero)Extend methods
---
Diffs of the changes: (+16 -0)
Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.86 llvm/lib/VMCore/Constants.cpp:1.87
--- llvm/lib/VMCore/Constants.cpp:1.86 Tue Mar 30 20:56:11 2004
+++ llvm/lib/VMCore/Constants.cpp Sun Apr 4 18:20:30 2004
@@ -1131,6 +1131,22 @@
return ExprConstants.getOrCreate(Ty, Key);
}
+Constant *ConstantExpr::getSignExtend(Constant *C, const Type *Ty) {
+ assert(C->getType()->isInteger() && Ty->isInteger() &&
+ C->getType()->getPrimitiveSize() <= Ty->getPrimitiveSize() &&
+ "This is an illegal sign extension!");
+ C = ConstantExpr::getCast(C, C->getType()->getSignedVersion());
+ return ConstantExpr::getCast(C, Ty);
+}
+
+Constant *ConstantExpr::getZeroExtend(Constant *C, const Type *Ty) {
+ assert(C->getType()->isInteger() && Ty->isInteger() &&
+ C->getType()->getPrimitiveSize() <= Ty->getPrimitiveSize() &&
+ "This is an illegal zero extension!");
+ C = ConstantExpr::getCast(C, C->getType()->getUnsignedVersion());
+ return ConstantExpr::getCast(C, Ty);
+}
+
Constant *ConstantExpr::getTy(const Type *ReqTy, unsigned Opcode,
Constant *C1, Constant *C2) {
if (Opcode == Instruction::Shl || Opcode == Instruction::Shr)
More information about the llvm-commits
mailing list