diff options
author | Chris Lattner <sabre@nondot.org> | 2006-09-17 19:29:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-09-17 19:29:56 +0000 |
commit | 2f463865c2f03b8835e35d3499fcd95eed922bc6 (patch) | |
tree | 2ca93b6d504bd0d1dc7084c66310549314824962 | |
parent | a5b07404f79036727ba47624050040defe59a5fa (diff) | |
download | external_llvm-2f463865c2f03b8835e35d3499fcd95eed922bc6.zip external_llvm-2f463865c2f03b8835e35d3499fcd95eed922bc6.tar.gz external_llvm-2f463865c2f03b8835e35d3499fcd95eed922bc6.tar.bz2 |
Add ShiftInst::isLogical/ArithmeticShift methods.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30445 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/InstrTypes.h | 12 | ||||
-rw-r--r-- | include/llvm/Instructions.h | 12 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 11 |
3 files changed, 28 insertions, 7 deletions
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 095adcb..7ce4300 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -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()); diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index ed407ac..d7e52d1 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -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: diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index c6730e1..393858c 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -1142,6 +1142,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 //===----------------------------------------------------------------------===// |