Added function to determine if an Instruction may trap.
authorTanya Lattner <tonic@nondot.org>
Thu, 31 Jul 2003 04:05:50 +0000 (04:05 +0000)
committerTanya Lattner <tonic@nondot.org>
Thu, 31 Jul 2003 04:05:50 +0000 (04:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7442 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Instruction.h
lib/VMCore/Instruction.cpp

index d09c140e14c5b6b236b99354913b5ebef28e2138..1b85e91cd0b303a1e276ff04c3c83fd071a3ecb6 100644 (file)
@@ -97,7 +97,13 @@ public:
   bool isCommutative() const { return isCommutative(getOpcode()); }
   static bool isCommutative(unsigned op);
 
-
+  /// isTrappingInstruction - Return true if the instruction may trap.
+  ///
+  bool isTrappingInstruction() const {
+    return isTrappingInstruction(getOpcode()); 
+  }
+  static bool isTrappingInstruction(unsigned op);
+  
   virtual void print(std::ostream &OS) const;
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
index ce1423a8631c636f69186e69666aa3d7c6ac732c..a1ccddf4161384f2781eacacf0af2ff7f4c7da70 100644 (file)
@@ -137,3 +137,20 @@ bool Instruction::isCommutative(unsigned op) {
     return false;
   }
 }
+
+
+/// isTrappingInstruction - Return true if the instruction may trap.
+///
+bool Instruction::isTrappingInstruction(unsigned op) {
+  switch(op) {
+  case Div:
+  case Rem:
+  case Load:
+  case Store:
+  case Call:
+  case Invoke:
+    return true;
+  default:
+    return false;
+  }
+}