mlir/tblgen: use std::optional in generation
This is part of an effort to migrate from llvm::Optional to std::optional. This patch changes the way mlir-tblgen generates .inc files, and modifies tests and documentation appropriately. It is a "no compromises" patch, and doesn't leave the user with an unpleasant mix of llvm::Optional and std::optional. A non-trivial change has been made to ControlFlowInterfaces to split one constructor into two, relating to a build failure on Windows. 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/D138934
This commit is contained in:
@@ -133,9 +133,10 @@ static scf::ForOp createFor(OpBuilder &builder, Location loc, Value upper,
|
||||
/// Gets the dimension size for the given sparse tensor at the given
|
||||
/// original dimension 'dim'. Returns std::nullopt if no sparse encoding is
|
||||
/// attached to the given tensor type.
|
||||
static Optional<Value> sizeFromTensorAtDim(OpBuilder &builder, Location loc,
|
||||
SparseTensorDescriptor desc,
|
||||
unsigned dim) {
|
||||
static std::optional<Value> sizeFromTensorAtDim(OpBuilder &builder,
|
||||
Location loc,
|
||||
SparseTensorDescriptor desc,
|
||||
unsigned dim) {
|
||||
RankedTensorType rtp = desc.getTensorType();
|
||||
// Access into static dimension can query original type directly.
|
||||
// Note that this is typically already done by DimOp's folding.
|
||||
@@ -681,7 +682,7 @@ public:
|
||||
LogicalResult
|
||||
matchAndRewrite(tensor::DimOp op, OpAdaptor adaptor,
|
||||
ConversionPatternRewriter &rewriter) const override {
|
||||
Optional<int64_t> index = op.getConstantIndex();
|
||||
std::optional<int64_t> index = op.getConstantIndex();
|
||||
if (!index || !getSparseTensorEncoding(adaptor.getSource().getType()))
|
||||
return failure();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user