diff --git a/mlir/docs/AttributesAndTypes.md b/mlir/docs/AttributesAndTypes.md --- a/mlir/docs/AttributesAndTypes.md +++ b/mlir/docs/AttributesAndTypes.md @@ -653,7 +653,7 @@ When using `OptionalParameter`, the default value is set to the C++ default-constructed value for the C++ storage type. For example, `Optional` -will be set to `llvm::None` and `Attribute` will be set to `nullptr`. The +will be set to `std::nullopt` and `Attribute` will be set to `nullptr`. The presence of these parameters is tested by comparing them to their "null" values. An optional group is a set of elements optionally printed based on the presence diff --git a/mlir/docs/DialectConversion.md b/mlir/docs/DialectConversion.md --- a/mlir/docs/DialectConversion.md +++ b/mlir/docs/DialectConversion.md @@ -301,15 +301,15 @@ /// to any of the following forms(where `T` is a class derived from `Type`: /// * Optional(T) /// - This form represents a 1-1 type conversion. It should return nullptr - /// or `llvm::None` to signify failure. If `llvm::None` is returned, the + /// or `std::nullopt` to signify failure. If `llvm::None` is returned, the /// converter is allowed to try another conversion function to perform /// the conversion. /// * Optional(T, SmallVectorImpl &) /// - This form represents a 1-N type conversion. It should return - /// `failure` or `llvm::None` to signify a failed conversion. If the new + /// `failure` or `std::nullopt` to signify a failed conversion. If the new /// set of types is empty, the type is removed and any usages of the /// existing value are expected to be removed during conversion. If - /// `llvm::None` is returned, the converter is allowed to try another + /// `std::nullopt` is returned, the converter is allowed to try another /// conversion function to perform the conversion. /// * Optional(T, SmallVectorImpl &, ArrayRef) /// - This form represents a 1-N type conversion supporting recursive @@ -334,7 +334,7 @@ /// This function is responsible for creating an operation, using the /// OpBuilder and Location provided, that "converts" a range of values into a /// single value of the given type `T`. It must return a Value of the - /// converted type on success, an `llvm::None` if it failed but other + /// converted type on success, an `std::nullopt` if it failed but other /// materialization can be attempted, and `nullptr` on unrecoverable failure. /// It will only be called for (sub)types of `T`. /// diff --git a/mlir/docs/OpDefinitions.md b/mlir/docs/OpDefinitions.md --- a/mlir/docs/OpDefinitions.md +++ b/mlir/docs/OpDefinitions.md @@ -1391,13 +1391,13 @@ return llvm::StringSwitch>(str) .Case("Case15", MyIntEnum::Case15) .Case("Case20", MyIntEnum::Case20) - .Default(llvm::None); + .Default(std::nullopt); } llvm::Optional symbolizeMyIntEnum(uint32_t value) { switch (value) { case 15: return MyIntEnum::Case15; case 20: return MyIntEnum::Case20; - default: return llvm::None; + default: return std::nullopt; } } @@ -1520,8 +1520,8 @@ .Case("Bit1", 2) .Case("Bit2", 4) .Case("Bit3", 8) - .Default(llvm::None); - if (bit) { val |= *bit; } else { return llvm::None; } + .Default(std::nullopt); + if (bit) { val |= *bit; } else { return std::nullopt; } } return static_cast(val); } @@ -1530,7 +1530,7 @@ // Special case for all bits unset. if (value == 0) return MyBitEnum::None; - if (value & ~static_cast(15u)) return llvm::None; + if (value & ~static_cast(15u)) return std::nullopt; return static_cast(value); } ``` diff --git a/mlir/examples/toy/Ch1/include/toy/AST.h b/mlir/examples/toy/Ch1/include/toy/AST.h --- a/mlir/examples/toy/Ch1/include/toy/AST.h +++ b/mlir/examples/toy/Ch1/include/toy/AST.h @@ -137,7 +137,7 @@ llvm::Optional getExpr() { if (expr.has_value()) return expr->get(); - return llvm::None; + return std::nullopt; } /// LLVM style RTTI diff --git a/mlir/examples/toy/Ch2/include/toy/AST.h b/mlir/examples/toy/Ch2/include/toy/AST.h --- a/mlir/examples/toy/Ch2/include/toy/AST.h +++ b/mlir/examples/toy/Ch2/include/toy/AST.h @@ -137,7 +137,7 @@ llvm::Optional getExpr() { if (expr.has_value()) return expr->get(); - return llvm::None; + return std::nullopt; } /// LLVM style RTTI diff --git a/mlir/examples/toy/Ch2/include/toy/Ops.td b/mlir/examples/toy/Ch2/include/toy/Ops.td --- a/mlir/examples/toy/Ch2/include/toy/Ops.td +++ b/mlir/examples/toy/Ch2/include/toy/Ops.td @@ -291,7 +291,7 @@ // Allow building a ReturnOp with no return operand. let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, llvm::None); }]> + OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> ]; // Provide extra utility definitions on the c++ operation class definition. diff --git a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp --- a/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch2/mlir/MLIRGen.cpp @@ -111,7 +111,7 @@ // Arguments type are uniformly unranked tensors. llvm::SmallVector argTypes(proto.getArgs().size(), getType(VarType{})); - auto funcType = builder.getFunctionType(argTypes, llvm::None); + auto funcType = builder.getFunctionType(argTypes, std::nullopt); return builder.create(location, proto.getName(), funcType); } diff --git a/mlir/examples/toy/Ch3/include/toy/AST.h b/mlir/examples/toy/Ch3/include/toy/AST.h --- a/mlir/examples/toy/Ch3/include/toy/AST.h +++ b/mlir/examples/toy/Ch3/include/toy/AST.h @@ -137,7 +137,7 @@ llvm::Optional getExpr() { if (expr.has_value()) return expr->get(); - return llvm::None; + return std::nullopt; } /// LLVM style RTTI diff --git a/mlir/examples/toy/Ch3/include/toy/Ops.td b/mlir/examples/toy/Ch3/include/toy/Ops.td --- a/mlir/examples/toy/Ch3/include/toy/Ops.td +++ b/mlir/examples/toy/Ch3/include/toy/Ops.td @@ -293,7 +293,7 @@ // Allow building a ReturnOp with no return operand. let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, llvm::None); }]> + OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> ]; // Provide extra utility definitions on the c++ operation class definition. diff --git a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp --- a/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch3/mlir/MLIRGen.cpp @@ -111,7 +111,7 @@ // Arguments type are uniformly unranked tensors. llvm::SmallVector argTypes(proto.getArgs().size(), getType(VarType{})); - auto funcType = builder.getFunctionType(argTypes, llvm::None); + auto funcType = builder.getFunctionType(argTypes, std::nullopt); return builder.create(location, proto.getName(), funcType); } diff --git a/mlir/examples/toy/Ch4/include/toy/AST.h b/mlir/examples/toy/Ch4/include/toy/AST.h --- a/mlir/examples/toy/Ch4/include/toy/AST.h +++ b/mlir/examples/toy/Ch4/include/toy/AST.h @@ -137,7 +137,7 @@ llvm::Optional getExpr() { if (expr.has_value()) return expr->get(); - return llvm::None; + return std::nullopt; } /// LLVM style RTTI diff --git a/mlir/examples/toy/Ch4/include/toy/Ops.td b/mlir/examples/toy/Ch4/include/toy/Ops.td --- a/mlir/examples/toy/Ch4/include/toy/Ops.td +++ b/mlir/examples/toy/Ch4/include/toy/Ops.td @@ -325,7 +325,7 @@ // Allow building a ReturnOp with no return operand. let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, llvm::None); }]> + OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> ]; // Provide extra utility definitions on the c++ operation class definition. diff --git a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp --- a/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch4/mlir/MLIRGen.cpp @@ -111,7 +111,7 @@ // Arguments type are uniformly unranked tensors. llvm::SmallVector argTypes(proto.getArgs().size(), getType(VarType{})); - auto funcType = builder.getFunctionType(argTypes, llvm::None); + auto funcType = builder.getFunctionType(argTypes, std::nullopt); return builder.create(location, proto.getName(), funcType); } diff --git a/mlir/examples/toy/Ch5/include/toy/AST.h b/mlir/examples/toy/Ch5/include/toy/AST.h --- a/mlir/examples/toy/Ch5/include/toy/AST.h +++ b/mlir/examples/toy/Ch5/include/toy/AST.h @@ -137,7 +137,7 @@ llvm::Optional getExpr() { if (expr.has_value()) return expr->get(); - return llvm::None; + return std::nullopt; } /// LLVM style RTTI diff --git a/mlir/examples/toy/Ch5/include/toy/Ops.td b/mlir/examples/toy/Ch5/include/toy/Ops.td --- a/mlir/examples/toy/Ch5/include/toy/Ops.td +++ b/mlir/examples/toy/Ch5/include/toy/Ops.td @@ -326,7 +326,7 @@ // Allow building a ReturnOp with no return operand. let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, llvm::None); }]> + OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> ]; // Provide extra utility definitions on the c++ operation class definition. diff --git a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp --- a/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch5/mlir/MLIRGen.cpp @@ -111,7 +111,7 @@ // Arguments type are uniformly unranked tensors. llvm::SmallVector argTypes(proto.getArgs().size(), getType(VarType{})); - auto funcType = builder.getFunctionType(argTypes, llvm::None); + auto funcType = builder.getFunctionType(argTypes, std::nullopt); return builder.create(location, proto.getName(), funcType); } diff --git a/mlir/examples/toy/Ch6/include/toy/AST.h b/mlir/examples/toy/Ch6/include/toy/AST.h --- a/mlir/examples/toy/Ch6/include/toy/AST.h +++ b/mlir/examples/toy/Ch6/include/toy/AST.h @@ -137,7 +137,7 @@ llvm::Optional getExpr() { if (expr.has_value()) return expr->get(); - return llvm::None; + return std::nullopt; } /// LLVM style RTTI diff --git a/mlir/examples/toy/Ch6/include/toy/Ops.td b/mlir/examples/toy/Ch6/include/toy/Ops.td --- a/mlir/examples/toy/Ch6/include/toy/Ops.td +++ b/mlir/examples/toy/Ch6/include/toy/Ops.td @@ -326,7 +326,7 @@ // Allow building a ReturnOp with no return operand. let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, llvm::None); }]> + OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> ]; // Provide extra utility definitions on the c++ operation class definition. diff --git a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp --- a/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch6/mlir/MLIRGen.cpp @@ -111,7 +111,7 @@ // Arguments type are uniformly unranked tensors. llvm::SmallVector argTypes(proto.getArgs().size(), getType(VarType{})); - auto funcType = builder.getFunctionType(argTypes, llvm::None); + auto funcType = builder.getFunctionType(argTypes, std::nullopt); return builder.create(location, proto.getName(), funcType); } diff --git a/mlir/examples/toy/Ch7/include/toy/AST.h b/mlir/examples/toy/Ch7/include/toy/AST.h --- a/mlir/examples/toy/Ch7/include/toy/AST.h +++ b/mlir/examples/toy/Ch7/include/toy/AST.h @@ -157,7 +157,7 @@ llvm::Optional getExpr() { if (expr.has_value()) return expr->get(); - return llvm::None; + return std::nullopt; } /// LLVM style RTTI diff --git a/mlir/examples/toy/Ch7/include/toy/Ops.td b/mlir/examples/toy/Ch7/include/toy/Ops.td --- a/mlir/examples/toy/Ch7/include/toy/Ops.td +++ b/mlir/examples/toy/Ch7/include/toy/Ops.td @@ -350,7 +350,7 @@ // Allow building a ReturnOp with no return operand. let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, llvm::None); }]> + OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> ]; // Provide extra utility definitions on the c++ operation class definition. diff --git a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp --- a/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp +++ b/mlir/examples/toy/Ch7/mlir/MLIRGen.cpp @@ -167,7 +167,7 @@ return nullptr; argTypes.push_back(type); } - auto funcType = builder.getFunctionType(argTypes, llvm::None); + auto funcType = builder.getFunctionType(argTypes, std::nullopt); return builder.create(location, proto.getName(), funcType); } @@ -277,19 +277,19 @@ // Lookup the struct node for the LHS. StructAST *structAST = getStructFor(accessOp.getLHS()); if (!structAST) - return llvm::None; + return std::nullopt; // Get the name from the RHS. VariableExprAST *name = llvm::dyn_cast(accessOp.getRHS()); if (!name) - return llvm::None; + return std::nullopt; auto structVars = structAST->getVariables(); const auto *it = llvm::find_if(structVars, [&](auto &var) { return var->getName() == name->getName(); }); if (it == structVars.end()) - return llvm::None; + return std::nullopt; return it - structVars.begin(); } @@ -426,10 +426,10 @@ for (auto &var : lit.getValues()) { if (auto *number = llvm::dyn_cast(var.get())) { attrElements.push_back(getConstantAttr(*number)); - typeElements.push_back(getType(llvm::None)); + typeElements.push_back(getType(std::nullopt)); } else if (auto *lit = llvm::dyn_cast(var.get())) { attrElements.push_back(getConstantAttr(*lit)); - typeElements.push_back(getType(llvm::None)); + typeElements.push_back(getType(std::nullopt)); } else { auto *structLit = llvm::cast(var.get()); auto attrTypePair = getConstantAttr(*structLit); diff --git a/mlir/include/mlir/AsmParser/AsmParserState.h b/mlir/include/mlir/AsmParser/AsmParserState.h --- a/mlir/include/mlir/AsmParser/AsmParserState.h +++ b/mlir/include/mlir/AsmParser/AsmParserState.h @@ -143,7 +143,7 @@ /// Finalize the most recently started operation definition. void finalizeOperationDefinition( Operation *op, SMRange nameLoc, SMLoc endLoc, - ArrayRef> resultGroups = llvm::None); + ArrayRef> resultGroups = std::nullopt); /// Start a definition for a region nested under the current operation. void startRegionDefinition(); diff --git a/mlir/include/mlir/CAPI/Wrap.h b/mlir/include/mlir/CAPI/Wrap.h --- a/mlir/include/mlir/CAPI/Wrap.h +++ b/mlir/include/mlir/CAPI/Wrap.h @@ -44,7 +44,7 @@ "incompatible C and C++ types"); if (size == 0) - return llvm::None; + return std::nullopt; assert(storage.empty() && "expected to populate storage"); storage.reserve(size); diff --git a/mlir/include/mlir/Conversion/MathToLibm/MathToLibm.h b/mlir/include/mlir/Conversion/MathToLibm/MathToLibm.h --- a/mlir/include/mlir/Conversion/MathToLibm/MathToLibm.h +++ b/mlir/include/mlir/Conversion/MathToLibm/MathToLibm.h @@ -21,7 +21,7 @@ /// If log1pBenefit is present, use it instead of benefit for the Log1p op. void populateMathToLibmConversionPatterns( RewritePatternSet &patterns, PatternBenefit benefit, - llvm::Optional log1pBenefit = llvm::None); + llvm::Optional log1pBenefit = std::nullopt); /// Create a pass to convert Math operations to libm calls. std::unique_ptr> createConvertMathToLibmPass(); diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h b/mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h --- a/mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h +++ b/mlir/include/mlir/Dialect/Affine/Analysis/AffineAnalysis.h @@ -143,7 +143,7 @@ Optional lb; // The upper bound of the dependence distance (inclusive). Optional ub; - DependenceComponent() : lb(llvm::None), ub(llvm::None) {} + DependenceComponent() : lb(std::nullopt), ub(llvm::None) {} }; /// Checks whether two accesses to the same memref access the same element. diff --git a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h --- a/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h +++ b/mlir/include/mlir/Dialect/Affine/Analysis/Utils.h @@ -110,7 +110,7 @@ bool isEmpty() const { return ivs.empty(); } /// Returns true if the computation slice encloses all the iterations of the - /// sliced loop nest. Returns false if it does not. Returns llvm::None if it + /// sliced loop nest. Returns false if it does not. Returns std::nullopt if it /// cannot determine if the slice is maximal or not. // TODO: Cache 'isMaximal' so that we don't recompute it when the slice // information hasn't changed. @@ -139,7 +139,7 @@ /// if each slice dimension maps to an existing dst dimension and both the src /// and the dst loops for those dimensions have the same bounds. Returns false /// if both the src and the dst loops don't have the same bounds. Returns - /// llvm::None if none of the above can be proven. + /// std::nullopt if none of the above can be proven. Optional isSliceMaximalFastCheck() const; }; diff --git a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td --- a/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td +++ b/mlir/include/mlir/Dialect/Affine/IR/AffineOps.td @@ -224,12 +224,12 @@ let skipDefaultBuilders = 1; let builders = [ OpBuilder<(ins "int64_t":$lowerBound, "int64_t":$upperBound, - CArg<"int64_t", "1">:$step, CArg<"ValueRange", "llvm::None">:$iterArgs, + CArg<"int64_t", "1">:$step, CArg<"ValueRange", "std::nullopt">:$iterArgs, CArg<"function_ref", "nullptr">:$bodyBuilder)>, OpBuilder<(ins "ValueRange":$lbOperands, "AffineMap":$lbMap, "ValueRange":$ubOperands, "AffineMap":$ubMap, CArg<"int64_t", "1">:$step, - CArg<"ValueRange", "llvm::None">:$iterArgs, + CArg<"ValueRange", "std::nullopt">:$iterArgs, CArg<"function_ref", "nullptr">:$bodyBuilder)> ]; @@ -925,7 +925,7 @@ let arguments = (ins Variadic:$operands); let builders = [ - OpBuilder<(ins), [{ build($_builder, $_state, llvm::None); }]> + OpBuilder<(ins), [{ build($_builder, $_state, std::nullopt); }]> ]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; diff --git a/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td b/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td --- a/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td +++ b/mlir/include/mlir/Dialect/Async/IR/AsyncOps.td @@ -281,7 +281,7 @@ let arguments = (ins Variadic:$operands); - let builders = [OpBuilder<(ins), [{build($_builder, $_state, llvm::None);}]>]; + let builders = [OpBuilder<(ins), [{build($_builder, $_state, std::nullopt);}]>]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; let hasVerifier = 1; diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td b/mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td --- a/mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td +++ b/mlir/include/mlir/Dialect/Bufferization/IR/AllocationOpInterface.td @@ -35,22 +35,22 @@ current allocation value (which refers to the current Op implementing this interface). The allocation value is a result of the current operation implementing this interface. If there is no compatible - deallocation operation, this method can return ::llvm::None. + deallocation operation, this method can return ::std::nullopt. }], "::mlir::Optional<::mlir::Operation*>", "buildDealloc", (ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}], - /*defaultImplementation=*/[{ return llvm::None; }] + /*defaultImplementation=*/[{ return std::nullopt; }] >, StaticInterfaceMethod<[{ Builds a clone operation using the provided builder and the current allocation value (which refers to the current Op implementing this interface). The allocation value is a result of the current operation implementing this interface. If there is no compatible clone operation, - this method can return ::llvm::None. + this method can return ::std::nullopt. }], "::mlir::Optional<::mlir::Value>", "buildClone", (ins "::mlir::OpBuilder&":$builder, "::mlir::Value":$alloc), [{}], - /*defaultImplementation=*/[{ return llvm::None; }] + /*defaultImplementation=*/[{ return std::nullopt; }] > ]; } diff --git a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h --- a/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h +++ b/mlir/include/mlir/Dialect/Bufferization/IR/BufferizableOpInterface.h @@ -230,7 +230,7 @@ bool bufferizeFunctionBoundaries = false; /// The default memory space that should be used when it cannot be inferred - /// from the context. If case of llvm::None, bufferization fails when the + /// from the context. If case of std::nullopt, bufferization fails when the /// memory space cannot be inferred at any point. Optional defaultMemorySpace = Attribute(); diff --git a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td --- a/mlir/include/mlir/Dialect/Func/IR/FuncOps.td +++ b/mlir/include/mlir/Dialect/Func/IR/FuncOps.td @@ -349,7 +349,7 @@ let arguments = (ins Variadic:$operands); let builders = [OpBuilder<(ins), [{ - build($_builder, $_state, llvm::None); + build($_builder, $_state, std::nullopt); }]>]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; diff --git a/mlir/include/mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h b/mlir/include/mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h --- a/mlir/include/mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h +++ b/mlir/include/mlir/Dialect/Func/Transforms/DecomposeCallGraphTypes.h @@ -72,7 +72,7 @@ SmallVectorImpl &newValues) -> Optional { if (T derivedType = type.dyn_cast()) return callback(builder, loc, derivedType, value, newValues); - return llvm::None; + return std::nullopt; }; } diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td @@ -273,7 +273,7 @@ llvm::MetadataAsValue::get(ctx, llvm::ValueAsMetadata::get(moduleTranslation.lookupValue(opInst.getOperand(0)))), llvm::MetadataAsValue::get(ctx, moduleTranslation.translateDebugInfo($varInfo)), - llvm::MetadataAsValue::get(ctx, llvm::DIExpression::get(ctx, llvm::None)), + llvm::MetadataAsValue::get(ctx, llvm::DIExpression::get(ctx, std::nullopt)), }); }]; let mlirBuilder = [{ diff --git a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h --- a/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h +++ b/mlir/include/mlir/Dialect/Linalg/Analysis/DependenceAnalysis.h @@ -76,29 +76,29 @@ return opView.get(); } // Return the indexing map of the operand/result in `opView` specified in - // the owning LinalgOp. If the owner is not a LinalgOp returns llvm::None. + // the owning LinalgOp. If the owner is not a LinalgOp returns std::nullopt. static Optional getIndexingMap(OpView opView) { auto owner = dyn_cast(getOwner(opView)); if (!owner) - return llvm::None; + return std::nullopt; if (OpOperand *operand = opView.dyn_cast()) return owner.getMatchingIndexingMap(operand); return owner.getMatchingIndexingMap(owner.getDpsInitOperand( opView.get().cast().getResultNumber())); } // Return the operand number if the `opView` is an OpOperand *. Otherwise - // return llvm::None. + // return std::nullopt. static Optional getOperandNumber(OpView opView) { if (OpOperand *operand = opView.dyn_cast()) return operand->getOperandNumber(); - return llvm::None; + return std::nullopt; } // Return the result number if the `opView` is an OpResult. Otherwise return - // llvm::None. + // std::nullopt. static Optional getResultNumber(OpView opView) { if (OpResult result = opView.dyn_cast().cast()) return result.getResultNumber(); - return llvm::None; + return std::nullopt; } // Return the owner of the dependent OpView. @@ -114,25 +114,25 @@ Value getIndexingValue() const { return getValue(indexingOpView); } // If the dependent OpView is an operand, return operand number. Return - // llvm::None otherwise. + // std::nullopt otherwise. Optional getDependentOpViewOperandNum() const { return getOperandNumber(dependentOpView); } // If the indexing OpView is an operand, return operand number. Return - // llvm::None otherwise. + // std::nullopt otherwise. Optional getIndexingOpViewOperandNum() const { return getOperandNumber(indexingOpView); } // If the dependent OpView is a result value, return the result - // number. Return llvm::None otherwise. + // number. Return std::nullopt otherwise. Optional getDependentOpViewResultNum() const { return getResultNumber(dependentOpView); } // If the dependent OpView is a result value, return the result - // number. Return llvm::None otherwise. + // number. Return std::nullopt otherwise. Optional getIndexingOpViewResultNum() const { return getResultNumber(indexingOpView); } diff --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h --- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h +++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h @@ -184,7 +184,7 @@ /// transformation returns early. /// /// Return a struct containing the tiled loops in the specified order -/// and the cloned op if successful, llvm::None otherwise. +/// and the cloned op if successful, std::nullopt otherwise. /// /// E.g. the permutation `(i,j,k) -> (j,k,i)` is expressed by /// `interchangeVector = [1,2,0]`. All values in `interchangeVector` must be diff --git a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h --- a/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h +++ b/mlir/include/mlir/Dialect/Linalg/Utils/Utils.h @@ -138,7 +138,7 @@ getReassociationMapForFoldingUnitDims(ArrayRef mixedSizes); /// Return the identity numeric value associated to the give op. Return -/// llvm::None if there is no known neutral element. +/// std::nullopt if there is no known neutral element. Optional getNeutralElement(Operation *op); //===----------------------------------------------------------------------===// @@ -222,7 +222,7 @@ /// number of values in `ivs`. /// /// Some of the `valuesToTile` won't be affected by tiling. For these values, -/// llvm::None will be returned. +/// std::nullopt will be returned. SmallVector> computeAllSliceParameters(OpBuilder &builder, Location loc, LinalgOp linalgOp, ValueRange valuesToTile, ArrayRef ivs, diff --git a/mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td b/mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td --- a/mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td +++ b/mlir/include/mlir/Dialect/MLProgram/IR/MLProgramOps.td @@ -457,7 +457,7 @@ let arguments = (ins Variadic:$operands); let builders = [OpBuilder<(ins), [{ - build($_builder, $_state, llvm::None); + build($_builder, $_state, std::nullopt); }]>]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; @@ -483,7 +483,7 @@ let arguments = (ins Variadic:$operands); let builders = [OpBuilder<(ins), [{ - build($_builder, $_state, llvm::None); + build($_builder, $_state, std::nullopt); }]>]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; diff --git a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td --- a/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td +++ b/mlir/include/mlir/Dialect/PDL/IR/PDLOps.td @@ -354,11 +354,11 @@ }]; let builders = [ - OpBuilder<(ins CArg<"Optional", "llvm::None">:$name, - CArg<"ValueRange", "llvm::None">:$operandValues, - CArg<"ArrayRef", "llvm::None">:$attrNames, - CArg<"ValueRange", "llvm::None">:$attrValues, - CArg<"ValueRange", "llvm::None">:$resultTypes), [{ + OpBuilder<(ins CArg<"Optional", "std::nullopt">:$name, + CArg<"ValueRange", "std::nullopt">:$operandValues, + CArg<"ArrayRef", "std::nullopt">:$attrNames, + CArg<"ValueRange", "std::nullopt">:$attrValues, + CArg<"ValueRange", "std::nullopt">:$resultTypes), [{ auto nameAttr = name ? $_builder.getStringAttr(*name) : StringAttr(); build($_builder, $_state, $_builder.getType(), nameAttr, operandValues, attrValues, $_builder.getStrArrayAttr(attrNames), @@ -420,7 +420,7 @@ let builders = [ OpBuilder<(ins CArg<"Optional", "1">:$benefit, - CArg<"Optional", "llvm::None">:$name)>, + CArg<"Optional", "std::nullopt">:$name)>, ]; let extraClassDeclaration = [{ //===------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td b/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td --- a/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td +++ b/mlir/include/mlir/Dialect/SCF/IR/SCFOps.td @@ -222,7 +222,7 @@ let skipDefaultBuilders = 1; let builders = [ OpBuilder<(ins "Value":$lowerBound, "Value":$upperBound, "Value":$step, - CArg<"ValueRange", "llvm::None">:$iterArgs, + CArg<"ValueRange", "std::nullopt">:$iterArgs, CArg<"function_ref", "nullptr">)> ]; @@ -273,13 +273,13 @@ return getOperation()->getNumOperands() - getNumControlOperands(); } /// Get the iter arg number for an operand. If it isnt an iter arg - /// operand return llvm::None. + /// operand return std::nullopt. Optional getIterArgNumberForOpOperand(OpOperand &opOperand) { if (opOperand.getOwner() != getOperation()) - return llvm::None; + return std::nullopt; unsigned operandNumber = opOperand.getOperandNumber(); if (operandNumber < getNumControlOperands()) - return llvm::None; + return std::nullopt; return operandNumber - getNumControlOperands(); } diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVAvailability.td @@ -68,7 +68,7 @@ "$overall = static_cast<" # scheme.returnType # ">(" "std::max(*$overall, $instance)); " "} else { $overall = $instance; }}"; - let initializer = "::llvm::None"; + let initializer = "::std::nullopt"; let instanceType = scheme.cppNamespace # "::" # scheme.enum.className; let instance = scheme.cppNamespace # "::" # scheme.enum.className # "::" # @@ -87,7 +87,7 @@ "$overall = static_cast<" # scheme.returnType # ">(" "std::min(*$overall, $instance)); " "} else { $overall = $instance; }}"; - let initializer = "::llvm::None"; + let initializer = "::std::nullopt"; let instanceType = scheme.cppNamespace # "::" # scheme.enum.className; let instance = scheme.cppNamespace # "::" # scheme.enum.className # "::" # diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVStructureOps.td @@ -490,11 +490,11 @@ let regions = (region AnyRegion); let builders = [ - OpBuilder<(ins CArg<"Optional", "llvm::None">:$name)>, + OpBuilder<(ins CArg<"Optional", "std::nullopt">:$name)>, OpBuilder<(ins "spirv::AddressingModel":$addressing_model, "spirv::MemoryModel":$memory_model, - CArg<"Optional", "llvm::None">:$vce_triple, - CArg<"Optional", "llvm::None">:$name)> + CArg<"Optional", "std::nullopt">:$vce_triple, + CArg<"Optional", "std::nullopt">:$name)> ]; // We need to ensure the block inside the region is properly terminated; diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h --- a/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h +++ b/mlir/include/mlir/Dialect/SPIRV/IR/SPIRVTypes.h @@ -56,7 +56,7 @@ /// the given `storage` class. This method does not guarantee the uniqueness /// of extensions; the same extension may be appended multiple times. void getExtensions(ExtensionArrayRefVector &extensions, - Optional storage = llvm::None); + Optional storage = std::nullopt); /// The capability requirements for each type are following the /// ((Capability::A OR Extension::B) AND (Capability::C OR Capability::D)) @@ -68,10 +68,10 @@ /// uniqueness of capabilities; the same capability may be appended multiple /// times. void getCapabilities(CapabilityArrayRefVector &capabilities, - Optional storage = llvm::None); + Optional storage = std::nullopt); /// Returns the size in bytes for each type. If no size can be calculated, - /// returns `llvm::None`. Note that if the type has explicit layout, it is + /// returns `std::nullopt`. Note that if the type has explicit layout, it is /// also taken into account in calculation. Optional getSizeInBytes(); }; @@ -89,9 +89,9 @@ static bool isValid(IntegerType); void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, - Optional storage = llvm::None); + Optional storage = std::nullopt); void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, - Optional storage = llvm::None); + Optional storage = std::nullopt); Optional getSizeInBytes(); }; @@ -117,9 +117,9 @@ bool hasCompileTimeKnownNumElements() const; void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, - Optional storage = llvm::None); + Optional storage = std::nullopt); void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, - Optional storage = llvm::None); + Optional storage = std::nullopt); Optional getSizeInBytes(); }; @@ -145,9 +145,9 @@ unsigned getArrayStride() const; void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, - Optional storage = llvm::None); + Optional storage = std::nullopt); void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, - Optional storage = llvm::None); + Optional storage = std::nullopt); /// Returns the array size in bytes. Since array type may have an explicit /// stride declaration (in bytes), we also include it in the calculation. @@ -188,9 +188,9 @@ // TODO: Add support for Access qualifier void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, - Optional storage = llvm::None); + Optional storage = std::nullopt); void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, - Optional storage = llvm::None); + Optional storage = std::nullopt); }; // SPIR-V pointer type @@ -206,9 +206,9 @@ StorageClass getStorageClass() const; void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, - Optional storage = llvm::None); + Optional storage = std::nullopt); void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, - Optional storage = llvm::None); + Optional storage = std::nullopt); }; // SPIR-V run-time array type @@ -230,9 +230,9 @@ unsigned getArrayStride() const; void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, - Optional storage = llvm::None); + Optional storage = std::nullopt); void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, - Optional storage = llvm::None); + Optional storage = std::nullopt); }; // SPIR-V sampled image type @@ -253,9 +253,9 @@ Type getImageType() const; void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, - Optional storage = llvm::None); + Optional storage = std::nullopt); void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, - Optional storage = llvm::None); + Optional storage = std::nullopt); }; /// SPIR-V struct type. Two kinds of struct types are supported: @@ -389,9 +389,9 @@ ArrayRef memberDecorations = {}); void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, - Optional storage = llvm::None); + Optional storage = std::nullopt); void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, - Optional storage = llvm::None); + Optional storage = std::nullopt); }; llvm::hash_code @@ -416,9 +416,9 @@ unsigned getColumns() const; void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, - Optional storage = llvm::None); + Optional storage = std::nullopt); void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, - Optional storage = llvm::None); + Optional storage = std::nullopt); }; // SPIR-V joint matrix type @@ -443,9 +443,9 @@ MatrixLayout getMatrixLayout() const; void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, - Optional storage = llvm::None); + Optional storage = std::nullopt); void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, - Optional storage = llvm::None); + Optional storage = std::nullopt); }; // SPIR-V matrix type @@ -480,9 +480,9 @@ Type getElementType() const; void getExtensions(SPIRVType::ExtensionArrayRefVector &extensions, - Optional storage = llvm::None); + Optional storage = std::nullopt); void getCapabilities(SPIRVType::CapabilityArrayRefVector &capabilities, - Optional storage = llvm::None); + Optional storage = std::nullopt); }; } // namespace spirv diff --git a/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h b/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h --- a/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h +++ b/mlir/include/mlir/Dialect/SPIRV/IR/TargetAndABI.h @@ -34,13 +34,13 @@ /// Returns true if the given capability is allowed. bool allows(Capability) const; /// Returns the first allowed one if any of the given capabilities is allowed. - /// Returns llvm::None otherwise. + /// Returns std::nullopt otherwise. Optional allows(ArrayRef) const; /// Returns true if the given extension is allowed. bool allows(Extension) const; /// Returns the first allowed one if any of the given extensions is allowed. - /// Returns llvm::None otherwise. + /// Returns std::nullopt otherwise. Optional allows(ArrayRef) const; /// Returns the vendor ID. diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td --- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td +++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td @@ -752,7 +752,7 @@ let arguments = (ins Variadic:$operands); let builders = [OpBuilder<(ins), - [{ build($_builder, $_state, llvm::None); }]> + [{ build($_builder, $_state, std::nullopt); }]> ]; let assemblyFormat = "attr-dict ($operands^ `:` type($operands))?"; diff --git a/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h b/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h --- a/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h +++ b/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h @@ -174,9 +174,9 @@ dimTypes(numTensors, std::vector(numLoops, DimLevelType::Undef)), loopIdxToDim(numTensors, - std::vector>(numLoops, llvm::None)), + std::vector>(numLoops, std::nullopt)), dimToLoopIdx(numTensors, - std::vector>(numLoops, llvm::None)) {} + std::vector>(numLoops, std::nullopt)) {} /// Adds a tensor expression. Returns its index. unsigned addExp(Kind k, unsigned e0, unsigned e1 = -1u, Value v = Value(), diff --git a/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td b/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td --- a/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td +++ b/mlir/include/mlir/Dialect/Tensor/IR/TensorOps.td @@ -1765,7 +1765,7 @@ OpBuilder<(ins "Value":$source, "Value":$dest, "ArrayRef":$innerDimsPos, "ArrayRef":$innerTiles, - CArg<"Optional", "llvm::None">:$paddingValue, + CArg<"Optional", "std::nullopt">:$paddingValue, CArg<"ArrayRef", "{}">:$outerDimsPerm)> ]; diff --git a/mlir/include/mlir/Dialect/Tosa/Utils/CoversionUtils.h b/mlir/include/mlir/Dialect/Tosa/Utils/CoversionUtils.h --- a/mlir/include/mlir/Dialect/Tosa/Utils/CoversionUtils.h +++ b/mlir/include/mlir/Dialect/Tosa/Utils/CoversionUtils.h @@ -68,7 +68,7 @@ if (llvm::any_of(dynTy.getShape().drop_front(), ShapedType::isDynamic)) { (void)rewriter.notifyMatchFailure( op, "input can only be dynamic for batch size"); - return llvm::None; + return std::nullopt; } } diff --git a/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h b/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h --- a/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h +++ b/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h @@ -149,7 +149,7 @@ /// Attaches a note to the last diagnostic. /// Expects this object to be a silenceable failure. - Diagnostic &attachNote(Optional loc = llvm::None) { + Diagnostic &attachNote(Optional loc = std::nullopt) { assert(isSilenceableFailure() && "can only attach notes to silenceable failures"); return diagnostics.back().attachNote(loc); @@ -212,7 +212,7 @@ } /// Attaches a note to the error. - Diagnostic &attachNote(Optional loc = llvm::None) { + Diagnostic &attachNote(Optional loc = std::nullopt) { return diag.attachNote(loc); } diff --git a/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h b/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h --- a/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h +++ b/mlir/include/mlir/Dialect/Utils/ReshapeOpsUtils.h @@ -64,7 +64,7 @@ OpBuilder &b, ArrayRef reassociationExprs); /// Return the reassociations maps to use to reshape given the source type and -/// the target type when possible. Return llvm::None when this computation +/// the target type when possible. Return std::nullopt when this computation /// failed. Optional> getReassociationIndicesForReshape(ShapedType sourceType, ShapedType targetType); @@ -360,14 +360,14 @@ if (srcSubShape == resultSubShape) composedReassociation.push_back(srcIndices); else - return llvm::None; + return std::nullopt; } // Find reassociation to collapse `srcSubShape` into `resultSubShape`. auto subShapeReassociation = getReassociationIndicesForCollapse(srcSubShape, resultSubShape); if (!subShapeReassociation) - return llvm::None; + return std::nullopt; // Remap the subshape indices back to the original srcShape. for (auto &subshape_indices : *subShapeReassociation) { diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h --- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h +++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h @@ -118,7 +118,7 @@ /// VectorToSCF, which reduces the rank of vector transfer ops. void populateVectorTransferLoweringPatterns( RewritePatternSet &patterns, - llvm::Optional maxTransferRank = llvm::None, + llvm::Optional maxTransferRank = std::nullopt, PatternBenefit benefit = 1); /// These patterns materialize masks for various vector ops such as transfers. diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td --- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td +++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td @@ -537,7 +537,7 @@ Note that this instruction resembles vector.extract, but is restricted to 0-D and 1-D vectors and relaxed to dynamic indices. - If the vector is 0-D, the position must be llvm::None. + If the vector is 0-D, the position must be std::nullopt. It is meant to be closer to LLVM's version: @@ -1351,19 +1351,19 @@ "Value":$source, "ValueRange":$indices, "AffineMap":$permutationMap, - CArg<"Optional>", "::llvm::None">:$inBounds)>, + CArg<"Optional>", "::std::nullopt">:$inBounds)>, /// 3. Builder that sets permutation map to 'getMinorIdentityMap'. OpBuilder<(ins "VectorType":$vectorType, "Value":$source, "ValueRange":$indices, "Value":$padding, - CArg<"Optional>", "::llvm::None">:$inBounds)>, + CArg<"Optional>", "::std::nullopt">:$inBounds)>, /// 4. Builder that sets padding to zero and permutation map to /// 'getMinorIdentityMap'. OpBuilder<(ins "VectorType":$vectorType, "Value":$source, "ValueRange":$indices, - CArg<"Optional>", "::llvm::None">:$inBounds)>, + CArg<"Optional>", "::std::nullopt">:$inBounds)>, ]; let extraClassDeclaration = [{ @@ -1500,13 +1500,13 @@ "Value":$dest, "ValueRange":$indices, "AffineMap":$permutationMap, - CArg<"Optional>", "::llvm::None">:$inBounds)>, + CArg<"Optional>", "::std::nullopt">:$inBounds)>, /// 4. Builder with type inference that sets an empty mask and sets permutation /// map to 'getMinorIdentityMap'. OpBuilder<(ins "Value":$vector, "Value":$dest, "ValueRange":$indices, - CArg<"Optional>", "::llvm::None">:$inBounds)>, + CArg<"Optional>", "::std::nullopt">:$inBounds)>, ]; let extraClassDeclaration = [{ diff --git a/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td b/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td --- a/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td +++ b/mlir/include/mlir/Dialect/Vector/Interfaces/MaskableOpInterface.td @@ -63,7 +63,7 @@ /*defaultImplementation=*/[{ // Default implementation is only aimed for operations that implement the // `getVectorType()` method. - return $_op.getVectorType().cloneWith(/*shape=*/llvm::None, + return $_op.getVectorType().cloneWith(/*shape=*/std::nullopt, IntegerType::get($_op.getContext(), /*width=*/1)); }]>, ]; diff --git a/mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h b/mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h --- a/mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h +++ b/mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h @@ -113,7 +113,8 @@ using NativeShapeFnType = std::function>(Operation *op)>; /// Function that returns the shape of the vector to unroll to for a given - /// operation. The unrolling is aborted if the function returns `llvm::None`. + /// operation. The unrolling is aborted if the function returns + /// `std::nullopt`. NativeShapeFnType nativeShape = nullptr; UnrollVectorOptions &setNativeShapeFn(NativeShapeFnType fn) { nativeShape = std::move(fn); diff --git a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h --- a/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h +++ b/mlir/include/mlir/ExecutionEngine/ExecutionEngine.h @@ -67,7 +67,7 @@ /// `jitCodeGenOptLevel`, when provided, is used as the optimization level for /// target code generation. - Optional jitCodeGenOptLevel = llvm::None; + Optional jitCodeGenOptLevel = std::nullopt; /// If `sharedLibPaths` are provided, the underlying JIT-compilation will /// open and link the shared libraries for symbol resolution. @@ -123,7 +123,7 @@ /// Invokes the function with the given name passing it the list of opaque /// pointers to the actual arguments. llvm::Error invokePacked(StringRef name, - MutableArrayRef args = llvm::None); + MutableArrayRef args = std::nullopt); /// Trait that defines how a given type is passed to the JIT code. This /// defaults to passing the address but can be specialized. diff --git a/mlir/include/mlir/IR/BlockSupport.h b/mlir/include/mlir/IR/BlockSupport.h --- a/mlir/include/mlir/IR/BlockSupport.h +++ b/mlir/include/mlir/IR/BlockSupport.h @@ -106,7 +106,7 @@ Block *, Block *, Block *> { public: using RangeBaseT::RangeBaseT; - BlockRange(ArrayRef blocks = llvm::None); + BlockRange(ArrayRef blocks = std::nullopt); BlockRange(SuccessorRange successors); template , Arg>::value>> diff --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h --- a/mlir/include/mlir/IR/Builders.h +++ b/mlir/include/mlir/IR/Builders.h @@ -408,15 +408,15 @@ /// 'parent'. `locs` contains the locations of the inserted arguments, and /// should match the size of `argTypes`. Block *createBlock(Region *parent, Region::iterator insertPt = {}, - TypeRange argTypes = llvm::None, - ArrayRef locs = llvm::None); + TypeRange argTypes = std::nullopt, + ArrayRef locs = std::nullopt); /// Add new block with 'argTypes' arguments and set the insertion point to the /// end of it. The block is placed before 'insertBefore'. `locs` contains the /// locations of the inserted arguments, and should match the size of /// `argTypes`. - Block *createBlock(Block *insertBefore, TypeRange argTypes = llvm::None, - ArrayRef locs = llvm::None); + Block *createBlock(Block *insertBefore, TypeRange argTypes = std::nullopt, + ArrayRef locs = std::nullopt); //===--------------------------------------------------------------------===// // Operation Creation diff --git a/mlir/include/mlir/IR/BuiltinAttributeInterfaces.h b/mlir/include/mlir/IR/BuiltinAttributeInterfaces.h --- a/mlir/include/mlir/IR/BuiltinAttributeInterfaces.h +++ b/mlir/include/mlir/IR/BuiltinAttributeInterfaces.h @@ -312,7 +312,7 @@ FailureOr indexer = getValuesImpl(TypeID::get()); if (failed(indexer)) - return llvm::None; + return std::nullopt; return iterator(std::move(*indexer), 0); } } // namespace mlir. diff --git a/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td b/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td --- a/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td +++ b/mlir/include/mlir/IR/BuiltinAttributeInterfaces.td @@ -393,23 +393,23 @@ // Failable Value Iteration /// If this attribute supports iterating over element values of type `T`, - /// return the iterable range. Otherwise, return llvm::None. + /// return the iterable range. Otherwise, return std::nullopt. template DefaultValueCheckT>> tryGetValues() const { if (Optional> beginIt = try_value_begin()) return iterator_range(getType(), *beginIt, value_end()); - return llvm::None; + return std::nullopt; } template DefaultValueCheckT>> try_value_begin() const; /// If this attribute supports iterating over element values of type `T`, - /// return the iterable range. Otherwise, return llvm::None. + /// return the iterable range. Otherwise, return std::nullopt. template > Optional> tryGetValues() const { auto values = tryGetValues(); if (!values) - return llvm::None; + return std::nullopt; auto castFn = [](Attribute attr) { return attr.template cast(); }; return DerivedAttrValueIteratorRange( @@ -421,7 +421,7 @@ Optional> try_value_begin() const { if (auto values = tryGetValues()) return values->begin(); - return llvm::None; + return std::nullopt; } }] # ElementsAttrInterfaceAccessors; } diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td --- a/mlir/include/mlir/IR/BuiltinAttributes.td +++ b/mlir/include/mlir/IR/BuiltinAttributes.td @@ -534,7 +534,7 @@ }]; let parameters = (ins ArrayRefParameter<"NamedAttribute", "">:$value); let builders = [ - AttrBuilder<(ins CArg<"ArrayRef", "llvm::None">:$value)> + AttrBuilder<(ins CArg<"ArrayRef", "std::nullopt">:$value)> ]; let extraClassDeclaration = [{ using ValueType = ArrayRef; @@ -576,7 +576,7 @@ static bool sortInPlace(SmallVectorImpl &array); /// Returns an entry with a duplicate name in `array`, if it exists, else - /// returns llvm::None. If `isSorted` is true, the array is assumed to be + /// returns std::nullopt. If `isSorted` is true, the array is assumed to be /// sorted else it will be sorted in place before finding the duplicate entry. static Optional findDuplicate(SmallVectorImpl &array, bool isSorted); diff --git a/mlir/include/mlir/IR/BuiltinOps.td b/mlir/include/mlir/IR/BuiltinOps.td --- a/mlir/include/mlir/IR/BuiltinOps.td +++ b/mlir/include/mlir/IR/BuiltinOps.td @@ -61,7 +61,7 @@ let builders = [OpBuilder<(ins CArg<"Optional", "{}">:$name)>]; let extraClassDeclaration = [{ /// Construct a module from the given location with an optional name. - static ModuleOp create(Location loc, Optional name = llvm::None); + static ModuleOp create(Location loc, Optional name = std::nullopt); /// Return the name of this module if present. Optional getName() { return getSymName(); } diff --git a/mlir/include/mlir/IR/BuiltinTypeInterfaces.td b/mlir/include/mlir/IR/BuiltinTypeInterfaces.td --- a/mlir/include/mlir/IR/BuiltinTypeInterfaces.td +++ b/mlir/include/mlir/IR/BuiltinTypeInterfaces.td @@ -121,7 +121,7 @@ } /// Return a clone of this type with the given new element type. auto clone(::mlir::Type elementType) { - return $_type.cloneWith(/*shape=*/llvm::None, elementType); + return $_type.cloneWith(/*shape=*/std::nullopt, elementType); } /// If an element type is an integer or a float, return its width. Otherwise, diff --git a/mlir/include/mlir/IR/BuiltinTypes.td b/mlir/include/mlir/IR/BuiltinTypes.td --- a/mlir/include/mlir/IR/BuiltinTypes.td +++ b/mlir/include/mlir/IR/BuiltinTypes.td @@ -880,7 +880,7 @@ using ShapedType::Trait::getDimSize; using ShapedType::Trait::getDynamicDimIndex; - ArrayRef getShape() const { return llvm::None; } + ArrayRef getShape() const { return std::nullopt; } /// [deprecated] Returns the memory space in old raw integer representation. /// New `Attribute getMemorySpace()` method should be used instead. @@ -933,7 +933,7 @@ using ShapedType::Trait::getDimSize; using ShapedType::Trait::getDynamicDimIndex; - ArrayRef getShape() const { return llvm::None; } + ArrayRef getShape() const { return std::nullopt; } }]; let skipDefaultBuilders = 1; let genVerifyDecl = 1; diff --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h --- a/mlir/include/mlir/IR/Diagnostics.h +++ b/mlir/include/mlir/IR/Diagnostics.h @@ -244,7 +244,7 @@ /// Attaches a note to this diagnostic. A new location may be optionally /// provided, if not, then the location defaults to the one specified for this /// diagnostic. Notes may not be attached to other notes. - Diagnostic &attachNote(Optional noteLoc = llvm::None); + Diagnostic &attachNote(Optional noteLoc = std::nullopt); using note_iterator = llvm::pointee_iterator; using const_note_iterator = @@ -342,7 +342,7 @@ } /// Attaches a note to this diagnostic. - Diagnostic &attachNote(Optional noteLoc = llvm::None) { + Diagnostic &attachNote(Optional noteLoc = std::nullopt) { assert(isActive() && "diagnostic not active"); return impl->attachNote(noteLoc); } diff --git a/mlir/include/mlir/IR/DialectImplementation.h b/mlir/include/mlir/IR/DialectImplementation.h --- a/mlir/include/mlir/IR/DialectImplementation.h +++ b/mlir/include/mlir/IR/DialectImplementation.h @@ -118,7 +118,7 @@ return {Optional(value)}; return failure(); } - return {llvm::None}; + return {std::nullopt}; } }; diff --git a/mlir/include/mlir/IR/FunctionInterfaces.h b/mlir/include/mlir/IR/FunctionInterfaces.h --- a/mlir/include/mlir/IR/FunctionInterfaces.h +++ b/mlir/include/mlir/IR/FunctionInterfaces.h @@ -62,13 +62,13 @@ /// Return all of the attributes for the argument at 'index'. inline ArrayRef getArgAttrs(Operation *op, unsigned index) { auto argDict = getArgAttrDict(op, index); - return argDict ? argDict.getValue() : llvm::None; + return argDict ? argDict.getValue() : std::nullopt; } /// Return all of the attributes for the result at 'index'. inline ArrayRef getResultAttrs(Operation *op, unsigned index) { auto resultDict = getResultAttrDict(op, index); - return resultDict ? resultDict.getValue() : llvm::None; + return resultDict ? resultDict.getValue() : std::nullopt; } /// Insert the specified arguments and update the function type attribute. diff --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h --- a/mlir/include/mlir/IR/Matchers.h +++ b/mlir/include/mlir/IR/Matchers.h @@ -77,7 +77,7 @@ // Fold the constant to an attribute. SmallVector foldedOp; - LogicalResult result = op->fold(/*operands=*/llvm::None, foldedOp); + LogicalResult result = op->fold(/*operands=*/std::nullopt, foldedOp); (void)result; assert(succeeded(result) && "expected ConstantLike op to be foldable"); diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -1035,7 +1035,7 @@ let storageType = attr.storageType; let returnType = "::llvm::Optional<" # attr.returnType #">"; let convertFromStorage = "$_self ? " # returnType # "(" # - attr.convertFromStorage # ") : (::llvm::None)"; + attr.convertFromStorage # ") : (::std::nullopt)"; let valueType = attr.valueType; let isOptional = 1; diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -41,7 +41,7 @@ OptionalParseResult(ParseResult result) : impl(result) {} OptionalParseResult(const InFlightDiagnostic &) : OptionalParseResult(failure()) {} - OptionalParseResult(std::nullopt_t) : impl(llvm::None) {} + OptionalParseResult(std::nullopt_t) : impl(std::nullopt) {} /// Returns true if we contain a valid ParseResult value. bool has_value() const { return impl.has_value(); } @@ -94,7 +94,7 @@ MLIRContext *getContext() { return getOperation()->getContext(); } /// Print the operation to the given stream. - void print(raw_ostream &os, OpPrintingFlags flags = llvm::None) { + void print(raw_ostream &os, OpPrintingFlags flags = std::nullopt) { state->print(os, flags); } void print(raw_ostream &os, AsmState &asmState) { diff --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h --- a/mlir/include/mlir/IR/OpImplementation.h +++ b/mlir/include/mlir/IR/OpImplementation.h @@ -1334,12 +1334,12 @@ /// skip parsing that component. virtual ParseResult parseGenericOperationAfterOpName( OperationState &result, - Optional> parsedOperandType = llvm::None, - Optional> parsedSuccessors = llvm::None, + Optional> parsedOperandType = std::nullopt, + Optional> parsedSuccessors = std::nullopt, Optional>> parsedRegions = - llvm::None, - Optional> parsedAttributes = llvm::None, - Optional parsedFnType = llvm::None) = 0; + std::nullopt, + Optional> parsedAttributes = std::nullopt, + Optional parsedFnType = std::nullopt) = 0; /// Parse a single SSA value operand name along with a result number if /// `allowResultNumber` is true. diff --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h --- a/mlir/include/mlir/IR/Operation.h +++ b/mlir/include/mlir/IR/Operation.h @@ -240,7 +240,7 @@ /// take O(N) where N is the number of operations within the parent block. bool isBeforeInBlock(Operation *other); - void print(raw_ostream &os, const OpPrintingFlags &flags = llvm::None); + void print(raw_ostream &os, const OpPrintingFlags &flags = std::nullopt); void print(raw_ostream &os, AsmState &state); void dump(); diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h --- a/mlir/include/mlir/IR/OperationSupport.h +++ b/mlir/include/mlir/IR/OperationSupport.h @@ -88,7 +88,7 @@ /// may not be populated. struct Impl { Impl(StringAttr name) - : name(name), dialect(nullptr), interfaceMap(llvm::None) {} + : name(name), dialect(nullptr), interfaceMap(std::nullopt) {} /// The name of the operation. StringAttr name; @@ -554,7 +554,7 @@ void pop_back() { attrs.pop_back(); } /// Returns an entry with a duplicate name the list, if it exists, else - /// returns llvm::None. + /// returns std::nullopt. Optional findDuplicate() const; /// Return a dictionary attribute for the underlying dictionary. This will diff --git a/mlir/include/mlir/IR/PatternMatch.h b/mlir/include/mlir/IR/PatternMatch.h --- a/mlir/include/mlir/IR/PatternMatch.h +++ b/mlir/include/mlir/IR/PatternMatch.h @@ -92,7 +92,7 @@ Optional getRootKind() const { if (rootKind == RootKind::OperationName) return OperationName::getFromOpaquePointer(rootValue); - return llvm::None; + return std::nullopt; } /// Return the interface ID used to match the root operation of this pattern. @@ -101,7 +101,7 @@ Optional getRootInterfaceID() const { if (rootKind == RootKind::InterfaceID) return TypeID::getFromOpaquePointer(rootValue); - return llvm::None; + return std::nullopt; } /// Return the trait ID used to match the root operation of this pattern. @@ -110,7 +110,7 @@ Optional getRootTraitID() const { if (rootKind == RootKind::TraitID) return TypeID::getFromOpaquePointer(rootValue); - return llvm::None; + return std::nullopt; } /// Return the benefit (the inverse of "cost") of matching this pattern. The @@ -465,12 +465,12 @@ /// 'argValues' is used to replace the block arguments of 'source' after /// merging. virtual void mergeBlocks(Block *source, Block *dest, - ValueRange argValues = llvm::None); + ValueRange argValues = std::nullopt); // Merge the operations of block 'source' before the operation 'op'. Source // block should not have existing predecessors or successors. void mergeBlockBefore(Block *source, Operation *op, - ValueRange argValues = llvm::None); + ValueRange argValues = std::nullopt); /// Split the operations starting at "before" (inclusive) out of the given /// block into a new block, and return it. @@ -1587,7 +1587,8 @@ RewritePatternSet &add(ConstructorArg &&arg, ConstructorArgs &&...args) { // The following expands a call to emplace_back for each of the pattern // types 'Ts'. - (addImpl(/*debugLabels=*/llvm::None, std::forward(arg), + (addImpl(/*debugLabels=*/std::nullopt, + std::forward(arg), std::forward(args)...), ...); return *this; @@ -1666,7 +1667,7 @@ RewritePatternSet &insert(ConstructorArg &&arg, ConstructorArgs &&...args) { // The following expands a call to emplace_back for each of the pattern // types 'Ts'. - (addImpl(/*debugLabels=*/llvm::None, arg, args...), ...); + (addImpl(/*debugLabels=*/std::nullopt, arg, args...), ...); return *this; } diff --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h --- a/mlir/include/mlir/IR/Region.h +++ b/mlir/include/mlir/IR/Region.h @@ -338,7 +338,7 @@ public: using RangeBaseT::RangeBaseT; - RegionRange(MutableArrayRef regions = llvm::None); + RegionRange(MutableArrayRef regions = std::nullopt); template >, Arg>::value>> diff --git a/mlir/include/mlir/IR/SubElementInterfaces.h b/mlir/include/mlir/IR/SubElementInterfaces.h --- a/mlir/include/mlir/IR/SubElementInterfaces.h +++ b/mlir/include/mlir/IR/SubElementInterfaces.h @@ -71,7 +71,7 @@ /// /// * Optional(T) /// - This either returns a valid Attribute/Type in the case of success, - /// nullptr in the case of failure, or `llvm::None` to signify that + /// nullptr in the case of failure, or `std::nullopt` to signify that /// additional replacement functions may be applied (i.e. this function /// doesn't handle that instance). /// diff --git a/mlir/include/mlir/IR/SymbolTable.h b/mlir/include/mlir/IR/SymbolTable.h --- a/mlir/include/mlir/IR/SymbolTable.h +++ b/mlir/include/mlir/IR/SymbolTable.h @@ -301,7 +301,7 @@ /// Return the users of the provided symbol operation. ArrayRef getUsers(Operation *symbol) const { auto it = symbolToUsers.find(symbol); - return it != symbolToUsers.end() ? it->second.getArrayRef() : llvm::None; + return it != symbolToUsers.end() ? it->second.getArrayRef() : std::nullopt; } /// Return true if the given symbol has no uses. diff --git a/mlir/include/mlir/IR/TypeRange.h b/mlir/include/mlir/IR/TypeRange.h --- a/mlir/include/mlir/IR/TypeRange.h +++ b/mlir/include/mlir/IR/TypeRange.h @@ -36,7 +36,7 @@ Type, Type, Type> { public: using RangeBaseT::RangeBaseT; - TypeRange(ArrayRef types = llvm::None); + TypeRange(ArrayRef types = std::nullopt); explicit TypeRange(OperandRange values); explicit TypeRange(ResultRange values); explicit TypeRange(ValueRange values); diff --git a/mlir/include/mlir/IR/ValueRange.h b/mlir/include/mlir/IR/ValueRange.h --- a/mlir/include/mlir/IR/ValueRange.h +++ b/mlir/include/mlir/IR/ValueRange.h @@ -122,13 +122,13 @@ /// and range length. `operandSegments` is an optional set of operand segments /// to be updated when mutating the operand list. MutableOperandRange(Operation *owner, unsigned start, unsigned length, - ArrayRef operandSegments = llvm::None); + ArrayRef operandSegments = std::nullopt); MutableOperandRange(Operation *owner); /// Slice this range into a sub range, with the additional operand segment. MutableOperandRange slice(unsigned subStart, unsigned subLen, - Optional segment = llvm::None) const; + Optional segment = std::nullopt) const; /// Append the given values to the range. void append(ValueRange values); @@ -369,7 +369,7 @@ : ValueRange(ResultRange(values)) {} ValueRange(ArrayRef values) : ValueRange(ArrayRef(values.data(), values.size())) {} - ValueRange(ArrayRef values = llvm::None); + ValueRange(ArrayRef values = std::nullopt); ValueRange(OperandRange values); ValueRange(ResultRange values); diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h --- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h +++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.h @@ -202,7 +202,7 @@ /// Returns the unknown invocation bounds, i.e., there is no information on /// how many times a region may be invoked. - static InvocationBounds getUnknown() { return {0, llvm::None}; } + static InvocationBounds getUnknown() { return {0, std::nullopt}; } private: /// The minimum number of times the successor region will be invoked. @@ -237,9 +237,9 @@ /// Returns the mutable operands that are passed to the region with the given /// `regionIndex`. If the operation does not implement the /// `RegionBranchTerminatorOpInterface` and is not marked as `ReturnLike`, the -/// result will be `llvm::None`. In all other cases, the resulting +/// result will be `std::nullopt`. In all other cases, the resulting /// `OperandRange` represents all operands that are passed to the specified -/// successor region. If `regionIndex` is `llvm::None`, all operands that are +/// successor region. If `regionIndex` is `std::nullopt`, all operands that are /// passed to the parent operation will be returned. Optional getMutableRegionBranchSuccessorOperands(Operation *operation, diff --git a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td --- a/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td +++ b/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td @@ -79,7 +79,7 @@ opaqueOp->getSuccessor(i))) return arg; } - return ::llvm::None; + return ::std::nullopt; }] >, InterfaceMethod<[{ @@ -171,7 +171,7 @@ regions yield normally, i.e. do not abort or invoke an infinite loop). The minimum number of invocations is at least 0. If the maximum number of invocations cannot be statically determined, then it will not have a - value (i.e., it is set to `llvm::None`). + value (i.e., it is set to `std::nullopt`). `operands` is a set of optional attributes that either correspond to constant values for each operand of this operation or null if that diff --git a/mlir/include/mlir/Interfaces/LoopLikeInterface.td b/mlir/include/mlir/Interfaces/LoopLikeInterface.td --- a/mlir/include/mlir/Interfaces/LoopLikeInterface.td +++ b/mlir/include/mlir/Interfaces/LoopLikeInterface.td @@ -50,50 +50,50 @@ >, InterfaceMethod<[{ If there is a single induction variable return it, otherwise return - llvm::None. + std::nullopt. }], /*retTy=*/"::llvm::Optional<::mlir::Value>", /*methodName=*/"getSingleInductionVar", /*args=*/(ins), /*methodBody=*/"", /*defaultImplementation=*/[{ - return llvm::None; + return std::nullopt; }] >, InterfaceMethod<[{ Return the single lower bound value or attribute if it exists, otherwise - return llvm::None. + return std::nullopt. }], /*retTy=*/"::llvm::Optional<::mlir::OpFoldResult>", /*methodName=*/"getSingleLowerBound", /*args=*/(ins), /*methodBody=*/"", /*defaultImplementation=*/[{ - return llvm::None; + return std::nullopt; }] >, InterfaceMethod<[{ Return the single step value or attribute if it exists, otherwise - return llvm::None. + return std::nullopt. }], /*retTy=*/"::llvm::Optional<::mlir::OpFoldResult>", /*methodName=*/"getSingleStep", /*args=*/(ins), /*methodBody=*/"", /*defaultImplementation=*/[{ - return llvm::None; + return std::nullopt; }] >, InterfaceMethod<[{ Return the single upper bound value or attribute if it exists, otherwise - return llvm::None. + return std::nullopt. }], /*retTy=*/"::llvm::Optional<::mlir::OpFoldResult>", /*methodName=*/"getSingleUpperBound", /*args=*/(ins), /*methodBody=*/"", /*defaultImplementation=*/[{ - return llvm::None; + return std::nullopt; }] >, ]; diff --git a/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td b/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td --- a/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td +++ b/mlir/include/mlir/Interfaces/SideEffectInterfaceBase.td @@ -115,7 +115,7 @@ return isa(it.getEffect()) && it.getValue() == value; }); if (it == effects.end()) - return llvm::None; + return std::nullopt; return *it; } diff --git a/mlir/include/mlir/Pass/AnalysisManager.h b/mlir/include/mlir/Pass/AnalysisManager.h --- a/mlir/include/mlir/Pass/AnalysisManager.h +++ b/mlir/include/mlir/Pass/AnalysisManager.h @@ -171,7 +171,7 @@ Optional> getCachedAnalysis() const { auto res = analyses.find(TypeID::get()); if (res == analyses.end()) - return llvm::None; + return std::nullopt; return {static_cast &>(*res->second).analysis}; } @@ -352,7 +352,7 @@ assert(op->getParentOp() == impl->getOperation()); auto it = impl->childAnalyses.find(op); if (it == impl->childAnalyses.end()) - return llvm::None; + return std::nullopt; return it->second->analyses.getCachedAnalysis(); } diff --git a/mlir/include/mlir/Pass/Pass.h b/mlir/include/mlir/Pass/Pass.h --- a/mlir/include/mlir/Pass/Pass.h +++ b/mlir/include/mlir/Pass/Pass.h @@ -159,7 +159,7 @@ } protected: - explicit Pass(TypeID passID, Optional opName = llvm::None) + explicit Pass(TypeID passID, Optional opName = std::nullopt) : passID(passID), opName(opName) {} Pass(const Pass &other) : Pass(other.passID, other.opName) {} diff --git a/mlir/include/mlir/Pass/PassOptions.h b/mlir/include/mlir/Pass/PassOptions.h --- a/mlir/include/mlir/Pass/PassOptions.h +++ b/mlir/include/mlir/Pass/PassOptions.h @@ -122,7 +122,7 @@ for (auto &it : this->Values) if (it.V.compare(value)) return it.Name; - return llvm::None; + return std::nullopt; } }; diff --git a/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h b/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h --- a/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h +++ b/mlir/include/mlir/Rewrite/FrozenRewritePatternSet.h @@ -49,8 +49,8 @@ /// their type name. FrozenRewritePatternSet( RewritePatternSet &&patterns, - ArrayRef disabledPatternLabels = llvm::None, - ArrayRef enabledPatternLabels = llvm::None); + ArrayRef disabledPatternLabels = std::nullopt, + ArrayRef enabledPatternLabels = std::nullopt); /// Return the op specific native patterns held by this list. const OpSpecificNativePatternListT &getOpSpecificNativePatterns() const { diff --git a/mlir/include/mlir/Support/StorageUniquer.h b/mlir/include/mlir/Support/StorageUniquer.h --- a/mlir/include/mlir/Support/StorageUniquer.h +++ b/mlir/include/mlir/Support/StorageUniquer.h @@ -97,7 +97,7 @@ template ArrayRef copyInto(ArrayRef elements) { if (elements.empty()) - return llvm::None; + return std::nullopt; auto result = allocator.Allocate(elements.size()); std::uninitialized_copy(elements.begin(), elements.end(), result); return ArrayRef(result, elements.size()); @@ -178,7 +178,7 @@ } template void registerSingletonStorageType(TypeID id) { - registerSingletonStorageType(id, llvm::None); + registerSingletonStorageType(id, std::nullopt); } /// Utility override when the storage type represents the type id. template diff --git a/mlir/include/mlir/Support/Timing.h b/mlir/include/mlir/Support/Timing.h --- a/mlir/include/mlir/Support/Timing.h +++ b/mlir/include/mlir/Support/Timing.h @@ -136,7 +136,7 @@ // // See the corresponding functions in `Timer` for additional details. - /// Return the root timer. Implementations should return `llvm::None` if the + /// Return the root timer. Implementations should return `std::nullopt` if the /// collection of timing samples is disabled. This will cause the timers /// constructed from the manager to be tombstones which can be skipped /// quickly. diff --git a/mlir/include/mlir/TableGen/Operator.h b/mlir/include/mlir/TableGen/Operator.h --- a/mlir/include/mlir/TableGen/Operator.h +++ b/mlir/include/mlir/TableGen/Operator.h @@ -259,9 +259,9 @@ // Pair representing either a index to an argument or a type constraint. Only // one of these entries should have the non-default value. struct ArgOrType { - explicit ArgOrType(int index) : index(index), constraint(None) {} + explicit ArgOrType(int index) : index(index), constraint(std::nullopt) {} explicit ArgOrType(TypeConstraint constraint) - : index(None), constraint(constraint) {} + : index(std::nullopt), constraint(constraint) {} bool isArg() const { assert(constraint.has_value() ^ index.has_value()); return index.has_value(); diff --git a/mlir/include/mlir/TableGen/Pattern.h b/mlir/include/mlir/TableGen/Pattern.h --- a/mlir/include/mlir/TableGen/Pattern.h +++ b/mlir/include/mlir/TableGen/Pattern.h @@ -282,7 +282,7 @@ enum class Kind : uint8_t { Attr, Operand, Result, Value, MultipleValues }; // Creates a SymbolInfo instance. `dagAndConstant` is only used for `Attr` - // and `Operand` so should be llvm::None for `Result` and `Value` kind. + // and `Operand` so should be std::nullopt for `Result` and `Value` kind. SymbolInfo(const Operator *op, Kind kind, Optional dagAndConstant); @@ -291,17 +291,17 @@ return SymbolInfo(op, Kind::Attr, DagAndConstant(nullptr, index)); } static SymbolInfo getAttr() { - return SymbolInfo(nullptr, Kind::Attr, llvm::None); + return SymbolInfo(nullptr, Kind::Attr, std::nullopt); } static SymbolInfo getOperand(DagNode node, const Operator *op, int index) { return SymbolInfo(op, Kind::Operand, DagAndConstant(node.getAsOpaquePointer(), index)); } static SymbolInfo getResult(const Operator *op) { - return SymbolInfo(op, Kind::Result, llvm::None); + return SymbolInfo(op, Kind::Result, std::nullopt); } static SymbolInfo getValue() { - return SymbolInfo(nullptr, Kind::Value, llvm::None); + return SymbolInfo(nullptr, Kind::Value, std::nullopt); } static SymbolInfo getMultipleValues(int numValues) { return SymbolInfo(nullptr, Kind::MultipleValues, diff --git a/mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h b/mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h --- a/mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Diagnostic.h @@ -44,7 +44,7 @@ /// Attach a note to this diagnostic. Diagnostic &attachNote(const Twine &msg, - Optional noteLoc = llvm::None) { + Optional noteLoc = std::nullopt) { assert(getSeverity() != Severity::DK_Note && "cannot attach a Note to a Note"); notes.emplace_back( diff --git a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h --- a/mlir/include/mlir/Tools/PDLL/AST/Nodes.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Nodes.h @@ -886,8 +886,8 @@ ArrayRef results, const CompoundStmt *body, Type resultType) { - return createImpl(ctx, name, inputs, /*nativeInputTypes=*/llvm::None, - results, /*codeBlock=*/llvm::None, body, resultType); + return createImpl(ctx, name, inputs, /*nativeInputTypes=*/std::nullopt, + results, /*codeBlock=*/std::nullopt, body, resultType); } /// Return the name of the constraint. @@ -1008,7 +1008,7 @@ /// Return the name of this operation, or none if the name is unknown. Optional getName() const { const Name *name = Decl::getName(); - return name ? Optional(name->getName()) : llvm::None; + return name ? Optional(name->getName()) : std::nullopt; } private: @@ -1093,7 +1093,7 @@ ArrayRef results, const CompoundStmt *body, Type resultType) { - return createImpl(ctx, name, inputs, results, /*codeBlock=*/llvm::None, + return createImpl(ctx, name, inputs, results, /*codeBlock=*/std::nullopt, body, resultType); } diff --git a/mlir/include/mlir/Tools/PDLL/AST/Types.h b/mlir/include/mlir/Tools/PDLL/AST/Types.h --- a/mlir/include/mlir/Tools/PDLL/AST/Types.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Types.h @@ -161,7 +161,7 @@ /// Return an instance of the Operation type with an optional operation name. /// If no name is provided, this type may refer to any operation. static OperationType get(Context &context, - Optional name = llvm::None, + Optional name = std::nullopt, const ods::Operation *odsOp = nullptr); /// Return the name of this operation type, or None if it doesn't have on. @@ -247,7 +247,7 @@ static TupleType get(Context &context, ArrayRef elementTypes, ArrayRef elementNames); static TupleType get(Context &context, - ArrayRef elementTypes = llvm::None); + ArrayRef elementTypes = std::nullopt); /// Return the element types of this tuple. ArrayRef getElementTypes() const; diff --git a/mlir/include/mlir/Tools/mlir-translate/Translation.h b/mlir/include/mlir/Tools/mlir-translate/Translation.h --- a/mlir/include/mlir/Tools/mlir-translate/Translation.h +++ b/mlir/include/mlir/Tools/mlir-translate/Translation.h @@ -100,11 +100,11 @@ TranslateToMLIRRegistration( llvm::StringRef name, llvm::StringRef description, const TranslateSourceMgrToMLIRFunction &function, - Optional inputAlignment = llvm::None); + Optional inputAlignment = std::nullopt); TranslateToMLIRRegistration( llvm::StringRef name, llvm::StringRef description, const TranslateStringRefToMLIRFunction &function, - Optional inputAlignment = llvm::None); + Optional inputAlignment = std::nullopt); }; struct TranslateFromMLIRRegistration { diff --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h --- a/mlir/include/mlir/Transforms/DialectConversion.h +++ b/mlir/include/mlir/Transforms/DialectConversion.h @@ -91,15 +91,15 @@ /// to any of the following forms(where `T` is a class derived from `Type`: /// * Optional(T) /// - This form represents a 1-1 type conversion. It should return nullptr - /// or `llvm::None` to signify failure. If `llvm::None` is returned, the - /// converter is allowed to try another conversion function to perform - /// the conversion. + /// or `std::nullopt` to signify failure. If `llvm::None` is returned, + /// the converter is allowed to try another conversion function to + /// perform the conversion. /// * Optional(T, SmallVectorImpl &) /// - This form represents a 1-N type conversion. It should return - /// `failure` or `llvm::None` to signify a failed conversion. If the new - /// set of types is empty, the type is removed and any usages of the + /// `failure` or `std::nullopt` to signify a failed conversion. If the + /// new set of types is empty, the type is removed and any usages of the /// existing value are expected to be removed during conversion. If - /// `llvm::None` is returned, the converter is allowed to try another + /// `std::nullopt` is returned, the converter is allowed to try another /// conversion function to perform the conversion. /// * Optional(T, SmallVectorImpl &, ArrayRef) /// - This form represents a 1-N type conversion supporting recursive @@ -123,7 +123,7 @@ /// where `T` is any subclass of `Type`. This function is responsible for /// creating an operation, using the OpBuilder and Location provided, that /// "casts" a range of values into a single value of the given type `T`. It - /// must return a Value of the converted type on success, an `llvm::None` if + /// must return a Value of the converted type on success, an `std::nullopt` if /// it failed but other materialization can be attempted, and `nullptr` on /// unrecoverable failure. It will only be called for (sub)types of `T`. /// Materialization functions must be provided when a type conversion may @@ -284,7 +284,7 @@ ArrayRef callStack) -> Optional { T derivedType = type.dyn_cast(); if (!derivedType) - return llvm::None; + return std::nullopt; return callback(derivedType, results, callStack); }; } @@ -306,7 +306,7 @@ Location loc) -> Optional { if (T derivedType = resultType.dyn_cast()) return callback(builder, derivedType, inputs, loc); - return llvm::None; + return std::nullopt; }; } diff --git a/mlir/include/mlir/Transforms/InliningUtils.h b/mlir/include/mlir/Transforms/InliningUtils.h --- a/mlir/include/mlir/Transforms/InliningUtils.h +++ b/mlir/include/mlir/Transforms/InliningUtils.h @@ -208,14 +208,14 @@ Operation *inlinePoint, BlockAndValueMapping &mapper, ValueRange resultsToReplace, TypeRange regionResultTypes, - Optional inlineLoc = llvm::None, + Optional inlineLoc = std::nullopt, bool shouldCloneInlinedRegion = true); LogicalResult inlineRegion(InlinerInterface &interface, Region *src, Block *inlineBlock, Block::iterator inlinePoint, BlockAndValueMapping &mapper, ValueRange resultsToReplace, TypeRange regionResultTypes, - Optional inlineLoc = llvm::None, + Optional inlineLoc = std::nullopt, bool shouldCloneInlinedRegion = true); /// This function is an overload of the above 'inlineRegion' that allows for @@ -224,13 +224,13 @@ LogicalResult inlineRegion(InlinerInterface &interface, Region *src, Operation *inlinePoint, ValueRange inlinedOperands, ValueRange resultsToReplace, - Optional inlineLoc = llvm::None, + Optional inlineLoc = std::nullopt, bool shouldCloneInlinedRegion = true); LogicalResult inlineRegion(InlinerInterface &interface, Region *src, Block *inlineBlock, Block::iterator inlinePoint, ValueRange inlinedOperands, ValueRange resultsToReplace, - Optional inlineLoc = llvm::None, + Optional inlineLoc = std::nullopt, bool shouldCloneInlinedRegion = true); /// This function inlines a given region, 'src', of a callable operation, diff --git a/mlir/include/mlir/Transforms/Passes.h b/mlir/include/mlir/Transforms/Passes.h --- a/mlir/include/mlir/Transforms/Passes.h +++ b/mlir/include/mlir/Transforms/Passes.h @@ -55,8 +55,8 @@ /// set to their type name. std::unique_ptr createCanonicalizerPass(const GreedyRewriteConfig &config, - ArrayRef disabledPatterns = llvm::None, - ArrayRef enabledPatterns = llvm::None); + ArrayRef disabledPatterns = std::nullopt, + ArrayRef enabledPatterns = std::nullopt); /// Creates a pass to perform control-flow sinking. std::unique_ptr createControlFlowSinkPass(); diff --git a/mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp b/mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp --- a/mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp +++ b/mlir/lib/Analysis/AliasAnalysis/LocalAliasAnalysis.cpp @@ -70,7 +70,7 @@ } return inputIndex - firstInputIndex; } - return llvm::None; + return std::nullopt; }; // Check branches from the parent operation. @@ -80,7 +80,7 @@ regionIndex = region->getRegionNumber(); } if (Optional operandIndex = - getOperandIndexIfPred(/*predIndex=*/llvm::None)) { + getOperandIndexIfPred(/*predIndex=*/std::nullopt)) { collectUnderlyingAddressValues( branch.getSuccessorEntryOperands(regionIndex)[*operandIndex], maxDepth, visited, output); diff --git a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp --- a/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlow/SparseAnalysis.cpp @@ -95,7 +95,8 @@ // The results of a region branch operation are determined by control-flow. if (auto branch = dyn_cast(op)) { return visitRegionSuccessors({branch}, branch, - /*successorIndex=*/llvm::None, resultLattices); + /*successorIndex=*/std::nullopt, + resultLattices); } // The results of a call operation are determined by the callgraph. diff --git a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp --- a/mlir/lib/Analysis/Presburger/IntegerRelation.cpp +++ b/mlir/lib/Analysis/Presburger/IntegerRelation.cpp @@ -1405,7 +1405,7 @@ // representation of the local vars. if (!std::all_of(eq.begin() + getNumDimAndSymbolVars(), eq.end() - 1, [](const MPInt &coeff) { return coeff == 0; })) - return None; + return std::nullopt; // This variable can only take a single value. if (lb) { @@ -1442,7 +1442,7 @@ } if (r == e) // If it doesn't, there isn't a bound on it. - return None; + return std::nullopt; // Positions of constraints that are lower/upper bounds on the variable. SmallVector lbIndices, ubIndices; @@ -1477,7 +1477,7 @@ atIneq(lbPos, pos)); // This bound is non-negative by definition. diff = std::max(diff, MPInt(0)); - if (minDiff == None || diff < minDiff) { + if (minDiff == std::nullopt || diff < minDiff) { minDiff = diff; minLbPosition = lbPos; minUbPosition = ubPos; @@ -1536,7 +1536,7 @@ } if (r == e) // If it doesn't, there isn't a bound on it. - return None; + return std::nullopt; Optional minOrMaxConst; @@ -1563,10 +1563,10 @@ isLower ? ceilDiv(-atIneq(r, getNumCols() - 1), atIneq(r, 0)) : floorDiv(atIneq(r, getNumCols() - 1), -atIneq(r, 0)); if (isLower) { - if (minOrMaxConst == None || boundConst > minOrMaxConst) + if (minOrMaxConst == std::nullopt || boundConst > minOrMaxConst) minOrMaxConst = boundConst; } else { - if (minOrMaxConst == None || boundConst < minOrMaxConst) + if (minOrMaxConst == std::nullopt || boundConst < minOrMaxConst) minOrMaxConst = boundConst; } } @@ -1589,7 +1589,7 @@ Optional ub = IntegerRelation(*this) .computeConstantLowerOrUpperBound(pos); - return (lb && ub && *lb == *ub) ? Optional(*ub) : None; + return (lb && ub && *lb == *ub) ? Optional(*ub) : std::nullopt; } // A simple (naive and conservative) check for hyper-rectangularity. diff --git a/mlir/lib/Analysis/Presburger/PWMAFunction.cpp b/mlir/lib/Analysis/Presburger/PWMAFunction.cpp --- a/mlir/lib/Analysis/Presburger/PWMAFunction.cpp +++ b/mlir/lib/Analysis/Presburger/PWMAFunction.cpp @@ -430,5 +430,5 @@ for (const Piece &piece : pieces) if (piece.domain.containsPoint(point)) return piece.output.valueAt(point); - return None; + return std::nullopt; } diff --git a/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp b/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp --- a/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp +++ b/mlir/lib/Analysis/Presburger/PresburgerRelation.cpp @@ -369,7 +369,7 @@ unsigned simplexSnapshot = simplex.getSnapshot(); IntegerRelation::CountsSnapshot bCounts = b.getCounts(); frames.push_back(Frame{simplexSnapshot, bCounts, sI, ineqsToProcess, - /*lastIneqProcessed=*/llvm::None}); + /*lastIneqProcessed=*/std::nullopt}); // We have completed the initial setup for this level. // Fallthrough to the main recursive part below. } diff --git a/mlir/lib/Analysis/Presburger/Utils.cpp b/mlir/lib/Analysis/Presburger/Utils.cpp --- a/mlir/lib/Analysis/Presburger/Utils.cpp +++ b/mlir/lib/Analysis/Presburger/Utils.cpp @@ -381,7 +381,7 @@ DivisionRepr::divValuesAt(ArrayRef point) const { assert(point.size() == getNumNonDivs() && "Incorrect point size"); - SmallVector, 4> divValues(getNumDivs(), None); + SmallVector, 4> divValues(getNumDivs(), std::nullopt); bool changed = true; while (changed) { changed = false; diff --git a/mlir/lib/AsmParser/AttributeParser.cpp b/mlir/lib/AsmParser/AttributeParser.cpp --- a/mlir/lib/AsmParser/AttributeParser.cpp +++ b/mlir/lib/AsmParser/AttributeParser.cpp @@ -357,7 +357,7 @@ APInt result; bool isHex = spelling.size() > 1 && spelling[1] == 'x'; if (spelling.getAsInteger(isHex ? 0 : 10, result)) - return llvm::None; + return std::nullopt; // Extend or truncate the bitwidth to the right size. unsigned width = type.isIndex() ? IndexType::kInternalStorageBitWidth @@ -369,7 +369,7 @@ // The parser can return an unnecessarily wide result with leading zeros. // This isn't a problem, but truncating off bits is bad. if (result.countLeadingZeros() < result.getBitWidth() - width) - return llvm::None; + return std::nullopt; result = result.trunc(width); } @@ -378,18 +378,18 @@ // 0 bit integers cannot be negative and manipulation of their sign bit will // assert, so short-cut validation here. if (isNegative) - return llvm::None; + return std::nullopt; } else if (isNegative) { // The value is negative, we have an overflow if the sign bit is not set // in the negated apInt. result.negate(); if (!result.isSignBitSet()) - return llvm::None; + return std::nullopt; } else if ((type.isSignedInteger() || type.isIndex()) && result.isSignBitSet()) { // The value is a positive signed integer or index, // we have an overflow if the sign bit is set. - return llvm::None; + return std::nullopt; } return result; @@ -1175,7 +1175,7 @@ SMLoc loc = getToken().getLoc(); auto emitWrongTokenError = [&] { emitError(loc, "expected a 64-bit signed integer or '?'"); - return llvm::None; + return std::nullopt; }; bool negative = consumeIf(Token::minus); diff --git a/mlir/lib/AsmParser/Parser.h b/mlir/lib/AsmParser/Parser.h --- a/mlir/lib/AsmParser/Parser.h +++ b/mlir/lib/AsmParser/Parser.h @@ -236,7 +236,7 @@ AttributeT &attr, Type type = {}) { if (getToken().isNot(kind)) - return llvm::None; + return std::nullopt; if (Attribute parsedAttr = parseAttribute(type)) { attr = parsedAttr.cast(); diff --git a/mlir/lib/AsmParser/Parser.cpp b/mlir/lib/AsmParser/Parser.cpp --- a/mlir/lib/AsmParser/Parser.cpp +++ b/mlir/lib/AsmParser/Parser.cpp @@ -250,7 +250,7 @@ Token curToken = getToken(); if (curToken.isNot(Token::integer, Token::minus)) - return llvm::None; + return std::nullopt; bool negative = consumeIf(Token::minus); Token curTok = getToken(); @@ -533,12 +533,12 @@ /// skip parsing that component. ParseResult parseGenericOperationAfterOpName( OperationState &result, - Optional> parsedOperandUseInfo = llvm::None, - Optional> parsedSuccessors = llvm::None, + Optional> parsedOperandUseInfo = std::nullopt, + Optional> parsedSuccessors = std::nullopt, Optional>> parsedRegions = - llvm::None, - Optional> parsedAttributes = llvm::None, - Optional parsedFnType = llvm::None); + std::nullopt, + Optional> parsedAttributes = std::nullopt, + Optional parsedFnType = std::nullopt); /// Parse an operation instance that is in the generic form and insert it at /// the provided insertion point. @@ -1073,7 +1073,7 @@ auto name = OperationName("builtin.unrealized_conversion_cast", getContext()); auto *op = Operation::create( getEncodedSourceLocation(loc), name, type, /*operands=*/{}, - /*attributes=*/llvm::None, /*successors=*/{}, /*numRegions=*/0); + /*attributes=*/std::nullopt, /*successors=*/{}, /*numRegions=*/0); forwardRefPlaceholders[op->getResult(0)] = loc; return op->getResult(0); } @@ -1524,7 +1524,7 @@ bool allowResultNumber = true) override { if (parser.getToken().isOrIsCodeCompletionFor(Token::percent_identifier)) return parseOperand(result, allowResultNumber); - return llvm::None; + return std::nullopt; } /// Parse zero or more SSA comma-separated operand references with a specified @@ -1657,7 +1657,7 @@ bool allowAttrs) override { if (parser.getToken().is(Token::percent_identifier)) return parseArgument(result, allowType, allowAttrs); - return llvm::None; + return std::nullopt; } ParseResult parseArgumentList(SmallVectorImpl &result, @@ -1697,7 +1697,7 @@ ArrayRef arguments, bool enableNameShadowing) override { if (parser.getToken().isNot(Token::l_brace)) - return llvm::None; + return std::nullopt; return parseRegion(region, arguments, enableNameShadowing); } @@ -1709,7 +1709,7 @@ ArrayRef arguments, bool enableNameShadowing = false) override { if (parser.getToken().isNot(Token::l_brace)) - return llvm::None; + return std::nullopt; std::unique_ptr newRegion = std::make_unique(); if (parseRegion(*newRegion, arguments, enableNameShadowing)) return failure(); @@ -1730,7 +1730,7 @@ /// Parse an optional operation successor and its operand list. OptionalParseResult parseOptionalSuccessor(Block *&dest) override { if (!parser.getToken().isOrIsCodeCompletionFor(Token::caret_identifier)) - return llvm::None; + return std::nullopt; return parseSuccessor(dest); } @@ -1759,7 +1759,7 @@ SmallVectorImpl &lhs, SmallVectorImpl &rhs) override { if (failed(parseOptionalLParen())) - return llvm::None; + return std::nullopt; auto parseElt = [&]() -> ParseResult { if (parseArgument(lhs.emplace_back()) || parseEqual() || @@ -2391,7 +2391,7 @@ // TODO: We could avoid an additional alloc+copy here if we pre-allocated // the buffer to use during hex processing. Optional blobData = - value.is(Token::string) ? value.getHexStringValue() : llvm::None; + value.is(Token::string) ? value.getHexStringValue() : std::nullopt; if (!blobData) return p.emitError(value.getLoc(), "expected hex string blob for key '" + key + "'"); diff --git a/mlir/lib/AsmParser/Token.h b/mlir/lib/AsmParser/Token.h --- a/mlir/lib/AsmParser/Token.h +++ b/mlir/lib/AsmParser/Token.h @@ -91,9 +91,9 @@ /// For an inttype token, return its bitwidth. Optional getIntTypeBitwidth() const; - /// For an inttype token, return its signedness semantics: llvm::None means no - /// signedness semantics; true means signed integer type; false means unsigned - /// integer type. + /// For an inttype token, return its signedness semantics: std::nullopt means + /// no signedness semantics; true means signed integer type; false means + /// unsigned integer type. Optional getIntTypeSignedness() const; /// Given a hash_identifier token like #123, try to parse the number out of diff --git a/mlir/lib/AsmParser/Token.cpp b/mlir/lib/AsmParser/Token.cpp --- a/mlir/lib/AsmParser/Token.cpp +++ b/mlir/lib/AsmParser/Token.cpp @@ -30,7 +30,7 @@ unsigned result = 0; if (spelling.getAsInteger(isHex ? 0 : 10, result)) - return None; + return std::nullopt; return result; } @@ -41,7 +41,7 @@ uint64_t result = 0; if (spelling.getAsInteger(isHex ? 0 : 10, result)) - return None; + return std::nullopt; return result; } @@ -50,7 +50,7 @@ Optional Token::getFloatingPointValue() const { double result = 0; if (spelling.getAsDouble(result)) - return None; + return std::nullopt; return result; } @@ -60,14 +60,14 @@ unsigned bitwidthStart = (spelling[0] == 'i' ? 1 : 2); unsigned result = 0; if (spelling.drop_front(bitwidthStart).getAsInteger(10, result)) - return None; + return std::nullopt; return result; } Optional Token::getIntTypeSignedness() const { assert(getKind() == inttype); if (spelling[0] == 'i') - return llvm::None; + return std::nullopt; if (spelling[0] == 's') return true; assert(spelling[0] == 'u'); @@ -138,7 +138,7 @@ std::string hex; if (!bytes.consume_front("0x") || (bytes.size() & 1) || !llvm::tryGetFromHex(bytes, hex)) - return llvm::None; + return std::nullopt; return hex; } @@ -161,7 +161,7 @@ assert(getKind() == hash_identifier); unsigned result = 0; if (spelling.drop_front().getAsInteger(10, result)) - return None; + return std::nullopt; return result; } diff --git a/mlir/lib/AsmParser/TypeParser.cpp b/mlir/lib/AsmParser/TypeParser.cpp --- a/mlir/lib/AsmParser/TypeParser.cpp +++ b/mlir/lib/AsmParser/TypeParser.cpp @@ -44,7 +44,7 @@ return failure(!(type = parseType())); default: - return llvm::None; + return std::nullopt; } } diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp --- a/mlir/lib/Bindings/Python/IRCore.cpp +++ b/mlir/lib/Bindings/Python/IRCore.cpp @@ -2626,7 +2626,7 @@ "__str__", [](PyOperationBase &self) { return self.getAsm(/*binary=*/false, - /*largeElementsLimit=*/llvm::None, + /*largeElementsLimit=*/std::nullopt, /*enableDebugInfo=*/false, /*prettyDebugInfo=*/false, /*printGenericOpForm=*/false, diff --git a/mlir/lib/Bindings/Python/IRModule.cpp b/mlir/lib/Bindings/Python/IRModule.cpp --- a/mlir/lib/Bindings/Python/IRModule.cpp +++ b/mlir/lib/Bindings/Python/IRModule.cpp @@ -91,14 +91,14 @@ const auto foundIt = dialectClassMap.find(dialectNamespace); if (foundIt != dialectClassMap.end()) { if (foundIt->second.is_none()) - return llvm::None; + return std::nullopt; assert(foundIt->second && "py::object is defined"); return foundIt->second; } // Not found and loading did not yield a registration. Negative cache. dialectClassMap[dialectNamespace] = py::none(); - return llvm::None; + return std::nullopt; } llvm::Optional @@ -107,7 +107,7 @@ auto foundIt = rawOpViewClassMapCache.find(operationName); if (foundIt != rawOpViewClassMapCache.end()) { if (foundIt->second.is_none()) - return llvm::None; + return std::nullopt; assert(foundIt->second && "py::object is defined"); return foundIt->second; } @@ -123,7 +123,7 @@ auto foundIt = rawOpViewClassMap.find(operationName); if (foundIt != rawOpViewClassMap.end()) { if (foundIt->second.is_none()) - return llvm::None; + return std::nullopt; assert(foundIt->second && "py::object is defined"); // Positive cache. rawOpViewClassMapCache[operationName] = foundIt->second; @@ -131,7 +131,7 @@ } // Negative cache. rawOpViewClassMap[operationName] = py::none(); - return llvm::None; + return std::nullopt; } } diff --git a/mlir/lib/Bindings/Python/IRTypes.cpp b/mlir/lib/Bindings/Python/IRTypes.cpp --- a/mlir/lib/Bindings/Python/IRTypes.cpp +++ b/mlir/lib/Bindings/Python/IRTypes.cpp @@ -390,7 +390,7 @@ [](PyRankedTensorType &self) -> llvm::Optional { MlirAttribute encoding = mlirRankedTensorTypeGetEncoding(self.get()); if (mlirAttributeIsNull(encoding)) - return llvm::None; + return std::nullopt; return PyAttribute(self.getContext(), encoding); }); } diff --git a/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp b/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp --- a/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp +++ b/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp @@ -304,7 +304,7 @@ if (type.isa()) return AsyncAPI::opaquePointerType(type.getContext()); - return llvm::None; + return std::nullopt; } }; } // namespace diff --git a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp --- a/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp +++ b/mlir/lib/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.cpp @@ -66,7 +66,7 @@ // Generate IR to call `abort`. Block *failureBlock = rewriter.createBlock(opBlock->getParent()); - rewriter.create(loc, abortFunc, llvm::None); + rewriter.create(loc, abortFunc, std::nullopt); rewriter.create(loc); // Generate assertion test. diff --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp --- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp +++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp @@ -183,7 +183,7 @@ converter.addConversion([&](MemRefType type) -> Optional { if (type.getMemorySpaceAsInt() != gpu::GPUDialect::getPrivateAddressSpace()) - return llvm::None; + return std::nullopt; return converter.convertType(MemRefType::Builder(type).setMemorySpace( IntegerAttr::get(IntegerType::get(m.getContext(), 64), 0))); }); diff --git a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp --- a/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp +++ b/mlir/lib/Conversion/GPUToSPIRV/GPUToSPIRV.cpp @@ -224,7 +224,7 @@ auto newFuncOp = rewriter.create( funcOp.getLoc(), funcOp.getName(), rewriter.getFunctionType(signatureConverter.getConvertedTypes(), - llvm::None)); + std::nullopt)); for (const auto &namedAttr : funcOp->getAttrs()) { if (namedAttr.getName() == FunctionOpInterface::getTypeAttrName() || namedAttr.getName() == SymbolTable::getSymbolAttrName()) @@ -329,7 +329,7 @@ // Add a keyword to the module name to avoid symbolic conflict. std::string spvModuleName = (kSPIRVModule + moduleOp.getName()).str(); auto spvModule = rewriter.create( - moduleOp.getLoc(), addressingModel, *memoryModel, llvm::None, + moduleOp.getLoc(), addressingModel, *memoryModel, std::nullopt, StringRef(spvModuleName)); // Move the region from the module op into the SPIR-V module. diff --git a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp --- a/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp +++ b/mlir/lib/Conversion/LLVMCommon/TypeConverter.cpp @@ -43,7 +43,7 @@ // order and those should take priority. addConversion([](Type type) { return LLVM::isCompatibleType(type) ? llvm::Optional(type) - : llvm::None; + : std::nullopt; }); // LLVM container types may (recursively) contain other types that must be @@ -53,7 +53,7 @@ return type; if (auto pointee = convertType(type.getElementType())) return LLVM::LLVMPointerType::get(pointee, type.getAddressSpace()); - return llvm::None; + return std::nullopt; }); addConversion([&](LLVM::LLVMStructType type, SmallVectorImpl &results, ArrayRef callStack) -> llvm::Optional { @@ -82,7 +82,7 @@ SmallVector convertedElemTypes; convertedElemTypes.reserve(type.getBody().size()); if (failed(convertTypes(type.getBody(), convertedElemTypes))) - return llvm::None; + return std::nullopt; if (failed(convertedType.setBody(convertedElemTypes, type.isPacked()))) return failure(); @@ -93,7 +93,7 @@ SmallVector convertedSubtypes; convertedSubtypes.reserve(type.getBody().size()); if (failed(convertTypes(type.getBody(), convertedSubtypes))) - return llvm::None; + return std::nullopt; results.push_back(LLVM::LLVMStructType::getLiteral( type.getContext(), convertedSubtypes, type.isPacked())); @@ -102,17 +102,17 @@ addConversion([&](LLVM::LLVMArrayType type) -> llvm::Optional { if (auto element = convertType(type.getElementType())) return LLVM::LLVMArrayType::get(element, type.getNumElements()); - return llvm::None; + return std::nullopt; }); addConversion([&](LLVM::LLVMFunctionType type) -> llvm::Optional { Type convertedResType = convertType(type.getReturnType()); if (!convertedResType) - return llvm::None; + return std::nullopt; SmallVector convertedArgTypes; convertedArgTypes.reserve(type.getNumParams()); if (failed(convertTypes(type.getParams(), convertedArgTypes))) - return llvm::None; + return std::nullopt; return LLVM::LLVMFunctionType::get(convertedResType, convertedArgTypes, type.isVarArg()); @@ -125,7 +125,7 @@ [&](OpBuilder &builder, UnrankedMemRefType resultType, ValueRange inputs, Location loc) -> Optional { if (inputs.size() == 1) - return llvm::None; + return std::nullopt; return UnrankedMemRefDescriptor::pack(builder, loc, *this, resultType, inputs); }); @@ -135,7 +135,7 @@ // TODO: bare ptr conversion could be handled here but we would need a way // to distinguish between FuncOp and other regions. if (inputs.size() == 1) - return llvm::None; + return std::nullopt; return MemRefDescriptor::pack(builder, loc, *this, resultType, inputs); }); // Add generic source and target materializations to handle cases where @@ -144,7 +144,7 @@ ValueRange inputs, Location loc) -> Optional { if (inputs.size() != 1) - return llvm::None; + return std::nullopt; return builder.create(loc, resultType, inputs) .getResult(0); @@ -153,7 +153,7 @@ ValueRange inputs, Location loc) -> Optional { if (inputs.size() != 1) - return llvm::None; + return std::nullopt; return builder.create(loc, resultType, inputs) .getResult(0); diff --git a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp --- a/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp +++ b/mlir/lib/Conversion/LinalgToSPIRV/LinalgToSPIRV.cpp @@ -67,29 +67,29 @@ // Make sure the linalg.generic is working on memrefs. if (!genericOp.hasBufferSemantics()) - return llvm::None; + return std::nullopt; // Make sure this is reduction with one input and one output. if (genericOp.getNumDpsInputs() != 1 || genericOp.getNumDpsInits() != 1) - return llvm::None; + return std::nullopt; auto originalInputType = op->getOperand(0).getType().cast(); auto originalOutputType = op->getOperand(1).getType().cast(); // Make sure the original input has one dimension. if (!originalInputType.hasStaticShape() || originalInputType.getRank() != 1) - return llvm::None; + return std::nullopt; // Make sure the original output has one element. if (!originalOutputType.hasStaticShape() || originalOutputType.getNumElements() != 1) - return llvm::None; + return std::nullopt; if (!genericOp.hasSingleReductionLoop()) - return llvm::None; + return std::nullopt; auto indexingMaps = genericOp.getIndexingMapsArray(); if (indexingMaps.size() != 2) - return llvm::None; + return std::nullopt; // TODO: create utility functions for these checks in Linalg // and use them. @@ -97,11 +97,11 @@ auto outputMap = indexingMaps[1]; // The indexing map for the input should be `(i) -> (i)`. if (inputMap != AffineMap::get(1, 0, getAffineDimExpr(0, op->getContext()))) - return llvm::None; + return std::nullopt; // The indexing map for the input should be `(i) -> (0)`. if (outputMap != AffineMap::get(1, 0, getAffineConstantExpr(0, op->getContext()))) - return llvm::None; + return std::nullopt; return linalg::RegionMatcher::matchAsScalarBinaryOp(genericOp); } diff --git a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp --- a/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp +++ b/mlir/lib/Conversion/MemRefToLLVM/MemRefToLLVM.cpp @@ -451,7 +451,7 @@ .getValue() .getSExtValue(); - return llvm::None; + return std::nullopt; } Value extractSizeOfRankedMemRef(Type operandType, memref::DimOp dimOp, @@ -1278,7 +1278,7 @@ UnrankedMemRefDescriptor::computeSizes(rewriter, loc, *getTypeConverter(), targetDesc, sizes); Value underlyingDescPtr = rewriter.create( - loc, getVoidPtrType(), sizes.front(), llvm::None); + loc, getVoidPtrType(), sizes.front(), std::nullopt); targetDesc.setMemRefDescPtr(rewriter, loc, underlyingDescPtr); // Extract pointers and offset from the source memref. @@ -1362,8 +1362,8 @@ // Hook up the cond exit to the remainder. rewriter.setInsertionPointToEnd(condBlock); - rewriter.create(loc, pred, bodyBlock, llvm::None, remainder, - llvm::None); + rewriter.create(loc, pred, bodyBlock, std::nullopt, + remainder, std::nullopt); // Reset position to beginning of new remainder block. rewriter.setInsertionPointToStart(remainder); @@ -1599,7 +1599,8 @@ initBlock->getParent(), Region::iterator(continueBlock), {}); } rewriter.create(loc, predNeOne, continueBlock, - srcStride, nextEntryBlock, llvm::None); + srcStride, nextEntryBlock, + std::nullopt); curEntryBlock = nextEntryBlock; } } @@ -2049,7 +2050,7 @@ case arith::AtomicRMWKind::andi: return LLVM::AtomicBinOp::_and; default: - return llvm::None; + return std::nullopt; } llvm_unreachable("Invalid AtomicRMWKind"); } diff --git a/mlir/lib/Conversion/MemRefToSPIRV/MapMemRefStorageClassPass.cpp b/mlir/lib/Conversion/MemRefToSPIRV/MapMemRefStorageClassPass.cpp --- a/mlir/lib/Conversion/MemRefToSPIRV/MapMemRefStorageClassPass.cpp +++ b/mlir/lib/Conversion/MemRefToSPIRV/MapMemRefStorageClassPass.cpp @@ -66,7 +66,7 @@ // Downstream callers should plug in more specialized ones. auto intAttr = memorySpaceAttr.dyn_cast(); if (!intAttr) - return llvm::None; + return std::nullopt; unsigned memorySpace = intAttr.getInt(); #define STORAGE_SPACE_MAP_FN(storage, space) \ @@ -78,7 +78,7 @@ default: break; } - return llvm::None; + return std::nullopt; #undef STORAGE_SPACE_MAP_FN } @@ -94,7 +94,7 @@ default: break; } - return llvm::None; + return std::nullopt; #undef STORAGE_SPACE_MAP_FN } @@ -120,7 +120,7 @@ // Downstream callers should plug in more specialized ones. auto intAttr = memorySpaceAttr.dyn_cast(); if (!intAttr) - return llvm::None; + return std::nullopt; unsigned memorySpace = intAttr.getInt(); #define STORAGE_SPACE_MAP_FN(storage, space) \ @@ -132,7 +132,7 @@ default: break; } - return llvm::None; + return std::nullopt; #undef STORAGE_SPACE_MAP_FN } @@ -148,7 +148,7 @@ default: break; } - return llvm::None; + return std::nullopt; #undef STORAGE_SPACE_MAP_FN } @@ -172,7 +172,7 @@ LLVM_DEBUG(llvm::dbgs() << "cannot convert " << memRefType << " due to being unable to find memory space in map\n"); - return llvm::None; + return std::nullopt; } auto storageAttr = diff --git a/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp b/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp --- a/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp +++ b/mlir/lib/Conversion/NVGPUToNVVM/NVGPUToNVVM.cpp @@ -305,7 +305,7 @@ "could not infer the PTX type for the accumulator/result"); // TODO: add an attribute to the op to customize this behavior. - Optional overflow(llvm::None); + Optional overflow(std::nullopt); if (aType.getElementType().isa()) overflow = NVVM::MMAIntOverflow::satfinite; @@ -322,7 +322,7 @@ Value intrinsicResult = rewriter.create( op.getLoc(), intrinsicResTy, matA, matB, matC, /*shape=*/gemmShape, - /*b1Op=*/llvm::None, + /*b1Op=*/std::nullopt, /*intOverflow=*/overflow, /*multiplicandPtxTypes=*/ std::array{*ptxTypeA, *ptxTypeB}, @@ -517,7 +517,7 @@ return failure(); // TODO: add an attribute to the op to customize this behavior. - Optional overflow(llvm::None); + Optional overflow(std::nullopt); if (aType.getElementType().isa()) overflow = NVVM::MMAIntOverflow::satfinite; diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp --- a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp +++ b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp @@ -614,7 +614,7 @@ builder.setInsertionPointToEnd(rewriterModule.getBody()); auto rewriterFunc = builder.create( pattern.getLoc(), "pdl_generated_rewriter", - builder.getFunctionType(llvm::None, llvm::None)); + builder.getFunctionType(std::nullopt, llvm::None)); rewriterSymbolTable.insert(rewriterFunc); // Generate the rewriter function body. @@ -681,7 +681,7 @@ // Update the signature of the rewrite function. rewriterFunc.setType(builder.getFunctionType( llvm::to_vector<8>(rewriterFunc.front().getArgumentTypes()), - /*results=*/llvm::None)); + /*results=*/std::nullopt)); builder.create(rewriter.getLoc()); return SymbolRefAttr::get( @@ -968,8 +968,8 @@ auto matcherFunc = builder.create( module.getLoc(), pdl_interp::PDLInterpDialect::getMatcherFunctionName(), builder.getFunctionType(builder.getType(), - /*results=*/llvm::None), - /*attrs=*/llvm::None); + /*results=*/std::nullopt), + /*attrs=*/std::nullopt); // Create a nested module to hold the functions invoked for rewriting the IR // after a successful match. diff --git a/mlir/lib/Conversion/PDLToPDLInterp/Predicate.h b/mlir/lib/Conversion/PDLToPDLInterp/Predicate.h --- a/mlir/lib/Conversion/PDLToPDLInterp/Predicate.h +++ b/mlir/lib/Conversion/PDLToPDLInterp/Predicate.h @@ -600,7 +600,7 @@ return OperandGroupPosition::get(uniquer, p, group, isVariadic); } Position *getAllOperands(OperationPosition *p) { - return getOperandGroup(p, /*group=*/llvm::None, /*isVariadic=*/true); + return getOperandGroup(p, /*group=*/std::nullopt, /*isVariadic=*/true); } /// Returns a result position for a result of the given operation. @@ -614,7 +614,7 @@ return ResultGroupPosition::get(uniquer, p, group, isVariadic); } Position *getAllResults(OperationPosition *p) { - return getResultGroup(p, /*group=*/llvm::None, /*isVariadic=*/true); + return getResultGroup(p, /*group=*/std::nullopt, /*isVariadic=*/true); } /// Returns a type position for the given entity. diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp --- a/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp +++ b/mlir/lib/Conversion/PDLToPDLInterp/PredicateTree.cpp @@ -110,7 +110,7 @@ Value val, PredicateBuilder &builder, DenseMap &inputs, OperationPosition *pos, - Optional ignoreOperand = llvm::None) { + Optional ignoreOperand = std::nullopt) { assert(val.getType().isa() && "expected operation"); pdl::OperationOp op = cast(val.getDefiningOp()); OperationPosition *opPos = cast(pos); @@ -458,7 +458,7 @@ // For those, the index is empty. if (operands.size() == 1 && operands[0].getType().isa()) { - toVisit.emplace(operands[0], entry.value, llvm::None, + toVisit.emplace(operands[0], entry.value, std::nullopt, entry.depth + 1); return; } diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp --- a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp +++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp @@ -179,7 +179,7 @@ // mapping a loop nest of depth "numLoops" rooted at "forOp" to a GPU kernel. // This may fail if the IR for computing loop bounds cannot be constructed, for // example if an affine loop uses semi-affine maps. Return the last loop to be -// mapped on success, llvm::None on failure. +// mapped on success, std::nullopt on failure. Optional AffineLoopToGpuConverter::collectBounds(AffineForOp forOp, unsigned numLoops) { OpBuilder builder(forOp.getOperation()); @@ -192,7 +192,7 @@ Value lowerBound = getOrEmitLowerBound(currentLoop, builder); Value upperBound = getOrEmitUpperBound(currentLoop, builder); if (!lowerBound || !upperBound) { - return llvm::None; + return std::nullopt; } Value range = builder.create(currentLoop.getLoc(), @@ -248,7 +248,7 @@ Location terminatorLoc = terminator.getLoc(); terminator.erase(); builder.setInsertionPointToEnd(innermostForOp.getBody()); - builder.create(terminatorLoc, llvm::None); + builder.create(terminatorLoc, std::nullopt); launchOp.getBody().front().getOperations().splice( launchOp.getBody().front().begin(), innermostForOp.getBody()->getOperations()); diff --git a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp --- a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp +++ b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp @@ -412,7 +412,7 @@ rewriter.setInsertionPointToEnd(&beforeBlock); rewriter.replaceOpWithNewOp( - cond, conditionVal, &afterBlock, condArgs, &mergeBlock, llvm::None); + cond, conditionVal, &afterBlock, condArgs, &mergeBlock, std::nullopt); // Convert the scf.yield op to a branch back to the header block. rewriter.setInsertionPointToEnd(&afterBlock); diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp @@ -188,7 +188,7 @@ convertStructTypeWithOffset(spirv::StructType type, LLVMTypeConverter &converter) { if (type != VulkanLayoutUtils::decorateType(type)) - return llvm::None; + return std::nullopt; auto elementsVector = llvm::to_vector<8>( llvm::map_range(type.getElementTypes(), [&](Type elementType) { @@ -253,7 +253,7 @@ Type elementType = type.getElementType(); auto sizeInBytes = elementType.cast().getSizeInBytes(); if (stride != 0 && (!sizeInBytes || *sizeInBytes != stride)) - return llvm::None; + return std::nullopt; auto llvmElementType = converter.convertType(elementType); unsigned numElements = type.getNumElements(); @@ -274,7 +274,7 @@ static Optional convertRuntimeArrayType(spirv::RuntimeArrayType type, TypeConverter &converter) { if (type.getArrayStride() != 0) - return llvm::None; + return std::nullopt; auto elementType = converter.convertType(type.getElementType()); return LLVM::LLVMArrayType::get(elementType, 0); } @@ -286,7 +286,7 @@ SmallVector memberDecorations; type.getMemberDecorations(memberDecorations); if (!memberDecorations.empty()) - return llvm::None; + return std::nullopt; if (type.hasOffset()) return convertStructTypeWithOffset(type, converter); return convertStructTypePacked(type, converter); @@ -812,7 +812,7 @@ ConversionPatternRewriter &rewriter) const override { if (callOp.getNumResults() == 0) { rewriter.replaceOpWithNewOp( - callOp, llvm::None, adaptor.getOperands(), callOp->getAttrs()); + callOp, std::nullopt, adaptor.getOperands(), callOp->getAttrs()); return success(); } diff --git a/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp b/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp --- a/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp +++ b/mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp @@ -119,10 +119,10 @@ SmallVector strides; if (failed(getStridesAndOffset(memrefType, strides, offset)) || strides.back() != 1) - return llvm::None; + return std::nullopt; int64_t stride = strides[strides.size() - 2]; if (stride == ShapedType::kDynamic) - return llvm::None; + return std::nullopt; return stride; } @@ -184,7 +184,7 @@ } /// Return the MMA elementwise enum associated with `op` if it is supported. -/// Return `llvm::None` otherwise. +/// Return `std::nullopt` otherwise. static std::optional convertElementwiseOpToMMA(Operation *op) { if (isa(op)) @@ -197,7 +197,7 @@ return gpu::MMAElementwiseOp::MINF; if (isa(op)) return gpu::MMAElementwiseOp::DIVF; - return llvm::None; + return std::nullopt; } /// Return true if the op is supported as elementwise op on MMAMatrix type. diff --git a/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp b/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp --- a/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/AffineAnalysis.cpp @@ -67,7 +67,7 @@ .Default([](Operation *) -> Optional { // TODO: AtomicRMW supports other kinds of reductions this is // currently not detecting, add those when the need arises. - return llvm::None; + return std::nullopt; }); if (!maybeKind) return nullptr; diff --git a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp --- a/mlir/lib/Dialect/Affine/Analysis/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Analysis/Utils.cpp @@ -146,7 +146,7 @@ /// each slice dimension maps to an existing dst dimension and both the src /// and the dst loops for those dimensions have the same bounds. Returns false /// if both the src and the dst loops don't have the same bounds. Returns -/// llvm::None if none of the above can be proven. +/// std::nullopt if none of the above can be proven. Optional ComputationSliceState::isSliceMaximalFastCheck() const { assert(lbs.size() == ubs.size() && !lbs.empty() && !ivs.empty() && "Unexpected number of lbs, ubs and ivs in slice"); @@ -164,19 +164,19 @@ // Make sure we skip those cases by checking that the lb result is not // just a constant. lbMap.getResult(0).isa()) - return llvm::None; + return std::nullopt; // Limited support: we expect the lb result to be just a loop dimension for // now. AffineDimExpr result = lbMap.getResult(0).dyn_cast(); if (!result) - return llvm::None; + return std::nullopt; // Retrieve dst loop bounds. AffineForOp dstLoop = getForInductionVarOwner(lbOperands[i][result.getPosition()]); if (!dstLoop) - return llvm::None; + return std::nullopt; AffineMap dstLbMap = dstLoop.getLowerBoundMap(); AffineMap dstUbMap = dstLoop.getUpperBoundMap(); @@ -190,7 +190,7 @@ // constant component per bound for now. if (srcLbMap.getNumResults() != 1 || srcUbMap.getNumResults() != 1 || dstLbMap.getNumResults() != 1 || dstUbMap.getNumResults() != 1) - return llvm::None; + return std::nullopt; AffineExpr srcLbResult = srcLbMap.getResult(0); AffineExpr dstLbResult = dstLbMap.getResult(0); @@ -200,7 +200,7 @@ !srcUbResult.isa() || !dstLbResult.isa() || !dstUbResult.isa()) - return llvm::None; + return std::nullopt; // Check if src and dst loop bounds are the same. If not, we can guarantee // that the slice is not maximal. @@ -235,20 +235,20 @@ // TODO: Store the source's domain to avoid computation at each depth. if (failed(getSourceAsConstraints(srcConstraints))) { LLVM_DEBUG(llvm::dbgs() << "Unable to compute source's domain\n"); - return llvm::None; + return std::nullopt; } // As the set difference utility currently cannot handle symbols in its // operands, validity of the slice cannot be determined. if (srcConstraints.getNumSymbolVars() > 0) { LLVM_DEBUG(llvm::dbgs() << "Cannot handle symbols in source domain\n"); - return llvm::None; + return std::nullopt; } // TODO: Handle local vars in the source domains while using the 'projectOut' // utility below. Currently, aligning is not done assuming that there will be // no local vars in the source domain. if (srcConstraints.getNumLocalVars() != 0) { LLVM_DEBUG(llvm::dbgs() << "Cannot handle locals in source domain\n"); - return llvm::None; + return std::nullopt; } // Create constraints for the slice loop nest that would be created if the @@ -256,7 +256,7 @@ FlatAffineValueConstraints sliceConstraints; if (failed(getAsConstraints(&sliceConstraints))) { LLVM_DEBUG(llvm::dbgs() << "Unable to compute slice's domain\n"); - return llvm::None; + return std::nullopt; } // Projecting out every dimension other than the 'ivs' to express slice's @@ -283,7 +283,7 @@ } /// Returns true if the computation slice encloses all the iterations of the -/// sliced loop nest. Returns false if it does not. Returns llvm::None if it +/// sliced loop nest. Returns false if it does not. Returns std::nullopt if it /// cannot determine if the slice is maximal or not. Optional ComputationSliceState::isMaximal() const { // Fast check to determine if the computation slice is maximal. If the result @@ -300,7 +300,7 @@ AffineForOp loop = getForInductionVarOwner(iv); assert(loop && "Expected affine for"); if (failed(srcConstraints.addAffineForOpDomain(loop))) - return llvm::None; + return std::nullopt; } // Create constraints for the slice using the dst loop nest information. We @@ -320,12 +320,12 @@ /*numLocals=*/0, consumerIVs); if (failed(sliceConstraints.addDomainFromSliceMaps(lbs, ubs, lbOperands[0]))) - return llvm::None; + return std::nullopt; if (srcConstraints.getNumDimVars() != sliceConstraints.getNumDimVars()) // Constraint dims are different. The integer set difference can't be // computed so we don't know if the slice is maximal. - return llvm::None; + return std::nullopt; // Compute the difference between the src loop nest and the slice integer // sets. diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -2263,7 +2263,7 @@ Optional AffineForOp::getSingleLowerBound() { if (!hasConstantLowerBound()) - return llvm::None; + return std::nullopt; OpBuilder b(getContext()); return OpFoldResult(b.getI64IntegerAttr(getConstantLowerBound())); } @@ -2275,7 +2275,7 @@ Optional AffineForOp::getSingleUpperBound() { if (!hasConstantUpperBound()) - return llvm::None; + return std::nullopt; OpBuilder b(getContext()); return OpFoldResult(b.getI64IntegerAttr(getConstantUpperBound())); } @@ -2365,8 +2365,8 @@ buildAffineLoopFromConstants(OpBuilder &builder, Location loc, int64_t lb, int64_t ub, int64_t step, AffineForOp::BodyBuilderFn bodyBuilderFn) { - return builder.create(loc, lb, ub, step, /*iterArgs=*/llvm::None, - bodyBuilderFn); + return builder.create(loc, lb, ub, step, + /*iterArgs=*/std::nullopt, bodyBuilderFn); } /// Creates an affine loop from the bounds that may or may not be constants. @@ -2381,7 +2381,7 @@ ubConst.value(), step, bodyBuilderFn); return builder.create(loc, lb, builder.getDimIdentityMap(), ub, builder.getDimIdentityMap(), step, - /*iterArgs=*/llvm::None, bodyBuilderFn); + /*iterArgs=*/std::nullopt, bodyBuilderFn); } void mlir::buildAffineLoopNest( @@ -3551,7 +3551,7 @@ Optional> AffineParallelOp::getConstantRanges() { if (hasMinMaxBounds()) - return llvm::None; + return std::nullopt; // Try to convert all the ranges to constant expressions. SmallVector out; @@ -3563,7 +3563,7 @@ auto expr = rangesValueMap.getResult(i); auto cst = expr.dyn_cast(); if (!cst) - return llvm::None; + return std::nullopt; out.push_back(cst.getValue()); } return out; diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp --- a/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineDataCopyGeneration.cpp @@ -141,7 +141,7 @@ if ((forOp = dyn_cast(&*it)) && copyNests.count(forOp) == 0) { // Perform the copying up unti this 'for' op first. (void)affineDataCopyGenerate(/*begin=*/curBegin, /*end=*/it, copyOptions, - /*filterMemRef=*/llvm::None, copyNests); + /*filterMemRef=*/std::nullopt, copyNests); // Returns true if the footprint is known to exceed capacity. auto exceedsCapacity = [&](AffineForOp forOp) { @@ -176,7 +176,7 @@ // loop's footprint fits. (void)affineDataCopyGenerate(/*begin=*/it, /*end=*/std::next(it), copyOptions, - /*filterMemRef=*/llvm::None, copyNests); + /*filterMemRef=*/std::nullopt, copyNests); } // Get to the next load or store op after 'forOp'. curBegin = std::find_if(std::next(it), block->end(), [&](Operation &op) { @@ -200,7 +200,7 @@ // Exclude the affine.yield - hence, the std::prev. (void)affineDataCopyGenerate(/*begin=*/curBegin, /*end=*/std::prev(block->end()), copyOptions, - /*filterMemRef=*/llvm::None, copyNests); + /*filterMemRef=*/std::nullopt, copyNests); } } diff --git a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp --- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp @@ -599,7 +599,7 @@ For(isVectorizableLoopPtrFactory(parallelLoops, d1), For(isVectorizableLoopPtrFactory(parallelLoops, d2)))); default: { - return llvm::None; + return std::nullopt; } } } diff --git a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp --- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp +++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp @@ -1509,7 +1509,7 @@ if (auto vectorIntType = t.dyn_cast()) { return vectorIntType.getElementType().cast().getWidth(); } - return llvm::None; + return std::nullopt; } OpFoldResult arith::CmpIOp::fold(ArrayRef operands) { diff --git a/mlir/lib/Dialect/Async/IR/Async.cpp b/mlir/lib/Dialect/Async/IR/Async.cpp --- a/mlir/lib/Dialect/Async/IR/Async.cpp +++ b/mlir/lib/Dialect/Async/IR/Async.cpp @@ -342,7 +342,7 @@ return; assert(type.getNumInputs() == argAttrs.size()); function_interface_impl::addArgAndResultAttrs(builder, state, argAttrs, - /*resultAttrs=*/llvm::None); + /*resultAttrs=*/std::nullopt); } ParseResult FuncOp::parse(OpAsmParser &parser, OperationState &result) { diff --git a/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp b/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp --- a/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp @@ -371,7 +371,8 @@ // parent operation. In this case, we have to introduce an additional clone // for buffer that is passed to the argument. SmallVector successorRegions; - regionInterface.getSuccessorRegions(/*index=*/llvm::None, successorRegions); + regionInterface.getSuccessorRegions(/*index=*/std::nullopt, + successorRegions); auto *it = llvm::find_if(successorRegions, [&](RegionSuccessor &successorRegion) { return successorRegion.getSuccessor() == argRegion; diff --git a/mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp b/mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp --- a/mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/BufferUtils.cpp @@ -131,7 +131,7 @@ // Start with all entry regions and test whether they induce a loop. SmallVector successorRegions; - regionInterface.getSuccessorRegions(/*index=*/llvm::None, successorRegions); + regionInterface.getSuccessorRegions(/*index=*/std::nullopt, successorRegions); for (RegionSuccessor ®ionEntry : successorRegions) { if (recurse(regionEntry.getSuccessor())) return true; diff --git a/mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp b/mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp --- a/mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/BufferViewFlowAnalysis.cpp @@ -82,7 +82,8 @@ op->walk([&](RegionBranchOpInterface regionInterface) { // Extract all entry regions and wire all initial entry successor inputs. SmallVector entrySuccessors; - regionInterface.getSuccessorRegions(/*index=*/llvm::None, entrySuccessors); + regionInterface.getSuccessorRegions(/*index=*/std::nullopt, + entrySuccessors); for (RegionSuccessor &entrySuccessor : entrySuccessors) { // Wire the entry region's successor arguments with the initial // successor inputs. diff --git a/mlir/lib/Dialect/Bufferization/Transforms/TensorCopyInsertion.cpp b/mlir/lib/Dialect/Bufferization/Transforms/TensorCopyInsertion.cpp --- a/mlir/lib/Dialect/Bufferization/Transforms/TensorCopyInsertion.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/TensorCopyInsertion.cpp @@ -166,7 +166,7 @@ struct TensorCopyInsertionPass : public bufferization::impl::TensorCopyInsertionBase< TensorCopyInsertionPass> { - TensorCopyInsertionPass() : options(llvm::None) {} + TensorCopyInsertionPass() : options(std::nullopt) {} TensorCopyInsertionPass(const OneShotBufferizationOptions &options) : options(options) {} diff --git a/mlir/lib/Dialect/Func/IR/FuncOps.cpp b/mlir/lib/Dialect/Func/IR/FuncOps.cpp --- a/mlir/lib/Dialect/Func/IR/FuncOps.cpp +++ b/mlir/lib/Dialect/Func/IR/FuncOps.cpp @@ -253,7 +253,7 @@ return; assert(type.getNumInputs() == argAttrs.size()); function_interface_impl::addArgAndResultAttrs(builder, state, argAttrs, - /*resultAttrs=*/llvm::None); + /*resultAttrs=*/std::nullopt); } ParseResult FuncOp::parse(OpAsmParser &parser, OperationState &result) { diff --git a/mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp b/mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp --- a/mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp +++ b/mlir/lib/Dialect/GPU/TransformOps/GPUTransformOps.cpp @@ -103,12 +103,12 @@ static DiagnosedSilenceableFailure createGpuLaunch(RewriterBase &rewriter, Location loc, TransformOpInterface transformOp, LaunchOp &launchOp, - Optional gridDimX = llvm::None, - Optional gridDimY = llvm::None, - Optional gridDimZ = llvm::None, - Optional blockDimX = llvm::None, - Optional blockDimY = llvm::None, - Optional blockDimZ = llvm::None) { + Optional gridDimX = std::nullopt, + Optional gridDimY = std::nullopt, + Optional gridDimZ = std::nullopt, + Optional blockDimX = std::nullopt, + Optional blockDimY = std::nullopt, + Optional blockDimZ = std::nullopt) { DiagnosedSilenceableFailure diag = checkGpuLimits(transformOp, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ); @@ -137,12 +137,12 @@ static DiagnosedSilenceableFailure alterGpuLaunch(SimpleRewriter &rewriter, LaunchOp gpuLaunch, TransformOpInterface transformOp, - Optional gridDimX = llvm::None, - Optional gridDimY = llvm::None, - Optional gridDimZ = llvm::None, - Optional blockDimX = llvm::None, - Optional blockDimY = llvm::None, - Optional blockDimZ = llvm::None) { + Optional gridDimX = std::nullopt, + Optional gridDimY = std::nullopt, + Optional gridDimZ = std::nullopt, + Optional blockDimX = std::nullopt, + Optional blockDimY = std::nullopt, + Optional blockDimZ = std::nullopt) { DiagnosedSilenceableFailure diag = checkGpuLimits(transformOp, gridDimX, gridDimY, gridDimZ, blockDimX, blockDimY, blockDimZ); @@ -546,7 +546,7 @@ blockDim.resize(/*size=*/3, /*value=*/1); DiagnosedSilenceableFailure diag = - checkGpuLimits(transformOp, llvm::None, llvm::None, llvm::None, + checkGpuLimits(transformOp, std::nullopt, llvm::None, llvm::None, blockDim[0], blockDim[1], blockDim[2]); if (diag.isSilenceableFailure()) { results.assign({target}); @@ -568,9 +568,9 @@ threadMappingAttributes); if (diag.succeeded()) { - diag = - alterGpuLaunch(rewriter, gpuLaunch, transformOp, llvm::None, llvm::None, - llvm::None, blockDim[0], blockDim[1], blockDim[2]); + diag = alterGpuLaunch(rewriter, gpuLaunch, transformOp, std::nullopt, + llvm::None, std::nullopt, blockDim[0], blockDim[1], + blockDim[2]); } results.assign({gpuLaunch}); diff --git a/mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp b/mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp --- a/mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/SerializeToBlob.cpp @@ -41,7 +41,7 @@ llvmModule.setDataLayout(targetMachine.createDataLayout()); if (failed(optimizeLlvm(llvmModule, targetMachine))) - return llvm::None; + return std::nullopt; std::string targetISA; llvm::raw_string_ostream stream(targetISA); @@ -52,7 +52,7 @@ if (targetMachine.addPassesToEmitFile(codegenPasses, pstream, nullptr, llvm::CGFT_AssemblyFile)) - return llvm::None; + return std::nullopt; codegenPasses.run(llvmModule); } diff --git a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp --- a/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp @@ -155,7 +155,7 @@ if (!llvm::sys::fs::is_directory(path)) { getOperation().emitRemark() << "Bitcode path: " << path << " does not exist or is not a directory\n"; - return llvm::None; + return std::nullopt; } for (const StringRef file : libraries) { @@ -168,7 +168,7 @@ if (!library) { getOperation().emitError() << "Failed to load library " << file << " from " << path << error.getMessage(); - return llvm::None; + return std::nullopt; } // Some ROCM builds don't strip this like they should if (auto *openclVersion = library->getNamedMetadata("opencl.ocl.version")) diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -776,7 +776,7 @@ auto llvmTy = type.dyn_cast(); if (!llvmTy) { parser.emitError(trailingTypeLoc, "expected LLVM pointer type"); - return llvm::None; + return std::nullopt; } return llvmTy.getElementType(); } @@ -2007,7 +2007,7 @@ assert(type.cast().getNumParams() == argAttrs.size() && "expected as many argument attribute lists as arguments"); function_interface_impl::addArgAndResultAttrs(builder, result, argAttrs, - /*resultAttrs=*/llvm::None); + /*resultAttrs=*/std::nullopt); } // Builds an LLVM function type from the given lists of input and output types. diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp @@ -305,7 +305,7 @@ : kDefaultPointerAlignment; } - return llvm::None; + return std::nullopt; } unsigned @@ -538,7 +538,7 @@ return entry.isTypeEntry(); }); if (currentEntry == params.end()) - return llvm::None; + return std::nullopt; auto attr = currentEntry->getValue().cast(); if (pos == StructDLEntryPos::Preferred && diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp @@ -92,16 +92,16 @@ if (operandElType.isa()) { if (isAccumulator) return NVVM::MMATypes::s32; - return llvm::None; + return std::nullopt; } if (auto structType = operandElType.dyn_cast()) { if (structType.getBody().empty()) - return llvm::None; + return std::nullopt; return inferOperandMMAType(structType.getBody()[0], isAccumulator); } - return llvm::None; + return std::nullopt; } static bool isInt4PtxType(MMATypes type) { diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp --- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp +++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp @@ -1174,7 +1174,7 @@ FailureOr result = linalg::tileReductionUsingForeachThread( rewriter, cast(target.getOperation()), - numThreadResults, /*mapping=*/llvm::None); + numThreadResults, /*mapping=*/std::nullopt); if (failed(result)) { results.assign(3, nullptr); diff --git a/mlir/lib/Dialect/Linalg/Transforms/ConstantFold.cpp b/mlir/lib/Dialect/Linalg/Transforms/ConstantFold.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/ConstantFold.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/ConstantFold.cpp @@ -291,8 +291,8 @@ // No computation; just return the orginal value. return [](const APIntOrFloatArray &inputs) { if (inputs.apFloats.empty()) - return APIntOrFloat{inputs.apInts.front(), llvm::None}; - return APIntOrFloat{llvm::None, inputs.apFloats.front()}; + return APIntOrFloat{inputs.apInts.front(), std::nullopt}; + return APIntOrFloat{std::nullopt, inputs.apFloats.front()}; }; } diff --git a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp @@ -386,7 +386,7 @@ Type actualType = opOperand->get().getType(); if (auto memref = actualType.dyn_cast()) { if (!memref.getLayout().isIdentity()) - return llvm::None; + return std::nullopt; } int64_t dim = 0; diff --git a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp @@ -734,10 +734,10 @@ isExpanding ? expandingReshapeOp.getReassociationMaps() : collapsingReshapeOp.getReassociationMaps(), expandedType.getShape(), collapsedType.getShape(), rewriter))) - return llvm::None; + return std::nullopt; if (failed(isGenericOpExpandable(genericOp, expansionInfo, rewriter))) - return llvm::None; + return std::nullopt; SmallVector expandedOpIndexingMaps = llvm::to_vector<4>( llvm::map_range(genericOp.getIndexingMapsArray(), [&](AffineMap m) { @@ -772,7 +772,7 @@ opOperandType.getShape(), expandedOperandType.getShape(), reassociation, /*isExpandingReshape=*/true))) - return llvm::None; + return std::nullopt; expandedOpOperands.push_back(rewriter.create( genericOp.getLoc(), expandedOperandType, opOperand->get(), reassociation)); @@ -799,7 +799,7 @@ opOperandType.getShape(), expandedOutputType.getShape(), reassociation, /*isExpandingReshape=*/true))) - return llvm::None; + return std::nullopt; outputs.push_back(rewriter.create( genericOp.getLoc(), expandedOutputType, opOperand->get(), reassociation)); @@ -960,9 +960,9 @@ //===---------------------------------------------------------------------===// /// For a given list of indices in the range of the `indexingMap` that are -/// folded, return the indices of the corresponding domain. Return `llvm::None` -/// on failure. Ensures that all the elements of the returned reassociation are -/// distinct. +/// folded, return the indices of the corresponding domain. Return +/// `std::nullopt` on failure. Ensures that all the elements of the returned +/// reassociation are distinct. static ReassociationIndices getDomainReassociation(AffineMap indexingMap, ReassociationIndicesRef rangeReassociation) { diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -467,7 +467,7 @@ calculateTileOffsetsAndSizes( b, loc, foreachThreadOp, numThreads, iterationDomain, /*omitTileOffsetBoundsCheck =*/false, - /*nominalTileSizes=*/llvm::None, tiledOffsets, tiledSizes); + /*nominalTileSizes=*/std::nullopt, tiledOffsets, tiledSizes); // 4. Clone the tileable op and update its destination operands to use the // output bbArgs of the ForeachThreadOp. diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp @@ -123,7 +123,7 @@ using ::mlir::vector::CombiningKind; if (!combinerOp) - return llvm::None; + return std::nullopt; return llvm::TypeSwitch>( combinerOp) .Case( @@ -137,7 +137,7 @@ [&](auto op) { return CombiningKind::MUL; }) .Case([&](auto op) { return CombiningKind::OR; }) .Case([&](auto op) { return CombiningKind::XOR; }) - .Default([&](auto op) { return llvm::None; }); + .Default([&](auto op) { return std::nullopt; }); } /// Check whether `outputOperand` is a reduction with a single combiner diff --git a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp --- a/mlir/lib/Dialect/Linalg/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Linalg/Utils/Utils.cpp @@ -105,17 +105,17 @@ RegionMatcher::matchAsScalarBinaryOp(GenericOp op) { auto ®ion = op.getRegion(); if (!llvm::hasSingleElement(region)) - return llvm::None; + return std::nullopt; Block &block = region.front(); if (block.getNumArguments() != 2 || !block.getArgument(0).getType().isSignlessIntOrFloat() || !block.getArgument(1).getType().isSignlessIntOrFloat()) - return llvm::None; + return std::nullopt; auto &ops = block.getOperations(); if (!llvm::hasSingleElement(block.without_terminator())) - return llvm::None; + return std::nullopt; using mlir::matchers::m_Val; auto a = m_Val(block.getArgument(0)); @@ -125,7 +125,7 @@ if (addPattern.match(&ops.back())) return BinaryOpKind::IAdd; - return llvm::None; + return std::nullopt; } /// Explicit instantiation of loop nest generator for different loop types. @@ -965,7 +965,7 @@ Type operandType = opOperand.get().getType(); if (!isTiled(map, tileSizes) && !(operandType.isa() && linalgOp.isDpsInit(&opOperand))) { - allSliceParams.push_back(llvm::None); + allSliceParams.push_back(std::nullopt); LLVM_DEBUG(llvm::dbgs() << ": not tiled: use shape: " << operandType << "\n"); continue; @@ -1087,7 +1087,7 @@ return b.getIntegerAttr(resultType, std::numeric_limits::max()); if (isa(op)) return b.getIntegerAttr(resultType, 1); - return llvm::None; + return std::nullopt; } } // namespace linalg diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp --- a/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp +++ b/mlir/lib/Dialect/MemRef/IR/MemRefDialect.cpp @@ -50,7 +50,7 @@ continue; // If we found > 1 dealloc, return None. if (dealloc) - return llvm::None; + return std::nullopt; dealloc = user; } return dealloc; diff --git a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp --- a/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp +++ b/mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp @@ -986,7 +986,7 @@ getStridesAndOffset(originalType, originalStrides, originalOffset)) || failed( getStridesAndOffset(reducedType, candidateStrides, candidateOffset))) - return llvm::None; + return std::nullopt; // For memrefs, a dimension is truly dropped if its corresponding stride is // also dropped. This is particularly important when more than one of the dims @@ -1021,13 +1021,13 @@ candidateStridesNumOccurences[originalStride]) { // This should never happen. Cant have a stride in the reduced rank type // that wasnt in the original one. - return llvm::None; + return std::nullopt; } } if ((int64_t)unusedDims.count() + reducedType.getRank() != originalType.getRank()) - return llvm::None; + return std::nullopt; return unusedDims; } diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp --- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp +++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp @@ -134,7 +134,7 @@ return failure(parser.parseLParen() || parseOperandAndType(parser, result) || parser.parseRParen()); } - return llvm::None; + return std::nullopt; } /// Parse optional operand and its type wrapped in parenthesis. @@ -145,7 +145,7 @@ if (succeeded(parser.parseOptionalLParen())) { return failure(parseOperandAndType(parser, result) || parser.parseRParen()); } - return llvm::None; + return std::nullopt; } /// Parse optional operand with its type prefixed with prefixKeyword `=`. @@ -158,7 +158,7 @@ return failure(); return success(); } - return llvm::None; + return std::nullopt; } static bool isComputeOperation(Operation *op) { diff --git a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp --- a/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp +++ b/mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp @@ -312,12 +312,12 @@ if (parser.parseOperand(*chunkSize) || parser.parseColonType(chunkType)) return failure(); } else { - chunkSize = llvm::None; + chunkSize = std::nullopt; } break; case ClauseScheduleKind::Auto: case ClauseScheduleKind::Runtime: - chunkSize = llvm::None; + chunkSize = std::nullopt; } // If there is a comma, we have one or more modifiers.. diff --git a/mlir/lib/Dialect/SCF/IR/SCF.cpp b/mlir/lib/Dialect/SCF/IR/SCF.cpp --- a/mlir/lib/Dialect/SCF/IR/SCF.cpp +++ b/mlir/lib/Dialect/SCF/IR/SCF.cpp @@ -583,7 +583,7 @@ ValueRange steps, function_ref bodyBuilder) { // Delegate to the main function by wrapping the body builder. - return buildLoopNest(builder, loc, lbs, ubs, steps, llvm::None, + return buildLoopNest(builder, loc, lbs, ubs, steps, std::nullopt, [&bodyBuilder](OpBuilder &nestedBuilder, Location nestedLoc, ValueRange ivs, ValueRange) -> ValueVector { @@ -719,7 +719,7 @@ }; /// Util function that tries to compute a constant diff between u and l. -/// Returns llvm::None when the difference between two AffineValueMap is +/// Returns std::nullopt when the difference between two AffineValueMap is /// dynamic. static Optional computeConstDiff(Value l, Value u) { IntegerAttr clb, cub; @@ -736,7 +736,7 @@ matchPattern( u, m_Op(m_ConstantInt(&diff), matchers::m_Val(l)))) return diff.getSExtValue(); - return llvm::None; + return std::nullopt; } /// Rewriting pattern that erases loops that are known not to iterate, replaces @@ -1451,7 +1451,7 @@ void IfOp::build(OpBuilder &builder, OperationState &result, Value cond, bool withElseRegion) { - build(builder, result, /*resultTypes=*/llvm::None, cond, withElseRegion); + build(builder, result, /*resultTypes=*/std::nullopt, cond, withElseRegion); } void IfOp::build(OpBuilder &builder, OperationState &result, @@ -2595,7 +2595,8 @@ auto newSteps = concatValues(op.getStep(), innerOp.getStep()); rewriter.replaceOpWithNewOp(op, newLowerBounds, newUpperBounds, - newSteps, llvm::None, bodyBuilder); + newSteps, std::nullopt, + bodyBuilder); return success(); } }; diff --git a/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp b/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp --- a/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp @@ -44,8 +44,8 @@ // // Derived classes should provide the following method which performs the - // actual conversion. It should return llvm::None upon conversion failure and - // return the converted operation upon success. + // actual conversion. It should return std::nullopt upon conversion failure + // and return the converted operation upon success. // // Optional convertSourceOp(SourceOp op, OpAdaptor adaptor, // ConversionPatternRewriter &rewriter, @@ -127,7 +127,7 @@ // convertRegionTypes already takes care of 1:N conversion. if (failed(rewriter.convertRegionTypes(&op.getLoopBody(), *typeConverter))) - return llvm::None; + return std::nullopt; // Unpacked the iteration arguments. SmallVector flatArgs; @@ -201,7 +201,7 @@ for (auto i : {0u, 1u}) { if (failed(rewriter.convertRegionTypes(&op.getRegion(i), *typeConverter))) - return llvm::None; + return std::nullopt; auto &dstRegion = newOp.getRegion(i); rewriter.inlineRegionBefore(op.getRegion(i), dstRegion, dstRegion.end()); } diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVAttributes.cpp @@ -156,7 +156,7 @@ if (getImpl()->storageClass) return static_cast( getImpl()->storageClass.cast().getValue().getZExtValue()); - return llvm::None; + return std::nullopt; } LogicalResult spirv::InterfaceVarABIAttr::verify( diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVCanonicalization.cpp @@ -30,14 +30,14 @@ /// or splat vector bool constant. static Optional getScalarOrSplatBoolAttr(Attribute attr) { if (!attr) - return llvm::None; + return std::nullopt; if (auto boolAttr = attr.dyn_cast()) return boolAttr.getValue(); if (auto splatAttr = attr.dyn_cast()) if (splatAttr.getElementType().isInteger(1)) return splatAttr.getSplatValue(); - return llvm::None; + return std::nullopt; } // Extracts an element from the given `composite` by following the given diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVDialect.cpp @@ -479,7 +479,7 @@ StringRef enumSpec; SMLoc enumLoc = parser.getCurrentLocation(); if (parser.parseKeyword(&enumSpec)) { - return llvm::None; + return std::nullopt; } auto val = spirv::symbolizeEnum(enumSpec); @@ -494,7 +494,7 @@ // TODO: Further verify that the element type can be sampled auto ty = parseAndVerifyType(dialect, parser); if (!ty) - return llvm::None; + return std::nullopt; return ty; } @@ -503,7 +503,7 @@ DialectAsmParser &parser) { IntTy offsetVal = std::numeric_limits::max(); if (parser.parseInteger(offsetVal)) - return llvm::None; + return std::nullopt; return offsetVal; } @@ -524,14 +524,14 @@ operator()(SPIRVDialect const &dialect, DialectAsmParser &parser) const { auto parseVal = parseAndVerify(dialect, parser); if (!parseVal) - return llvm::None; + return std::nullopt; auto numArgs = std::tuple_size>::value; if (numArgs != 0 && failed(parser.parseComma())) - return llvm::None; + return std::nullopt; auto remainingValues = ParseCommaSeparatedList{}(dialect, parser); if (!remainingValues) - return llvm::None; + return std::nullopt; return std::tuple_cat(std::tuple(parseVal.value()), remainingValues.value()); } @@ -545,7 +545,7 @@ DialectAsmParser &parser) const { if (auto value = parseAndVerify(dialect, parser)) return std::tuple(*value); - return llvm::None; + return std::nullopt; } }; } // namespace diff --git a/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp --- a/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp @@ -80,7 +80,7 @@ auto elementType = getElementType().cast(); Optional size = elementType.getSizeInBytes(); if (!size) - return llvm::None; + return std::nullopt; return (*size + getArrayStride()) * getNumElements(); } @@ -194,10 +194,10 @@ Optional elementSize = vectorType.getElementType().cast().getSizeInBytes(); if (!elementSize) - return llvm::None; + return std::nullopt; return *elementSize * vectorType.getNumElements(); } - return llvm::None; + return std::nullopt; } //===----------------------------------------------------------------------===// @@ -716,7 +716,7 @@ // non-externally visible shader Storage Classes: Workgroup, CrossWorkgroup, // Private, Function, Input, and Output." if (bitWidth == 1) - return llvm::None; + return std::nullopt; return bitWidth / 8; } @@ -783,7 +783,7 @@ return scalarType.getSizeInBytes(); if (auto compositeType = dyn_cast()) return compositeType.getSizeInBytes(); - return llvm::None; + return std::nullopt; } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp --- a/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp @@ -54,7 +54,7 @@ }); if (chosen != caps.end()) return *chosen; - return llvm::None; + return std::nullopt; } bool spirv::TargetEnv::allows(spirv::Extension extension) const { @@ -68,7 +68,7 @@ }); if (chosen != exts.end()) return *chosen; - return llvm::None; + return std::nullopt; } spirv::Vendor spirv::TargetEnv::getVendorID() const { diff --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp @@ -235,7 +235,7 @@ // Creates a new function with the update signature. rewriter.updateRootInPlace(funcOp, [&] { funcOp.setType(rewriter.getFunctionType( - signatureConverter.getConvertedTypes(), llvm::None)); + signatureConverter.getConvertedTypes(), std::nullopt)); }); return success(); } diff --git a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/SPIRVConversion.cpp @@ -140,14 +140,14 @@ // non-externally visible shader Storage Classes: Workgroup, CrossWorkgroup, // Private, Function, Input, and Output." if (bitWidth == 1) - return llvm::None; + return std::nullopt; return bitWidth / 8; } if (auto vecType = type.dyn_cast()) { auto elementSize = getTypeNumBytes(options, vecType.getElementType()); if (!elementSize) - return llvm::None; + return std::nullopt; return vecType.getNumElements() * *elementSize; } @@ -158,14 +158,14 @@ SmallVector strides; if (!memRefType.hasStaticShape() || failed(getStridesAndOffset(memRefType, strides, offset))) - return llvm::None; + return std::nullopt; // To get the size of the memref object in memory, the total size is the // max(stride * dimension-size) computed for all dimensions times the size // of the element. auto elementSize = getTypeNumBytes(options, memRefType.getElementType()); if (!elementSize) - return llvm::None; + return std::nullopt; if (memRefType.getRank() == 0) return elementSize; @@ -174,7 +174,7 @@ if (llvm::is_contained(dims, ShapedType::kDynamic) || ShapedType::isDynamic(offset) || llvm::is_contained(strides, ShapedType::kDynamic)) - return llvm::None; + return std::nullopt; int64_t memrefSize = -1; for (const auto &shape : enumerate(dims)) @@ -185,11 +185,11 @@ if (auto tensorType = type.dyn_cast()) { if (!tensorType.hasStaticShape()) - return llvm::None; + return std::nullopt; auto elementSize = getTypeNumBytes(options, tensorType.getElementType()); if (!elementSize) - return llvm::None; + return std::nullopt; int64_t size = *elementSize; for (auto shape : tensorType.getShape()) @@ -199,7 +199,7 @@ } // TODO: Add size computation for other types. - return llvm::None; + return std::nullopt; } /// Converts a scalar `type` to a suitable type under the given `targetEnv`. diff --git a/mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/UnifyAliasedResourcePass.cpp @@ -82,7 +82,7 @@ } /// Given a list of resource element `types`, returns the index of the canonical -/// resource that all resources should be unified into. Returns llvm::None if +/// resource that all resources should be unified into. Returns std::nullopt if /// unable to unify. static Optional deduceCanonicalResource(ArrayRef types) { // scalarNumBits: contains all resources' scalar types' bit counts. @@ -98,11 +98,12 @@ assert(type.isScalarOrVector()); if (auto vectorType = type.dyn_cast()) { if (vectorType.getNumElements() % 2 != 0) - return llvm::None; // Odd-sized vector has special layout requirements. + return std::nullopt; // Odd-sized vector has special layout + // requirements. Optional numBytes = type.getSizeInBytes(); if (!numBytes) - return llvm::None; + return std::nullopt; scalarNumBits.push_back( vectorType.getElementType().getIntOrFloatBitWidth()); @@ -122,7 +123,7 @@ // With out this, we cannot properly adjust the index later. if (llvm::any_of(vectorNumBits, [&](int bits) { return bits % *minVal != 0; })) - return llvm::None; + return std::nullopt; // Require all scalar type bit counts to be a multiple of the chosen // vector's primitive type to avoid reading/writing subcomponents. @@ -130,7 +131,7 @@ int baseNumBits = scalarNumBits[index]; if (llvm::any_of(scalarNumBits, [&](int bits) { return bits % baseNumBits != 0; })) - return llvm::None; + return std::nullopt; return index; } @@ -140,7 +141,7 @@ auto *minVal = std::min_element(scalarNumBits.begin(), scalarNumBits.end()); if (llvm::any_of(scalarNumBits, [minVal](int64_t bit) { return bit % *minVal != 0; })) - return llvm::None; + return std::nullopt; return std::distance(scalarNumBits.begin(), minVal); } diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -1073,7 +1073,7 @@ return constSizeOp.getValue().getLimitedValue(); if (auto constantOp = getIndex().getDefiningOp()) return constantOp.getValue().cast().getInt(); - return llvm::None; + return std::nullopt; } OpFoldResult DimOp::fold(ArrayRef operands) { @@ -1301,7 +1301,7 @@ return; assert(type.getNumInputs() == argAttrs.size()); function_interface_impl::addArgAndResultAttrs(builder, state, argAttrs, - /*resultAttrs=*/llvm::None); + /*resultAttrs=*/std::nullopt); } ParseResult FuncOp::parse(OpAsmParser &parser, OperationState &result) { @@ -1327,7 +1327,7 @@ return constSizeOp.getValue().getLimitedValue(); if (auto constantOp = getDim().getDefiningOp()) return constantOp.getValue().cast().getInt(); - return llvm::None; + return std::nullopt; } OpFoldResult GetExtentOp::fold(ArrayRef operands) { diff --git a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp --- a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp +++ b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp @@ -593,7 +593,7 @@ OpBuilder &builder, OperationState &result, Value tensor, function_ref bodyBuilder) { - build(builder, result, tensor, llvm::None, bodyBuilder); + build(builder, result, tensor, std::nullopt, bodyBuilder); } void ForeachOp::build( diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp @@ -117,7 +117,7 @@ Value adaptedValue, unsigned dim) { auto enc = getSparseTensorEncoding(tensorTp); if (!enc) - return llvm::None; + return std::nullopt; // Access into static dimension can query original type directly. // Note that this is typically already done by DimOp's folding. @@ -195,7 +195,7 @@ convertSparseTensorType(Type type, SmallVectorImpl &fields) { auto enc = getSparseTensorEncoding(type); if (!enc) - return llvm::None; + return std::nullopt; // Construct the basic types. auto *context = type.getContext(); unsigned idxWidth = enc.getIndexBitWidth(); @@ -1020,7 +1020,7 @@ Location loc) -> Optional { if (!getSparseTensorEncoding(tp)) // Not a sparse tensor. - return llvm::None; + return std::nullopt; // Sparse compiler knows how to cancel out these casts. return genTuple(builder, loc, tp, inputs); }); diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp @@ -42,7 +42,7 @@ static Optional convertSparseTensorTypes(Type type) { if (getSparseTensorEncoding(type) != nullptr) return LLVM::LLVMPointerType::get(IntegerType::get(type.getContext(), 8)); - return llvm::None; + return std::nullopt; } /// Replaces the `op` with a `CallOp` to the function reference returned diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp @@ -682,7 +682,7 @@ Block *insertionBlock = rewriter.getInsertionBlock(); bool noEscape = bufferization::allocationDoesNotEscape(op->getOpResult(0)); - rewriter.create(loc, src, llvm::None, + rewriter.create(loc, src, std::nullopt, [&](OpBuilder &builder, Location loc, ValueRange args, Value v, ValueRange reduc) { builder.create(loc, v, dst, @@ -1053,7 +1053,7 @@ ModuleOp module = op->getParentOfType(); // For each element in the source tensor, output the element. rewriter.create( - loc, src, llvm::None, + loc, src, std::nullopt, [&](OpBuilder &builder, Location loc, ValueRange args, Value v, ValueRange reduc) { for (uint64_t i = 0; i < rank; i++) { diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp @@ -508,7 +508,8 @@ if (tldx && merger.isFilterLoop(tldx.value())) { assert(!ta.isa() && !isDenseDLT(getDimLevelType(enc, d))); - addAffineOrderings(adjM, inDegree, ta, AffineExpr(), llvm::None, tldx); + addAffineOrderings(adjM, inDegree, ta, AffineExpr(), std::nullopt, + tldx); // Now that the ordering of affine expression is captured by filter // loop idx, we only need to ensure the affine ordering against filter // loop. Thus, we reset the affine express to nil here to mark it as @@ -1532,7 +1533,7 @@ genLoopBoundary(codegen, merger, [&](MutableArrayRef reduc) { codegen.loopEmitter.exitCurrentLoop(rewriter, op.getLoc(), reduc); - return llvm::None; + return std::nullopt; }); return needsUniv; diff --git a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp --- a/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp +++ b/mlir/lib/Dialect/Tensor/IR/TensorOps.cpp @@ -2330,7 +2330,7 @@ auto getSourceOfCastOp = [](Value v) -> Optional { auto castOp = v.getDefiningOp(); if (!castOp || !canFoldIntoConsumerOp(castOp)) - return llvm::None; + return std::nullopt; return castOp.getSource(); }; Optional sourceCastSource = diff --git a/mlir/lib/Dialect/Traits.cpp b/mlir/lib/Dialect/Traits.cpp --- a/mlir/lib/Dialect/Traits.cpp +++ b/mlir/lib/Dialect/Traits.cpp @@ -148,11 +148,11 @@ } // Returns the type kind if the given type is a vector or ranked tensor type. - // Returns llvm::None otherwise. + // Returns std::nullopt otherwise. auto getCompositeTypeKind = [](Type type) -> Optional { if (type.isa()) return type.getTypeID(); - return llvm::None; + return std::nullopt; }; // Make sure the composite type, if has, is consistent. diff --git a/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp b/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp --- a/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp +++ b/mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp @@ -24,14 +24,14 @@ if (sourceType.getRank() < targetType.getRank()) return getReassociationIndicesForCollapse(targetType.getShape(), sourceType.getShape()); - return llvm::None; + return std::nullopt; } Optional> mlir::getReassociationIndicesForCollapse(ArrayRef sourceShape, ArrayRef targetShape) { if (sourceShape.size() <= targetShape.size()) - return llvm::None; + return std::nullopt; unsigned sourceDim = 0; SmallVector reassociationMap; reassociationMap.reserve(targetShape.size()); @@ -59,18 +59,18 @@ if (sourceShape[sourceDim] == ShapedType::kDynamic && (currTargetShape != ShapedType::kDynamic || prodOfCollapsedDims != 1)) - return llvm::None; + return std::nullopt; // If the collapsed dim is dynamic, the current expanded dim should also // be dynamic. if (currTargetShape == ShapedType::kDynamic && sourceShape[sourceDim] != ShapedType::kDynamic) - return llvm::None; + return std::nullopt; // For static shapes, if the product of dimensions of the expanded shape // should match the collapsed dimension shape. if (prodOfCollapsedDims * sourceShape[sourceDim] != currTargetShape) - return llvm::None; + return std::nullopt; currIndices.push_back(sourceDim++); reassociationMap.emplace_back(ReassociationIndices{}); @@ -79,13 +79,13 @@ } // All the dimensions in the target must have been processed. if (reassociationMap.size() != targetShape.size()) - return llvm::None; + return std::nullopt; // Process any remaining entries in the source shape. They all need to be // 1 or dynamic. for (; sourceDim < sourceShape.size(); sourceDim++) { if (sourceShape[sourceDim] != ShapedType::kDynamic && sourceShape[sourceDim] != 1) - return llvm::None; + return std::nullopt; // The map is empty when the target type is a scalar. if (!reassociationMap.empty()) reassociationMap.back().push_back(sourceDim); @@ -101,7 +101,7 @@ // Make the producer the larger sized vector. If they are of same size, the // resulting reshape is not a supported reshape op. if (producerReassociations.size() == consumerReassociations.size()) - return llvm::None; + return std::nullopt; if (producerReassociations.size() < consumerReassociations.size()) std::swap(producerReassociations, consumerReassociations); @@ -116,7 +116,7 @@ return all + indices.size(); }); if (producerReassociations.size() != consumerDims) - return llvm::None; + return std::nullopt; for (ReassociationIndicesRef consumerIndices : consumerReassociations) { ReassociationIndices reassociations; diff --git a/mlir/lib/Dialect/Utils/StaticValueUtils.cpp b/mlir/lib/Dialect/Utils/StaticValueUtils.cpp --- a/mlir/lib/Dialect/Utils/StaticValueUtils.cpp +++ b/mlir/lib/Dialect/Utils/StaticValueUtils.cpp @@ -99,13 +99,13 @@ APSInt intVal; if (matchPattern(val, m_ConstantInt(&intVal))) return intVal.getSExtValue(); - return llvm::None; + return std::nullopt; } // Case 2: Check for IntegerAttr. Attribute attr = ofr.dyn_cast(); if (auto intAttr = attr.dyn_cast_or_null()) return intAttr.getValue().getSExtValue(); - return llvm::None; + return std::nullopt; } /// Return true if `ofr` is constant integer equal to `value`. diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp --- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp @@ -5462,7 +5462,7 @@ TypeRange resultTypes, Value laneId, int64_t warpSize) { build(builder, result, resultTypes, laneId, warpSize, - /*operands=*/llvm::None, /*argTypes=*/llvm::None); + /*operands=*/std::nullopt, /*argTypes=*/llvm::None); } void WarpExecuteOnLane0Op::build(OpBuilder &builder, OperationState &result, diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp --- a/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp +++ b/mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp @@ -190,13 +190,13 @@ } /// Look for a given dimension in an affine map and return its position. Return -/// llvm::None if the dimension is not in the map results. +/// std::nullopt if the dimension is not in the map results. static llvm::Optional getDimPosition(AffineMap map, unsigned dim) { for (unsigned i = 0, e = map.getNumResults(); i < e; i++) { if (map.getDimPosition(i) == dim) return i; } - return llvm::None; + return std::nullopt; } namespace { diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp --- a/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp +++ b/mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp @@ -132,28 +132,28 @@ resultTypes, op->getAttrs()); } -/// Return the target shape for unrolling for the given `op`. Return llvm::None -/// if the op shouldn't be or cannot be unrolled. +/// Return the target shape for unrolling for the given `op`. Return +/// std::nullopt if the op shouldn't be or cannot be unrolled. static Optional> getTargetShape(const vector::UnrollVectorOptions &options, Operation *op) { if (options.filterConstraint && failed(options.filterConstraint(op))) - return llvm::None; + return std::nullopt; assert(options.nativeShape && "vector unrolling expects the native shape or native" "shape call back function to be set"); auto unrollableVectorOp = dyn_cast(op); if (!unrollableVectorOp) - return llvm::None; + return std::nullopt; auto maybeUnrollShape = unrollableVectorOp.getShapeForUnroll(); if (!maybeUnrollShape) - return llvm::None; + return std::nullopt; Optional> targetShape = options.nativeShape(op); if (!targetShape) - return llvm::None; + return std::nullopt; auto maybeShapeRatio = computeShapeRatio(*maybeUnrollShape, *targetShape); if (!maybeShapeRatio || llvm::all_of(*maybeShapeRatio, [](int64_t v) { return v == 1; })) - return llvm::None; + return std::nullopt; return targetShape; } diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp --- a/mlir/lib/IR/AffineMap.cpp +++ b/mlir/lib/IR/AffineMap.cpp @@ -63,13 +63,13 @@ if (auto attr = operandConsts[expr.cast().getPosition()] .dyn_cast_or_null()) return attr.getInt(); - return llvm::None; + return std::nullopt; case AffineExprKind::SymbolId: if (auto attr = operandConsts[numDims + expr.cast().getPosition()] .dyn_cast_or_null()) return attr.getInt(); - return llvm::None; + return std::nullopt; } llvm_unreachable("Unknown AffineExpr"); } @@ -81,7 +81,7 @@ if (auto lhs = constantFoldImpl(binOpExpr.getLHS())) if (auto rhs = constantFoldImpl(binOpExpr.getRHS())) return op(*lhs, *rhs); - return llvm::None; + return std::nullopt; } // The number of dimension operands in AffineMap containing this expression. diff --git a/mlir/lib/IR/BuiltinAttributes.cpp b/mlir/lib/IR/BuiltinAttributes.cpp --- a/mlir/lib/IR/BuiltinAttributes.cpp +++ b/mlir/lib/IR/BuiltinAttributes.cpp @@ -92,10 +92,10 @@ } /// Returns an entry with a duplicate name from the given sorted array of named -/// attributes. Returns llvm::None if all elements have unique names. +/// attributes. Returns std::nullopt if all elements have unique names. static Optional findDuplicateElement(ArrayRef value) { - const Optional none{llvm::None}; + const Optional none{std::nullopt}; if (value.size() < 2) return none; @@ -1604,7 +1604,7 @@ DenseResourceElementsAttrBase::tryGetAsArrayRef() const { if (AsmResourceBlob *blob = this->getRawHandle().getBlob()) return blob->template getDataAs(); - return llvm::None; + return std::nullopt; } template diff --git a/mlir/lib/IR/BuiltinTypes.cpp b/mlir/lib/IR/BuiltinTypes.cpp --- a/mlir/lib/IR/BuiltinTypes.cpp +++ b/mlir/lib/IR/BuiltinTypes.cpp @@ -405,11 +405,11 @@ // If no match on `originalIdx`, the `originalShape` at this dimension // must be 1, otherwise we bail. if (originalShape[originalIdx] != 1) - return llvm::None; + return std::nullopt; } // The whole reducedShape must be scanned, otherwise we bail. if (reducedIdx != reducedRank) - return llvm::None; + return std::nullopt; return unusedDims; } diff --git a/mlir/lib/IR/Diagnostics.cpp b/mlir/lib/IR/Diagnostics.cpp --- a/mlir/lib/IR/Diagnostics.cpp +++ b/mlir/lib/IR/Diagnostics.cpp @@ -401,9 +401,9 @@ return callLoc; } } - return llvm::None; + return std::nullopt; } - return llvm::None; + return std::nullopt; } /// Given a diagnostic kind, returns the LLVM DiagKind. @@ -530,7 +530,7 @@ if (!shouldShowLocFn) return loc; if (!shouldShowLocFn(loc)) - return llvm::None; + return std::nullopt; // Recurse into the child locations of some of location types. return TypeSwitch>(loc) @@ -546,7 +546,7 @@ for (Location childLoc : fusedLoc.getLocations()) if (Optional showableLoc = findLocToShow(childLoc)) return showableLoc; - return llvm::None; + return std::nullopt; }) .Case([&](NameLoc nameLoc) -> Optional { return findLocToShow(nameLoc.getChildLoc()); @@ -557,7 +557,7 @@ }) .Case([](UnknownLoc) -> Optional { // Prefer not to show unknown locations. - return llvm::None; + return std::nullopt; }); } @@ -699,7 +699,7 @@ auto expectedDiags = expectedDiagsPerFile.find(bufName); if (expectedDiags != expectedDiagsPerFile.end()) return MutableArrayRef(expectedDiags->second); - return llvm::None; + return std::nullopt; } MutableArrayRef @@ -707,7 +707,7 @@ raw_ostream &os, llvm::SourceMgr &mgr, const llvm::MemoryBuffer *buf) { // If the buffer is invalid, return an empty list. if (!buf) - return llvm::None; + return std::nullopt; auto &expectedDiags = expectedDiagsPerFile[buf->getBufferIdentifier()]; // The number of the last line that did not correlate to a designator. diff --git a/mlir/lib/IR/ExtensibleDialect.cpp b/mlir/lib/IR/ExtensibleDialect.cpp --- a/mlir/lib/IR/ExtensibleDialect.cpp +++ b/mlir/lib/IR/ExtensibleDialect.cpp @@ -468,7 +468,7 @@ StringRef typeName, AsmParser &parser, Type &resultType) const { DynamicTypeDefinition *typeDef = lookupTypeDefinition(typeName); if (!typeDef) - return llvm::None; + return std::nullopt; DynamicType dynType; if (DynamicType::parse(parser, typeDef, dynType)) @@ -490,7 +490,7 @@ StringRef attrName, AsmParser &parser, Attribute &resultAttr) const { DynamicAttrDefinition *attrDef = lookupAttrDefinition(attrName); if (!attrDef) - return llvm::None; + return std::nullopt; DynamicAttr dynAttr; if (DynamicAttr::parse(parser, attrDef, dynAttr)) diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp --- a/mlir/lib/IR/MLIRContext.cpp +++ b/mlir/lib/IR/MLIRContext.cpp @@ -753,7 +753,7 @@ auto it = impl.registeredOperations.find(name); if (it != impl.registeredOperations.end()) return it->getValue(); - return llvm::None; + return std::nullopt; } ParseResult diff --git a/mlir/lib/IR/SymbolTable.cpp b/mlir/lib/IR/SymbolTable.cpp --- a/mlir/lib/IR/SymbolTable.cpp +++ b/mlir/lib/IR/SymbolTable.cpp @@ -555,7 +555,7 @@ return walkSymbolTable(regions, [&](Operation *op) -> Optional { // Check that this isn't a potentially unknown symbol table. if (isPotentiallyUnknownSymbolTable(op)) - return llvm::None; + return std::nullopt; return walkSymbolRefs(op, callback); }); @@ -571,7 +571,7 @@ // symbol table, so we can't opaquely know if we should traverse to find // nested uses. if (isPotentiallyUnknownSymbolTable(from)) - return llvm::None; + return std::nullopt; // Walk the uses on this operation. if (walkSymbolRefs(from, callback).wasInterrupted()) @@ -740,7 +740,8 @@ return WalkResult::advance(); }; auto result = walkSymbolUses(from, walkFn); - return result ? Optional(std::move(uses)) : llvm::None; + return result ? Optional(std::move(uses)) + : std::nullopt; } /// Get an iterator range for all of the uses, for any symbol, that are nested @@ -770,7 +771,7 @@ if (isReferencePrefixOf(scope.symbol, symbolUse.getSymbolRef())) uses.push_back(symbolUse); })) - return llvm::None; + return std::nullopt; } return SymbolTable::UseRange(std::move(uses)); } diff --git a/mlir/lib/Interfaces/ControlFlowInterfaces.cpp b/mlir/lib/Interfaces/ControlFlowInterfaces.cpp --- a/mlir/lib/Interfaces/ControlFlowInterfaces.cpp +++ b/mlir/lib/Interfaces/ControlFlowInterfaces.cpp @@ -42,13 +42,13 @@ OperandRange forwardedOperands = operands.getForwardedOperands(); // Check that the operands are valid. if (forwardedOperands.empty()) - return llvm::None; + return std::nullopt; // Check to ensure that this operand is within the range. unsigned operandsStart = forwardedOperands.getBeginOperandIndex(); if (operandIndex < operandsStart || operandIndex >= (operandsStart + forwardedOperands.size())) - return llvm::None; + return std::nullopt; // Index the successor. unsigned argIndex = @@ -85,9 +85,9 @@ //===----------------------------------------------------------------------===// /// Verify that types match along all region control flow edges originating from -/// `sourceNo` (region # if source is a region, llvm::None if source is parent +/// `sourceNo` (region # if source is a region, std::nullopt if source is parent /// op). `getInputsTypesForRegion` is a function that returns the types of the -/// inputs that flow from `sourceIndex' to the given region, or llvm::None if +/// inputs that flow from `sourceIndex' to the given region, or std::nullopt if /// the exact type match verification is not necessary (e.g., if the Op verifies /// the match itself). static LogicalResult @@ -156,7 +156,7 @@ }; // Verify types along control flow edges originating from the parent. - if (failed(verifyTypesAlongAllEdges(op, llvm::None, inputTypesFromParent))) + if (failed(verifyTypesAlongAllEdges(op, std::nullopt, inputTypesFromParent))) return failure(); auto areTypesCompatible = [&](TypeRange lhs, TypeRange rhs) { @@ -206,7 +206,7 @@ // If there is no return-like terminator, the op itself should verify // type consistency. if (!regionReturnOperands) - return llvm::None; + return std::nullopt; // All successors get the same set of operand types. return TypeRange(regionReturnOperands->getTypes()); @@ -363,9 +363,9 @@ /// Returns the mutable operands that are passed to the region with the given /// `regionIndex`. If the operation does not implement the /// `RegionBranchTerminatorOpInterface` and is not marked as `ReturnLike`, the -/// result will be `llvm::None`. In all other cases, the resulting +/// result will be `std::nullopt`. In all other cases, the resulting /// `OperandRange` represents all operands that are passed to the specified -/// successor region. If `regionIndex` is `llvm::None`, all operands that are +/// successor region. If `regionIndex` is `std::nullopt`, all operands that are /// passed to the parent operation will be returned. Optional mlir::getMutableRegionBranchSuccessorOperands(Operation *operation, @@ -382,7 +382,7 @@ // easier. Furthermore, this may even make this function obsolete. if (operation->hasTrait()) return MutableOperandRange(operation); - return llvm::None; + return std::nullopt; } /// Returns the read only operands that are passed to the region with the given @@ -392,5 +392,5 @@ mlir::getRegionBranchSuccessorOperands(Operation *operation, Optional regionIndex) { auto range = getMutableRegionBranchSuccessorOperands(operation, regionIndex); - return range ? Optional(*range) : llvm::None; + return range ? Optional(*range) : std::nullopt; } diff --git a/mlir/lib/Pass/Pass.cpp b/mlir/lib/Pass/Pass.cpp --- a/mlir/lib/Pass/Pass.cpp +++ b/mlir/lib/Pass/Pass.cpp @@ -716,7 +716,7 @@ for (auto ®ion : getOperation()->getRegions()) { for (Operation &op : region.getOps()) { // Get the pass manager index for this operation type. - auto pmIdxIt = knownOpPMIdx.try_emplace(op.getName(), llvm::None); + auto pmIdxIt = knownOpPMIdx.try_emplace(op.getName(), std::nullopt); if (pmIdxIt.second) { if (auto *mgr = findPassManagerFor(mgrs, op.getName(), *context)) pmIdxIt.first->second = std::distance(mgrs.begin(), mgr); diff --git a/mlir/lib/Pass/PassStatistics.cpp b/mlir/lib/Pass/PassStatistics.cpp --- a/mlir/lib/Pass/PassStatistics.cpp +++ b/mlir/lib/Pass/PassStatistics.cpp @@ -27,7 +27,7 @@ /// Utility to print a pass entry in the statistics output. static void printPassEntry(raw_ostream &os, unsigned indent, StringRef pass, - MutableArrayRef stats = llvm::None) { + MutableArrayRef stats = std::nullopt) { os.indent(indent) << pass << "\n"; if (stats.empty()) return; diff --git a/mlir/lib/Support/FileUtilities.cpp b/mlir/lib/Support/FileUtilities.cpp --- a/mlir/lib/Support/FileUtilities.cpp +++ b/mlir/lib/Support/FileUtilities.cpp @@ -37,7 +37,7 @@ std::unique_ptr mlir::openInputFile(StringRef inputFilename, std::string *errorMessage) { return openInputFileImpl(inputFilename, errorMessage, - /*alignment=*/llvm::None); + /*alignment=*/std::nullopt); } std::unique_ptr mlir::openInputFile(llvm::StringRef inputFilename, llvm::Align alignment, diff --git a/mlir/lib/Support/Timing.cpp b/mlir/lib/Support/Timing.cpp --- a/mlir/lib/Support/Timing.cpp +++ b/mlir/lib/Support/Timing.cpp @@ -511,7 +511,7 @@ Optional DefaultTimingManager::rootTimer() { if (impl->enabled) return impl->rootTimer.get(); - return llvm::None; + return std::nullopt; } void DefaultTimingManager::startTimer(void *handle) { diff --git a/mlir/lib/TableGen/AttrOrTypeDef.cpp b/mlir/lib/TableGen/AttrOrTypeDef.cpp --- a/mlir/lib/TableGen/AttrOrTypeDef.cpp +++ b/mlir/lib/TableGen/AttrOrTypeDef.cpp @@ -22,7 +22,7 @@ Optional AttrOrTypeBuilder::getReturnType() const { Optional type = def->getValueAsOptionalString("returnType"); - return type && !type->empty() ? type : llvm::None; + return type && !type->empty() ? type : std::nullopt; } bool AttrOrTypeBuilder::hasInferredContextParameter() const { @@ -282,7 +282,7 @@ Optional AttrOrTypeParameter::getDefaultValue() const { Optional result = getDefValue("defaultValue"); - return result && !result->empty() ? result : llvm::None; + return result && !result->empty() ? result : std::nullopt; } llvm::Init *AttrOrTypeParameter::getDef() const { return def->getArg(index); } diff --git a/mlir/lib/TableGen/Attribute.cpp b/mlir/lib/TableGen/Attribute.cpp --- a/mlir/lib/TableGen/Attribute.cpp +++ b/mlir/lib/TableGen/Attribute.cpp @@ -73,7 +73,7 @@ llvm::Optional Attribute::getValueType() const { if (auto *defInit = dyn_cast(def->getValueInit("valueType"))) return Type(defInit->getDef()); - return llvm::None; + return std::nullopt; } StringRef Attribute::getConvertFromStorageCall() const { diff --git a/mlir/lib/TableGen/Builder.cpp b/mlir/lib/TableGen/Builder.cpp --- a/mlir/lib/TableGen/Builder.cpp +++ b/mlir/lib/TableGen/Builder.cpp @@ -36,10 +36,10 @@ /// parameter. Optional Builder::Parameter::getDefaultValue() const { if (isa(def)) - return llvm::None; + return std::nullopt; const llvm::Record *record = cast(def)->getDef(); Optional value = record->getValueAsOptionalString("defaultValue"); - return value && !value->empty() ? value : llvm::None; + return value && !value->empty() ? value : std::nullopt; } //===----------------------------------------------------------------------===// @@ -77,5 +77,5 @@ /// Return an optional string containing the body of the builder. Optional Builder::getBody() const { Optional body = def->getValueAsOptionalString("body"); - return body && !body->empty() ? body : llvm::None; + return body && !body->empty() ? body : std::nullopt; } diff --git a/mlir/lib/TableGen/Constraint.cpp b/mlir/lib/TableGen/Constraint.cpp --- a/mlir/lib/TableGen/Constraint.cpp +++ b/mlir/lib/TableGen/Constraint.cpp @@ -90,20 +90,20 @@ if (const auto *defInit = dyn_cast(defValue->getValue())) return Constraint(defInit->getDef(), kind).getDefName(); } - return llvm::None; + return std::nullopt; }; switch (kind) { case CK_Attr: if (def->isAnonymous()) return checkBaseDefFn("baseAttr"); - return llvm::None; + return std::nullopt; case CK_Type: if (def->isAnonymous()) return checkBaseDefFn("baseType"); - return llvm::None; + return std::nullopt; default: - return llvm::None; + return std::nullopt; } } diff --git a/mlir/lib/TableGen/Interfaces.cpp b/mlir/lib/TableGen/Interfaces.cpp --- a/mlir/lib/TableGen/Interfaces.cpp +++ b/mlir/lib/TableGen/Interfaces.cpp @@ -120,7 +120,7 @@ llvm::Optional Interface::getVerify() const { // Only OpInterface supports the verify method. if (!isa(this)) - return llvm::None; + return std::nullopt; auto value = def->getValueAsString("verify"); return value.empty() ? llvm::Optional() : value; } diff --git a/mlir/lib/TableGen/Type.cpp b/mlir/lib/TableGen/Type.cpp --- a/mlir/lib/TableGen/Type.cpp +++ b/mlir/lib/TableGen/Type.cpp @@ -49,13 +49,13 @@ // Check to see if this type constraint has a builder call. const llvm::RecordVal *builderCall = baseType->getValue("builderCall"); if (!builderCall || !builderCall->getValue()) - return llvm::None; + return std::nullopt; return TypeSwitch>(builderCall->getValue()) .Case([&](auto *init) { StringRef value = init->getValue(); return value.empty() ? Optional() : value; }) - .Default([](auto *) { return llvm::None; }); + .Default([](auto *) { return std::nullopt; }); } // Return the C++ class name for this type (which may just be ::mlir::Type). diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp --- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp @@ -125,7 +125,7 @@ /*File=*/nullptr, /*Line=*/0, /*Scope=*/nullptr, translate(attr.getBaseType()), attr.getSizeInBits(), attr.getAlignInBits(), attr.getOffsetInBits(), - /*DWARFAddressSpace=*/llvm::None, /*Flags=*/llvm::DINode::FlagZero); + /*DWARFAddressSpace=*/std::nullopt, /*Flags=*/llvm::DINode::FlagZero); } llvm::DIFile *DebugTranslation::translateImpl(DIFileAttr attr) { diff --git a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp --- a/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.cpp @@ -213,7 +213,7 @@ SmallVector loopOptions; // Reserve operand 0 for loop id self reference. - auto dummy = llvm::MDNode::getTemporary(ctx, llvm::None); + auto dummy = llvm::MDNode::getTemporary(ctx, std::nullopt); loopOptions.push_back(dummy.get()); auto loopAttr = attr.cast(); diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -56,7 +56,7 @@ static FailureOr translateDataLayout(DataLayoutSpecInterface attribute, const DataLayout &dataLayout, - Optional loc = llvm::None) { + Optional loc = std::nullopt) { if (!loc) loc = UnknownLoc::get(attribute.getContext()); diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h --- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h +++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.h @@ -421,7 +421,7 @@ /// compose the error message) or the next instruction is malformed. LogicalResult sliceInstruction(spirv::Opcode &opcode, ArrayRef &operands, - Optional expectedOpcode = llvm::None); + Optional expectedOpcode = std::nullopt); /// Processes a SPIR-V instruction with the given `opcode` and `operands`. /// This method is the main entrance for handling SPIR-V instruction; it diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp --- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp +++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp @@ -490,7 +490,7 @@ } curBlock = nullptr; - curFunction = llvm::None; + curFunction = std::nullopt; LLVM_DEBUG({ logger.unindent(); @@ -504,7 +504,7 @@ spirv::Deserializer::getConstant(uint32_t id) { auto constIt = constantMap.find(id); if (constIt == constantMap.end()) - return llvm::None; + return std::nullopt; return constIt->getSecond(); } @@ -512,7 +512,7 @@ spirv::Deserializer::getSpecConstantOperation(uint32_t id) { auto constIt = specConstOperationMap.find(id); if (constIt == specConstOperationMap.end()) - return llvm::None; + return std::nullopt; return constIt->getSecond(); } @@ -2103,7 +2103,7 @@ return success(); } -void spirv::Deserializer::clearDebugLine() { debugLine = llvm::None; } +void spirv::Deserializer::clearDebugLine() { debugLine = std::nullopt; } LogicalResult spirv::Deserializer::processDebugString(ArrayRef operands) { diff --git a/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp b/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp --- a/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp +++ b/mlir/lib/Tools/PDLL/CodeGen/MLIRGen.cpp @@ -346,8 +346,8 @@ Value results = builder.create( loc, pdl::RangeType::get(builder.getType()), /*types=*/ArrayAttr()); - return builder.create(loc, opType.getName(), operands, - llvm::None, ValueRange(), results); + return builder.create( + loc, opType.getName(), operands, std::nullopt, ValueRange(), results); } if (ast::RangeType rangeTy = type.dyn_cast()) { diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp --- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp +++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp @@ -981,7 +981,8 @@ // Build the native constraint. auto *constraintDecl = ast::UserConstraintDecl::createNative( ctx, ast::Name::create(ctx, name, loc), paramVar, - /*results=*/llvm::None, codeBlock, ast::TupleType::get(ctx), nativeType); + /*results=*/std::nullopt, codeBlock, ast::TupleType::get(ctx), + nativeType); constraintDecl->setDocComment(ctx, docString); curDeclScope->add(constraintDecl); return constraintDecl; @@ -1783,7 +1784,7 @@ FailureOr Parser::parseArgOrResultConstraint() { Optional typeConstraint; - return parseConstraint(typeConstraint, /*existingConstraints=*/llvm::None, + return parseConstraint(typeConstraint, /*existingConstraints=*/std::nullopt, /*allowInlineTypeConstraints=*/false); } @@ -2859,7 +2860,7 @@ SmallVectorImpl &operands) { return validateOperationOperandsOrResults( "operand", loc, odsOp ? odsOp->getLoc() : Optional(), name, - operands, odsOp ? odsOp->getOperands() : llvm::None, valueTy, + operands, odsOp ? odsOp->getOperands() : std::nullopt, valueTy, valueRangeTy); } @@ -2869,7 +2870,7 @@ SmallVectorImpl &results) { return validateOperationOperandsOrResults( "result", loc, odsOp ? odsOp->getLoc() : Optional(), name, - results, odsOp ? odsOp->getResults() : llvm::None, typeTy, typeRangeTy); + results, odsOp ? odsOp->getResults() : std::nullopt, typeTy, typeRangeTy); } void Parser::checkOperationResultTypeInferrence(SMRange loc, StringRef opName, @@ -2968,8 +2969,8 @@ // Otherwise, create dummy values for each of the entries so that we // adhere to the ODS signature. for (unsigned i = 0, e = odsValues.size(); i < e; ++i) { - values.push_back( - ast::RangeExpr::create(ctx, loc, /*elements=*/llvm::None, rangeTy)); + values.push_back(ast::RangeExpr::create( + ctx, loc, /*elements=*/std::nullopt, rangeTy)); } return success(); } diff --git a/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp b/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp --- a/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp +++ b/mlir/lib/Tools/lsp-server-support/SourceMgrUtils.cpp @@ -71,10 +71,10 @@ // cover the most common. We essentially look for a comment preceding the // line, and if we find one, use that as the documentation. if (!loc.isValid()) - return llvm::None; + return std::nullopt; int bufferId = sourceMgr.FindBufferContainingLoc(loc); if (bufferId == 0) - return llvm::None; + return std::nullopt; const char *bufferStart = sourceMgr.getMemoryBuffer(bufferId)->getBufferStart(); StringRef buffer(bufferStart, loc.getPointer() - bufferStart); @@ -83,7 +83,7 @@ auto popLastLine = [&]() -> Optional { size_t newlineOffset = buffer.find_last_of("\n"); if (newlineOffset == StringRef::npos) - return llvm::None; + return std::nullopt; StringRef lastLine = buffer.drop_front(newlineOffset).trim(); buffer = buffer.take_front(newlineOffset); return lastLine; @@ -91,7 +91,7 @@ // Try to pop the current line. if (!popLastLine()) - return llvm::None; + return std::nullopt; // Try to parse a comment string from the source file. SmallVector commentLines; @@ -105,7 +105,7 @@ } if (commentLines.empty()) - return llvm::None; + return std::nullopt; return llvm::join(llvm::reverse(commentLines), "\n"); } diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -32,7 +32,7 @@ lsp::Logger::error("Failed to create URI for file `{0}`: {1}", loc.getFilename(), llvm::toString(sourceURI.takeError())); - return llvm::None; + return std::nullopt; } lsp::Position position; @@ -140,7 +140,7 @@ // Check to see if this location indexes into the result group, via `#`. If it // doesn't, we can't extract a sub result number. if (*curPtr != '#') - return llvm::None; + return std::nullopt; // Compute the sub result number from the remaining portion of the string. const char *numberStart = ++curPtr; @@ -490,7 +490,7 @@ hoverRange, block.block->getArgument(arg.index()), block); } } - return llvm::None; + return std::nullopt; } Optional MLIRDocument::buildHoverForOperation( @@ -1227,7 +1227,7 @@ Optional lsp::MLIRServer::removeDocument(const URIForFile &uri) { auto it = impl->files.find(uri.file()); if (it == impl->files.end()) - return llvm::None; + return std::nullopt; int64_t version = it->second->getVersion(); impl->files.erase(it); @@ -1255,7 +1255,7 @@ auto fileIt = impl->files.find(uri.file()); if (fileIt != impl->files.end()) return fileIt->second->findHover(uri, hoverPos); - return llvm::None; + return std::nullopt; } void lsp::MLIRServer::findDocumentSymbols( diff --git a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp --- a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp +++ b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp @@ -79,7 +79,7 @@ // Skip diagnostics that weren't emitted within the main file. if (loc.uri != uri) - return llvm::None; + return std::nullopt; // Convert the severity for the diagnostic. switch (diag.getSeverity()) { @@ -460,7 +460,7 @@ SMRange hoverRange; const PDLIndexSymbol *symbol = index.lookup(posLoc, &hoverRange); if (!symbol) - return llvm::None; + return std::nullopt; // Add hover for operation names. if (const auto *op = symbol->definition.dyn_cast()) @@ -491,7 +491,7 @@ if (const auto *rewrite = dyn_cast(decl)) return buildHoverForUserConstraintOrRewrite("Rewrite", rewrite, hoverRange); - return llvm::None; + return std::nullopt; } lsp::Hover PDLDocument::buildHoverForOpName(const ods::Operation *op, @@ -1037,7 +1037,7 @@ const ods::Operation *odsOp = opName ? odsContext.lookupOperation(*opName) : nullptr; codeCompleteOperationOperandOrResultSignature( - opName, odsOp, odsOp ? odsOp->getOperands() : llvm::None, + opName, odsOp, odsOp ? odsOp->getOperands() : std::nullopt, currentNumOperands, "operand", "Value"); } @@ -1046,7 +1046,7 @@ const ods::Operation *odsOp = opName ? odsContext.lookupOperation(*opName) : nullptr; codeCompleteOperationOperandOrResultSignature( - opName, odsOp, odsOp ? odsOp->getResults() : llvm::None, + opName, odsOp, odsOp ? odsOp->getResults() : std::nullopt, currentNumResults, "result", "Type"); } @@ -1732,7 +1732,7 @@ Optional lsp::PDLLServer::removeDocument(const URIForFile &uri) { auto it = impl->files.find(uri.file()); if (it == impl->files.end()) - return llvm::None; + return std::nullopt; int64_t version = it->second->getVersion(); impl->files.erase(it); @@ -1767,7 +1767,7 @@ auto fileIt = impl->files.find(uri.file()); if (fileIt != impl->files.end()) return fileIt->second->findHover(uri, hoverPos); - return llvm::None; + return std::nullopt; } void lsp::PDLLServer::findDocumentSymbols( @@ -1813,5 +1813,5 @@ auto fileIt = impl->files.find(uri.file()); if (fileIt != impl->files.end()) return fileIt->second->getPDLLViewOutput(kind); - return llvm::None; + return std::nullopt; } diff --git a/mlir/lib/Tools/mlir-translate/Translation.cpp b/mlir/lib/Tools/mlir-translate/Translation.cpp --- a/mlir/lib/Tools/mlir-translate/Translation.cpp +++ b/mlir/lib/Tools/mlir-translate/Translation.cpp @@ -62,7 +62,7 @@ TranslateRegistration::TranslateRegistration( StringRef name, StringRef description, const TranslateFunction &function) { - registerTranslation(name, description, /*inputAlignment=*/llvm::None, + registerTranslation(name, description, /*inputAlignment=*/std::nullopt, function); } @@ -116,7 +116,7 @@ const TranslateFromMLIRFunction &function, const std::function &dialectRegistration) { registerTranslation( - name, description, /*inputAlignment=*/llvm::None, + name, description, /*inputAlignment=*/std::nullopt, [function, dialectRegistration](llvm::SourceMgr &sourceMgr, raw_ostream &output, MLIRContext *context) { diff --git a/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp b/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp --- a/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp +++ b/mlir/lib/Tools/tblgen-lsp-server/TableGenServer.cpp @@ -59,7 +59,7 @@ const lsp::URIForFile &uri) { auto *sourceMgr = const_cast(diag.getSourceMgr()); if (!sourceMgr || !diag.getLoc().isValid()) - return llvm::None; + return std::nullopt; lsp::Diagnostic lspDiag; lspDiag.source = "tablegen"; @@ -71,7 +71,7 @@ // Skip diagnostics that weren't emitted within the main file. if (loc.uri != uri) - return llvm::None; + return std::nullopt; // Convert the severity for the diagnostic. switch (diag.getKind()) { @@ -531,7 +531,7 @@ SMLoc posLoc = hoverPos.getAsSMLoc(sourceMgr); const TableGenIndexSymbol *symbol = index.lookup(posLoc, &hoverRange); if (!symbol) - return llvm::None; + return std::nullopt; // Build hover for a Record. if (auto *record = dyn_cast(symbol)) @@ -693,7 +693,7 @@ Optional lsp::TableGenServer::removeDocument(const URIForFile &uri) { auto it = impl->files.find(uri.file()); if (it == impl->files.end()) - return llvm::None; + return std::nullopt; int64_t version = it->second->getVersion(); impl->files.erase(it); @@ -728,5 +728,5 @@ auto fileIt = impl->files.find(uri.file()); if (fileIt != impl->files.end()) return fileIt->second->findHover(uri, hoverPos); - return llvm::None; + return std::nullopt; } diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -1571,7 +1571,7 @@ Value ConversionPatternRewriter::getRemappedValue(Value key) { SmallVector remappedValues; - if (failed(impl->remapValues("value", /*inputLoc=*/llvm::None, *this, key, + if (failed(impl->remapValues("value", /*inputLoc=*/std::nullopt, *this, key, remappedValues))) return nullptr; return remappedValues.front(); @@ -1582,7 +1582,7 @@ SmallVectorImpl &results) { if (keys.empty()) return success(); - return impl->remapValues("value", /*inputLoc=*/llvm::None, *this, keys, + return impl->remapValues("value", /*inputLoc=*/std::nullopt, *this, keys, results); } @@ -3048,7 +3048,7 @@ -> Optional { SignatureConversion conversion(block->getNumArguments()); if (failed(convertSignatureArgs(block->getArgumentTypes(), conversion))) - return llvm::None; + return std::nullopt; return conversion; } @@ -3147,7 +3147,7 @@ -> Optional { Optional info = getOpInfo(op->getName()); if (!info) - return llvm::None; + return std::nullopt; // Returns true if this operation instance is known to be legal. auto isOpLegal = [&] { @@ -3162,7 +3162,7 @@ return info->action == LegalizationAction::Legal; }; if (!isOpLegal()) - return llvm::None; + return std::nullopt; // This operation is legal, compute any additional legality information. LegalOpDetails legalityDetails; @@ -3269,7 +3269,7 @@ if (unknownLegalityFn) return LegalizationInfo{LegalizationAction::Dynamic, /*isRecursivelyLegal=*/false, unknownLegalityFn}; - return llvm::None; + return std::nullopt; } //===----------------------------------------------------------------------===// diff --git a/mlir/lib/Transforms/ViewOpGraph.cpp b/mlir/lib/Transforms/ViewOpGraph.cpp --- a/mlir/lib/Transforms/ViewOpGraph.cpp +++ b/mlir/lib/Transforms/ViewOpGraph.cpp @@ -69,7 +69,7 @@ /// cluster, an invisible "anchor" node is created. struct Node { public: - Node(int id = 0, Optional clusterId = llvm::None) + Node(int id = 0, Optional clusterId = std::nullopt) : id(id), clusterId(clusterId) {} int id; diff --git a/mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp b/mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp --- a/mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp +++ b/mlir/test/lib/Dialect/Func/TestDecomposeCallGraphTypes.cpp @@ -75,7 +75,7 @@ [](OpBuilder &builder, TupleType resultType, ValueRange inputs, Location loc) -> Optional { if (inputs.size() == 1) - return llvm::None; + return std::nullopt; TupleType tuple = builder.getTupleType(inputs.getTypes()); Value value = builder.create(loc, tuple, inputs); return value; diff --git a/mlir/test/lib/Dialect/Test/TestAttributes.cpp b/mlir/test/lib/Dialect/Test/TestAttributes.cpp --- a/mlir/test/lib/Dialect/Test/TestAttributes.cpp +++ b/mlir/test/lib/Dialect/Test/TestAttributes.cpp @@ -157,7 +157,7 @@ ArrayRef TestExtern1DI64ElementsAttr::getElements() const { if (auto *blob = getHandle().getBlob()) return blob->getDataAs(); - return llvm::None; + return std::nullopt; } //===----------------------------------------------------------------------===// diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -94,7 +94,7 @@ .Case("alias_test:sanitize_conflict_b", StringRef("test_alias_conflict0_")) .Case("alias_test:tensor_encoding", StringRef("test_encoding")) - .Default(llvm::None); + .Default(std::nullopt); if (!aliasName) return AliasResult::NoAlias; diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -311,7 +311,7 @@ std::array values = {{fop.getArgument(i), fop.getArgument(j)}}; SmallVector inferredReturnTypes; if (succeeded(OpTy::inferReturnTypes( - context, llvm::None, values, op->getAttrDictionary(), + context, std::nullopt, values, op->getAttrDictionary(), op->getRegions(), inferredReturnTypes))) { OperationState state(location, OpTy::getOperationName()); // TODO: Expand to regions. @@ -568,8 +568,8 @@ LogicalResult matchAndRewrite(Operation *op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { - rewriter.replaceOpWithNewOp(op, llvm::None, operands, - llvm::None); + rewriter.replaceOpWithNewOp(op, std::nullopt, operands, + std::nullopt); return success(); } }; diff --git a/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp b/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp --- a/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp +++ b/mlir/test/lib/Dialect/Vector/TestVectorTransforms.cpp @@ -84,10 +84,10 @@ for (Operation *users : readOp->getUsers()) { auto extract = dyn_cast(users); if (!extract) - return llvm::None; + return std::nullopt; auto vecType = extract.getResult().getType().cast(); if (dstVec && dstVec != vecType) - return llvm::None; + return std::nullopt; dstVec = vecType; } return SmallVector(dstVec.getShape().begin(), @@ -96,11 +96,11 @@ if (auto writeOp = dyn_cast(op)) { auto insert = writeOp.getVector().getDefiningOp(); if (!insert) - return llvm::None; + return std::nullopt; ArrayRef shape = insert.getSourceVectorType().getShape(); return SmallVector(shape.begin(), shape.end()); } - return llvm::None; + return std::nullopt; } static LogicalResult filter(Operation *op) { diff --git a/mlir/test/mlir-tblgen/attrdefs.td b/mlir/test/mlir-tblgen/attrdefs.td --- a/mlir/test/mlir-tblgen/attrdefs.td +++ b/mlir/test/mlir-tblgen/attrdefs.td @@ -33,7 +33,7 @@ // DEF-NEXT: return ::mlir::success(!!value); // DEF: .Default([&](llvm::StringRef keyword, // DEF-NEXT: *mnemonic = keyword; -// DEF-NEXT: return llvm::None; +// DEF-NEXT: return std::nullopt; def Test_Dialect: Dialect { // DECL-NOT: TestDialect diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -112,7 +112,7 @@ // DEF-NEXT: ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 1, (*this)->getAttrs().end() - 0, getCAttrAttrName()).dyn_cast_or_null() // DEF: ::llvm::Optional AOp::getCAttr() { // DEF-NEXT: auto attr = getCAttrAttr() -// DEF-NEXT: return attr ? ::llvm::Optional(attr.some-convert-from-storage()) : (::llvm::None); +// DEF-NEXT: return attr ? ::llvm::Optional(attr.some-convert-from-storage()) : (::std::nullopt); // DEF: some-attr-kind AOp::getDAttrAttr() // DEF-NEXT: ::mlir::impl::getAttrFromSortedRange((*this)->getAttrs().begin() + 1, (*this)->getAttrs().end() - 0, getDAttrAttrName()).dyn_cast_or_null() @@ -249,7 +249,7 @@ // DEF-NEXT: return ::mlir::impl::getAttrFromSortedRange({{.*}}).dyn_cast_or_null() // DEF: ::llvm::Optional AgetOp::getCAttr() { // DEF-NEXT: auto attr = getCAttrAttr() -// DEF-NEXT: return attr ? ::llvm::Optional(attr.some-convert-from-storage()) : (::llvm::None); +// DEF-NEXT: return attr ? ::llvm::Optional(attr.some-convert-from-storage()) : (::std::nullopt); // Test setter methods // --- diff --git a/mlir/test/mlir-tblgen/typedefs.td b/mlir/test/mlir-tblgen/typedefs.td --- a/mlir/test/mlir-tblgen/typedefs.td +++ b/mlir/test/mlir-tblgen/typedefs.td @@ -33,7 +33,7 @@ // DEF-NEXT: return ::mlir::success(!!value); // DEF: .Default([&](llvm::StringRef keyword, // DEF-NEXT: *mnemonic = keyword; -// DEF-NEXT: return llvm::None; +// DEF-NEXT: return std::nullopt; def Test_Dialect: Dialect { // DECL-NOT: TestDialect diff --git a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp --- a/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp +++ b/mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp @@ -398,7 +398,7 @@ if (it.value().name == name) return it.index(); } - return None; + return std::nullopt; } // Try to map the TypeVar to a predefined or an argument type. @@ -425,7 +425,7 @@ .str(); } - return None; + return std::nullopt; } static ScalarAssign *findAssignment(StringRef name, @@ -525,7 +525,7 @@ (ins "ValueRange":$inputs, "ValueRange":$outputs, CArg<"ArrayRef", "{{}">:$attributes), [{{ - buildStructuredOp($_builder, $_state, llvm::None, inputs, outputs, + buildStructuredOp($_builder, $_state, std::nullopt, inputs, outputs, attributes, {0}::getRegionBuilder()); }]>, OpBuilder< @@ -1064,7 +1064,7 @@ if (!argIndex) { emitError(genContext.getLoc()) << "scalar argument not defined on the op: " << *expression.arg; - return None; + return std::nullopt; } return std::string( llvm::formatv("block.getArgument({0})", *argIndex)); @@ -1118,7 +1118,7 @@ << "type variable " << expression.scalarFn->typeVar.value() << ", used in a type conversion, must map to a predefined or " << "an argument type but it does not"; - return None; + return std::nullopt; } operandCppValues.push_back(typeCppValue.value()); } @@ -1127,7 +1127,7 @@ for (ScalarExpression &operand : expression.scalarFn->operands) { auto operandCppValue = generateExpression(operand); if (!operandCppValue) - return None; + return std::nullopt; operandCppValues.push_back(*operandCppValue); } @@ -1139,7 +1139,7 @@ return cppIdent; } emitError(genContext.getLoc()) << "unknown ScalarExpression type"; - return None; + return std::nullopt; }; Optional cppValue = generateExpression(assignment->value); if (!cppValue) diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp --- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp @@ -815,7 +815,7 @@ } parse.body() << " .Default([&](llvm::StringRef keyword, llvm::SMLoc) {\n" " *mnemonic = keyword;\n" - " return llvm::None;\n" + " return std::nullopt;\n" " });"; printer.body() << " .Default([](auto) { return ::mlir::failure(); });"; diff --git a/mlir/tools/mlir-tblgen/DialectGen.cpp b/mlir/tools/mlir-tblgen/DialectGen.cpp --- a/mlir/tools/mlir-tblgen/DialectGen.cpp +++ b/mlir/tools/mlir-tblgen/DialectGen.cpp @@ -59,7 +59,7 @@ Optional tblgen::findDialectToGenerate(ArrayRef dialects) { if (dialects.empty()) { llvm::errs() << "no dialect was found\n"; - return llvm::None; + return std::nullopt; } // Select the dialect to gen for. @@ -69,7 +69,7 @@ if (selectedDialect.getNumOccurrences() == 0) { llvm::errs() << "when more than 1 dialect is present, one must be selected " "via '-dialect'\n"; - return llvm::None; + return std::nullopt; } const auto *dialectIt = llvm::find_if(dialects, [](const Dialect &dialect) { @@ -77,7 +77,7 @@ }); if (dialectIt == dialects.end()) { llvm::errs() << "selected dialect with '-dialect' does not exist\n"; - return llvm::None; + return std::nullopt; } return *dialectIt; } diff --git a/mlir/tools/mlir-tblgen/EnumsGen.cpp b/mlir/tools/mlir-tblgen/EnumsGen.cpp --- a/mlir/tools/mlir-tblgen/EnumsGen.cpp +++ b/mlir/tools/mlir-tblgen/EnumsGen.cpp @@ -226,7 +226,7 @@ os << "}\n\n"; } -// Returns the EnumAttrCase whose value is zero if exists; returns llvm::None +// Returns the EnumAttrCase whose value is zero if exists; returns std::nullopt // otherwise. static llvm::Optional getAllBitsUnsetCase(llvm::ArrayRef cases) { @@ -234,7 +234,7 @@ if (attrCase.getValue() == 0) return attrCase; } - return llvm::None; + return std::nullopt; } // Emits the following inline function for bit enums: @@ -392,7 +392,7 @@ os << formatv(" .Case(\"{1}\", {0}::{2})\n", enumName, str, makeIdentifier(symbol)); } - os << " .Default(::llvm::None);\n"; + os << " .Default(::std::nullopt);\n"; os << "}\n"; } @@ -433,9 +433,9 @@ if (auto val = enumerant.getValue()) os.indent(6) << formatv(".Case(\"{0}\", {1})\n", enumerant.getStr(), val); } - os.indent(6) << ".Default(::llvm::None);\n"; + os.indent(6) << ".Default(::std::nullopt);\n"; - os << " if (bit) { val |= *bit; } else { return ::llvm::None; }\n"; + os << " if (bit) { val |= *bit; } else { return ::std::nullopt; }\n"; os << " }\n"; os << formatv(" return static_cast<{0}>(val);\n", enumName); @@ -468,7 +468,7 @@ os << formatv(" case {0}: return {1}::{2};\n", value, enumName, makeIdentifier(symbol)); } - os << " default: return ::llvm::None;\n" + os << " default: return ::std::nullopt;\n" << " }\n" << "}\n\n"; } @@ -548,7 +548,7 @@ makeIdentifier(allBitsUnsetCase->getSymbol())); } int64_t validBits = enumDef.getValueAsInt("validBits"); - os << formatv(" if (value & ~static_cast<{0}>({1}u)) return llvm::None;\n", + os << formatv(" if (value & ~static_cast<{0}>({1}u)) return std::nullopt;\n", underlyingType, validBits); os << formatv(" return static_cast<{0}>(value);\n", enumName); os << "}\n"; diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -354,13 +354,13 @@ attrMetadata.insert( {operandSegmentAttrName, AttributeMetadata{operandSegmentAttrName, /*isRequired=*/true, - /*attr=*/llvm::None}}); + /*attr=*/std::nullopt}}); } if (op.getTrait("::mlir::OpTrait::AttrSizedResultSegments")) { attrMetadata.insert( {resultSegmentAttrName, AttributeMetadata{resultSegmentAttrName, /*isRequired=*/true, - /*attr=*/llvm::None}}); + /*attr=*/std::nullopt}}); } // Store the metadata in sorted order. diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp --- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp @@ -61,7 +61,7 @@ /// if it doesn't have one. llvm::Optional getTypeBuilder() const { llvm::Optional attrType = var->attr.getValueType(); - return attrType ? attrType->getBuilderCall() : llvm::None; + return attrType ? attrType->getBuilderCall() : std::nullopt; } /// Return if this attribute refers to a UnitAttr. @@ -2472,7 +2472,7 @@ return success(); } // Return None to indicate that we reached the end. - return llvm::None; + return std::nullopt; } /// For the given elements, check whether any attributes are followed by a colon @@ -2751,9 +2751,9 @@ // Mark this value as the type resolver for the other variables. for (unsigned j = 0; j != i; ++j) - variableTyResolver[values[j]] = {arg, llvm::None}; + variableTyResolver[values[j]] = {arg, std::nullopt}; for (unsigned j = i + 1; j != e; ++j) - variableTyResolver[values[j]] = {arg, llvm::None}; + variableTyResolver[values[j]] = {arg, std::nullopt}; } } @@ -2774,11 +2774,11 @@ // Set the resolvers for each operand and result. for (unsigned i = 0, e = op.getNumOperands(); i != e; ++i) if (!seenOperandTypes.test(i)) - variableTyResolver[op.getOperand(i).name] = {resolver, llvm::None}; + variableTyResolver[op.getOperand(i).name] = {resolver, std::nullopt}; if (includeResults) { for (unsigned i = 0, e = op.getNumResults(); i != e; ++i) if (!seenResultTypes.test(i)) - variableTyResolver[op.getResultName(i)] = {resolver, llvm::None}; + variableTyResolver[op.getResultName(i)] = {resolver, std::nullopt}; } } diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -362,7 +362,7 @@ if (classCasePair.getValue().size() < enumAttr.getAllCases().size()) os << " default: break;\n"; os << " }\n" - << " return llvm::None;\n" + << " return std::nullopt;\n" << "}\n"; } } @@ -407,7 +407,7 @@ } os << " default: break;\n"; os << " }\n" - << " return llvm::None;\n" + << " return std::nullopt;\n" << "}\n"; } } diff --git a/mlir/unittests/IR/OperationSupportTest.cpp b/mlir/unittests/IR/OperationSupportTest.cpp --- a/mlir/unittests/IR/OperationSupportTest.cpp +++ b/mlir/unittests/IR/OperationSupportTest.cpp @@ -18,13 +18,13 @@ using namespace mlir::detail; static Operation *createOp(MLIRContext *context, - ArrayRef operands = llvm::None, - ArrayRef resultTypes = llvm::None, + ArrayRef operands = std::nullopt, + ArrayRef resultTypes = std::nullopt, unsigned int numRegions = 0) { context->allowUnregisteredDialects(); return Operation::create(UnknownLoc::get(context), OperationName("foo.bar", context), resultTypes, - operands, llvm::None, llvm::None, numRegions); + operands, std::nullopt, llvm::None, numRegions); } namespace { @@ -33,7 +33,7 @@ Builder builder(&context); Operation *useOp = - createOp(&context, /*operands=*/llvm::None, builder.getIntegerType(16)); + createOp(&context, /*operands=*/std::nullopt, builder.getIntegerType(16)); Value operand = useOp->getResult(0); // Create a non-resizable operation with one operand. @@ -44,7 +44,7 @@ EXPECT_EQ(user->getNumOperands(), 1u); // Removing is okay. - user->setOperands(llvm::None); + user->setOperands(std::nullopt); EXPECT_EQ(user->getNumOperands(), 0u); // Destroy the operations. @@ -57,7 +57,7 @@ Builder builder(&context); Operation *useOp = - createOp(&context, /*operands=*/llvm::None, builder.getIntegerType(16)); + createOp(&context, /*operands=*/std::nullopt, builder.getIntegerType(16)); Value operand = useOp->getResult(0); // Create a resizable operation with one operand. @@ -68,7 +68,7 @@ EXPECT_EQ(user->getNumOperands(), 1u); // Removing is okay. - user->setOperands(llvm::None); + user->setOperands(std::nullopt); EXPECT_EQ(user->getNumOperands(), 0u); // Adding more operands is okay. @@ -85,7 +85,7 @@ Builder builder(&context); Operation *useOp = - createOp(&context, /*operands=*/llvm::None, builder.getIntegerType(16)); + createOp(&context, /*operands=*/std::nullopt, builder.getIntegerType(16)); Value operand = useOp->getResult(0); // Create a resizable operation with one operand. @@ -121,7 +121,7 @@ Builder builder(&context); Operation *useOp = - createOp(&context, /*operands=*/llvm::None, builder.getIntegerType(16)); + createOp(&context, /*operands=*/std::nullopt, builder.getIntegerType(16)); Value operand = useOp->getResult(0); // Create a resizable operation with one operand. @@ -158,7 +158,8 @@ Builder builder(&context); Type type = builder.getNoneType(); - Operation *useOp = createOp(&context, /*operands=*/llvm::None, {type, type}); + Operation *useOp = + createOp(&context, /*operands=*/std::nullopt, {type, type}); Value operand1 = useOp->getResult(0); Value operand2 = useOp->getResult(1); @@ -189,7 +190,7 @@ Builder builder(&context); Operation *containerOp = - createOp(&context, /*operands=*/llvm::None, /*resultTypes=*/llvm::None, + createOp(&context, /*operands=*/std::nullopt, /*resultTypes=*/llvm::None, /*numRegions=*/1); Region ®ion = containerOp->getRegion(0); Block *block = new Block(); diff --git a/mlir/unittests/Pass/AnalysisManagerTest.cpp b/mlir/unittests/Pass/AnalysisManagerTest.cpp --- a/mlir/unittests/Pass/AnalysisManagerTest.cpp +++ b/mlir/unittests/Pass/AnalysisManagerTest.cpp @@ -65,7 +65,7 @@ OwningOpRef module(ModuleOp::create(UnknownLoc::get(&context))); func::FuncOp func1 = func::FuncOp::create(builder.getUnknownLoc(), "foo", - builder.getFunctionType(llvm::None, llvm::None)); + builder.getFunctionType(std::nullopt, llvm::None)); func1.setPrivate(); module->push_back(func1); @@ -96,7 +96,7 @@ OwningOpRef module(ModuleOp::create(UnknownLoc::get(&context))); func::FuncOp func1 = func::FuncOp::create(builder.getUnknownLoc(), "foo", - builder.getFunctionType(llvm::None, llvm::None)); + builder.getFunctionType(std::nullopt, llvm::None)); func1.setPrivate(); module->push_back(func1); diff --git a/mlir/unittests/Pass/PassManagerTest.cpp b/mlir/unittests/Pass/PassManagerTest.cpp --- a/mlir/unittests/Pass/PassManagerTest.cpp +++ b/mlir/unittests/Pass/PassManagerTest.cpp @@ -62,7 +62,7 @@ for (StringRef name : {"secret", "not_secret"}) { auto func = func::FuncOp::create(builder.getUnknownLoc(), name, - builder.getFunctionType(llvm::None, llvm::None)); + builder.getFunctionType(std::nullopt, llvm::None)); func.setPrivate(); module->push_back(func); } diff --git a/mlir/unittests/TableGen/EnumsGenTest.cpp b/mlir/unittests/TableGen/EnumsGenTest.cpp --- a/mlir/unittests/TableGen/EnumsGenTest.cpp +++ b/mlir/unittests/TableGen/EnumsGenTest.cpp @@ -56,7 +56,7 @@ TEST(EnumsGenTest, GeneratedStringToSymbolFn) { EXPECT_EQ(llvm::Optional(FooEnum::CaseA), ConvertToEnum("CaseA")); EXPECT_EQ(llvm::Optional(FooEnum::CaseB), ConvertToEnum("CaseB")); - EXPECT_EQ(llvm::None, ConvertToEnum("X")); + EXPECT_EQ(std::nullopt, ConvertToEnum("X")); } TEST(EnumsGenTest, GeneratedUnderlyingType) { @@ -94,10 +94,10 @@ EXPECT_EQ(symbolizeBitEnumWithNone("Bit3|Bit0"), BitEnumWithNone::Bit3 | BitEnumWithNone::Bit0); - EXPECT_EQ(symbolizeBitEnumWithNone("Bit2"), llvm::None); - EXPECT_EQ(symbolizeBitEnumWithNone("Bit3 | Bit4"), llvm::None); + EXPECT_EQ(symbolizeBitEnumWithNone("Bit2"), std::nullopt); + EXPECT_EQ(symbolizeBitEnumWithNone("Bit3 | Bit4"), std::nullopt); - EXPECT_EQ(symbolizeBitEnumWithoutNone("None"), llvm::None); + EXPECT_EQ(symbolizeBitEnumWithoutNone("None"), std::nullopt); } TEST(EnumsGenTest, GeneratedSymbolToStringFnForGroupedBitEnum) { @@ -115,7 +115,7 @@ TEST(EnumsGenTest, GeneratedStringToSymbolForGroupedBitEnum) { EXPECT_EQ(symbolizeBitEnumWithGroup("Bit0"), BitEnumWithGroup::Bit0); EXPECT_EQ(symbolizeBitEnumWithGroup("Bit3"), BitEnumWithGroup::Bit3); - EXPECT_EQ(symbolizeBitEnumWithGroup("Bit5"), llvm::None); + EXPECT_EQ(symbolizeBitEnumWithGroup("Bit5"), std::nullopt); EXPECT_EQ(symbolizeBitEnumWithGroup("Bit3|Bit0"), BitEnumWithGroup::Bit3 | BitEnumWithGroup::Bit0); } diff --git a/mlir/unittests/Transforms/DialectConversion.cpp b/mlir/unittests/Transforms/DialectConversion.cpp --- a/mlir/unittests/Transforms/DialectConversion.cpp +++ b/mlir/unittests/Transforms/DialectConversion.cpp @@ -14,8 +14,8 @@ static Operation *createOp(MLIRContext *context) { context->allowUnregisteredDialects(); return Operation::create(UnknownLoc::get(context), - OperationName("foo.bar", context), llvm::None, - llvm::None, llvm::None, llvm::None, 0); + OperationName("foo.bar", context), std::nullopt, + std::nullopt, llvm::None, llvm::None, 0); } namespace { @@ -39,7 +39,7 @@ int callbackCalled2 = 0; target.addDynamicallyLegalOp([&](Operation *) -> Optional { callbackCalled2 = ++index; - return llvm::None; + return std::nullopt; }); auto *op = createOp(&context); @@ -60,7 +60,7 @@ int callbackCalled = 0; target.addDynamicallyLegalOp([&](Operation *) -> Optional { callbackCalled = ++index; - return llvm::None; + return std::nullopt; }); auto *op = createOp(&context); @@ -85,7 +85,7 @@ int callbackCalled2 = 0; target.markUnknownOpDynamicallyLegal([&](Operation *) -> Optional { callbackCalled2 = ++index; - return llvm::None; + return std::nullopt; }); auto *op = createOp(&context); @@ -103,7 +103,7 @@ ConversionTarget target(context); target.addDynamicallyLegalOp( - [&](Operation *) -> Optional { return llvm::None; }); + [&](Operation *) -> Optional { return std::nullopt; }); auto *op = createOp(&context); EXPECT_FALSE(target.isLegal(op)); @@ -120,7 +120,7 @@ ConversionTarget target(context); target.markUnknownOpDynamicallyLegal( - [&](Operation *) -> Optional { return llvm::None; }); + [&](Operation *) -> Optional { return std::nullopt; }); auto *op = createOp(&context); EXPECT_FALSE(target.isLegal(op));