This is an archive of the discontinued LLVM Phabricator instance.

[mlir][ods] Ignore AttributeSelfTypeParameter in assembly formats
ClosedPublic

Authored by Mogball on May 16 2022, 1:15 PM.

Details

Summary

The attribute self type parameter is currently treated like any other attribute parameter in the assembly format. The self type parameter should be handled by the operation parser and printer and play no role in the generated parsers and printers of attributes.

Diff Detail

Event Timeline

Mogball created this revision.May 16 2022, 1:15 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2022, 1:15 PM
Mogball requested review of this revision.May 16 2022, 1:15 PM
rriddle accepted this revision.May 16 2022, 1:18 PM

Thanks!

mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp
237

nit: Please drop the const here.

This revision is now accepted and ready to land.May 16 2022, 1:18 PM

There's a further wrinkle here: attribute parsers embedded in operation assembly formats won't be able to have types.

def MyAttr : ... {
  let parameters = (ins "int":$a, AttributeSelfTypeParameter<"">:$type);
  let assemblyFormat = "$a";
}

def MyOp : ... {
  let arguments = (ins MyAttr:$a);
  let assemblyFormat = "$a attr-dict"
}

The pretty format won't be able to have a type because the parser directly invokes MyAttr::parse and won't be able to look ahead for the type.

Mogball updated this revision to Diff 429832.May 16 2022, 1:22 PM

drop const

There's a further wrinkle here: attribute parsers embedded in operation assembly formats won't be able to have types.

def MyAttr : ... {
  let parameters = (ins "int":$a, AttributeSelfTypeParameter<"">:$type);
  let assemblyFormat = "$a";
}

def MyOp : ... {
  let arguments = (ins MyAttr:$a);
  let assemblyFormat = "$a attr-dict"
}

The pretty format won't be able to have a type because the parser directly invokes MyAttr::parse and won't be able to look ahead for the type.

Can you just file a general bug for me to fix Attribute type handling in assembly formats (declarative and not)? There are also things surrounding type elision, providing types, etc. that should "just work" but we haven't invested in.

This revision was landed with ongoing or failed builds.May 16 2022, 1:24 PM
This revision was automatically updated to reflect the committed changes.

Sure. I was thinking we needed a $type-elision directive or something in operation assembly formats.