[llvm-commits] CVS: llvm/include/llvm/Instruction.h

Chris Lattner lattner at cs.uiuc.edu
Wed Oct 30 22:15:01 PST 2002


Changes in directory llvm/include/llvm:

Instruction.h updated: 1.35 -> 1.36

---
Log message:

New isAssociative/isCommutative inspection methods, graciously contributed by 
Casey Carter.



---
Diffs of the changes:

Index: llvm/include/llvm/Instruction.h
diff -u llvm/include/llvm/Instruction.h:1.35 llvm/include/llvm/Instruction.h:1.36
--- llvm/include/llvm/Instruction.h:1.35	Sun Oct 13 14:39:07 2002
+++ llvm/include/llvm/Instruction.h	Wed Oct 30 22:13:59 2002
@@ -74,6 +74,27 @@
     return iType >= BinaryOpsBegin && iType < BinaryOpsEnd;
   }
 
+  /// isAssociative - Return true if the instruction is associative:
+  ///
+  ///   Associative operators satisfy:  x op (y op z) === (x op y) op z)
+  ///
+  /// In LLVM, the Add, Mul, And, Or, and Xor operators are associative, when
+  /// not applied to floating point types.
+  ///
+  bool isAssociative() const { return isAssociative(getOpcode(), getType()); }
+  static bool isAssociative(unsigned op, const Type *Ty);
+
+  /// isCommutative - Return true if the instruction is commutative:
+  ///
+  ///   Commutative operators satistify: (x op y) === (y op x)
+  ///
+  /// In LLVM, these are the associative operators, plus SetEQ and SetNE, when
+  /// applied to any type.
+  ///
+  bool isCommutative() const { return isCommutative(getOpcode()); }
+  static bool isCommutative(unsigned op);
+
+
   virtual void print(std::ostream &OS) const;
 
   /// Methods for support type inquiry through isa, cast, and dyn_cast:





More information about the llvm-commits mailing list