rearrange some code, simplify handling of shifts.
[oota-llvm.git] / lib / VMCore / Instruction.cpp
index feff59dff9f12483e9a8285b83d843260cbdd29f..6f09c907083831999419926d97aa3a568589c4c1 100644 (file)
@@ -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.
 //
 //===----------------------------------------------------------------------===//
 //
@@ -13,8 +13,8 @@
 
 #include "llvm/Type.h"
 #include "llvm/Instructions.h"
-#include "llvm/IntrinsicInst.h"
 #include "llvm/Function.h"
+#include "llvm/Support/CallSite.h"
 #include "llvm/Support/LeakDetector.h"
 using namespace llvm;
 
@@ -138,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 "<Invalid operator> ";
   }
@@ -203,17 +204,12 @@ bool Instruction::mayWriteToMemory() const {
   switch (getOpcode()) {
   default: return false;
   case Instruction::Free:
-  case Instruction::Store:
   case Instruction::Invoke:
+  case Instruction::Store:
   case Instruction::VAArg:
     return true;
   case Instruction::Call:
-    //if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(this)) {
-      // If the intrinsic doesn't write memory, it is safe.
-      // FIXME: this is obviously supposed to determine which  intrinsics 
-      // don't write to memory, but hasn't been implemented yet.
-    //}
-    return true;
+    return !cast<CallInst>(this)->onlyReadsMemory();
   case Instruction::Load:
     return cast<LoadInst>(this)->isVolatile();
   }
@@ -270,6 +266,7 @@ bool Instruction::isTrapping(unsigned op) {
   case Store:
   case Call:
   case Invoke:
+  case VAArg:
     return true;
   default:
     return false;