diff options
| author | Chris Lattner <sabre@nondot.org> | 2004-04-04 23:20:30 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2004-04-04 23:20:30 +0000 |
| commit | dd2847461034684b8eed3b3449cfa174ecfff961 (patch) | |
| tree | a5df2e5e754b70323b29910bb1ce1feabfcb76c2 /llvm/lib | |
| parent | dfcf8e34cf71f8262981ce113afa451a8e684d91 (diff) | |
| download | bcm5719-llvm-dd2847461034684b8eed3b3449cfa174ecfff961.tar.gz bcm5719-llvm-dd2847461034684b8eed3b3449cfa174ecfff961.zip | |
Add ConstantExpr::get(Sign|Zero)Extend methods
llvm-svn: 12648
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/VMCore/Constants.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index 6c6557dccde..3ed70089c1a 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/lib/VMCore/Constants.cpp @@ -1131,6 +1131,22 @@ Constant *ConstantExpr::getCast(Constant *C, const Type *Ty) { 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) |

