[llvm-dev] [RFC] Proposed update to convert two 64-bit attribute bitmasks to std::bitset

Philip Reames via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 5 09:45:25 PDT 2019


The representation change seems fine per se, but we still have a concern
with the 65th attribute increasing the size of the objects in question. 
Do you have a plan to minimize that impact?

To be clear, I think the representation change is fine regardless.  As
one example, we have a bunch of downstream attributes, and would happily
pay the extra word to integrate them cleanly with the built in variety
in our downstream code.  I'm sure we're not the only ones.

Philip

On 4/4/19 3:38 PM, Snider, Todd via llvm-dev wrote:
>
>  
>
> 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
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190405/95c0b654/attachment.html>


More information about the llvm-dev mailing list