summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2019-03-04 02:02:22 +0000
committerCraig Topper <craig.topper@intel.com>2019-03-04 02:02:22 +0000
commita761f9f4079acff4a3b1ace5e439d4c446a8db05 (patch)
tree18a31c49e9eb55937d88d93c1fe886cf2496f0b0
parent088b1c9cdcdb3d83fa730c1fcbae6db8252fe76d (diff)
downloadbcm5719-llvm-a761f9f4079acff4a3b1ace5e439d4c446a8db05.tar.gz
bcm5719-llvm-a761f9f4079acff4a3b1ace5e439d4c446a8db05.zip
[SubtargetFeatuers] Simplify the code used to imply features from CPU name.
If we make SetImpliedBits OR features outside of its loop, we can reuse it for the first round of implying features for CPUs. llvm-svn: 355298
-rw-r--r--llvm/lib/MC/SubtargetFeature.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/llvm/lib/MC/SubtargetFeature.cpp b/llvm/lib/MC/SubtargetFeature.cpp
index c34c6ff9007..84c743c5e33 100644
--- a/llvm/lib/MC/SubtargetFeature.cpp
+++ b/llvm/lib/MC/SubtargetFeature.cpp
@@ -124,12 +124,12 @@ std::string SubtargetFeatures::getString() const {
static
void SetImpliedBits(FeatureBitset &Bits, const FeatureBitset &Implies,
ArrayRef<SubtargetFeatureKV> FeatureTable) {
- for (const SubtargetFeatureKV &FE : FeatureTable) {
- if (Implies.test(FE.Value)) {
- Bits.set(FE.Value);
+ // OR the Implies bits in outside the loop. This allows the Implies for CPUs
+ // which might imply features not in FeatureTable to use this.
+ Bits |= Implies;
+ for (const SubtargetFeatureKV &FE : FeatureTable)
+ if (Implies.test(FE.Value))
SetImpliedBits(Bits, FE.Implies.getAsBitset(), FeatureTable);
- }
- }
}
/// For each feature that (transitively) implies this feature, clear it.
@@ -219,15 +219,8 @@ SubtargetFeatures::getFeatureBits(StringRef CPU,
// If there is a match
if (CPUEntry) {
- // Set base feature bits
- FeatureBitset CPUImplies = CPUEntry->Implies.getAsBitset();
- Bits = CPUImplies;
-
- // Set the feature implied by this CPU feature, if any.
- for (auto &FE : FeatureTable) {
- if (CPUImplies.test(FE.Value))
- SetImpliedBits(Bits, FE.Implies.getAsBitset(), FeatureTable);
- }
+ // Set the features implied by this CPU feature, if any.
+ SetImpliedBits(Bits, CPUEntry->Implies.getAsBitset(), FeatureTable);
} else {
errs() << "'" << CPU << "' is not a recognized processor for this target"
<< " (ignoring processor)\n";
OpenPOWER on IntegriCloud