[Mlir-commits] [mlir] 6984623 - [MLIR] expose applyCmpPredicate

Stephen Neuendorffer llvmlistbot at llvm.org
Tue Jun 9 22:25:53 PDT 2020


Author: Stephen Neuendorffer
Date: 2020-06-09T22:25:03-07:00
New Revision: 698462336abbeb2b02b80305e135baba2385b842

URL: https://github.com/llvm/llvm-project/commit/698462336abbeb2b02b80305e135baba2385b842
DIFF: https://github.com/llvm/llvm-project/commit/698462336abbeb2b02b80305e135baba2385b842.diff

LOG: [MLIR] expose applyCmpPredicate

This is useful for manipulating the standard dialect from transformations
outside of the standard dialect.

Differential Revision: https://reviews.llvm.org/D80609

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
    mlir/lib/Dialect/StandardOps/IR/Ops.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
index 0ffc176664a7..8005ecbbdc49 100644
--- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
+++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h
@@ -339,6 +339,16 @@ raw_ostream &operator<<(raw_ostream &os, SubViewOp::Range &range);
 ///   consumer %0 ... : memref<?x16xf32, affine_map<(i, j)->(16 * i + j)>>
 /// ```
 bool canFoldIntoConsumerOp(MemRefCastOp castOp);
+
+/// Compute `lhs` `pred` `rhs`, where `pred` is one of the known integer
+/// comparison predicates.
+bool applyCmpPredicate(CmpIPredicate predicate, const APInt &lhs,
+                       const APInt &rhs);
+
+/// Compute `lhs` `pred` `rhs`, where `pred` is one of the known floating point
+/// comparison predicates.
+bool applyCmpPredicate(CmpFPredicate predicate, const APFloat &lhs,
+                       const APFloat &rhs);
 } // end namespace mlir
 
 #endif // MLIR_DIALECT_IR_STANDARDOPS_IR_OPS_H

diff  --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
index 4f72996c910e..2738c2aefce4 100644
--- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -784,8 +784,8 @@ static void buildCmpIOp(OpBuilder &build, OperationState &result,
 
 // Compute `lhs` `pred` `rhs`, where `pred` is one of the known integer
 // comparison predicates.
-static bool applyCmpPredicate(CmpIPredicate predicate, const APInt &lhs,
-                              const APInt &rhs) {
+bool mlir::applyCmpPredicate(CmpIPredicate predicate, const APInt &lhs,
+                             const APInt &rhs) {
   switch (predicate) {
   case CmpIPredicate::eq:
     return lhs.eq(rhs);
@@ -838,8 +838,8 @@ static void buildCmpFOp(OpBuilder &build, OperationState &result,
 
 /// Compute `lhs` `pred` `rhs`, where `pred` is one of the known floating point
 /// comparison predicates.
-static bool applyCmpPredicate(CmpFPredicate predicate, const APFloat &lhs,
-                              const APFloat &rhs) {
+bool mlir::applyCmpPredicate(CmpFPredicate predicate, const APFloat &lhs,
+                             const APFloat &rhs) {
   auto cmpResult = lhs.compare(rhs);
   switch (predicate) {
   case CmpFPredicate::AlwaysFalse:


        


More information about the Mlir-commits mailing list