[llvm-branch-commits] [mlir] 73ad0bb - [NFC][mlir] Adding more operators to EDSC TemplatedIndexedValue

Kern Handa via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jun 8 04:08:32 PDT 2021


Author: Kern Handa
Date: 2020-02-16T12:24:23-08:00
New Revision: 73ad0bbe52880a03e0112e00bf810f15998346c4

URL: https://github.com/llvm/llvm-project/commit/73ad0bbe52880a03e0112e00bf810f15998346c4
DIFF: https://github.com/llvm/llvm-project/commit/73ad0bbe52880a03e0112e00bf810f15998346c4.diff

LOG: [NFC][mlir] Adding more operators to EDSC TemplatedIndexedValue

This change adds some missing arithmetic and logical operators to `TemplatedIndexedValue` for EDSC usage.

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/AffineOps/EDSC/Builders.h
    mlir/include/mlir/EDSC/Builders.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/AffineOps/EDSC/Builders.h b/mlir/include/mlir/Dialect/AffineOps/EDSC/Builders.h
index c20c8d72ae963..30bd4f78f89fa 100644
--- a/mlir/include/mlir/Dialect/AffineOps/EDSC/Builders.h
+++ b/mlir/include/mlir/Dialect/AffineOps/EDSC/Builders.h
@@ -113,6 +113,16 @@ ValueHandle TemplatedIndexedValue<Load, Store>::operator/(ValueHandle e) {
   using op::operator/;
   return static_cast<ValueHandle>(*this) / e;
 }
+template <typename Load, typename Store>
+ValueHandle TemplatedIndexedValue<Load, Store>::operator%(ValueHandle e) {
+  using op::operator%;
+  return static_cast<ValueHandle>(*this) % e;
+}
+template <typename Load, typename Store>
+ValueHandle TemplatedIndexedValue<Load, Store>::operator^(ValueHandle e) {
+  using op::operator^;
+  return static_cast<ValueHandle>(*this) ^ e;
+}
 
 template <typename Load, typename Store>
 OperationHandle TemplatedIndexedValue<Load, Store>::operator+=(ValueHandle e) {
@@ -134,6 +144,58 @@ OperationHandle TemplatedIndexedValue<Load, Store>::operator/=(ValueHandle e) {
   using op::operator/;
   return Store(*this / e, getBase(), {indices.begin(), indices.end()});
 }
+template <typename Load, typename Store>
+OperationHandle TemplatedIndexedValue<Load, Store>::operator%=(ValueHandle e) {
+  using op::operator%;
+  return Store(*this % e, getBase(), {indices.begin(), indices.end()});
+}
+template <typename Load, typename Store>
+OperationHandle TemplatedIndexedValue<Load, Store>::operator^=(ValueHandle e) {
+  using op::operator^;
+  return Store(*this ^ e, getBase(), {indices.begin(), indices.end()});
+}
+
+template <typename Load, typename Store>
+ValueHandle TemplatedIndexedValue<Load, Store>::operator&&(ValueHandle e) {
+  using op::operator&&;
+  return static_cast<ValueHandle>(*this) && e;
+}
+template <typename Load, typename Store>
+ValueHandle TemplatedIndexedValue<Load, Store>::operator||(ValueHandle e) {
+  using op::operator||;
+  return static_cast<ValueHandle>(*this) || e;
+}
+
+template <typename Load, typename Store>
+ValueHandle TemplatedIndexedValue<Load, Store>::operator==(ValueHandle e) {
+  using op::operator==;
+  return static_cast<ValueHandle>(*this) == e;
+}
+template <typename Load, typename Store>
+ValueHandle TemplatedIndexedValue<Load, Store>::operator!=(ValueHandle e) {
+  using op::operator!=;
+  return static_cast<ValueHandle>(*this) != e;
+}
+template <typename Load, typename Store>
+ValueHandle TemplatedIndexedValue<Load, Store>::operator<(ValueHandle e) {
+  using op::operator<;
+  return static_cast<ValueHandle>(*this) < e;
+}
+template <typename Load, typename Store>
+ValueHandle TemplatedIndexedValue<Load, Store>::operator<=(ValueHandle e) {
+  using op::operator<=;
+  return static_cast<ValueHandle>(*this) <= e;
+}
+template <typename Load, typename Store>
+ValueHandle TemplatedIndexedValue<Load, Store>::operator>(ValueHandle e) {
+  using op::operator>;
+  return static_cast<ValueHandle>(*this) > e;
+}
+template <typename Load, typename Store>
+ValueHandle TemplatedIndexedValue<Load, Store>::operator>=(ValueHandle e) {
+  using op::operator>=;
+  return static_cast<ValueHandle>(*this) >= e;
+}
 
 } // namespace edsc
 } // namespace mlir

diff  --git a/mlir/include/mlir/EDSC/Builders.h b/mlir/include/mlir/EDSC/Builders.h
index 5309187d17145..3ec365dbac5d9 100644
--- a/mlir/include/mlir/EDSC/Builders.h
+++ b/mlir/include/mlir/EDSC/Builders.h
@@ -543,10 +543,14 @@ class TemplatedIndexedValue {
   ValueHandle operator-(ValueHandle e);
   ValueHandle operator*(ValueHandle e);
   ValueHandle operator/(ValueHandle e);
+  ValueHandle operator%(ValueHandle e);
+  ValueHandle operator^(ValueHandle e);
   OperationHandle operator+=(ValueHandle e);
   OperationHandle operator-=(ValueHandle e);
   OperationHandle operator*=(ValueHandle e);
   OperationHandle operator/=(ValueHandle e);
+  OperationHandle operator%=(ValueHandle e);
+  OperationHandle operator^=(ValueHandle e);
   ValueHandle operator+(TemplatedIndexedValue e) {
     return *this + static_cast<ValueHandle>(e);
   }
@@ -559,6 +563,12 @@ class TemplatedIndexedValue {
   ValueHandle operator/(TemplatedIndexedValue e) {
     return *this / static_cast<ValueHandle>(e);
   }
+  ValueHandle operator%(TemplatedIndexedValue e) {
+    return *this % static_cast<ValueHandle>(e);
+  }
+  ValueHandle operator^(TemplatedIndexedValue e) {
+    return *this ^ static_cast<ValueHandle>(e);
+  }
   OperationHandle operator+=(TemplatedIndexedValue e) {
     return this->operator+=(static_cast<ValueHandle>(e));
   }
@@ -571,6 +581,46 @@ class TemplatedIndexedValue {
   OperationHandle operator/=(TemplatedIndexedValue e) {
     return this->operator/=(static_cast<ValueHandle>(e));
   }
+  OperationHandle operator%=(TemplatedIndexedValue e) {
+    return this->operator%=(static_cast<ValueHandle>(e));
+  }
+  OperationHandle operator^=(TemplatedIndexedValue e) {
+    return this->operator^=(static_cast<ValueHandle>(e));
+  }
+
+  ValueHandle operator&&(ValueHandle e);
+  ValueHandle operator||(ValueHandle e);
+  ValueHandle operator&&(TemplatedIndexedValue e) {
+    return *this && static_cast<ValueHandle>(e);
+  }
+  ValueHandle operator||(TemplatedIndexedValue e) {
+    return *this || static_cast<ValueHandle>(e);
+  }
+
+  ValueHandle operator==(ValueHandle e);
+  ValueHandle operator!=(ValueHandle e);
+  ValueHandle operator<(ValueHandle e);
+  ValueHandle operator<=(ValueHandle e);
+  ValueHandle operator>(ValueHandle e);
+  ValueHandle operator>=(ValueHandle e);
+  ValueHandle operator==(TemplatedIndexedValue e) {
+    return *this == static_cast<ValueHandle>(e);
+  }
+  ValueHandle operator!=(TemplatedIndexedValue e) {
+    return *this != static_cast<ValueHandle>(e);
+  }
+  ValueHandle operator<(TemplatedIndexedValue e) {
+    return *this < static_cast<ValueHandle>(e);
+  }
+  ValueHandle operator<=(TemplatedIndexedValue e) {
+    return *this <= static_cast<ValueHandle>(e);
+  }
+  ValueHandle operator>(TemplatedIndexedValue e) {
+    return *this > static_cast<ValueHandle>(e);
+  }
+  ValueHandle operator>=(TemplatedIndexedValue e) {
+    return *this >= static_cast<ValueHandle>(e);
+  }
 
 private:
   TemplatedIndexedValue(ValueHandle base, ArrayRef<ValueHandle> indices)


        


More information about the llvm-branch-commits mailing list