This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Improve bitEnumContains methods.
ClosedPublic

Authored by hanchung on Sep 8 2022, 10:35 AM.

Details

Summary

https://github.com/llvm/llvm-project/commit/839b436c93604e042f74050cf2adadd75f30e898
changes the behavior. Based on the discussion, we also want to support
"and" behavior. The revision changes it into two functions, bitEnumContainsAny
and bitEnumContainsAll.

Diff Detail

Event Timeline

hanchung created this revision.Sep 8 2022, 10:35 AM
hanchung requested review of this revision.Sep 8 2022, 10:35 AM
krzysz00 requested changes to this revision.Sep 8 2022, 10:48 AM

This patch seems incorrect, though I'm not unhappy with the idea

mlir/docs/OpDefinitions.md
1449

I don't think this is the check - this just checks that there's a bit in either input that's set. I think this should and bits and bit together, then cast to the underlying type and check if the result isn't zero.

mlir/tools/mlir-tblgen/EnumsGen.cpp
165

Also, this should be generic to the enum using {0} and {1}

This revision now requires changes to proceed.Sep 8 2022, 10:48 AM
hanchung added inline comments.Sep 8 2022, 12:42 PM
mlir/docs/OpDefinitions.md
1449

Sorry that I copied wrong line. You're right on it.

hanchung updated this revision to Diff 458831.Sep 8 2022, 12:45 PM

address issues

hanchung updated this revision to Diff 458856.Sep 8 2022, 2:03 PM

fix EnumsGen.cpp

hanchung updated this revision to Diff 458857.Sep 8 2022, 2:04 PM

fix EnumsGen.cpp

antiagainst accepted this revision.Sep 8 2022, 4:18 PM
krzysz00 accepted this revision.Sep 8 2022, 11:33 PM

LGTM

Could we also have a bitEnumContains that asserts the bit only has one bit set, for backwards compatibility? That might be a separate patch.

This revision is now accepted and ready to land.Sep 8 2022, 11:33 PM
hanchung updated this revision to Diff 459127.Sep 9 2022, 10:55 AM

update existing uses

hanchung updated this revision to Diff 459129.Sep 9 2022, 10:57 AM

update tests

This revision was automatically updated to reflect the committed changes.