diff options
author | Chris Lattner <sabre@nondot.org> | 2001-12-13 00:43:03 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-12-13 00:43:03 +0000 |
commit | 9a49b210c1ae2c619ecd969b5ec17a68690928a9 (patch) | |
tree | d14ae9d5cecaa497dcd307278357681517c334a4 /include/llvm/InstrTypes.h | |
parent | 82d18aa0e42a4858c2cb7c15934cc3e567432490 (diff) | |
download | external_llvm-9a49b210c1ae2c619ecd969b5ec17a68690928a9.zip external_llvm-9a49b210c1ae2c619ecd969b5ec17a68690928a9.tar.gz external_llvm-9a49b210c1ae2c619ecd969b5ec17a68690928a9.tar.bz2 |
Swap operands now preserves the semantics of the binary operator by changing
the opcode of the instruction if possible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1444 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/InstrTypes.h')
-rw-r--r-- | include/llvm/InstrTypes.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 54aab32..3d834e9 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -127,10 +127,14 @@ public: virtual const char *getOpcodeName() const = 0; - // swapOperands - Exchange the two operands to this instruction - void swapOperands() { - swap(Operands[0], Operands[1]); - } + // swapOperands - Exchange the two operands to this instruction. + // This instruction is safe to use on any binary instruction and + // does not modify the semantics of the instruction. If the + // instruction is order dependant (SetLT f.e.) the opcode is + // changed. If the instruction cannot be reversed (ie, it's a Div), + // then return true. + // + bool swapOperands(); // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const BinaryOperator *) { return true; } |