Skip to content

Commit

Permalink
Added function to determine if an Instruction may trap.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7442 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
tlattner committed Jul 31, 2003
1 parent 0ad1361 commit 741bb00
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 7 additions & 1 deletion include/llvm/Instruction.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,13 @@ class Instruction : public User {
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:
Expand Down
17 changes: 17 additions & 0 deletions lib/VMCore/Instruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit 741bb00

Please sign in to comment.