mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-25 17:20:48 +00:00
Split the logic behind CastInst::isNoopCast into a separate static function,
as is done with most other cast opcode predicates. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105008 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -625,6 +625,14 @@ public:
|
|||||||
/// platform. Generally, the result of TargetData::getIntPtrType() should be
|
/// platform. Generally, the result of TargetData::getIntPtrType() should be
|
||||||
/// passed in. If that's not available, use Type::Int64Ty, which will make
|
/// passed in. If that's not available, use Type::Int64Ty, which will make
|
||||||
/// the isNoopCast call conservative.
|
/// the isNoopCast call conservative.
|
||||||
|
/// @brief Determine if the described cast is a no-op cast.
|
||||||
|
static bool isNoopCast(
|
||||||
|
Instruction::CastOps Opcode, ///< Opcode of cast
|
||||||
|
const Type *SrcTy, ///< SrcTy of cast
|
||||||
|
const Type *DstTy, ///< DstTy of cast
|
||||||
|
const Type *IntPtrTy ///< Integer type corresponding to Ptr types, or null
|
||||||
|
);
|
||||||
|
|
||||||
/// @brief Determine if this cast is a no-op cast.
|
/// @brief Determine if this cast is a no-op cast.
|
||||||
bool isNoopCast(
|
bool isNoopCast(
|
||||||
const Type *IntPtrTy ///< Integer type corresponding to pointer
|
const Type *IntPtrTy ///< Integer type corresponding to pointer
|
||||||
|
@@ -1911,9 +1911,12 @@ bool CastInst::isLosslessCast() const {
|
|||||||
/// # bitcast i32* %x to i8*
|
/// # bitcast i32* %x to i8*
|
||||||
/// # bitcast <2 x i32> %x to <4 x i16>
|
/// # bitcast <2 x i32> %x to <4 x i16>
|
||||||
/// # ptrtoint i32* %x to i32 ; on 32-bit plaforms only
|
/// # ptrtoint i32* %x to i32 ; on 32-bit plaforms only
|
||||||
/// @brief Determine if a cast is a no-op.
|
/// @brief Determine if the described cast is a no-op.
|
||||||
bool CastInst::isNoopCast(const Type *IntPtrTy) const {
|
bool CastInst::isNoopCast(Instruction::CastOps Opcode,
|
||||||
switch (getOpcode()) {
|
const Type *SrcTy,
|
||||||
|
const Type *DestTy,
|
||||||
|
const Type *IntPtrTy) {
|
||||||
|
switch (Opcode) {
|
||||||
default:
|
default:
|
||||||
assert(!"Invalid CastOp");
|
assert(!"Invalid CastOp");
|
||||||
case Instruction::Trunc:
|
case Instruction::Trunc:
|
||||||
@@ -1930,13 +1933,18 @@ bool CastInst::isNoopCast(const Type *IntPtrTy) const {
|
|||||||
return true; // BitCast never modifies bits.
|
return true; // BitCast never modifies bits.
|
||||||
case Instruction::PtrToInt:
|
case Instruction::PtrToInt:
|
||||||
return IntPtrTy->getScalarSizeInBits() ==
|
return IntPtrTy->getScalarSizeInBits() ==
|
||||||
getType()->getScalarSizeInBits();
|
DestTy->getScalarSizeInBits();
|
||||||
case Instruction::IntToPtr:
|
case Instruction::IntToPtr:
|
||||||
return IntPtrTy->getScalarSizeInBits() ==
|
return IntPtrTy->getScalarSizeInBits() ==
|
||||||
getOperand(0)->getType()->getScalarSizeInBits();
|
SrcTy->getScalarSizeInBits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Determine if a cast is a no-op.
|
||||||
|
bool CastInst::isNoopCast(const Type *IntPtrTy) const {
|
||||||
|
return isNoopCast(getOpcode(), getOperand(0)->getType(), getType(), IntPtrTy);
|
||||||
|
}
|
||||||
|
|
||||||
/// This function determines if a pair of casts can be eliminated and what
|
/// This function determines if a pair of casts can be eliminated and what
|
||||||
/// opcode should be used in the elimination. This assumes that there are two
|
/// opcode should be used in the elimination. This assumes that there are two
|
||||||
/// instructions like this:
|
/// instructions like this:
|
||||||
|
Reference in New Issue
Block a user