This is an archive of the discontinued LLVM Phabricator instance.

[mlir][ods] Add query for derived attribute
ClosedPublic

Authored by jpienaar on Feb 29 2020, 12:22 PM.

Details

Summary

For ODS generated operations, enable querying whether there is a derived
attribute with a given name.

Diff Detail

Event Timeline

jpienaar created this revision.Feb 29 2020, 12:22 PM
Herald added a project: Restricted Project. · View Herald Transcript
rriddle requested changes to this revision.Feb 29 2020, 2:34 PM

What is a derived attribute? When would this be used?

This revision now requires changes to proceed.Feb 29 2020, 2:34 PM

What is a derived attribute? When would this be used?

Derived attributes are attributes that are not stored in the Op but instead computed from properties of the op (https://mlir.llvm.org/docs/OpDefinitions/#operation-arguments). E.g., a derived attribute T corresponding to the result type results in a convenience accessor T() that returns the result type but is not additionally stored. This allows for convenience functions that query the op (and return the result in convenient user usable format) without needing to store redundant information.

rriddle accepted this revision.Mar 2 2020, 11:45 AM
rriddle added inline comments.
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
401

nit: Can we just use llvm::is_contained instead? That would avoid bringing in StringSwitch to OperationSupport, which is included in a lot of places.

This revision is now accepted and ready to land.Mar 2 2020, 11:45 AM
jpienaar updated this revision to Diff 247720.Mar 2 2020, 1:27 PM

Switch to using is_contained

jpienaar marked 2 inline comments as done.Mar 2 2020, 1:30 PM
jpienaar added inline comments.
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
401

It is probably less efficient compared to the StringSwitch. But I do agree it is a smaller dependency though, and we could optimize this if it is problematic.

jpienaar closed this revision.Mar 2 2020, 1:35 PM
jpienaar marked an inline comment as done.