Reapply "Use std::map<K, V> rather than std::map<K, std::unique_ptr<V>>""

Just avoid using std::map::emplace since it's not implemented in
libstdc++ 4.7.

Reapplies r222937, reverted in r222939.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222940 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2014-11-28 22:15:06 +00:00
parent 833ccf86e5
commit 5f95140d02

View File

@@ -423,7 +423,7 @@ struct MatchableInfo {
SmallVector<AsmOperand, 8> AsmOperands; SmallVector<AsmOperand, 8> AsmOperands;
/// Predicates - The required subtarget features to match this instruction. /// Predicates - The required subtarget features to match this instruction.
SmallVector<SubtargetFeatureInfo*, 4> RequiredFeatures; SmallVector<const SubtargetFeatureInfo *, 4> RequiredFeatures;
/// ConversionFnKind - The enum value which is passed to the generated /// ConversionFnKind - The enum value which is passed to the generated
/// convertToMCInst to convert parsed operands into an MCInst for this /// convertToMCInst to convert parsed operands into an MCInst for this
@@ -621,8 +621,7 @@ public:
RegisterClassesTy RegisterClasses; RegisterClassesTy RegisterClasses;
/// Map of Predicate records to their subtarget information. /// Map of Predicate records to their subtarget information.
std::map<Record*, std::unique_ptr<SubtargetFeatureInfo>, std::map<Record *, SubtargetFeatureInfo, LessRecordByID> SubtargetFeatures;
LessRecordByID> SubtargetFeatures;
/// Map of AsmOperandClass records to their class information. /// Map of AsmOperandClass records to their class information.
std::map<Record*, ClassInfo*> AsmOperandClasses; std::map<Record*, ClassInfo*> AsmOperandClasses;
@@ -670,10 +669,10 @@ public:
/// getSubtargetFeature - Lookup or create the subtarget feature info for the /// getSubtargetFeature - Lookup or create the subtarget feature info for the
/// given operand. /// given operand.
SubtargetFeatureInfo *getSubtargetFeature(Record *Def) const { const SubtargetFeatureInfo *getSubtargetFeature(Record *Def) const {
assert(Def->isSubClassOf("Predicate") && "Invalid predicate type!"); assert(Def->isSubClassOf("Predicate") && "Invalid predicate type!");
const auto &I = SubtargetFeatures.find(Def); const auto &I = SubtargetFeatures.find(Def);
return I == SubtargetFeatures.end() ? nullptr : I->second.get(); return I == SubtargetFeatures.end() ? nullptr : &I->second;
} }
RecordKeeper &getRecords() const { RecordKeeper &getRecords() const {
@@ -777,8 +776,8 @@ void MatchableInfo::initialize(const AsmMatcherInfo &Info,
// Compute the require features. // Compute the require features.
std::vector<Record*> Predicates =TheDef->getValueAsListOfDefs("Predicates"); std::vector<Record*> Predicates =TheDef->getValueAsListOfDefs("Predicates");
for (unsigned i = 0, e = Predicates.size(); i != e; ++i) for (unsigned i = 0, e = Predicates.size(); i != e; ++i)
if (SubtargetFeatureInfo *Feature = if (const SubtargetFeatureInfo *Feature =
Info.getSubtargetFeature(Predicates[i])) Info.getSubtargetFeature(Predicates[i]))
RequiredFeatures.push_back(Feature); RequiredFeatures.push_back(Feature);
// Collect singleton registers, if used. // Collect singleton registers, if used.
@@ -1310,11 +1309,10 @@ void AsmMatcherInfo::buildInfo() {
if (Pred->getName().empty()) if (Pred->getName().empty())
PrintFatalError(Pred->getLoc(), "Predicate has no name!"); PrintFatalError(Pred->getLoc(), "Predicate has no name!");
uint64_t FeatureNo = SubtargetFeatures.size(); SubtargetFeatures.insert(std::make_pair(
SubtargetFeatures[Pred] = Pred, SubtargetFeatureInfo(Pred, SubtargetFeatures.size())));
llvm::make_unique<SubtargetFeatureInfo>(Pred, FeatureNo); DEBUG(SubtargetFeatures.find(Pred)->second.dump());
DEBUG(SubtargetFeatures[Pred]->dump()); assert(SubtargetFeatures.size() <= 64 && "Too many subtarget features!");
assert(FeatureNo < 64 && "Too many subtarget features!");
} }
// Parse the instructions; we need to do this first so that we can gather the // Parse the instructions; we need to do this first so that we can gather the
@@ -2177,7 +2175,7 @@ static void emitSubtargetFeatureFlagEnumeration(AsmMatcherInfo &Info,
OS << "enum SubtargetFeatureFlag : " << getMinimalRequiredFeaturesType(Info) OS << "enum SubtargetFeatureFlag : " << getMinimalRequiredFeaturesType(Info)
<< " {\n"; << " {\n";
for (const auto &SF : Info.SubtargetFeatures) { for (const auto &SF : Info.SubtargetFeatures) {
SubtargetFeatureInfo &SFI = *SF.second; const SubtargetFeatureInfo &SFI = SF.second;
OS << " " << SFI.getEnumName() << " = (1ULL << " << SFI.Index << "),\n"; OS << " " << SFI.getEnumName() << " = (1ULL << " << SFI.Index << "),\n";
} }
OS << " Feature_None = 0\n"; OS << " Feature_None = 0\n";
@@ -2213,7 +2211,7 @@ static void emitGetSubtargetFeatureName(AsmMatcherInfo &Info, raw_ostream &OS) {
if (!Info.SubtargetFeatures.empty()) { if (!Info.SubtargetFeatures.empty()) {
OS << " switch(Val) {\n"; OS << " switch(Val) {\n";
for (const auto &SF : Info.SubtargetFeatures) { for (const auto &SF : Info.SubtargetFeatures) {
SubtargetFeatureInfo &SFI = *SF.second; const SubtargetFeatureInfo &SFI = SF.second;
// FIXME: Totally just a placeholder name to get the algorithm working. // FIXME: Totally just a placeholder name to get the algorithm working.
OS << " case " << SFI.getEnumName() << ": return \"" OS << " case " << SFI.getEnumName() << ": return \""
<< SFI.TheDef->getValueAsString("PredicateName") << "\";\n"; << SFI.TheDef->getValueAsString("PredicateName") << "\";\n";
@@ -2238,7 +2236,7 @@ static void emitComputeAvailableFeatures(AsmMatcherInfo &Info,
<< "ComputeAvailableFeatures(uint64_t FB) const {\n"; << "ComputeAvailableFeatures(uint64_t FB) const {\n";
OS << " uint64_t Features = 0;\n"; OS << " uint64_t Features = 0;\n";
for (const auto &SF : Info.SubtargetFeatures) { for (const auto &SF : Info.SubtargetFeatures) {
SubtargetFeatureInfo &SFI = *SF.second; const SubtargetFeatureInfo &SFI = SF.second;
OS << " if ("; OS << " if (";
std::string CondStorage = std::string CondStorage =
@@ -2284,7 +2282,7 @@ static std::string GetAliasRequiredFeatures(Record *R,
std::string Result; std::string Result;
unsigned NumFeatures = 0; unsigned NumFeatures = 0;
for (unsigned i = 0, e = ReqFeatures.size(); i != e; ++i) { for (unsigned i = 0, e = ReqFeatures.size(); i != e; ++i) {
SubtargetFeatureInfo *F = Info.getSubtargetFeature(ReqFeatures[i]); const SubtargetFeatureInfo *F = Info.getSubtargetFeature(ReqFeatures[i]);
if (!F) if (!F)
PrintFatalError(R->getLoc(), "Predicate '" + ReqFeatures[i]->getName() + PrintFatalError(R->getLoc(), "Predicate '" + ReqFeatures[i]->getName() +