mlir/DialectConversion: use std::optional (NFC)

This is part of an effort to migrate from llvm::Optional to
std::optional. This patch touches DialectConversion, and modifies
existing conversions and tests appropriately.

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

Signed-off-by: Ramkumar Ramachandra <r@artagnon.com>

Differential Revision: https://reviews.llvm.org/D140303
This commit is contained in:
Ramkumar Ramachandra
2022-12-19 14:25:14 +01:00
parent 2f6439bcf9
commit 0de16fafa5
27 changed files with 209 additions and 191 deletions

View File

@@ -178,7 +178,7 @@ static void createPushback(OpBuilder &builder, Location loc,
}
/// Maps a sparse tensor type to the appropriate compounded buffers.
static Optional<LogicalResult>
static std::optional<LogicalResult>
convertSparseTensorType(Type type, SmallVectorImpl<Type> &fields) {
auto enc = getSparseTensorEncoding(type);
if (!enc)
@@ -1039,7 +1039,7 @@ mlir::SparseTensorTypeToBufferConverter::SparseTensorTypeToBufferConverter() {
// Required by scf.for 1:N type conversion.
addSourceMaterialization([](OpBuilder &builder, RankedTensorType tp,
ValueRange inputs,
Location loc) -> Optional<Value> {
Location loc) -> std::optional<Value> {
if (!getSparseTensorEncoding(tp))
// Not a sparse tensor.
return std::nullopt;