diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-09-18 04:54:57 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-09-18 04:54:57 +0000 |
| commit | b0b8ddd175bc45960f5ea453b763423f70b1457a (patch) | |
| tree | a82c7ed56263a70ec04dcbe50771deece31a8f77 /llvm/lib/VMCore/Instructions.cpp | |
| parent | 4a13d3b391af602ccb863a38a5d6ed6871a9c861 (diff) | |
| download | bcm5719-llvm-b0b8ddd175bc45960f5ea453b763423f70b1457a.tar.gz bcm5719-llvm-b0b8ddd175bc45960f5ea453b763423f70b1457a.zip | |
add a helper method
llvm-svn: 30452
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
| -rw-r--r-- | llvm/lib/VMCore/Instructions.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index 393858cd871..8f3633a66b5 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -1151,6 +1151,22 @@ bool ShiftInst::isLogicalShift() const { return getOpcode() == Instruction::Shl || getType()->isUnsigned(); } +//===----------------------------------------------------------------------===// +// CastInst Class +//===----------------------------------------------------------------------===// + +/// isTruncIntCast - Return true if this is a truncating integer cast +/// instruction, e.g. a cast from long to uint. +bool CastInst::isTruncIntCast() const { + // The dest type has to be integral, the input has to be integer. + if (!getType()->isIntegral() || !getOperand(0)->getType()->isInteger()) + return false; + + // Has to be large to smaller. + return getOperand(0)->getType()->getPrimitiveSizeInBits() > + getType()->getPrimitiveSizeInBits(); +} + //===----------------------------------------------------------------------===// // SetCondInst Class |

