X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FInstruction.cpp;h=5107b74417a549afffc88446b30971db7622a386;hb=e6be34a53ecbe8c2ff9f0793b13d847e94c0de91;hp=39a895510ae27b4c2810127a54fca6c2d0c499e7;hpb=f00042a9990d90885a8f236ed0f6bf07902d1374;p=oota-llvm.git diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index 39a895510ae..5107b74417a 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -14,11 +14,12 @@ #include "llvm/Type.h" #include "llvm/Instructions.h" #include "llvm/Function.h" +#include "llvm/Support/CallSite.h" #include "llvm/Support/LeakDetector.h" using namespace llvm; Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, - const std::string &Name, Instruction *InsertBefore) + Instruction *InsertBefore) : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); @@ -29,11 +30,10 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, "Instruction to insert before is not in a basic block!"); InsertBefore->getParent()->getInstList().insert(InsertBefore, this); } - setName(Name); } Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, - const std::string &Name, BasicBlock *InsertAtEnd) + BasicBlock *InsertAtEnd) : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); @@ -41,34 +41,6 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, // append this instruction into the basic block assert(InsertAtEnd && "Basic block to append to may not be NULL!"); InsertAtEnd->getInstList().push_back(this); - setName(Name); -} - -Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, - const char *Name, Instruction *InsertBefore) - : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { - // Make sure that we get added to a basicblock - LeakDetector::addGarbageObject(this); - - // If requested, insert this instruction into a basic block... - if (InsertBefore) { - assert(InsertBefore->getParent() && - "Instruction to insert before is not in a basic block!"); - InsertBefore->getParent()->getInstList().insert(InsertBefore, this); - } - if (Name && *Name) setName(Name); -} - -Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, - const char *Name, BasicBlock *InsertAtEnd) - : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { - // Make sure that we get added to a basicblock - LeakDetector::addGarbageObject(this); - - // append this instruction into the basic block - assert(InsertAtEnd && "Basic block to append to may not be NULL!"); - InsertAtEnd->getInstList().push_back(this); - if (Name && *Name) setName(Name); } @@ -166,6 +138,7 @@ const char *Instruction::getOpcodeName(unsigned OpCode) { case ExtractElement: return "extractelement"; case InsertElement: return "insertelement"; case ShuffleVector: return "shufflevector"; + case GetResult: return "getresult"; default: return " "; } @@ -225,6 +198,22 @@ bool Instruction::isSameOperationAs(Instruction *I) const { return true; } +/// mayWriteToMemory - Return true if this instruction may modify memory. +/// +bool Instruction::mayWriteToMemory() const { + switch (getOpcode()) { + default: return false; + case Instruction::Free: + case Instruction::Invoke: + case Instruction::Store: + case Instruction::VAArg: + return true; + case Instruction::Call: + return !cast(this)->onlyReadsMemory(); + case Instruction::Load: + return cast(this)->isVolatile(); + } +} /// isAssociative - Return true if the instruction is associative: ///