[llvm] r222939 - Revert "Use std::map<K, V> rather than std::map<K, std::unique_ptr<V>>"
David Blaikie
dblaikie at gmail.com
Fri Nov 28 14:01:06 PST 2014
Author: dblaikie
Date: Fri Nov 28 16:01:06 2014
New Revision: 222939
URL: http://llvm.org/viewvc/llvm-project?rev=222939&view=rev
Log:
Revert "Use std::map<K, V> rather than std::map<K, std::unique_ptr<V>>"
Seems libstdc++ on some buildbots is lacking std::map::emplace, which is
weird... reverting while I look into it.
This reverts commit r222937.
Modified:
llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=222939&r1=222938&r2=222939&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Fri Nov 28 16:01:06 2014
@@ -423,7 +423,7 @@ struct MatchableInfo {
SmallVector<AsmOperand, 8> AsmOperands;
/// Predicates - The required subtarget features to match this instruction.
- SmallVector<const SubtargetFeatureInfo *, 4> RequiredFeatures;
+ SmallVector<SubtargetFeatureInfo*, 4> RequiredFeatures;
/// ConversionFnKind - The enum value which is passed to the generated
/// convertToMCInst to convert parsed operands into an MCInst for this
@@ -621,7 +621,8 @@ public:
RegisterClassesTy RegisterClasses;
/// Map of Predicate records to their subtarget information.
- std::map<Record *, SubtargetFeatureInfo, LessRecordByID> SubtargetFeatures;
+ std::map<Record*, std::unique_ptr<SubtargetFeatureInfo>,
+ LessRecordByID> SubtargetFeatures;
/// Map of AsmOperandClass records to their class information.
std::map<Record*, ClassInfo*> AsmOperandClasses;
@@ -669,10 +670,10 @@ public:
/// getSubtargetFeature - Lookup or create the subtarget feature info for the
/// given operand.
- const SubtargetFeatureInfo *getSubtargetFeature(Record *Def) const {
+ SubtargetFeatureInfo *getSubtargetFeature(Record *Def) const {
assert(Def->isSubClassOf("Predicate") && "Invalid predicate type!");
const auto &I = SubtargetFeatures.find(Def);
- return I == SubtargetFeatures.end() ? nullptr : &I->second;
+ return I == SubtargetFeatures.end() ? nullptr : I->second.get();
}
RecordKeeper &getRecords() const {
@@ -776,8 +777,8 @@ void MatchableInfo::initialize(const Asm
// Compute the require features.
std::vector<Record*> Predicates =TheDef->getValueAsListOfDefs("Predicates");
for (unsigned i = 0, e = Predicates.size(); i != e; ++i)
- if (const SubtargetFeatureInfo *Feature =
- Info.getSubtargetFeature(Predicates[i]))
+ if (SubtargetFeatureInfo *Feature =
+ Info.getSubtargetFeature(Predicates[i]))
RequiredFeatures.push_back(Feature);
// Collect singleton registers, if used.
@@ -1309,11 +1310,11 @@ void AsmMatcherInfo::buildInfo() {
if (Pred->getName().empty())
PrintFatalError(Pred->getLoc(), "Predicate has no name!");
- SubtargetFeatures.emplace(
- std::piecewise_construct, std::forward_as_tuple(Pred),
- std::forward_as_tuple(Pred, SubtargetFeatures.size()));
- DEBUG(SubtargetFeatures.find(Pred)->second.dump());
- assert(SubtargetFeatures.size() <= 64 && "Too many subtarget features!");
+ uint64_t FeatureNo = SubtargetFeatures.size();
+ SubtargetFeatures[Pred] =
+ llvm::make_unique<SubtargetFeatureInfo>(Pred, FeatureNo);
+ DEBUG(SubtargetFeatures[Pred]->dump());
+ assert(FeatureNo < 64 && "Too many subtarget features!");
}
// Parse the instructions; we need to do this first so that we can gather the
@@ -2176,7 +2177,7 @@ static void emitSubtargetFeatureFlagEnum
OS << "enum SubtargetFeatureFlag : " << getMinimalRequiredFeaturesType(Info)
<< " {\n";
for (const auto &SF : Info.SubtargetFeatures) {
- const SubtargetFeatureInfo &SFI = SF.second;
+ SubtargetFeatureInfo &SFI = *SF.second;
OS << " " << SFI.getEnumName() << " = (1ULL << " << SFI.Index << "),\n";
}
OS << " Feature_None = 0\n";
@@ -2212,7 +2213,7 @@ static void emitGetSubtargetFeatureName(
if (!Info.SubtargetFeatures.empty()) {
OS << " switch(Val) {\n";
for (const auto &SF : Info.SubtargetFeatures) {
- const SubtargetFeatureInfo &SFI = SF.second;
+ SubtargetFeatureInfo &SFI = *SF.second;
// FIXME: Totally just a placeholder name to get the algorithm working.
OS << " case " << SFI.getEnumName() << ": return \""
<< SFI.TheDef->getValueAsString("PredicateName") << "\";\n";
@@ -2237,7 +2238,7 @@ static void emitComputeAvailableFeatures
<< "ComputeAvailableFeatures(uint64_t FB) const {\n";
OS << " uint64_t Features = 0;\n";
for (const auto &SF : Info.SubtargetFeatures) {
- const SubtargetFeatureInfo &SFI = SF.second;
+ SubtargetFeatureInfo &SFI = *SF.second;
OS << " if (";
std::string CondStorage =
@@ -2283,7 +2284,7 @@ static std::string GetAliasRequiredFeatu
std::string Result;
unsigned NumFeatures = 0;
for (unsigned i = 0, e = ReqFeatures.size(); i != e; ++i) {
- const SubtargetFeatureInfo *F = Info.getSubtargetFeature(ReqFeatures[i]);
+ SubtargetFeatureInfo *F = Info.getSubtargetFeature(ReqFeatures[i]);
if (!F)
PrintFatalError(R->getLoc(), "Predicate '" + ReqFeatures[i]->getName() +
More information about the llvm-commits
mailing list