Skip to content

[MLIR] ArrayRefParameter together with struct printing breaks print + parse roundtrip #156623

@Dinistro

Description

@Dinistro

Using ArrayRefParameter together with a struct(params) assembly format can result in a broken printer and parser pair. If one adds another attribute after the ArrayRef parameter, things start to fail.

For example, the following attribute

def Repro_Attr : LLVM_Attr<"ReproAttr", "repro", []> {
  let parameters = (ins
    ArrayRefParameter<"IntegerAttr">:$elements,
    OptionalParameter<"StringAttr">:$str,
  );

  let assemblyFormat = "`<` struct(params) `>`";
}

could print as

#llvm.repro<elements = 32 : i64, str = "bar">

which then explodes during parsing.

I assume that a potential fix for this would be to print the ArrayRefParameter with some brackets, to avoid any ambiguities.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions