[PATCH] D58520: [Subtarget] Remove static global constructor call from the tablegened subtarget feature tables

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 21 10:54:42 PST 2019


craig.topper created this revision.
craig.topper added reviewers: echristo, dblaikie, rengolin.
Herald added a subscriber: jdoerfert.

Subtarget features are stored in a std::bitset that has been subclassed. There is a special constructor to allow the tablegen files to provide a list of bits to initialize the std::bitset to. This constructor isn't constexpr and std::bitset doesn't support many constexpr operations either. This results in a static global constructor being used to initialize the feature bitsets in these files at startup.

To fix this I've introduced a new FeatureBitArray class that holds three 64-bit values representing the initial bit values and taught tablegen to emit hex constants for them based on the feature enum values. This makes the tablegen files less readable than they were before. I can add the list of features back as a comment if we think that's important.

I've added a method to convert from this class into the std::bitset subclass we had before. I considered making the new FeatureBitArray class just implement the std::bitset interface we need instead, but thought I'd see how others felts about that first.

I've simplified the interfaces to SetImpliedBits and ClearImpliedBits a little minimize the number of times we need to convert to the bitset.

This removes about 27K from my local release+asserts build of llc.

I'm open to any suggestions on better ways to do this.


https://reviews.llvm.org/D58520

Files:
  include/llvm/MC/SubtargetFeature.h
  lib/MC/SubtargetFeature.cpp
  utils/TableGen/SubtargetEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58520.187820.patch
Type: text/x-patch
Size: 10105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190221/74bf4c24/attachment.bin>


More information about the llvm-commits mailing list