[llvm-commits] [llvm] r172967 - /llvm/trunk/include/llvm/IR/IRBuilder.h
Michael Gottesman
mgottesman at apple.com
Sat Jan 19 23:33:27 PST 2013
Author: mgottesman
Date: Sun Jan 20 01:33:26 2013
New Revision: 172967
URL: http://llvm.org/viewvc/llvm-project?rev=172967&view=rev
Log:
Changed IRBuilder::CreateZExtOrTrunc and IRBuilder::CreateSExtOrTrunc so they also work with vectors.
I also changed the name of a variable in IRBuilder::CreateFPExtOrFPTrunc to
match the names used in its two matching brethern as well.
Modified:
llvm/trunk/include/llvm/IR/IRBuilder.h
Modified: llvm/trunk/include/llvm/IR/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/IRBuilder.h?rev=172967&r1=172966&r2=172967&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/IR/IRBuilder.h Sun Jan 20 01:33:26 2013
@@ -1031,27 +1031,29 @@
}
/// \brief Create a ZExt or Trunc from the integer value V to DestTy. Return
/// the value untouched if the type of V is already DestTy.
- Value *CreateZExtOrTrunc(Value *V, IntegerType *DestTy,
+ Value *CreateZExtOrTrunc(Value *V, Type *DestTy,
const Twine &Name = "") {
- assert(isa<IntegerType>(V->getType()) &&
+ assert(V->getType()->isIntOrIntVectorTy() &&
+ DestTy->isIntOrIntVectorTy() &&
"Can only zero extend/truncate integers!");
- IntegerType *IntTy = cast<IntegerType>(V->getType());
- if (IntTy->getBitWidth() < DestTy->getBitWidth())
+ Type *VTy = V->getType();
+ if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
return CreateZExt(V, DestTy, Name);
- if (IntTy->getBitWidth() > DestTy->getBitWidth())
+ if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
return CreateTrunc(V, DestTy, Name);
return V;
}
/// \brief Create a SExt or Trunc from the integer value V to DestTy. Return
/// the value untouched if the type of V is already DestTy.
- Value *CreateSExtOrTrunc(Value *V, IntegerType *DestTy,
+ Value *CreateSExtOrTrunc(Value *V, Type *DestTy,
const Twine &Name = "") {
- assert(isa<IntegerType>(V->getType()) &&
+ assert(V->getType()->isIntOrIntVectorTy() &&
+ DestTy->isIntOrIntVectorTy() &&
"Can only sign extend/truncate integers!");
- IntegerType *IntTy = cast<IntegerType>(V->getType());
- if (IntTy->getBitWidth() < DestTy->getBitWidth())
+ Type *VTy = V->getType();
+ if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
return CreateSExt(V, DestTy, Name);
- if (IntTy->getBitWidth() > DestTy->getBitWidth())
+ if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
return CreateTrunc(V, DestTy, Name);
return V;
}
@@ -1062,10 +1064,10 @@
assert(V->getType()->isFPOrFPVectorTy() &&
DestTy->isFPOrFPVectorTy() &&
"Can only FPExt/FPTrunc floating point types!");
- Type *Ty = V->getType();
- if (Ty->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
+ Type *VTy = V->getType();
+ if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
return CreateFPExt(V, DestTy, Name);
- if (Ty->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
+ if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
return CreateFPTrunc(V, DestTy, Name);
return V;
}
More information about the llvm-commits
mailing list