This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Change the return type for {Min|Max}VersionBase
ClosedPublic

Authored by antiagainst on Aug 18 2021, 11:21 AM.

Details

Summary

For synthesizing an op's implementation of the generated interface
from {Min|Max}Version, we need to define an initializer and
mergeAction. The initializer specifies the initial version,
and mergeAction specifies how version specifications from
different parts of the op should be merged to generate a final
version requirements.

Previously we use the specified version enum as the type for both
the initializer and thus the final return type. This means we need
to perform static_cast over some hopefully not used number (~0u)
as the initializer. This is quite opaque and sort of not guaranteed
to work. Also, there are ops that have an enum attribute where some
values declare version requirements (e.g., enumerant B requires
v1.1+) but some not (e.g., enumerant A requires nothing). Then a
concrete op instance with A will still declare it implements the
version interface (because interface implementation is static for
an op) but actually theirs no requirements for version.

So this commit changes to use an more explicit llvm::Optional
to wrap around the returned version enum. This should make it
more clear.

Depends On D108311

Diff Detail

Event Timeline

antiagainst created this revision.Aug 18 2021, 11:21 AM
antiagainst requested review of this revision.Aug 18 2021, 11:21 AM
jpienaar accepted this revision.Nov 23 2021, 4:07 PM

Changing from sentinel to explicit optional LGTM

This revision is now accepted and ready to land.Nov 23 2021, 4:07 PM