[llvm-dev] RFC: Refactor SubclassData

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Fri Dec 27 10:57:27 PST 2019

Ehud, can you elaborate on which classes you're trying to change. I know
some of the classes already use methods
like getSubclassDataFromInstruction() to hide bits from the subclasses.
They could probably shift the data too.


On Fri, Dec 27, 2019 at 9:35 AM Bruno Ricci via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi,
> On 26/12/2019 20:53, Ehud Katz via llvm-dev wrote:
> > I've tested it on MSVC, gcc, clang and icc.
> >
> > The solution in clang (in Decl.h) is not ideal (as you have said
> yourself). The solution I offer, is using a union of fields of class
> BitField (this is a new class that implements a bitfield of a specific type
> requested). With this, the definition, of the required bitfields in the
> subclass data, remains in the hands of the actual class needing them. And
> these are all restricted hierarchically by the superclasses of that class.
> I spent some time packing various bits of data into bit-fields in clang.
> My experience
> is that the solution in clang actually works just fine. The Stmt hierarchy
> has a huge
> number of bit-field classes (I count more than 40! [1]), but because the
> offsets are
> relative adding a bit means only adding one to an enum value a few lines
> below
> (a static_assert then checks that the union is not too large).
> [1]
> https://github.com/llvm/llvm-project/blob/f20fc65887e2085332d111ee0b05736794423c72/clang/include/clang/AST/Stmt.h#L948
> Bruno Ricci
> _______________________________________________
> 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/20191227/2c2706fb/attachment.html>

More information about the llvm-dev mailing list