X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FInstruction.cpp;h=5107b74417a549afffc88446b30971db7622a386;hb=95cb2ad919043d8ec5dbcc36cd59ac7d9a46999f;hp=2891269979122de4eb091a1eb4fb8a85d6a5a073;hpb=e4d87aa2de6e52952dca73716386db09aad5a8fd;p=oota-llvm.git diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index 28912699791..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,13 +14,13 @@ #include "llvm/Type.h" #include "llvm/Instructions.h" #include "llvm/Function.h" -#include "llvm/SymbolTable.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) - : User(ty, Value::InstructionVal + it, Ops, NumOps, Name), Parent(0) { + Instruction *InsertBefore) + : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); @@ -33,8 +33,8 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, } Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, - const std::string &Name, BasicBlock *InsertAtEnd) - : User(ty, Value::InstructionVal + it, Ops, NumOps, Name), Parent(0) { + BasicBlock *InsertAtEnd) + : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) { // Make sure that we get added to a basicblock LeakDetector::addGarbageObject(this); @@ -43,16 +43,13 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps, InsertAtEnd->getInstList().push_back(this); } + // Out of line virtual method, so the vtable, etc has a home. Instruction::~Instruction() { assert(Parent == 0 && "Instruction still linked in the program!"); } -void Instruction::setOpcode(unsigned opc) { - setValueType(Value::InstructionVal + opc); -} - void Instruction::setParent(BasicBlock *P) { if (getParent()) { if (!P) LeakDetector::addGarbageObject(this); @@ -141,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 " "; } @@ -200,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: ///