[Mlir-commits] [mlir] 4f81805 - [mlir] Use std::optional instead of None in comments (NFC)

Kazu Hirata llvmlistbot at llvm.org
Sat Dec 10 17:11:28 PST 2022


Author: Kazu Hirata
Date: 2022-12-10T17:11:23-08:00
New Revision: 4f81805a3f8874ad055586724c3985c190bca801

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

LOG: [mlir] Use std::optional instead of None in comments (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 
    

Modified: 
    mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
    mlir/include/mlir/Analysis/Presburger/Simplex.h
    mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
    mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
    mlir/include/mlir/IR/OperationSupport.h
    mlir/include/mlir/IR/SubElementInterfaces.h
    mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
    mlir/include/mlir/TableGen/Attribute.h
    mlir/include/mlir/TableGen/Builder.h
    mlir/include/mlir/Transforms/DialectConversion.h
    mlir/lib/Analysis/Presburger/IntegerRelation.cpp
    mlir/lib/Bytecode/Reader/BytecodeReader.cpp
    mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
    mlir/lib/IR/SymbolTable.cpp
    mlir/lib/TableGen/Attribute.cpp
    mlir/lib/Transforms/Utils/DialectConversion.cpp
    mlir/tools/mlir-tblgen/OpFormatGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
index 2c4aa9f6d1eb5..772bcea6187cb 100644
--- a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
+++ b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h
@@ -460,18 +460,18 @@ class IntegerRelation {
   /// variable (pos^th), i.e., the smallest known constant that is greater
   /// than or equal to 'exclusive upper bound' - 'lower bound' of the
   /// variable. This constant bound is guaranteed to be non-negative. Returns
-  /// None if it's not a constant. This method employs trivial (low complexity /
-  /// cost) checks and detection. Symbolic variables are treated specially,
-  /// i.e., it looks for constant 
diff erences between affine expressions
-  /// involving only the symbolic variables. `lb` and `ub` (along with the
-  /// `boundFloorDivisor`) are set to represent the lower and upper bound
-  /// associated with the constant 
diff erence: `lb`, `ub` have the coefficients,
-  /// and `boundFloorDivisor`, their divisor. `minLbPos` and `minUbPos` if
-  /// non-null are set to the position of the constant lower bound and upper
-  /// bound respectively (to the same if they are from an equality). Ex: if the
-  /// lower bound is [(s0 + s2 - 1) floordiv 32] for a system with three
-  /// symbolic variables, *lb = [1, 0, 1], lbDivisor = 32. See comments at
-  /// function definition for examples.
+  /// std::nullopt if it's not a constant. This method employs trivial (low
+  /// complexity / cost) checks and detection. Symbolic variables are treated
+  /// specially, i.e., it looks for constant 
diff erences between affine
+  /// expressions involving only the symbolic variables. `lb` and `ub` (along
+  /// with the `boundFloorDivisor`) are set to represent the lower and upper
+  /// bound associated with the constant 
diff erence: `lb`, `ub` have the
+  /// coefficients, and `boundFloorDivisor`, their divisor. `minLbPos` and
+  /// `minUbPos` if non-null are set to the position of the constant lower bound
+  /// and upper bound respectively (to the same if they are from an
+  /// equality). Ex: if the lower bound is [(s0 + s2 - 1) floordiv 32] for a
+  /// system with three symbolic variables, *lb = [1, 0, 1], lbDivisor = 32. See
+  /// comments at function definition for examples.
   Optional<MPInt> getConstantBoundOnDimSize(
       unsigned pos, SmallVectorImpl<MPInt> *lb = nullptr,
       MPInt *boundFloorDivisor = nullptr, SmallVectorImpl<MPInt> *ub = nullptr,
@@ -497,7 +497,7 @@ class IntegerRelation {
   }
 
   /// Returns the constant bound for the pos^th variable if there is one;
-  /// None otherwise.
+  /// std::nullopt otherwise.
   Optional<MPInt> getConstantBound(BoundType type, unsigned pos) const;
   /// The same, but casts to int64_t. This is unsafe and will assert-fail if the
   /// value does not fit in an int64_t.

diff  --git a/mlir/include/mlir/Analysis/Presburger/Simplex.h b/mlir/include/mlir/Analysis/Presburger/Simplex.h
index bcbec8ce5a819..e5d9b6e3257e2 100644
--- a/mlir/include/mlir/Analysis/Presburger/Simplex.h
+++ b/mlir/include/mlir/Analysis/Presburger/Simplex.h
@@ -804,7 +804,7 @@ class Simplex : public SimplexBase {
   bool isRationalSubsetOf(const IntegerRelation &rel);
 
   /// Returns the current sample point if it is integral. Otherwise, returns
-  /// None.
+  /// std::nullopt.
   Optional<SmallVector<MPInt, 8>> getSamplePointIfIntegral() const;
 
   /// Returns the current sample point, which may contain non-integer (rational)

diff  --git a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
index f78ebeff3e164..3ce4ea36c268f 100644
--- a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
+++ b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
@@ -129,7 +129,7 @@ struct ComputationSliceState {
   /// If this 
diff erence is empty, the slice is declared to be valid. Otherwise,
   /// return false as it implies that the effective fusion results in at least
   /// one iteration of the slice that was not originally in the source's domain.
-  /// If the validity cannot be determined, returns llvm:None.
+  /// If the validity cannot be determined, returns std::nullopt.
   Optional<bool> isSliceValid();
 
   void dump() const;
@@ -292,15 +292,16 @@ struct MemRefRegion {
   void setWrite(bool flag) { write = flag; }
 
   /// Returns a constant upper bound on the number of elements in this region if
-  /// bounded by a known constant (always possible for static shapes), None
-  /// otherwise. Note that the symbols of the region are treated specially,
-  /// i.e., the returned bounding constant holds for *any given* value of the
-  /// symbol variables. The 'shape' vector is set to the corresponding
-  /// dimension-wise bounds major to minor. The number of elements and all the
-  /// dimension-wise bounds are guaranteed to be non-negative. We use int64_t
-  /// instead of uint64_t since index types can be at most int64_t. `lbs` are
-  /// set to the lower bounds for each of the rank dimensions, and lbDivisors
-  /// contains the corresponding denominators for floorDivs.
+  /// bounded by a known constant (always possible for static shapes),
+  /// std::nullopt otherwise. Note that the symbols of the region are treated
+  /// specially, i.e., the returned bounding constant holds for *any given*
+  /// value of the symbol variables. The 'shape' vector is set to the
+  /// corresponding dimension-wise bounds major to minor. The number of elements
+  /// and all the dimension-wise bounds are guaranteed to be non-negative. We
+  /// use int64_t instead of uint64_t since index types can be at most
+  /// int64_t. `lbs` are set to the lower bounds for each of the rank
+  /// dimensions, and lbDivisors contains the corresponding denominators for
+  /// floorDivs.
   Optional<int64_t> getConstantBoundingSizeAndShape(
       SmallVectorImpl<int64_t> *shape = nullptr,
       std::vector<SmallVector<int64_t, 4>> *lbs = nullptr,

diff  --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index 4081eb04d8098..81ec026a8a79f 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -930,7 +930,7 @@ struct ExtractSliceOfPadTensorSwapPattern
   /// A function to control pattern application and rewrite logic.
   ///
   /// The function will be given the slice op and should return:
-  /// -  None: to fail the match and not apply the pattern;
+  /// -  std::nullopt: to fail the match and not apply the pattern;
   /// -  true: to apply the pattern with zero slice guard;
   /// - false: to apply the pattern without zero slice guard.
   ///

diff  --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index b7d1e2083e422..cfd8844403a9a 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -134,8 +134,8 @@ class OperationName {
   /// Return if this operation is registered.
   bool isRegistered() const { return impl->isRegistered(); }
 
-  /// If this operation is registered, returns the registered information, None
-  /// otherwise.
+  /// If this operation is registered, returns the registered information,
+  /// std::nullopt otherwise.
   Optional<RegisteredOperationName> getRegisteredInfo() const;
 
   /// Returns true if the operation was registered with a particular trait, e.g.

diff  --git a/mlir/include/mlir/IR/SubElementInterfaces.h b/mlir/include/mlir/IR/SubElementInterfaces.h
index e284c043a8c1a..87f4ae50a6550 100644
--- a/mlir/include/mlir/IR/SubElementInterfaces.h
+++ b/mlir/include/mlir/IR/SubElementInterfaces.h
@@ -56,9 +56,9 @@ class AttrTypeReplacer {
   // Registration
   //===--------------------------------------------------------------------===//
 
-  /// A replacement mapping function, which returns either None (to signal the
-  /// element wasn't handled), or a pair of the replacement element and a
-  /// WalkResult.
+  /// A replacement mapping function, which returns either std::nullopt (to
+  /// signal the element wasn't handled), or a pair of the replacement element
+  /// and a WalkResult.
   template <typename T>
   using ReplaceFnResult = Optional<std::pair<T, WalkResult>>;
   template <typename T>

diff  --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
index b390586201962..f206c51d222c2 100644
--- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
+++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h
@@ -207,8 +207,8 @@ class InvocationBounds {
 private:
   /// The minimum number of times the successor region will be invoked.
   unsigned lower;
-  /// The maximum number of times the successor region will be invoked or `None`
-  /// if an upper bound is not known.
+  /// The maximum number of times the successor region will be invoked or
+  /// `std::nullopt` if an upper bound is not known.
   Optional<unsigned> upper;
 };
 

diff  --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h
index 6b81189ba16fb..d0a9430d4ed6c 100644
--- a/mlir/include/mlir/TableGen/Attribute.h
+++ b/mlir/include/mlir/TableGen/Attribute.h
@@ -57,7 +57,7 @@ class Attribute : public AttrConstraint {
   StringRef getReturnType() const;
 
   // Return the type constraint corresponding to the type of this attribute, or
-  // None if this is not a TypedAttr.
+  // std::nullopt if this is not a TypedAttr.
   std::optional<Type> getValueType() const;
 
   // Returns the template getter method call which reads this attribute's

diff  --git a/mlir/include/mlir/TableGen/Builder.h b/mlir/include/mlir/TableGen/Builder.h
index a7ad8716e7f04..d6e34b79a50ff 100644
--- a/mlir/include/mlir/TableGen/Builder.h
+++ b/mlir/include/mlir/TableGen/Builder.h
@@ -39,7 +39,7 @@ class Builder {
     StringRef getCppType() const;
 
     /// Return an optional string containing the name of this parameter. If
-    /// None, no name was specified for this parameter by the user.
+    /// std::nullopt, no name was specified for this parameter by the user.
     std::optional<StringRef> getName() const { return name; }
 
     /// Return an optional string containing the default value to use for this

diff  --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h
index 11a53206c2095..343d8db8b2393 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -202,7 +202,7 @@ class TypeConverter {
 
   /// This function converts the type signature of the given block, by invoking
   /// 'convertSignatureArg' for each argument. This function should return a
-  /// valid conversion for the signature on success, None otherwise.
+  /// valid conversion for the signature on success, std::nullopt otherwise.
   Optional<SignatureConversion> convertBlockSignature(Block *block);
 
   /// Materialize a conversion from a set of types into one result type by

diff  --git a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
index 9186f920fdc61..a39bb499cfd3f 100644
--- a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
+++ b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp
@@ -1378,13 +1378,13 @@ void IntegerRelation::constantFoldVarRange(unsigned pos, unsigned num) {
 
 /// Returns a non-negative constant bound on the extent (upper bound - lower
 /// bound) of the specified variable if it is found to be a constant; returns
-/// None if it's not a constant. This methods treats symbolic variables
+/// std::nullopt if it's not a constant. This methods treats symbolic variables
 /// specially, i.e., it looks for constant 
diff erences between affine
-/// expressions involving only the symbolic variables. See comments at
-/// function definition for example. 'lb', if provided, is set to the lower
-/// bound associated with the constant 
diff erence. Note that 'lb' is purely
-/// symbolic and thus will contain the coefficients of the symbolic variables
-/// and the constant coefficient.
+/// expressions involving only the symbolic variables. See comments at function
+/// definition for example. 'lb', if provided, is set to the lower bound
+/// associated with the constant 
diff erence. Note that 'lb' is purely symbolic
+/// and thus will contain the coefficients of the symbolic variables and the
+/// constant coefficient.
 //  Egs: 0 <= i <= 15, return 16.
 //       s0 + 2 <= i <= s0 + 17, returns 16. (s0 has to be a symbol)
 //       s0 + s1 + 16 <= d0 <= s0 + s1 + 31, returns 16.

diff  --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
index 590986eb6d079..1c291ab86e19f 100644
--- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -434,8 +434,9 @@ struct BytecodeDialect {
     return *dialect;
   }
 
-  /// The loaded dialect entry. This field is None if we haven't attempted to
-  /// load, nullptr if we failed to load, otherwise the loaded dialect.
+  /// The loaded dialect entry. This field is std::nullopt if we haven't
+  /// attempted to load, nullptr if we failed to load, otherwise the loaded
+  /// dialect.
   std::optional<Dialect *> dialect;
 
   /// The bytecode interface of the dialect, or nullptr if the dialect does not

diff  --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
index a4860e35bc2fe..1afd98feeafb0 100644
--- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
+++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
@@ -769,8 +769,8 @@ void LoadOp::print(OpAsmPrinter &p) {
 }
 
 // Extract the pointee type from the LLVM pointer type wrapped in MLIR. Return
-// the resulting type if any, null type if opaque pointers are used, and None
-// if the given type is not the pointer type.
+// the resulting type if any, null type if opaque pointers are used, and
+// std::nullopt if the given type is not the pointer type.
 static Optional<Type> getLoadStoreElementType(OpAsmParser &parser, Type type,
                                               SMLoc trailingTypeLoc) {
   auto llvmTy = type.dyn_cast<LLVM::LLVMPointerType>();

diff  --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp
index 1f659d404cce1..11bb980119e63 100644
--- a/mlir/lib/IR/SymbolTable.cpp
+++ b/mlir/lib/IR/SymbolTable.cpp
@@ -749,8 +749,8 @@ static Optional<SymbolTable::UseRange> getSymbolUsesImpl(FromT from) {
 /// symbol tables, and will also only return uses on 'from' if it does not
 /// also define a symbol table. This is because we treat the region as the
 /// boundary of the symbol table, and not the op itself. This function returns
-/// None if there are any unknown operations that may potentially be symbol
-/// tables.
+/// std::nullopt if there are any unknown operations that may potentially be
+/// symbol tables.
 auto SymbolTable::getSymbolUses(Operation *from) -> Optional<UseRange> {
   return getSymbolUsesImpl(from);
 }

diff  --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp
index 2018ecc5a8e7a..57c77c74106b9 100644
--- a/mlir/lib/TableGen/Attribute.cpp
+++ b/mlir/lib/TableGen/Attribute.cpp
@@ -69,7 +69,7 @@ StringRef Attribute::getReturnType() const {
 }
 
 // Return the type constraint corresponding to the type of this attribute, or
-// None if this is not a TypedAttr.
+// std::nullopt if this is not a TypedAttr.
 std::optional<Type> Attribute::getValueType() const {
   if (auto *defInit = dyn_cast<llvm::DefInit>(def->getValueInit("valueType")))
     return Type(defInit->getDef());

diff  --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp
index e942238cd6dfc..2fb3422b881e7 100644
--- a/mlir/lib/Transforms/Utils/DialectConversion.cpp
+++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp
@@ -495,7 +495,7 @@ struct ArgConverter {
     Block *origBlock;
 
     /// The conversion information for each of the arguments. The information is
-    /// None if the argument was dropped during conversion.
+    /// std::nullopt if the argument was dropped during conversion.
     SmallVector<Optional<ConvertedArgInfo>, 1> argInfo;
 
     /// The type converter used to convert the arguments.

diff  --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
index 9620a8639e746..4199e97c5169a 100644
--- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -2434,7 +2434,7 @@ static bool isOptionallyParsed(FormatElement *el) {
 /// element that satisfies `isInvalid`, skipping any optionally-parsed elements.
 /// If an optional group is encountered, this function recurses into the 'then'
 /// and 'else' elements to check if they are invalid. Returns `success` if the
-/// range is known to be valid or `None` if scanning reached the end.
+/// range is known to be valid or `std::nullopt` if scanning reached the end.
 ///
 /// Since the guard element of an optional group is required, this function
 /// accepts an optional element pointer to mark it as required.


        


More information about the Mlir-commits mailing list