From ecf670391ba6efc58ee31dedc2bd3ffbea7cb8e1 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Fri, 27 Feb 2015 17:57:01 +0000 Subject: [PATCH] Switch a std::map to a DenseMap in CodeGenRegisters. The keys of the map are unique by pointer address, so there's no need to use the llvm::less comparator. This allows us to use DenseMap instead, which reduces tblgen time by 20% on my stress test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230769 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/CodeGenRegisters.cpp | 2 ++ utils/TableGen/CodeGenRegisters.h | 3 +-- utils/TableGen/RegisterInfoEmitter.cpp | 16 +++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/utils/TableGen/CodeGenRegisters.cpp b/utils/TableGen/CodeGenRegisters.cpp index 37f890531ad..3284ba46a44 100644 --- a/utils/TableGen/CodeGenRegisters.cpp +++ b/utils/TableGen/CodeGenRegisters.cpp @@ -258,6 +258,8 @@ CodeGenRegister::computeSubRegs(CodeGenRegBank &RegBank) { // Look at the possible compositions of Idx. // They may not all be supported by SR. + // NOTE: Iteration order does not matter here because the EnumValue's + // of subreg indices are unique. for (CodeGenSubRegIndex::CompMap::const_iterator I = Comps.begin(), E = Comps.end(); I != E; ++I) { SubRegMap::const_iterator SRI = Map.find(I->first); diff --git a/utils/TableGen/CodeGenRegisters.h b/utils/TableGen/CodeGenRegisters.h index 7c723d93a23..dad0f6cec7e 100644 --- a/utils/TableGen/CodeGenRegisters.h +++ b/utils/TableGen/CodeGenRegisters.h @@ -74,8 +74,7 @@ namespace llvm { std::string getQualifiedName() const; // Map of composite subreg indices. - typedef std::map> CompMap; + typedef DenseMap CompMap; // Returns the subreg index that results from composing this with Idx. // Returns NULL if this and Idx don't compose. diff --git a/utils/TableGen/RegisterInfoEmitter.cpp b/utils/TableGen/RegisterInfoEmitter.cpp index 5a6694ea7f1..0e9cbeb439f 100644 --- a/utils/TableGen/RegisterInfoEmitter.cpp +++ b/utils/TableGen/RegisterInfoEmitter.cpp @@ -610,17 +610,19 @@ static void printMask(raw_ostream &OS, unsigned Val) { static bool combine(const CodeGenSubRegIndex *Idx, SmallVectorImpl &Vec) { const CodeGenSubRegIndex::CompMap &Map = Idx->getComposites(); - for (CodeGenSubRegIndex::CompMap::const_iterator - I = Map.begin(), E = Map.end(); I != E; ++I) { - CodeGenSubRegIndex *&Entry = Vec[I->first->EnumValue - 1]; - if (Entry && Entry != I->second) + for (const auto &I : Map) { + CodeGenSubRegIndex *&Entry = Vec[I.first->EnumValue - 1]; + if (Entry && Entry != I.second) return false; } // All entries are compatible. Make it so. - for (CodeGenSubRegIndex::CompMap::const_iterator - I = Map.begin(), E = Map.end(); I != E; ++I) - Vec[I->first->EnumValue - 1] = I->second; + for (const auto &I : Map) { + auto *&Entry = Vec[I.first->EnumValue - 1]; + assert((!Entry || Entry == I.second) && + "Expected EnumValue to be unique"); + Entry = I.second; + } return true; } -- 2.34.1