[Mlir-commits] [mlir] fe81e8f - Add default LoopOptionsAttrBuilder constructor and method to check if empty() (NFC)

Mehdi Amini llvmlistbot at llvm.org
Tue Mar 9 13:12:28 PST 2021


Author: Mehdi Amini
Date: 2021-03-09T21:12:15Z
New Revision: fe81e8f3b52e86ccd93d44601a65c6084c9dd5d6

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

LOG: Add default LoopOptionsAttrBuilder constructor and method to check if empty() (NFC)

Also move setters out-of-line to make sure the templated helper is
actually instantiated.

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
    mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
index 735d72904af6..7d21437b3171 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
@@ -79,27 +79,27 @@ bool satisfiesLLVMModule(Operation *op);
 /// creation once all the options are in place.
 class LoopOptionsAttrBuilder {
 public:
+  /// Construct a empty builder.
+  LoopOptionsAttrBuilder() = default;
+
   /// Construct a builder with an initial list of options from an existing
   /// LoopOptionsAttr.
   LoopOptionsAttrBuilder(LoopOptionsAttr attr);
 
   /// Set the `disable_licm` option to the provided value. If no value
   /// is provided the option is deleted.
-  LoopOptionsAttrBuilder &setDisableLICM(Optional<bool> value) {
-    return setOption(LoopOptionCase::disable_licm, value);
-  }
+  LoopOptionsAttrBuilder &setDisableLICM(Optional<bool> value);
 
   /// Set the `interleave_count` option to the provided value. If no value
   /// is provided the option is deleted.
-  LoopOptionsAttrBuilder &setInterleaveCount(Optional<uint64_t> count) {
-    return setOption(LoopOptionCase::interleave_count, count);
-  }
+  LoopOptionsAttrBuilder &setInterleaveCount(Optional<uint64_t> count);
 
   /// Set the `disable_unroll` option to the provided value. If no value
   /// is provided the option is deleted.
-  LoopOptionsAttrBuilder &setDisableUnroll(Optional<bool> value) {
-    return setOption(LoopOptionCase::disable_unroll, value);
-  }
+  LoopOptionsAttrBuilder &setDisableUnroll(Optional<bool> value);
+
+  /// Returns true if any option has been set.
+  bool empty() { return options.empty(); }
 
 private:
   template <typename T>

diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index 07f4217a2479..414a718323aa 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -2412,6 +2412,25 @@ LoopOptionsAttrBuilder &LoopOptionsAttrBuilder::setOption(LoopOptionCase tag,
   return *this;
 }
 
+LoopOptionsAttrBuilder &
+LoopOptionsAttrBuilder::setDisableLICM(Optional<bool> value) {
+  return setOption(LoopOptionCase::disable_licm, value);
+}
+
+/// Set the `interleave_count` option to the provided value. If no value
+/// is provided the option is deleted.
+LoopOptionsAttrBuilder &
+LoopOptionsAttrBuilder::setInterleaveCount(Optional<uint64_t> count) {
+  return setOption(LoopOptionCase::interleave_count, count);
+}
+
+/// Set the `disable_unroll` option to the provided value. If no value
+/// is provided the option is deleted.
+LoopOptionsAttrBuilder &
+LoopOptionsAttrBuilder::setDisableUnroll(Optional<bool> value) {
+  return setOption(LoopOptionCase::disable_unroll, value);
+}
+
 template <typename T>
 static Optional<T>
 getOption(ArrayRef<std::pair<LoopOptionCase, int64_t>> options,


        


More information about the Mlir-commits mailing list