Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mlir/include/mlir/CAPI/Wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static llvm::ArrayRef<CppTy> unwrapList(size_t size, CTy *first,
"incompatible C and C++ types");

if (size == 0)
return std::nullopt;
return {};

assert(storage.empty() && "expected to populate storage");
storage.reserve(size);
Expand Down
13 changes: 7 additions & 6 deletions mlir/include/mlir/Dialect/PDL/IR/PDLOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,13 @@ def PDL_OperationOp : PDL_Op<"operation", [AttrSizedOperandSegments]> {
(`->` `(` $typeValues^ `:` type($typeValues) `)`)? attr-dict
}];

let builders = [
OpBuilder<(ins CArg<"std::optional<StringRef>", "std::nullopt">:$name,
CArg<"ValueRange", "std::nullopt">:$operandValues,
CArg<"ArrayRef<StringRef>", "std::nullopt">:$attrNames,
CArg<"ValueRange", "std::nullopt">:$attrValues,
CArg<"ValueRange", "std::nullopt">:$resultTypes), [{
let builders =
[OpBuilder<(ins CArg<"std::optional<StringRef>", "std::nullopt">:$name,
CArg<"ValueRange", "{}">:$operandValues,
CArg<"ArrayRef<StringRef>", "{}">:$attrNames,
CArg<"ValueRange", "{}">:$attrValues,
CArg<"ValueRange", "{}">:$resultTypes),
[{
auto nameAttr = name ? $_builder.getStringAttr(*name) : StringAttr();
build($_builder, $_state, $_builder.getType<OperationType>(), nameAttr,
operandValues, attrValues, $_builder.getStrArrayAttr(attrNames),
Expand Down
5 changes: 2 additions & 3 deletions mlir/include/mlir/IR/BuiltinAttributes.td
Original file line number Diff line number Diff line change
Expand Up @@ -535,9 +535,8 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", "dictionary"> {
```
}];
let parameters = (ins ArrayRefParameter<"NamedAttribute", "">:$value);
let builders = [
AttrBuilder<(ins CArg<"ArrayRef<NamedAttribute>", "std::nullopt">:$value)>
];
let builders = [AttrBuilder<(
ins CArg<"ArrayRef<NamedAttribute>", "{}">:$value)>];
let extraClassDeclaration = [{
using ValueType = ArrayRef<NamedAttribute>;

Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/Support/StorageUniquer.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class StorageUniquer {
template <typename T>
ArrayRef<T> copyInto(ArrayRef<T> elements) {
if (elements.empty())
return std::nullopt;
return {};
auto result = allocator.Allocate<T>(elements.size());
llvm::uninitialized_copy(elements, result);
return ArrayRef<T>(result, elements.size());
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Interfaces/FunctionInterfaces.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ function_interface_impl::getResultAttrDict(FunctionOpInterface op,
ArrayRef<NamedAttribute>
function_interface_impl::getArgAttrs(FunctionOpInterface op, unsigned index) {
auto argDict = getArgAttrDict(op, index);
return argDict ? argDict.getValue() : std::nullopt;
return argDict ? argDict.getValue() : ArrayRef<NamedAttribute>();
}

ArrayRef<NamedAttribute>
function_interface_impl::getResultAttrs(FunctionOpInterface op,
unsigned index) {
auto resultDict = getResultAttrDict(op, index);
return resultDict ? resultDict.getValue() : std::nullopt;
return resultDict ? resultDict.getValue() : ArrayRef<NamedAttribute>();
}

/// Get either the argument or result attributes array.
Expand Down
9 changes: 6 additions & 3 deletions mlir/lib/Tools/PDLL/Parser/Parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2883,8 +2883,9 @@ Parser::validateOperationOperands(SMRange loc, std::optional<StringRef> name,
SmallVectorImpl<ast::Expr *> &operands) {
return validateOperationOperandsOrResults(
"operand", loc, odsOp ? odsOp->getLoc() : std::optional<SMRange>(), name,
operands, odsOp ? odsOp->getOperands() : std::nullopt, valueTy,
valueRangeTy);
operands,
odsOp ? odsOp->getOperands() : ArrayRef<pdll::ods::OperandOrResult>(),
valueTy, valueRangeTy);
}

LogicalResult
Expand All @@ -2893,7 +2894,9 @@ Parser::validateOperationResults(SMRange loc, std::optional<StringRef> name,
SmallVectorImpl<ast::Expr *> &results) {
return validateOperationOperandsOrResults(
"result", loc, odsOp ? odsOp->getLoc() : std::optional<SMRange>(), name,
results, odsOp ? odsOp->getResults() : std::nullopt, typeTy, typeRangeTy);
results,
odsOp ? odsOp->getResults() : ArrayRef<pdll::ods::OperandOrResult>(),
typeTy, typeRangeTy);
}

void Parser::checkOperationResultTypeInferrence(SMRange loc, StringRef opName,
Expand Down
6 changes: 4 additions & 2 deletions mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1044,7 +1044,8 @@ class LSPSignatureHelpContext : public CodeCompleteContext {
const ods::Operation *odsOp =
opName ? odsContext.lookupOperation(*opName) : nullptr;
codeCompleteOperationOperandOrResultSignature(
opName, odsOp, odsOp ? odsOp->getOperands() : std::nullopt,
opName, odsOp,
odsOp ? odsOp->getOperands() : ArrayRef<ods::OperandOrResult>(),
currentNumOperands, "operand", "Value");
}

Expand All @@ -1053,7 +1054,8 @@ class LSPSignatureHelpContext : public CodeCompleteContext {
const ods::Operation *odsOp =
opName ? odsContext.lookupOperation(*opName) : nullptr;
codeCompleteOperationOperandOrResultSignature(
opName, odsOp, odsOp ? odsOp->getResults() : std::nullopt,
opName, odsOp,
odsOp ? odsOp->getResults() : ArrayRef<ods::OperandOrResult>(),
currentNumResults, "result", "Type");
}

Expand Down
2 changes: 1 addition & 1 deletion mlir/test/lib/Dialect/Test/TestAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void TestSubElementsAccessAttr::print(::mlir::AsmPrinter &printer) const {
ArrayRef<uint64_t> TestExtern1DI64ElementsAttr::getElements() const {
if (auto *blob = getHandle().getBlob())
return blob->getDataAs<uint64_t>();
return std::nullopt;
return {};
}

//===----------------------------------------------------------------------===//
Expand Down
Loading