[llvm-commits] CVS: llvm/lib/VMCore/Instructions.cpp

Chris Lattner sabre at nondot.org
Sun Sep 17 21:55:13 PDT 2006



Changes in directory llvm/lib/VMCore:

Instructions.cpp updated: 1.40 -> 1.41
---
Log message:

add a helper method


---
Diffs of the changes:  (+16 -0)

 Instructions.cpp |   16 ++++++++++++++++
 1 files changed, 16 insertions(+)


Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.40 llvm/lib/VMCore/Instructions.cpp:1.41
--- llvm/lib/VMCore/Instructions.cpp:1.40	Sun Sep 17 14:29:56 2006
+++ llvm/lib/VMCore/Instructions.cpp	Sun Sep 17 23:54:57 2006
@@ -1151,6 +1151,22 @@
   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






More information about the llvm-commits mailing list