From 176a9b2a53f8d2f209c046bc96274317579bce54 Mon Sep 17 00:00:00 2001 From: Artyom Skrobov Date: Tue, 5 Jan 2016 10:25:56 +0000 Subject: [PATCH] (NFC) Change SubtargetFeatures::ToggleFeature and SubtargetFeatures::ApplyFeatureFlag to be static, so that MCSubtargetInfo doesn't need to instantiate SubtargetFeatures for nothing. Also change the return type to void, as it wasn't ever used. This is a partial commit of http://reviews.llvm.org/D15746 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256823 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/SubtargetFeature.h | 15 +++++++-------- lib/MC/MCSubtargetInfo.cpp | 6 ++---- lib/MC/SubtargetFeature.cpp | 18 ++++++------------ 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/include/llvm/MC/SubtargetFeature.h b/include/llvm/MC/SubtargetFeature.h index 40d4739fe9c..75d1e799711 100644 --- a/include/llvm/MC/SubtargetFeature.h +++ b/include/llvm/MC/SubtargetFeature.h @@ -103,14 +103,13 @@ public: /// Adding Features. void AddFeature(StringRef String, bool Enable = true); - /// ToggleFeature - Toggle a feature and returns the newly updated feature - /// bits. - FeatureBitset ToggleFeature(FeatureBitset Bits, StringRef String, - ArrayRef FeatureTable); - - /// Apply the feature flag and return the newly updated feature bits. - FeatureBitset ApplyFeatureFlag(FeatureBitset Bits, StringRef Feature, - ArrayRef FeatureTable); + /// ToggleFeature - Toggle a feature and update the feature bits. + static void ToggleFeature(FeatureBitset &Bits, StringRef String, + ArrayRef FeatureTable); + + /// Apply the feature flag and update the feature bits. + static void ApplyFeatureFlag(FeatureBitset &Bits, StringRef Feature, + ArrayRef FeatureTable); /// Get feature bits of a CPU. FeatureBitset getFeatureBits(StringRef CPU, diff --git a/lib/MC/MCSubtargetInfo.cpp b/lib/MC/MCSubtargetInfo.cpp index b29d3f48310..1b592504b1e 100644 --- a/lib/MC/MCSubtargetInfo.cpp +++ b/lib/MC/MCSubtargetInfo.cpp @@ -63,14 +63,12 @@ FeatureBitset MCSubtargetInfo::ToggleFeature(const FeatureBitset &FB) { /// ToggleFeature - Toggle a feature and returns the re-computed feature /// bits. This version will also change all implied bits. FeatureBitset MCSubtargetInfo::ToggleFeature(StringRef FS) { - SubtargetFeatures Features; - FeatureBits = Features.ToggleFeature(FeatureBits, FS, ProcFeatures); + SubtargetFeatures::ToggleFeature(FeatureBits, FS, ProcFeatures); return FeatureBits; } FeatureBitset MCSubtargetInfo::ApplyFeatureFlag(StringRef FS) { - SubtargetFeatures Features; - FeatureBits = Features.ApplyFeatureFlag(FeatureBits, FS, ProcFeatures); + SubtargetFeatures::ApplyFeatureFlag(FeatureBits, FS, ProcFeatures); return FeatureBits; } diff --git a/lib/MC/SubtargetFeature.cpp b/lib/MC/SubtargetFeature.cpp index c1f5fc95cf5..7cce0fe756e 100644 --- a/lib/MC/SubtargetFeature.cpp +++ b/lib/MC/SubtargetFeature.cpp @@ -160,10 +160,9 @@ void ClearImpliedBits(FeatureBitset &Bits, } } -/// ToggleFeature - Toggle a feature and returns the newly updated feature -/// bits. -FeatureBitset -SubtargetFeatures::ToggleFeature(FeatureBitset Bits, StringRef Feature, +/// ToggleFeature - Toggle a feature and update the feature bits. +void +SubtargetFeatures::ToggleFeature(FeatureBitset &Bits, StringRef Feature, ArrayRef FeatureTable) { // Find feature in table. @@ -186,12 +185,9 @@ SubtargetFeatures::ToggleFeature(FeatureBitset Bits, StringRef Feature, << "' is not a recognized feature for this target" << " (ignoring feature)\n"; } - - return Bits; } -FeatureBitset -SubtargetFeatures::ApplyFeatureFlag(FeatureBitset Bits, StringRef Feature, +void SubtargetFeatures::ApplyFeatureFlag(FeatureBitset &Bits, StringRef Feature, ArrayRef FeatureTable) { assert(hasFlag(Feature)); @@ -203,7 +199,7 @@ SubtargetFeatures::ApplyFeatureFlag(FeatureBitset Bits, StringRef Feature, if (FeatureEntry) { // Enable/disable feature in bits if (isEnabled(Feature)) { - Bits |= FeatureEntry->Value; + Bits |= FeatureEntry->Value; // For each feature that this implies, set it. SetImpliedBits(Bits, FeatureEntry, FeatureTable); @@ -218,8 +214,6 @@ SubtargetFeatures::ApplyFeatureFlag(FeatureBitset Bits, StringRef Feature, << "' is not a recognized feature for this target" << " (ignoring feature)\n"; } - - return Bits; } @@ -273,7 +267,7 @@ SubtargetFeatures::getFeatureBits(StringRef CPU, if (Feature == "+help") Help(CPUTable, FeatureTable); - Bits = ApplyFeatureFlag(Bits, Feature, FeatureTable); + ApplyFeatureFlag(Bits, Feature, FeatureTable); } return Bits; -- 2.34.1