diff options
author | Craig Topper <craig.topper@intel.com> | 2019-03-01 02:19:26 +0000 |
---|---|---|
committer | Craig Topper <craig.topper@intel.com> | 2019-03-01 02:19:26 +0000 |
commit | 4f61308af274c72fa30ae6441d6a5c799924f221 (patch) | |
tree | 0b5e0fb5d855fbc684e331aaf499d7c1855d7e84 /llvm/lib/MC/SubtargetFeature.cpp | |
parent | 93317d82daf864956ae0608594ee94293e3a4257 (diff) | |
download | bcm5719-llvm-4f61308af274c72fa30ae6441d6a5c799924f221.tar.gz bcm5719-llvm-4f61308af274c72fa30ae6441d6a5c799924f221.zip |
[Subtarget] Remove static global constructor call from the tablegened subtarget feature tables
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.
Differential Revision: https://reviews.llvm.org/D58520
llvm-svn: 355167
Diffstat (limited to 'llvm/lib/MC/SubtargetFeature.cpp')
-rw-r--r-- | llvm/lib/MC/SubtargetFeature.cpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/llvm/lib/MC/SubtargetFeature.cpp b/llvm/lib/MC/SubtargetFeature.cpp index 50f979b9d11..c34c6ff9007 100644 --- a/llvm/lib/MC/SubtargetFeature.cpp +++ b/llvm/lib/MC/SubtargetFeature.cpp @@ -122,29 +122,24 @@ std::string SubtargetFeatures::getString() const { /// For each feature that is (transitively) implied by this feature, set it. static -void SetImpliedBits(FeatureBitset &Bits, const SubtargetFeatureKV &FeatureEntry, +void SetImpliedBits(FeatureBitset &Bits, const FeatureBitset &Implies, ArrayRef<SubtargetFeatureKV> FeatureTable) { for (const SubtargetFeatureKV &FE : FeatureTable) { - if (FeatureEntry.Value == FE.Value) continue; - - if (FeatureEntry.Implies.test(FE.Value)) { + if (Implies.test(FE.Value)) { Bits.set(FE.Value); - SetImpliedBits(Bits, FE, FeatureTable); + SetImpliedBits(Bits, FE.Implies.getAsBitset(), FeatureTable); } } } /// For each feature that (transitively) implies this feature, clear it. static -void ClearImpliedBits(FeatureBitset &Bits, - const SubtargetFeatureKV &FeatureEntry, +void ClearImpliedBits(FeatureBitset &Bits, unsigned Value, ArrayRef<SubtargetFeatureKV> FeatureTable) { for (const SubtargetFeatureKV &FE : FeatureTable) { - if (FeatureEntry.Value == FE.Value) continue; - - if (FE.Implies.test(FeatureEntry.Value)) { + if (FE.Implies.getAsBitset().test(Value)) { Bits.reset(FE.Value); - ClearImpliedBits(Bits, FE, FeatureTable); + ClearImpliedBits(Bits, FE.Value, FeatureTable); } } } @@ -160,12 +155,12 @@ SubtargetFeatures::ToggleFeature(FeatureBitset &Bits, StringRef Feature, if (Bits.test(FeatureEntry->Value)) { Bits.reset(FeatureEntry->Value); // For each feature that implies this, clear it. - ClearImpliedBits(Bits, *FeatureEntry, FeatureTable); + ClearImpliedBits(Bits, FeatureEntry->Value, FeatureTable); } else { Bits.set(FeatureEntry->Value); // For each feature that this implies, set it. - SetImpliedBits(Bits, *FeatureEntry, FeatureTable); + SetImpliedBits(Bits, FeatureEntry->Implies.getAsBitset(), FeatureTable); } } else { errs() << "'" << Feature << "' is not a recognized feature for this target" @@ -187,12 +182,12 @@ void SubtargetFeatures::ApplyFeatureFlag(FeatureBitset &Bits, StringRef Feature, Bits.set(FeatureEntry->Value); // For each feature that this implies, set it. - SetImpliedBits(Bits, *FeatureEntry, FeatureTable); + SetImpliedBits(Bits, FeatureEntry->Implies.getAsBitset(), FeatureTable); } else { Bits.reset(FeatureEntry->Value); // For each feature that implies this, clear it. - ClearImpliedBits(Bits, *FeatureEntry, FeatureTable); + ClearImpliedBits(Bits, FeatureEntry->Value, FeatureTable); } } else { errs() << "'" << Feature << "' is not a recognized feature for this target" @@ -225,12 +220,13 @@ SubtargetFeatures::getFeatureBits(StringRef CPU, // If there is a match if (CPUEntry) { // Set base feature bits - Bits = CPUEntry->Implies; + FeatureBitset CPUImplies = CPUEntry->Implies.getAsBitset(); + Bits = CPUImplies; // Set the feature implied by this CPU feature, if any. for (auto &FE : FeatureTable) { - if (CPUEntry->Implies.test(FE.Value)) - SetImpliedBits(Bits, FE, FeatureTable); + if (CPUImplies.test(FE.Value)) + SetImpliedBits(Bits, FE.Implies.getAsBitset(), FeatureTable); } } else { errs() << "'" << CPU << "' is not a recognized processor for this target" |