Add ShiftInst::isLogical/ArithmeticShift methods.
authorChris Lattner <sabre@nondot.org>
Sun, 17 Sep 2006 19:29:56 +0000 (19:29 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 17 Sep 2006 19:29:56 +0000 (19:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30445 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/InstrTypes.h
include/llvm/Instructions.h
lib/VMCore/Instructions.cpp

index 095adcb3da4b85c2e9a796a424a2f185faaea82f..7ce430073113cec0c31867322a0ccde33a7462ec 100644 (file)
@@ -207,16 +207,16 @@ public:
 
   /// isNeg, isNot - Check if the given Value is a NEG or NOT instruction.
   ///
-  static bool            isNeg(const Value *V);
-  static bool            isNot(const Value *V);
+  static bool isNeg(const Value *V);
+  static bool isNot(const Value *V);
 
   /// getNegArgument, getNotArgument - Helper functions to extract the
   ///     unary argument of a NEG or NOT operation implemented via Sub or Xor.
   ///
-  static const Value*    getNegArgument(const Value *BinOp);
-  static       Value*    getNegArgument(      Value *BinOp);
-  static const Value*    getNotArgument(const Value *BinOp);
-  static       Value*    getNotArgument(      Value *BinOp);
+  static const Value *getNegArgument(const Value *BinOp);
+  static       Value *getNegArgument(      Value *BinOp);
+  static const Value *getNotArgument(const Value *BinOp);
+  static       Value *getNotArgument(      Value *BinOp);
 
   BinaryOps getOpcode() const {
     return static_cast<BinaryOps>(Instruction::getOpcode());
index ed407acfb76ee21c626d495e15fd67f516a5cc87..d7e52d1d6aa021fe61d413531d44c273864ae042 100644 (file)
@@ -16,7 +16,6 @@
 #ifndef LLVM_INSTRUCTIONS_H
 #define LLVM_INSTRUCTIONS_H
 
-#include "llvm/Instruction.h"
 #include "llvm/InstrTypes.h"
 
 namespace llvm {
@@ -633,6 +632,17 @@ public:
   }
   unsigned getNumOperands() const { return 2; }
 
+  /// isLogicalShift - Return true if this is a logical shift left or a logical
+  /// shift right.
+  bool isLogicalShift() const;
+  
+  /// isArithmeticShift - Return true if this is a sign-extending shift right
+  /// operation.
+  bool isArithmeticShift() const {
+    return !isLogicalShift();
+  }
+  
+  
   virtual ShiftInst *clone() const;
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
index c6730e14c5c098750ebdb113503337606f4ffe12..393858cd8716e4381426affc8ef0afe3c22530c1 100644 (file)
@@ -1141,6 +1141,17 @@ bool BinaryOperator::swapOperands() {
 }
 
 
+//===----------------------------------------------------------------------===//
+//                               ShiftInst Class
+//===----------------------------------------------------------------------===//
+
+/// isLogicalShift - Return true if this is a logical shift left or a logical
+/// shift right.
+bool ShiftInst::isLogicalShift() const {
+  return getOpcode() == Instruction::Shl || getType()->isUnsigned();
+}
+
+
 //===----------------------------------------------------------------------===//
 //                             SetCondInst Class
 //===----------------------------------------------------------------------===//