[Mlir-commits] [mlir] 15ae996 - [mlir] Use std::nullopt instead of None in comments (NFC)
Kazu Hirata
llvmlistbot at llvm.org
Wed Dec 7 20:17:45 PST 2022
Author: Kazu Hirata
Date: 2022-12-07T20:17:39-08:00
New Revision: 15ae99647c23e19ba7caf105b61a2b5a45dc1daa
URL: https://github.com/llvm/llvm-project/commit/15ae99647c23e19ba7caf105b61a2b5a45dc1daa
DIFF: https://github.com/llvm/llvm-project/commit/15ae99647c23e19ba7caf105b61a2b5a45dc1daa.diff
LOG: [mlir] Use std::nullopt 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/Dialect/Affine/Analysis/LoopAnalysis.h
mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
mlir/include/mlir/IR/BuiltinAttributes.td
mlir/include/mlir/IR/OperationSupport.h
mlir/lib/AsmParser/Token.cpp
mlir/lib/AsmParser/Token.h
mlir/lib/Conversion/PDLToPDLInterp/Predicate.h
mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp
mlir/lib/Dialect/Affine/Analysis/Utils.cpp
mlir/lib/Dialect/Index/IR/IndexOps.cpp
mlir/lib/IR/BuiltinAttributes.cpp
mlir/lib/IR/OperationSupport.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/LoopAnalysis.h b/mlir/include/mlir/Dialect/Affine/Analysis/LoopAnalysis.h
index c1fd24fd79dab..15f8f255c6005 100644
--- a/mlir/include/mlir/Dialect/Affine/Analysis/LoopAnalysis.h
+++ b/mlir/include/mlir/Dialect/Affine/Analysis/LoopAnalysis.h
@@ -37,9 +37,9 @@ class Value;
void getTripCountMapAndOperands(AffineForOp forOp, AffineMap *map,
SmallVectorImpl<Value> *operands);
-/// Returns the trip count of the loop if it's a constant, None otherwise. This
-/// uses affine expression analysis and is able to determine constant trip count
-/// in non-trivial cases.
+/// Returns the trip count of the loop if it's a constant, std::nullopt
+/// otherwise. This uses affine expression analysis and is able to determine
+/// constant trip count in non-trivial cases.
Optional<uint64_t> getConstantTripCount(AffineForOp forOp);
/// Returns the greatest known integral divisor of the trip count. Affine
diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
index 961827d1f171f..f78ebeff3e164 100644
--- a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
+++ b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h
@@ -353,8 +353,8 @@ struct MemRefRegion {
FlatAffineValueConstraints cst;
};
-/// Returns the size of memref data in bytes if it's statically shaped, None
-/// otherwise.
+/// Returns the size of memref data in bytes if it's statically shaped,
+/// std::nullopt otherwise.
Optional<uint64_t> getMemRefSizeInBytes(MemRefType memRefType);
/// Checks a load or store op for an out of bound access; returns failure if the
diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
index 048546a04b2c1..fc9cd5da8589d 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMTypes.h
@@ -282,7 +282,7 @@ enum class PtrDLEntryPos { Size = 0, Abi = 1, Preferred = 2, Index = 3 };
/// Returns the value that corresponds to named position `pos` from the
/// data layout entry `attr` assuming it's a dense integer elements attribute.
-/// Returns `None` if `pos` is not present in the entry.
+/// Returns `std::nullopt` if `pos` is not present in the entry.
/// Currently only `PtrDLEntryPos::Index` is optional, and all other positions
/// may be assumed to be present.
Optional<unsigned> extractPointerSpecValue(Attribute attr, PtrDLEntryPos pos);
diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td
index adb19dbcfcab2..2f2d9f4a89edd 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.td
+++ b/mlir/include/mlir/IR/BuiltinAttributes.td
@@ -530,7 +530,7 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", [
Attribute get(StringRef name) const;
Attribute get(StringAttr name) const;
- /// Return the specified named attribute if present, None otherwise.
+ /// Return the specified named attribute if present, std::nullopt otherwise.
Optional<NamedAttribute> getNamed(StringRef name) const;
Optional<NamedAttribute> getNamed(StringAttr name) const;
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index 586b6cd5e3bd8..b7d1e2083e422 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -568,7 +568,7 @@ class NamedAttrList {
Attribute get(StringAttr name) const;
Attribute get(StringRef name) const;
- /// Return the specified named attribute if present, None otherwise.
+ /// Return the specified named attribute if present, std::nullopt otherwise.
Optional<NamedAttribute> getNamed(StringRef name) const;
Optional<NamedAttribute> getNamed(StringAttr name) const;
diff --git a/mlir/lib/AsmParser/Token.cpp b/mlir/lib/AsmParser/Token.cpp
index 120a810ee6e52..48faea38cc9f5 100644
--- a/mlir/lib/AsmParser/Token.cpp
+++ b/mlir/lib/AsmParser/Token.cpp
@@ -155,8 +155,8 @@ std::string Token::getSymbolReference() const {
}
/// Given a hash_identifier token like #123, try to parse the number out of
-/// the identifier, returning None if it is a named identifier like #x or
-/// if the integer doesn't fit.
+/// the identifier, returning std::nullopt if it is a named identifier like #x
+/// or if the integer doesn't fit.
Optional<unsigned> Token::getHashIdentifierNumber() const {
assert(getKind() == hash_identifier);
unsigned result = 0;
diff --git a/mlir/lib/AsmParser/Token.h b/mlir/lib/AsmParser/Token.h
index 5f712b8937938..95e67cc2bca7a 100644
--- a/mlir/lib/AsmParser/Token.h
+++ b/mlir/lib/AsmParser/Token.h
@@ -97,8 +97,8 @@ class Token {
Optional<bool> getIntTypeSignedness() const;
/// Given a hash_identifier token like #123, try to parse the number out of
- /// the identifier, returning None if it is a named identifier like #x or
- /// if the integer doesn't fit.
+ /// the identifier, returning std::nullopt if it is a named identifier like #x
+ /// or if the integer doesn't fit.
Optional<unsigned> getHashIdentifierNumber() const;
/// Given a token containing a string literal, return its value, including
diff --git a/mlir/lib/Conversion/PDLToPDLInterp/Predicate.h b/mlir/lib/Conversion/PDLToPDLInterp/Predicate.h
index af6a45601047b..0307239865f2b 100644
--- a/mlir/lib/Conversion/PDLToPDLInterp/Predicate.h
+++ b/mlir/lib/Conversion/PDLToPDLInterp/Predicate.h
@@ -231,8 +231,8 @@ struct OperandGroupPosition
return llvm::hash_value(key);
}
- /// Returns the group number of this position. If None, this group refers to
- /// all operands.
+ /// Returns the group number of this position. If std::nullopt, this group
+ /// refers to all operands.
Optional<unsigned> getOperandGroupNumber() const { return std::get<1>(key); }
/// Returns if the operand group has unknown size. If false, the operand group
@@ -309,8 +309,8 @@ struct ResultGroupPosition
return llvm::hash_value(key);
}
- /// Returns the group number of this position. If None, this group refers to
- /// all results.
+ /// Returns the group number of this position. If std::nullopt, this group
+ /// refers to all results.
Optional<unsigned> getResultGroupNumber() const { return std::get<1>(key); }
/// Returns if the result group has unknown size. If false, the result group
diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
index b441105a60bec..f7eb550a3e15a 100644
--- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
+++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
@@ -52,7 +52,7 @@ struct VectorToSCFPattern : public OpRewritePattern<OpTy> {
/// Given a vector transfer op, calculate which dimension of the `source`
/// memref should be unpacked in the next application of TransferOpConversion.
-/// A return value of None indicates a broadcast.
+/// A return value of std::nullopt indicates a broadcast.
template <typename OpTy>
static Optional<int64_t> unpackedDim(OpTy xferOp) {
// TODO: support 0-d corner case.
@@ -1090,7 +1090,8 @@ namespace lowering_1_d {
/// Compute the indices into the memref for the LoadOp/StoreOp generated as
/// part of TransferOp1dConversion. Return the memref dimension on which
-/// the transfer is operating. A return value of None indicates a broadcast.
+/// the transfer is operating. A return value of std::nullopt indicates a
+/// broadcast.
template <typename OpTy>
static Optional<int64_t>
get1dMemrefIndices(OpBuilder &b, OpTy xferOp, Value iv,
diff --git a/mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp b/mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp
index daf593de03f49..375a113558d5b 100644
--- a/mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/LoopAnalysis.cpp
@@ -78,9 +78,10 @@ void mlir::getTripCountMapAndOperands(
tripCountValueMap.getOperands().end());
}
-/// Returns the trip count of the loop if it's a constant, None otherwise. This
-/// method uses affine expression analysis (in turn using getTripCount) and is
-/// able to determine constant trip count in non-trivial cases.
+/// Returns the trip count of the loop if it's a constant, std::nullopt
+/// otherwise. This method uses affine expression analysis (in turn using
+/// getTripCount) and is able to determine constant trip count in non-trivial
+/// cases.
Optional<uint64_t> mlir::getConstantTripCount(AffineForOp forOp) {
SmallVector<Value, 4> operands;
AffineMap map;
diff --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
index 33c0f207a1895..df7e13caffbdc 100644
--- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp
@@ -634,9 +634,9 @@ Optional<int64_t> MemRefRegion::getRegionSize() {
return getMemRefEltSizeInBytes(memRefType) * *numElements;
}
-/// Returns the size of memref data in bytes if it's statically shaped, None
-/// otherwise. If the element of the memref has vector type, takes into account
-/// size of the vector as well.
+/// Returns the size of memref data in bytes if it's statically shaped,
+/// std::nullopt otherwise. If the element of the memref has vector type, takes
+/// into account size of the vector as well.
// TODO: improve/complete this when we have target data.
Optional<uint64_t> mlir::getMemRefSizeInBytes(MemRefType memRefType) {
if (!memRefType.hasStaticShape())
diff --git a/mlir/lib/Dialect/Index/IR/IndexOps.cpp b/mlir/lib/Dialect/Index/IR/IndexOps.cpp
index 3604127fbe747..2eadabbe6273e 100644
--- a/mlir/lib/Dialect/Index/IR/IndexOps.cpp
+++ b/mlir/lib/Dialect/Index/IR/IndexOps.cpp
@@ -84,8 +84,8 @@ static OpFoldResult foldBinaryOpUnchecked(
/// bits of the results.
///
/// The function accepts a lambda that computes the integer result in both
-/// 64-bit and 32-bit. If either call returns `None`, the operation is not
-/// folded.
+/// 64-bit and 32-bit. If either call returns `std::nullopt`, the operation is
+/// not folded.
static OpFoldResult foldBinaryOpChecked(
ArrayRef<Attribute> operands,
function_ref<Optional<APInt>(const APInt &, const APInt &lhs)> calculate) {
diff --git a/mlir/lib/IR/BuiltinAttributes.cpp b/mlir/lib/IR/BuiltinAttributes.cpp
index e73ca99b0d90d..0263a15ab2c2a 100644
--- a/mlir/lib/IR/BuiltinAttributes.cpp
+++ b/mlir/lib/IR/BuiltinAttributes.cpp
@@ -170,7 +170,7 @@ Attribute DictionaryAttr::get(StringAttr name) const {
return it.second ? it.first->getValue() : Attribute();
}
-/// Return the specified named attribute if present, None otherwise.
+/// Return the specified named attribute if present, std::nullopt otherwise.
Optional<NamedAttribute> DictionaryAttr::getNamed(StringRef name) const {
auto it = impl::findAttrSorted(begin(), end(), name);
return it.second ? *it.first : Optional<NamedAttribute>();
diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp
index 97d09eba7eb2f..e6503383be4fa 100644
--- a/mlir/lib/IR/OperationSupport.cpp
+++ b/mlir/lib/IR/OperationSupport.cpp
@@ -89,7 +89,7 @@ Attribute NamedAttrList::get(StringAttr name) const {
return it.second ? it.first->getValue() : Attribute();
}
-/// Return the specified named attribute if present, None otherwise.
+/// Return the specified named attribute if present, std::nullopt otherwise.
Optional<NamedAttribute> NamedAttrList::getNamed(StringRef name) const {
auto it = findAttr(*this, name);
return it.second ? *it.first : Optional<NamedAttribute>();
More information about the Mlir-commits
mailing list