From e825bde1255a55d004a4c1f6cadf2ab68c3eef52 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 20 Aug 2002 18:17:12 +0000 Subject: [PATCH] Add new SetCondInst::getInverseCondition() method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3405 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/iOperators.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/VMCore/iOperators.cpp b/lib/VMCore/iOperators.cpp index d243dbc1fa4..ba5aca13012 100644 --- a/lib/VMCore/iOperators.cpp +++ b/lib/VMCore/iOperators.cpp @@ -122,3 +122,19 @@ SetCondInst::SetCondInst(BinaryOps opType, Value *S1, Value *S2, // Make sure it's a valid type... assert(getOpcodeName() != 0); } + +// getInverseCondition - Return the inverse of the current condition opcode. +// For example seteq -> setne, setgt -> setle, setlt -> setge, etc... +// +Instruction::BinaryOps SetCondInst::getInverseCondition() const { + switch (getOpcode()) { + default: + assert(0 && "Unknown setcc opcode!"); + case SetEQ: return SetNE; + case SetNE: return SetEQ; + case SetGT: return SetLE; + case SetLT: return SetGE; + case SetGE: return SetLT; + case SetLE: return SetGT; + } +}