Lines Matching defs:element
39 /// This class represents an instance of an op variable element. A variable
47 /// Create an op variable element with the variable value.
223 /// clause starts with a literal element and has a coressponding parsing
224 /// element. A parsing element is a continous sequence of format elements.
251 /// If the parsing element is a single UnitAttr element, then it returns the
264 /// A vector of `LiteralElement` objects. Each element stores the keyword
265 /// for one case of oilist element. For example, an oilist element along with
275 /// For example, an oilist element along with the parsingElements vector:
336 /// The context in which an element is generated.
338 /// The element is generated at the top-level or with the same behaviour.
340 /// The element is generated inside an optional group.
358 /// Generate the parser code for a specific format element.
359 void genElementParser(FormatElement *element, MethodBody &body,
379 /// Generate the printer code for a specific format element.
380 void genElementPrinter(FormatElement *element, MethodBody &body, Operator &op,
792 /// The argument is a single element, i.e. always represents 1 element.
855 /// Generate the storage code required for parsing the given element.
856 static void genElementParserStorage(FormatElement *element, const Operator &op,
858 if (auto *optional = dyn_cast<OptionalElement>(element)) {
873 } else if (auto *oilist = dyn_cast<OIListElement>(element)) {
876 for (FormatElement *element : pelement)
877 genElementParserStorage(element, op, body);
880 } else if (auto *custom = dyn_cast<CustomDirective>(element)) {
884 } else if (isa<OperandsDirective>(element)) {
888 } else if (isa<RegionsDirective>(element)) {
892 } else if (isa<SuccessorsDirective>(element)) {
895 } else if (auto *attr = dyn_cast<AttributeVariable>(element)) {
899 } else if (auto *operand = dyn_cast<OperandVariable>(element)) {
919 } else if (auto *region = dyn_cast<RegionVariable>(element)) {
932 } else if (auto *successor = dyn_cast<SuccessorVariable>(element)) {
942 } else if (auto *dir = dyn_cast<TypeDirective>(element)) {
953 } else if (auto *dir = dyn_cast<FunctionalTypeDirective>(element)) {
1388 for (FormatElement *element : elements)
1389 genElementParserStorage(element, op, body);
1396 for (FormatElement *element : elements)
1397 genElementParser(element, body, attrTypeCtx);
1411 void OperationFormat::genElementParser(FormatElement *element, MethodBody &body,
1415 if (auto *optional = dyn_cast<OptionalElement>(element)) {
1456 // Generate a special optional parser for the first element to gate the
1516 } else if (OIListElement *oilist = dyn_cast<OIListElement>(element)) {
1557 } else if (LiteralElement *literal = dyn_cast<LiteralElement>(element)) {
1563 } else if (isa<WhitespaceElement>(element)) {
1567 } else if (auto *attr = dyn_cast<AttributeVariable>(element)) {
1572 } else if (auto *prop = dyn_cast<PropertyVariable>(element)) {
1575 } else if (auto *operand = dyn_cast<OperandVariable>(element)) {
1587 } else if (auto *region = dyn_cast<RegionVariable>(element)) {
1600 } else if (auto *successor = dyn_cast<SuccessorVariable>(element)) {
1606 } else if (auto *attrDict = dyn_cast<AttrDictDirective>(element)) {
1623 } else if (isa<PropDictDirective>(element)) {
1628 } else if (auto *customDir = dyn_cast<CustomDirective>(element)) {
1630 } else if (isa<OperandsDirective>(element)) {
1636 } else if (isa<RegionsDirective>(element)) {
1643 } else if (isa<SuccessorsDirective>(element)) {
1646 } else if (auto *dir = dyn_cast<TypeDirective>(element)) {
1668 } else if (auto *dir = dyn_cast<FunctionalTypeDirective>(element)) {
1674 llvm_unreachable("unknown format element");
2119 /// space should be emitted before this element. `lastWasPunctuation` is true if
2120 /// the previous element was a punctuation literal.
2150 static void genCustomDirectiveParameterPrinter(FormatElement *element,
2153 if (auto *attr = dyn_cast<AttributeVariable>(element)) {
2156 } else if (isa<AttrDictDirective>(element)) {
2159 } else if (isa<PropDictDirective>(element)) {
2162 } else if (auto *operand = dyn_cast<OperandVariable>(element)) {
2165 } else if (auto *region = dyn_cast<RegionVariable>(element)) {
2168 } else if (auto *successor = dyn_cast<SuccessorVariable>(element)) {
2171 } else if (auto *dir = dyn_cast<RefDirective>(element)) {
2174 } else if (auto *dir = dyn_cast<TypeDirective>(element)) {
2187 } else if (auto *string = dyn_cast<StringElement>(element)) {
2193 } else if (auto *property = dyn_cast<PropertyVariable>(element)) {
2320 .Case<OperandVariable, ResultVariable>([&](auto *element) {
2321 const NamedTypeConstraint *var = element->getVar();
2328 .Case([&](RegionVariable *element) {
2329 const NamedRegion *var = element->getVar();
2334 .Case([&](TypeDirective *element) {
2335 genOptionalGroupPrinterAnchor(element->getArg(), op, body);
2337 .Case([&](FunctionalTypeDirective *element) {
2338 genOptionalGroupPrinterAnchor(element->getInputs(), op, body);
2340 .Case([&](AttributeVariable *element) {
2343 genNonDefaultValueCheck(body, op, *element);
2345 .Case([&](PropertyVariable *element) {
2346 genNonDefaultValueCheck(body, op, *element);
2362 void collect(FormatElement *element,
2364 TypeSwitch<FormatElement *>(element)
2387 void OperationFormat::genElementPrinter(FormatElement *element,
2391 if (LiteralElement *literal = dyn_cast<LiteralElement>(element))
2395 // Emit a whitespace element.
2396 if (auto *space = dyn_cast<WhitespaceElement>(element)) {
2407 if (OptionalElement *optional = dyn_cast<OptionalElement>(element)) {
2408 // Emit the check for the presence of the anchor element.
2453 if (auto *oilist = dyn_cast<OIListElement>(element)) {
2499 for (FormatElement *element : pelement)
2500 genElementPrinter(element, body, op, shouldEmitSpace,
2509 if (auto *attrDict = dyn_cast<AttrDictDirective>(element)) {
2516 if (isa<PropDictDirective>(element)) {
2522 // Optionally insert a space before the next element. The AttrDict printer
2529 if (auto *attr = dyn_cast<AttributeVariable>(element)) {
2554 } else if (auto *property = dyn_cast<PropertyVariable>(element)) {
2561 } else if (auto *operand = dyn_cast<OperandVariable>(element)) {
2577 } else if (auto *region = dyn_cast<RegionVariable>(element)) {
2585 } else if (auto *successor = dyn_cast<SuccessorVariable>(element)) {
2592 } else if (auto *dir = dyn_cast<CustomDirective>(element)) {
2594 } else if (isa<OperandsDirective>(element)) {
2596 } else if (isa<RegionsDirective>(element)) {
2599 } else if (isa<SuccessorsDirective>(element)) {
2602 } else if (auto *dir = dyn_cast<TypeDirective>(element)) {
2642 } else if (auto *dir = dyn_cast<FunctionalTypeDirective>(element)) {
2647 llvm_unreachable("unknown format element");
2657 // Flags for if we should emit a space, and if the last element was
2660 for (FormatElement *element : elements)
2661 genElementPrinter(element, body, op, shouldEmitSpace, lastWasPunctuation);
2668 /// Function to find an element within the given range that has the same name as
2697 LogicalResult verifyOptionalGroupElement(SMLoc loc, FormatElement *element,
2700 LogicalResult markQualified(SMLoc loc, FormatElement *element) override;
2774 LogicalResult verifyOIListParsingElement(FormatElement *element, SMLoc loc);
2883 /// Returns whether the single format element is optionally parsed.
2906 /// element that satisfies `isInvalid`, skipping any optionally-parsed elements.
2911 /// Since the guard element of an optional group is required, this function
2912 /// accepts an optional element pointer to mark it as required.
2918 for (FormatElement *element : elementRange) {
2919 // If we encounter an invalid element, return an error.
2920 if (isInvalid(base, element))
2924 if (auto *optional = dyn_cast<OptionalElement>(element)) {
2940 if (element != optionalGuard && isOptionallyParsed(element))
2943 // We found a closing element that is valid.
2975 // Otherwise, move on to the next element.
3185 // We just saw an oilist element in last iteration. Literals should not
3204 " is used both in oilist element and the adjacent literal.");
3566 LogicalResult OpFormatParser::verifyOIListParsingElement(FormatElement *element,
3569 collect(element, vars);
3635 LogicalResult OpFormatParser::markQualified(SMLoc loc, FormatElement *element) {
3636 return TypeSwitch<FormatElement *, LogicalResult>(element)
3637 .Case<AttributeVariable, TypeDirective>([](auto *element) {
3638 element->setShouldBeQualified();
3641 .Default([&](auto *element) {
3654 FormatElement *element = *result;
3655 if (isa<LiteralElement>(element))
3659 if (auto *var = dyn_cast<OperandVariable>(element)) {
3668 } else if (auto *var = dyn_cast<ResultVariable>(element)) {
3677 } else if (isa<OperandsDirective>(&*element)) {
3684 } else if (isa<ResultsDirective>(&*element)) {
3694 return element;
3699 for (FormatElement *element : elements) {
3700 if (failed(verifyOptionalGroupElement(loc, element, element == anchor)))
3707 FormatElement *element,
3709 return TypeSwitch<FormatElement *, LogicalResult>(element)