From e18700a09ac14dc957684472244a2681b536a118 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 26 Oct 2009 18:36:40 +0000 Subject: [PATCH] Add CreateZExtOrBitCast and CreateSExtOrBitCast to TargetFolder for consistency with ConstantFolder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85137 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/TargetFolder.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/llvm/Support/TargetFolder.h b/include/llvm/Support/TargetFolder.h index 8e28632b7eb..46ad9b601f7 100644 --- a/include/llvm/Support/TargetFolder.h +++ b/include/llvm/Support/TargetFolder.h @@ -179,6 +179,16 @@ public: Constant *CreatePtrToInt(Constant *C, const Type *DestTy) const { return CreateCast(Instruction::PtrToInt, C, DestTy); } + Constant *CreateZExtOrBitCast(Constant *C, const Type *DestTy) const { + if (C->getType() == DestTy) + return C; // avoid calling Fold + return Fold(ConstantExpr::getZExtOrBitCast(C, DestTy)); + } + Constant *CreateSExtOrBitCast(Constant *C, const Type *DestTy) const { + if (C->getType() == DestTy) + return C; // avoid calling Fold + return Fold(ConstantExpr::getSExtOrBitCast(C, DestTy)); + } Constant *CreateTruncOrBitCast(Constant *C, const Type *DestTy) const { if (C->getType() == DestTy) return C; // avoid calling Fold