From: Tanya Lattner Date: Thu, 31 Jul 2003 04:05:50 +0000 (+0000) Subject: Added function to determine if an Instruction may trap. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=741bb0019de9aa28a731b4eef2422a3397f99cd0;p=oota-llvm.git Added function to determine if an Instruction may trap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7442 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index d09c140e14c..1b85e91cd0b 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -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: diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index ce1423a8631..a1ccddf4161 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -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; + } +}