diff options
author | Michael Gottesman <mgottesman@apple.com> | 2013-01-20 03:56:31 +0000 |
---|---|---|
committer | Michael Gottesman <mgottesman@apple.com> | 2013-01-20 03:56:31 +0000 |
commit | 8b289987770bae81752f934fc089c93099864324 (patch) | |
tree | 59c78b1707767bb7fe2903a2606883c029c35c12 /include/llvm/IR | |
parent | fe311dba3ecb5a6b9451bbd56181a3f3b5fb2319 (diff) | |
download | external_llvm-8b289987770bae81752f934fc089c93099864324.zip external_llvm-8b289987770bae81752f934fc089c93099864324.tar.gz external_llvm-8b289987770bae81752f934fc089c93099864324.tar.bz2 |
Added IRBuilder::CreateFPExtOrFPTrunc.
This method serves an analogous purpose to CreateZExtOrTrunc/CreateSExtOrTrunc
but for floating point types.
In detail, it provides a manner when one is handling conversions of floating
point types of automatically selecting fpext, fptrunc, or identity depending on
the relative bitsize of the source and destination types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172957 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/IR')
-rw-r--r-- | include/llvm/IR/IRBuilder.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h index 0b01db2..abd6f90 100644 --- a/include/llvm/IR/IRBuilder.h +++ b/include/llvm/IR/IRBuilder.h @@ -1048,6 +1048,20 @@ public: return CreateTrunc(V, DestTy, Name); return V; } + /// CreateFPExtOrFPTrunc - Create a FPExt or FPTrunc from the float value V to + /// DestTy. Return the value untouched if the type of V is already DestTy. + Value *CreateFPExtOrFPTrunc(Value *V, Type *DestTy, + const Twine &Name = "") { + assert(V->getType()->isFPOrFPVectorTy() && + DestTy->isFPOrFPVectorTy() && + "Can only FPExt/FPTrunc floating point types!"); + Type *Ty = V->getType(); + if (Ty->getScalarSizeInBits() < DestTy->getScalarSizeInBits()) + return CreateFPExt(V, DestTy, Name); + if (Ty->getScalarSizeInBits() > DestTy->getScalarSizeInBits()) + return CreateFPTrunc(V, DestTy, Name); + return V; + } Value *CreateFPToUI(Value *V, Type *DestTy, const Twine &Name = ""){ return CreateCast(Instruction::FPToUI, V, DestTy, Name); } |