Page MenuHomePhabricator

[mlir] Add support for defining Traits and Interfaces on Attributes/Types.
ClosedPublic

Authored by rriddle on Mon, Jun 15, 2:16 PM.

Details

Summary

This revisions add mechanisms to Attribute/Type for attaching traits and interfaces. The mechanisms are modeled 1-1 after those for operations to keep the system consistent. AttrBase and TypeBase now accepts a trailing list of Trait types that will be attached to the object. These traits should inherit from AttributeTrait::TraitBase and TypeTrait::TraitBase respectively as necessary. A followup commit will refactor the interface gen mechanisms in ODS to support Attribute/Type interface generation and add tests for the mechanisms.

Depends On D81882

Diff Detail

Event Timeline

rriddle created this revision.Mon, Jun 15, 2:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptMon, Jun 15, 2:16 PM
mehdi_amini accepted this revision.Thu, Jun 25, 9:03 PM

What about trait in the test dialect that could test this?

This revision is now accepted and ready to land.Thu, Jun 25, 9:03 PM

What about trait in the test dialect that could test this?

I intended for this revision to be very simple and just add the basic infra for it, the next revision in the series adds proper tests for all of the different use cases: https://reviews.llvm.org/D81884

stellaraccident accepted this revision.Sat, Jun 27, 11:44 PM

Thank you!

jpienaar accepted this revision.Sun, Jun 28, 7:47 AM

These still require a trait being added explicitly to the type? E.g., a user can't opt a type into a trait (say I want to add a ComparableToDialectFooFixed trait, I'd need to change the definition of Int type to have that trait vs being able to opt in the type later?)

mlir/include/mlir/IR/AttributeSupport.h
83

Why is this type now?

mlir/include/mlir/IR/TypeSupport.h
74–75

Nit: preference towards public, protected, private, to match order of visibility/order of generality of use.

mlir/lib/IR/MLIRContext.cpp
583

report_fatal_error ?

619

Same here

rriddle updated this revision to Diff 274306.Mon, Jun 29, 6:29 PM
rriddle marked 4 inline comments as done.

Address comments

These still require a trait being added explicitly to the type? E.g., a user can't opt a type into a trait (say I want to add a ComparableToDialectFooFixed trait, I'd need to change the definition of Int type to have that trait vs being able to opt in the type later?)

This is intended to match the functionality that operations currently have. Given operations don't support that, I'd rather discuss new things separately.

This revision was automatically updated to reflect the committed changes.