diff options
author | Nate Begeman <natebegeman@mac.com> | 2007-11-17 03:58:34 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2007-11-17 03:58:34 +0000 |
commit | b348d18caf834bc26a80e60aa7a2c9b1748734e8 (patch) | |
tree | a2c805de94c3e8f5ffbbeae56cee332a2a5a5695 /lib/VMCore/Constants.cpp | |
parent | 247fdca789b10543848e110ab0860f99724b6788 (diff) | |
download | external_llvm-b348d18caf834bc26a80e60aa7a2c9b1748734e8.zip external_llvm-b348d18caf834bc26a80e60aa7a2c9b1748734e8.tar.gz external_llvm-b348d18caf834bc26a80e60aa7a2c9b1748734e8.tar.bz2 |
Add support for vectors to int <-> float casts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44204 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Constants.cpp')
-rw-r--r-- | lib/VMCore/Constants.cpp | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 74f6287..49c27b8 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -1643,26 +1643,38 @@ Constant *ConstantExpr::getFPExtend(Constant *C, const Type *Ty) { } Constant *ConstantExpr::getUIToFP(Constant *C, const Type *Ty) { - assert(C->getType()->isInteger() && Ty->isFloatingPoint() && - "This is an illegal i32 to floating point cast!"); + bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; + bool toVec = Ty->getTypeID() == Type::VectorTyID; + assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); + assert(C->getType()->isIntOrIntVector() && Ty->isFPOrFPVector() && + "This is an illegal uint to floating point cast!"); return getFoldedCast(Instruction::UIToFP, C, Ty); } Constant *ConstantExpr::getSIToFP(Constant *C, const Type *Ty) { - assert(C->getType()->isInteger() && Ty->isFloatingPoint() && + bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; + bool toVec = Ty->getTypeID() == Type::VectorTyID; + assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); + assert(C->getType()->isIntOrIntVector() && Ty->isFPOrFPVector() && "This is an illegal sint to floating point cast!"); return getFoldedCast(Instruction::SIToFP, C, Ty); } Constant *ConstantExpr::getFPToUI(Constant *C, const Type *Ty) { - assert(C->getType()->isFloatingPoint() && Ty->isInteger() && - "This is an illegal floating point to i32 cast!"); + bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; + bool toVec = Ty->getTypeID() == Type::VectorTyID; + assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); + assert(C->getType()->isFPOrFPVector() && Ty->isIntOrIntVector() && + "This is an illegal floating point to uint cast!"); return getFoldedCast(Instruction::FPToUI, C, Ty); } Constant *ConstantExpr::getFPToSI(Constant *C, const Type *Ty) { - assert(C->getType()->isFloatingPoint() && Ty->isInteger() && - "This is an illegal floating point to i32 cast!"); + bool fromVec = C->getType()->getTypeID() == Type::VectorTyID; + bool toVec = Ty->getTypeID() == Type::VectorTyID; + assert((fromVec == toVec) && "Cannot convert from scalar to/from vector"); + assert(C->getType()->isFPOrFPVector() && Ty->isIntOrIntVector() && + "This is an illegal floating point to sint cast!"); return getFoldedCast(Instruction::FPToSI, C, Ty); } |