[llvm-dev] [RFC] Proposed update to convert two 64-bit attribute bitmasks to std::bitset
Snider, Todd via llvm-dev
llvm-dev at lists.llvm.org
Thu Apr 4 15:38:47 PDT 2019
There are two 64-bit bitmasks maintained in AttributeImpl.h<https://sdocc.itg.ti.com/ui#file:review=11893/version=393846>:
- AvailableFunctionAttrs is part of the AttributeListImpl class, and
- AvailableAttrs is part of the AttributeSetNode class
Both of these assume that the number of available enum attributes is limited to 64. In fact, a static_assert in Attributes.cpp<https://sdocc.itg.ti.com/ui#file:review=11893/version=393848> enforces that the number of enum attributes stays at 64 or below. However, the bitcode writer and reader don't communicate enum attributes via bitmask anymore. Enum attributes are encoded in attribute groups.
The AvailableFunctionAttrs and AvailableAttrs bitmasks are leftovers that need to be updated to remove the limitation on the number of enum attributes that can be defined in the Attribute::AttrKind enum.
Per a suggestion that I received a while ago from Reid Kleckner (on the llvm-dev list), I propose to implement both of these data members as std::bitset objects.
Here are the details for this proposed change:
llvm/lib/IR/AttributeImpl.h<https://sdocc.itg.ti.com/ui#file:review=11893/version=393846>:
- Define AvailableAttrs and AvailableFunctionAttrs with type std::bitset<AttributeEndAttrKinds> instead of uint64_t
- Update AttributeSetNode::hasAttribute() to use the std::bitset test function on AvailableAttrs to check if an enum attribute is present
- Update AttributeListImpl::hasFnAttribute() to use the std::bitset test function on AvailableFunctionAttrs to check if an enum attribute is present
llvm/lib/IR/Attributes.cpp<https://sdocc.itg.ti.com/ui#file:review=11893/version=393848>:
- Update AttributeSetNode::AttributeSetNode() constructor to use the std::bitset's set function to initialize AvailableAttrs
- Update AttributeListImpl::AttributeListImpl() constructor to use the std::bitset's set function to initialize AvailableFunctionAttrs and remove the static_assert that enforces an upper limit of 64 on the number of enum attributes allowed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190404/67ecb08a/attachment.html>
More information about the llvm-dev
mailing list