From: Kazu Hirata Date: Sun, 11 Dec 2022 01:11:23 +0000 (-0800) Subject: [mlir] Use std::optional instead of None in comments (NFC) X-Git-Tag: upstream/17.0.6~24347 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4f81805a3f8874ad055586724c3985c190bca801;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h index 2c4aa9f..772bcea 100644 --- a/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h +++ b/mlir/include/mlir/Analysis/Presburger/IntegerRelation.h @@ -460,18 +460,18 @@ public: /// 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 differences 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 difference: `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 differences 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 difference: `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 getConstantBoundOnDimSize( unsigned pos, SmallVectorImpl *lb = nullptr, MPInt *boundFloorDivisor = nullptr, SmallVectorImpl *ub = nullptr, @@ -497,7 +497,7 @@ public: } /// Returns the constant bound for the pos^th variable if there is one; - /// None otherwise. + /// std::nullopt otherwise. Optional 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 bcbec8c..e5d9b6e 100644 --- a/mlir/include/mlir/Analysis/Presburger/Simplex.h +++ b/mlir/include/mlir/Analysis/Presburger/Simplex.h @@ -804,7 +804,7 @@ public: bool isRationalSubsetOf(const IntegerRelation &rel); /// Returns the current sample point if it is integral. Otherwise, returns - /// None. + /// std::nullopt. Optional> 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 f78ebef..3ce4ea3 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 difference 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 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 getConstantBoundingSizeAndShape( SmallVectorImpl *shape = nullptr, std::vector> *lbs = nullptr, diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h index 4081eb0..81ec026 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 b7d1e20..cfd8844 100644 --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -134,8 +134,8 @@ public: /// 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 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 e284c04..87f4ae5 100644 --- a/mlir/include/mlir/IR/SubElementInterfaces.h +++ b/mlir/include/mlir/IR/SubElementInterfaces.h @@ -56,9 +56,9 @@ public: // 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 using ReplaceFnResult = Optional>; template diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h index b390586..f206c51 100644 --- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h +++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h @@ -207,8 +207,8 @@ public: 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 upper; }; diff --git a/mlir/include/mlir/TableGen/Attribute.h b/mlir/include/mlir/TableGen/Attribute.h index 6b81189..d0a9430 100644 --- a/mlir/include/mlir/TableGen/Attribute.h +++ b/mlir/include/mlir/TableGen/Attribute.h @@ -57,7 +57,7 @@ public: 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 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 a7ad871..d6e34b7 100644 --- a/mlir/include/mlir/TableGen/Builder.h +++ b/mlir/include/mlir/TableGen/Builder.h @@ -39,7 +39,7 @@ public: 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 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 11a5320..343d8db 100644 --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -202,7 +202,7 @@ public: /// 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 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 9186f92..a39bb49 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 differences 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 difference. 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 difference. 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 590986e..1c291ab 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; /// 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 a4860e3..1afd98f 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 getLoadStoreElementType(OpAsmParser &parser, Type type, SMLoc trailingTypeLoc) { auto llvmTy = type.dyn_cast(); diff --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp index 1f659d4..11bb980 100644 --- a/mlir/lib/IR/SymbolTable.cpp +++ b/mlir/lib/IR/SymbolTable.cpp @@ -749,8 +749,8 @@ static Optional 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 { return getSymbolUsesImpl(from); } diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp index 2018ecc..57c77c7 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 Attribute::getValueType() const { if (auto *defInit = dyn_cast(def->getValueInit("valueType"))) return Type(defInit->getDef()); diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp index e942238..2fb3422 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, 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 9620a86..4199e97 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.