Lines Matching defs:optional
65 std::optional<StringRef> getTypeBuilder() const {
66 std::optional<Type> attrType = var->attr.getValueType();
222 /// This class represents a group of order-independent optional clauses. Each
303 std::optional<int> getBuilderIdx() const { return builderIdx; }
315 std::optional<StringRef> getVarTransformer() const {
318 void setResolver(ConstArgument arg, std::optional<StringRef> transformer) {
327 std::optional<int> builderIdx;
333 std::optional<StringRef> variableTransformer;
340 /// The element is generated inside an optional group.
480 // Parsing an optional symbol name doesn't fail, so no need to check the
707 /// The code snippet used to generate a parser call for an optional region.
790 /// The argument is optional, and may contain 0 or 1 elements.
858 if (auto *optional = dyn_cast<OptionalElement>(element)) {
859 ArrayRef<FormatElement *> elements = optional->getThenElements();
863 auto *anchor = dyn_cast<AttributeLikeVariable>(optional->getAnchor());
870 for (FormatElement *childElement : optional->getElseElements())
1033 // * Add a local variable for optional operands and types. This provides a
1043 " ::std::optional<::mlir::OpAsmParser::UnresolvedOperand> "
1072 "::std::optional<::mlir::OpAsmParser::UnresolvedOperand>",
1101 // After parsing, add handling for any of the optional constructs.
1172 // If the attribute is not optional, build an error message for the missing
1246 if (std::optional<StringRef> typeBuilder = attr->getTypeBuilder()) {
1350 // If the attribute has a default value or is optional, it does not need to
1386 // allows for referencing these variables in the presence of optional
1415 if (auto *optional = dyn_cast<OptionalElement>(element)) {
1422 auto *anchorVar = dyn_cast<AttributeLikeVariable>(optional->getAnchor());
1426 if (!thenGroup == optional->isInverted()) {
1445 // Generate the rest of the elements inside an optional group. Elements in
1446 // an optional group after the guard are parsed as required.
1454 optional->getThenElements(/*parseable=*/true);
1456 // Generate a special optional parser for the first element to gate the
1504 auto elseElements = optional->getElseElements();
1508 optional->getElseElements(/*parseable=*/true);
1685 std::optional<StringRef> transformer = resolver.getVarTransformer();
1718 if (std::optional<int> val = resolver.getBuilderIdx()) {
1721 if (std::optional<StringRef> tform = resolver.getVarTransformer()) {
1735 if (std::optional<StringRef> tform = resolver.getVarTransformer())
1982 /// Generate a check that an optional or default-valued attribute or property
1984 /// optional attribute is its presence, even if the attribute itself has a
2315 /// Generate the check for the anchor of an optional group.
2331 // TODO: Add a check for optional regions here when ODS supports it.
2342 // default value and an optional one present if it is set.
2406 // Emit an optional group.
2407 if (OptionalElement *optional = dyn_cast<OptionalElement>(element)) {
2409 FormatElement *anchor = optional->getAnchor();
2411 if (optional->isInverted())
2419 ArrayRef<FormatElement *> thenElements = optional->getThenElements();
2420 ArrayRef<FormatElement *> elseElements = optional->getElseElements();
2693 /// Verify the elements of an optional group.
2711 /// type as well as an optional transformer to apply to that type in order to
2715 std::optional<StringRef> transformer;
2860 // type. The attribute grammar contains an optional trailing colon type, which
2866 // Both start with `{` and so the optional attribute dictionary can cause
2907 /// If an optional group is encountered, this function recurses into the 'then'
2911 /// Since the guard element of an optional group is required, this function
2912 /// accepts an optional element pointer to mark it as required.
2913 static std::optional<LogicalResult> checkRangeForElement(
2923 // Recurse on optional groups.
2924 if (auto *optional = dyn_cast<OptionalElement>(element)) {
2925 if (std::optional<LogicalResult> result = checkRangeForElement(
2926 base, isInvalid, optional->getThenElements(),
2927 // The optional group guard is required for the group.
2928 optional->getThenElements().front()))
2931 if (std::optional<LogicalResult> result = checkRangeForElement(
2932 base, isInvalid, optional->getElseElements()))
2935 // Skip the optional group.
2964 } else if (auto *optional = dyn_cast<OptionalElement>(*it)) {
2965 // Recurse on optional groups.
2967 isBase, isInvalid, optional->getThenElements());
2971 isBase, isInvalid, optional->getElseElements());
2974 // If either optional group has an unverified attribute, save it.
2983 if (std::optional<LogicalResult> result =
3077 std::optional<StringRef> builder = operand.constraint.getBuilderCall();
3142 std::optional<StringRef> builder = result.constraint.getBuilderCall();
3573 // Only optional attributes can be within an oilist parsing group.
3577 return emitError(loc, "only optional attributes can be used in "
3581 // Only optional properties can be within an oilist parsing group.
3586 "only default-valued or optional properties can be used in "
3590 // Only optional-like(i.e. variadic) operands can be within an
3598 // Only optional-like(i.e. variadic) results can be within an oilist
3710 // All attributes can be within the optional group, but only optional
3715 return emitError(loc, "only optional or default-valued attributes "
3716 "can be used to anchor an optional group");
3719 // All properties can be within the optional group, but only optional
3726 "can be used to anchor an optional group");
3729 // Only optional-like(i.e. variadic) operands can be within an optional
3734 "within an optional group");
3737 // Only optional-like(i.e. variadic) results can be within an optional
3742 "within an optional group");
3746 // TODO: When ODS has proper support for marking "optional" regions, add
3764 // Verify each child as being valid in an optional group. They are all
3780 "to anchor an optional group");
3785 "used within an optional group");