This is an archive of the discontinued LLVM Phabricator instance.

[mlir][ODS] Verify type constraint in `TypeAttrOf`
ClosedPublic

Authored by zero9178 on Apr 7 2023, 3:14 AM.

Details

Summary

The current implementation does not verify the type constraint, meaning that any type that happens to be of the same C++ type would pass the verifier.
E.g. a TypeAttrOf<I64> would happily accept a i32 since both satisfy isa<IntegerType>().

This patch fixes that by adding an optional type predicate parameter to TypeAttrBase that the type within TypeAttr has to satisfy. TypeAttrOf then simply passes the predicate of its type parameter as argument.

Diff Detail

Event Timeline

zero9178 created this revision.Apr 7 2023, 3:14 AM
zero9178 requested review of this revision.Apr 7 2023, 3:14 AM
ftynse accepted this revision.Apr 7 2023, 3:28 AM
This revision is now accepted and ready to land.Apr 7 2023, 3:28 AM
This revision was automatically updated to reflect the committed changes.