[llvm-commits] [llvm] r79158 - in /llvm/trunk/include/llvm/Support: ConstantFolder.h IRBuilder.h
Erick Tryzelaar
idadesub at users.sourceforge.net
Sat Aug 15 19:19:46 PDT 2009
Author: erickt
Date: Sat Aug 15 21:19:46 2009
New Revision: 79158
URL: http://llvm.org/viewvc/llvm-project?rev=79158&view=rev
Log:
Add more casts to the IRBuilder.
Modified:
llvm/trunk/include/llvm/Support/ConstantFolder.h
llvm/trunk/include/llvm/Support/IRBuilder.h
Modified: llvm/trunk/include/llvm/Support/ConstantFolder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ConstantFolder.h?rev=79158&r1=79157&r2=79158&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ConstantFolder.h (original)
+++ llvm/trunk/include/llvm/Support/ConstantFolder.h Sat Aug 15 21:19:46 2009
@@ -142,10 +142,16 @@
const Type *DestTy) const {
return ConstantExpr::getCast(Op, C, DestTy);
}
+ Constant *CreatePointerCast(Constant *C, const Type *DestTy) const {
+ return ConstantExpr::getPointerCast(C, DestTy);
+ }
Constant *CreateIntCast(Constant *C, const Type *DestTy,
bool isSigned) const {
return ConstantExpr::getIntegerCast(C, DestTy, isSigned);
}
+ Constant *CreateFPCast(Constant *C, const Type *DestTy) const {
+ return ConstantExpr::getFPCast(C, DestTy);
+ }
Constant *CreateBitCast(Constant *C, const Type *DestTy) const {
return CreateCast(Instruction::BitCast, C, DestTy);
@@ -156,6 +162,13 @@
Constant *CreatePtrToInt(Constant *C, const Type *DestTy) const {
return CreateCast(Instruction::PtrToInt, C, DestTy);
}
+ Constant *CreateZExtOrBitCast(Constant *C, const Type *DestTy) const {
+ return ConstantExpr::getZExtOrBitCast(C, DestTy);
+ }
+ Constant *CreateSExtOrBitCast(Constant *C, const Type *DestTy) const {
+ return ConstantExpr::getSExtOrBitCast(C, DestTy);
+ }
+
Constant *CreateTruncOrBitCast(Constant *C, const Type *DestTy) const {
return ConstantExpr::getTruncOrBitCast(C, DestTy);
}
Modified: llvm/trunk/include/llvm/Support/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=79158&r1=79157&r2=79158&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/IRBuilder.h Sat Aug 15 21:19:46 2009
@@ -598,7 +598,30 @@
const char *Name = "") {
return CreateCast(Instruction::BitCast, V, DestTy, Name);
}
-
+ Value *CreateZExtOrBitCast(Value *V, const Type *DestTy,
+ const char *Name = "") {
+ if (V->getType() == DestTy)
+ return V;
+ if (Constant *VC = dyn_cast<Constant>(V))
+ return Folder.CreateZExtOrBitCast(VC, DestTy);
+ return Insert(CastInst::CreateZExtOrBitCast(V, DestTy), Name);
+ }
+ Value *CreateSExtOrBitCast(Value *V, const Type *DestTy,
+ const char *Name = "") {
+ if (V->getType() == DestTy)
+ return V;
+ if (Constant *VC = dyn_cast<Constant>(V))
+ return Folder.CreateSExtOrBitCast(VC, DestTy);
+ return Insert(CastInst::CreateSExtOrBitCast(V, DestTy), Name);
+ }
+ Value *CreateTruncOrBitCast(Value *V, const Type *DestTy,
+ const char *Name = "") {
+ if (V->getType() == DestTy)
+ return V;
+ if (Constant *VC = dyn_cast<Constant>(V))
+ return Folder.CreateTruncOrBitCast(VC, DestTy);
+ return Insert(CastInst::CreateTruncOrBitCast(V, DestTy), Name);
+ }
Value *CreateCast(Instruction::CastOps Op, Value *V, const Type *DestTy,
const char *Name = "") {
if (V->getType() == DestTy)
@@ -607,6 +630,14 @@
return Folder.CreateCast(Op, VC, DestTy);
return Insert(CastInst::Create(Op, V, DestTy), Name);
}
+ Value *CreatePointerCast(Value *V, const Type *DestTy,
+ const char *Name = "") {
+ if (V->getType() == DestTy)
+ return V;
+ if (Constant *VC = dyn_cast<Constant>(V))
+ return Folder.CreatePointerCast(VC, DestTy);
+ return Insert(CastInst::CreatePointerCast(V, DestTy), Name);
+ }
Value *CreateIntCast(Value *V, const Type *DestTy, bool isSigned,
const char *Name = "") {
if (V->getType() == DestTy)
@@ -615,6 +646,13 @@
return Folder.CreateIntCast(VC, DestTy, isSigned);
return Insert(CastInst::CreateIntegerCast(V, DestTy, isSigned), Name);
}
+ Value *CreateFPCast(Value *V, const Type *DestTy, const char *Name = "") {
+ if (V->getType() == DestTy)
+ return V;
+ if (Constant *VC = dyn_cast<Constant>(V))
+ return Folder.CreateFPCast(VC, DestTy);
+ return Insert(CastInst::CreateFPCast(V, DestTy), Name);
+ }
//===--------------------------------------------------------------------===//
// Instruction creation methods: Compare Instructions
More information about the llvm-commits
mailing list