diff options
author | Chris Lattner <sabre@nondot.org> | 2004-11-30 02:51:53 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-11-30 02:51:53 +0000 |
commit | 38f14553939e574becab6ea1e0b055d31293b0cf (patch) | |
tree | f5791ecabae032bdf4e8aa26b02ffdae43c8f732 /lib/VMCore | |
parent | 8cca1a7cbc1b1d0d1975f6cc607d2bcf6e327530 (diff) | |
download | external_llvm-38f14553939e574becab6ea1e0b055d31293b0cf.zip external_llvm-38f14553939e574becab6ea1e0b055d31293b0cf.tar.gz external_llvm-38f14553939e574becab6ea1e0b055d31293b0cf.tar.bz2 |
Add method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18368 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Instruction.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index 17970ac..696b12e 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -11,14 +11,14 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Instructions.h" #include "llvm/Function.h" #include "llvm/SymbolTable.h" #include "llvm/Type.h" #include "llvm/Support/LeakDetector.h" using namespace llvm; -void Instruction::init() -{ +void Instruction::init() { // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); } @@ -134,6 +134,31 @@ const char *Instruction::getOpcodeName(unsigned OpCode) { return 0; } +/// isIdenticalTo - Return true if the specified instruction is exactly +/// identical to the current one. This means that all operands match and any +/// extra information (e.g. load is volatile) agree. +bool Instruction::isIdenticalTo(Instruction *I) const { + if (getOpcode() != I->getOpcode() || + getNumOperands() != I->getNumOperands() || + getType() != I->getType()) + return false; + + // We have two instructions of identical opcode and #operands. Check to see + // if all operands are the same. + for (unsigned i = 0, e = getNumOperands(); i != e; ++i) + if (getOperand(i) != I->getOperand(i)) + return false; + + // Check special state that is a part of some instructions. + if (const LoadInst *LI = dyn_cast<LoadInst>(this)) + return LI->isVolatile() == cast<LoadInst>(I)->isVolatile(); + if (const StoreInst *SI = dyn_cast<StoreInst>(this)) + return SI->isVolatile() == cast<StoreInst>(I)->isVolatile(); + if (const VANextInst *VAN = dyn_cast<VANextInst>(this)) + return VAN->getArgType() == cast<VANextInst>(I)->getArgType(); + return true; +} + /// isAssociative - Return true if the instruction is associative: /// |