mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-02 19:24:25 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172967 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1031,27 +1031,29 @@ public:
|
|||||||
}
|
}
|
||||||
/// \brief Create a ZExt or Trunc from the integer value V to DestTy. Return
|
/// \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.
|
/// 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 = "") {
|
const Twine &Name = "") {
|
||||||
assert(isa<IntegerType>(V->getType()) &&
|
assert(V->getType()->isIntOrIntVectorTy() &&
|
||||||
|
DestTy->isIntOrIntVectorTy() &&
|
||||||
"Can only zero extend/truncate integers!");
|
"Can only zero extend/truncate integers!");
|
||||||
IntegerType *IntTy = cast<IntegerType>(V->getType());
|
Type *VTy = V->getType();
|
||||||
if (IntTy->getBitWidth() < DestTy->getBitWidth())
|
if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
|
||||||
return CreateZExt(V, DestTy, Name);
|
return CreateZExt(V, DestTy, Name);
|
||||||
if (IntTy->getBitWidth() > DestTy->getBitWidth())
|
if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
|
||||||
return CreateTrunc(V, DestTy, Name);
|
return CreateTrunc(V, DestTy, Name);
|
||||||
return V;
|
return V;
|
||||||
}
|
}
|
||||||
/// \brief Create a SExt or Trunc from the integer value V to DestTy. Return
|
/// \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.
|
/// 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 = "") {
|
const Twine &Name = "") {
|
||||||
assert(isa<IntegerType>(V->getType()) &&
|
assert(V->getType()->isIntOrIntVectorTy() &&
|
||||||
|
DestTy->isIntOrIntVectorTy() &&
|
||||||
"Can only sign extend/truncate integers!");
|
"Can only sign extend/truncate integers!");
|
||||||
IntegerType *IntTy = cast<IntegerType>(V->getType());
|
Type *VTy = V->getType();
|
||||||
if (IntTy->getBitWidth() < DestTy->getBitWidth())
|
if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
|
||||||
return CreateSExt(V, DestTy, Name);
|
return CreateSExt(V, DestTy, Name);
|
||||||
if (IntTy->getBitWidth() > DestTy->getBitWidth())
|
if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
|
||||||
return CreateTrunc(V, DestTy, Name);
|
return CreateTrunc(V, DestTy, Name);
|
||||||
return V;
|
return V;
|
||||||
}
|
}
|
||||||
@ -1062,10 +1064,10 @@ public:
|
|||||||
assert(V->getType()->isFPOrFPVectorTy() &&
|
assert(V->getType()->isFPOrFPVectorTy() &&
|
||||||
DestTy->isFPOrFPVectorTy() &&
|
DestTy->isFPOrFPVectorTy() &&
|
||||||
"Can only FPExt/FPTrunc floating point types!");
|
"Can only FPExt/FPTrunc floating point types!");
|
||||||
Type *Ty = V->getType();
|
Type *VTy = V->getType();
|
||||||
if (Ty->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
|
if (VTy->getScalarSizeInBits() < DestTy->getScalarSizeInBits())
|
||||||
return CreateFPExt(V, DestTy, Name);
|
return CreateFPExt(V, DestTy, Name);
|
||||||
if (Ty->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
|
if (VTy->getScalarSizeInBits() > DestTy->getScalarSizeInBits())
|
||||||
return CreateFPTrunc(V, DestTy, Name);
|
return CreateFPTrunc(V, DestTy, Name);
|
||||||
return V;
|
return V;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user