llvm.org GIT mirror llvm / 9589ff8
Replace push_back(Constructor(foo)) with emplace_back(foo) for non-trivial types If the type isn't trivially moveable emplace can skip a potentially expensive move. It also saves a couple of characters. Call sites were found with the ASTMatcher + some semi-automated cleanup. memberCallExpr( argumentCountIs(1), callee(methodDecl(hasName("push_back"))), on(hasType(recordDecl(has(namedDecl(hasName("emplace_back")))))), hasArgument(0, bindTemporaryExpr( hasType(recordDecl(hasNonTrivialDestructor())), has(constructExpr()))), unless(isInTemplateInstantiation())) No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238602 91177308-0d34-0410-b5e6-96231b3b80d8 Benjamin Kramer 4 years ago
42 changed file(s) with 109 addition(s) and 140 deletion(s). Raw diff Collapse all Expand all
229229 void addCalledFunction(CallSite CS, CallGraphNode *M) {
230230 assert(!CS.getInstruction() || !CS.getCalledFunction() ||
231231 !CS.getCalledFunction()->isIntrinsic());
232 CalledFunctions.push_back(std::make_pair(CS.getInstruction(), M));
232 CalledFunctions.emplace_back(CS.getInstruction(), M);
233233 M->AddRef();
234234 }
235235
112112 return *const_cast(BI);
113113
114114 // Otherwise, add a new record.
115 BlockInfoRecords.push_back(BlockInfo());
115 BlockInfoRecords.emplace_back();
116116 BlockInfoRecords.back().BlockID = BlockID;
117117 return BlockInfoRecords.back();
118118 }
214214
215215 // Push the outer block's abbrev set onto the stack, start out with an
216216 // empty abbrev set.
217 BlockScope.push_back(Block(OldCodeSize, BlockSizeWordIndex));
217 BlockScope.emplace_back(OldCodeSize, BlockSizeWordIndex);
218218 BlockScope.back().PrevAbbrevs.swap(CurAbbrevs);
219219
220220 // If there is a blockinfo for this BlockID, add all the predefined abbrevs
502502 return *BI;
503503
504504 // Otherwise, add a new record.
505 BlockInfoRecords.push_back(BlockInfo());
505 BlockInfoRecords.emplace_back();
506506 BlockInfoRecords.back().BlockID = BlockID;
507507 return BlockInfoRecords.back();
508508 }
120120 /// label just prior to the safe point (if the code generator is using
121121 /// MachineModuleInfo).
122122 void addSafePoint(GC::PointKind Kind, MCSymbol *Label, DebugLoc DL) {
123 SafePoints.push_back(GCPoint(Kind, Label, DL));
123 SafePoints.emplace_back(Kind, Label, DL);
124124 }
125125
126126 /// getFrameSize/setFrameSize - Records the function's frame size.
259259 #ifndef NDEBUG
260260 const SUnit *Addr = SUnits.empty() ? nullptr : &SUnits[0];
261261 #endif
262 SUnits.push_back(SUnit(MI, (unsigned)SUnits.size()));
262 SUnits.emplace_back(MI, (unsigned)SUnits.size());
263263 assert((Addr == nullptr || Addr == &SUnits[0]) &&
264264 "SUnits std::vector reallocated on the fly!");
265265 SUnits.back().OrigNode = &SUnits.back();
389389 for (auto &F : *M) {
390390 if (F.isDeclaration())
391391 continue;
392 Partitioning.push_back(std::vector());
393 Partitioning.back().push_back(&F);
392 Partitioning.emplace_back(1, &F);
394393 }
395394 addLogicalModule(*LogicalDylibs.back(),
396395 std::shared_ptr(std::move(M)),
129129 void AliasSet::addUnknownInst(Instruction *I, AliasAnalysis &AA) {
130130 if (UnknownInsts.empty())
131131 addRef();
132 UnknownInsts.push_back(I);
132 UnknownInsts.emplace_back(I);
133133
134134 if (!I->mayWriteToMemory()) {
135135 AliasTy = MayAlias;
17111711 // would confuse the logic below that expects proper IVs.
17121712 if (Value *V = SimplifyInstruction(Phi, DL, SE.TLI, SE.DT, SE.AC)) {
17131713 Phi->replaceAllUsesWith(V);
1714 DeadInsts.push_back(Phi);
1714 DeadInsts.emplace_back(Phi);
17151715 ++NumElim;
17161716 DEBUG_WITH_TYPE(DebugType, dbgs()
17171717 << "INDVARS: Eliminated constant iv: " << *Phi << '\n');
17861786 CreateTruncOrBitCast(OrigInc, IsomorphicInc->getType(), IVName);
17871787 }
17881788 IsomorphicInc->replaceAllUsesWith(NewInc);
1789 DeadInsts.push_back(IsomorphicInc);
1789 DeadInsts.emplace_back(IsomorphicInc);
17901790 }
17911791 }
17921792 DEBUG_WITH_TYPE(DebugType, dbgs()
17991799 NewIV = Builder.CreateTruncOrBitCast(OrigPhiRef, Phi->getType(), IVName);
18001800 }
18011801 Phi->replaceAllUsesWith(NewIV);
1802 DeadInsts.push_back(Phi);
1802 DeadInsts.emplace_back(Phi);
18031803 }
18041804 return NumElim;
18051805 }
19011901 return Error(TypeLoc, "invalid type for function argument");
19021902
19031903 unsigned AttrIndex = 1;
1904 ArgList.push_back(ArgInfo(TypeLoc, ArgTy,
1905 AttributeSet::get(ArgTy->getContext(),
1906 AttrIndex++, Attrs), Name));
1904 ArgList.emplace_back(TypeLoc, ArgTy, AttributeSet::get(ArgTy->getContext(),
1905 AttrIndex++, Attrs),
1906 std::move(Name));
19071907
19081908 while (EatIfPresent(lltok::comma)) {
19091909 // Handle ... at end of arg list.
19291929 if (!ArgTy->isFirstClassType())
19301930 return Error(TypeLoc, "invalid type for function argument");
19311931
1932 ArgList.push_back(ArgInfo(TypeLoc, ArgTy,
1933 AttributeSet::get(ArgTy->getContext(),
1934 AttrIndex++, Attrs),
1935 Name));
1932 ArgList.emplace_back(
1933 TypeLoc, ArgTy,
1934 AttributeSet::get(ArgTy->getContext(), AttrIndex++, Attrs),
1935 std::move(Name));
19361936 }
19371937 }
19381938
6262 // vector compatibility methods
6363 unsigned size() const { return ValuePtrs.size(); }
6464 void resize(unsigned N) { ValuePtrs.resize(N); }
65 void push_back(Value *V) {
66 ValuePtrs.push_back(V);
67 }
65 void push_back(Value *V) { ValuePtrs.emplace_back(V); }
6866
6967 void clear() {
7068 assert(ResolveConstants.empty() && "Constants not resolved?");
113113
114114 // Otherwise, this is a new entry, create a new symbol for it and add an
115115 // entry to BBCallbacks so we can be notified if the BB is deleted or RAUWd.
116 BBCallbacks.push_back(BB);
116 BBCallbacks.emplace_back(BB);
117117 BBCallbacks.back().setMap(this);
118118 Entry.Index = BBCallbacks.size()-1;
119119 Entry.Fn = BB->getParent();
7070 if (!SUnits.empty())
7171 Addr = &SUnits[0];
7272 #endif
73 SUnits.push_back(SUnit(N, (unsigned)SUnits.size()));
73 SUnits.emplace_back(N, (unsigned)SUnits.size());
7474 assert((Addr == nullptr || Addr == &SUnits[0]) &&
7575 "SUnits std::vector reallocated on the fly!");
7676 SUnits.back().OrigNode = &SUnits.back();
74367436 JumpTableHeader JTH(Clusters[First].Low->getValue(),
74377437 Clusters[Last].High->getValue(), SI->getCondition(),
74387438 nullptr, false);
7439 JTCases.push_back(JumpTableBlock(JTH, JT));
7439 JTCases.emplace_back(std::move(JTH), std::move(JT));
74407440
74417441 JTCluster = CaseCluster::jumpTable(Clusters[First].Low, Clusters[Last].High,
74427442 JTCases.size() - 1, Weight);
76497649 FuncInfo.MF->CreateMachineBasicBlock(SI->getParent());
76507650 BTI.push_back(BitTestCase(CB.Mask, BitTestBB, CB.BB, CB.ExtraWeight));
76517651 }
7652 BitTestCases.push_back(BitTestBlock(LowBound, CmpRange, SI->getCondition(),
7653 -1U, MVT::Other, false, nullptr,
7654 nullptr, std::move(BTI)));
7652 BitTestCases.emplace_back(std::move(LowBound), std::move(CmpRange),
7653 SI->getCondition(), -1U, MVT::Other, false, nullptr,
7654 nullptr, std::move(BTI));
76557655
76567656 BTCluster = CaseCluster::bitTests(Clusters[First].Low, Clusters[Last].High,
76577657 BitTestCases.size() - 1, TotalWeight);
351351 if (!TUs.empty())
352352 return;
353353 for (const auto &I : getTypesSections()) {
354 TUs.push_back(DWARFUnitSection());
354 TUs.emplace_back();
355355 TUs.back().parse(*this, I.second);
356356 }
357357 }
364364 if (!DWOTUs.empty())
365365 return;
366366 for (const auto &I : getTypesDWOSections()) {
367 DWOTUs.push_back(DWARFUnitSection());
367 DWOTUs.emplace_back();
368368 DWOTUs.back().parseDWO(*this, I.second);
369369 }
370370 }
437437 if (NumArgs > 2) {
438438 std::vector EnvVars;
439439 for (unsigned i = 0; envp[i]; ++i)
440 EnvVars.push_back(envp[i]);
440 EnvVars.emplace_back(envp[i]);
441441 // Arg #2 = envp.
442442 GVArgs.push_back(PTOGV(CEnv.reset(Fn->getContext(), this, EnvVars)));
443443 }
253253 unsigned ArgC, const char * const *ArgV,
254254 const char * const *EnvP) {
255255 unwrap(EE)->finalizeObject();
256
257 std::vector ArgVec;
258 for (unsigned I = 0; I != ArgC; ++I)
259 ArgVec.push_back(ArgV[I]);
260
256
257 std::vector ArgVec(ArgV, ArgV + ArgC);
261258 return unwrap(EE)->runFunctionAsMain(unwrap(F), ArgVec, EnvP);
262259 }
263260
20782078 ECStack.back().Caller.arg_size() == ArgVals.size()) &&
20792079 "Incorrect number of arguments passed into function call!");
20802080 // Make a new stack frame... and fill it in.
2081 ECStack.push_back(ExecutionContext());
2081 ECStack.emplace_back();
20822082 ExecutionContext &StackFrame = ECStack.back();
20832083 StackFrame.CurFunction = F;
20842084
19481948 if (Vararg) {
19491949 if (Lexer.isNot(AsmToken::EndOfStatement)) {
19501950 StringRef Str = parseStringToEndOfStatement();
1951 MA.push_back(AsmToken(AsmToken::String, Str));
1951 MA.emplace_back(AsmToken::String, Str);
19521952 }
19531953 return false;
19541954 }
43454345 StringRef Body = StringRef(BodyStart, BodyEnd - BodyStart);
43464346
43474347 // We Are Anonymous.
4348 MacroLikeBodies.push_back(
4349 MCAsmMacro(StringRef(), Body, MCAsmMacroParameters()));
4348 MacroLikeBodies.emplace_back(StringRef(), Body, MCAsmMacroParameters());
43504349 return &MacroLikeBodies.back();
43514350 }
43524351
44894488 StringRef Values = A.front().front().getString();
44904489 for (std::size_t I = 0, End = Values.size(); I != End; ++I) {
44914490 MCAsmMacroArgument Arg;
4492 Arg.push_back(AsmToken(AsmToken::Identifier, Values.slice(I, I + 1)));
4491 Arg.emplace_back(AsmToken::Identifier, Values.slice(I, I + 1));
44934492
44944493 // Note that the AtPseudoVariable is enabled for instantiations of .irpc.
44954494 // This is undocumented, but GAS seems to support it.
16001600 // DagArg ::= VARNAME
16011601 if (Lex.getCode() == tgtok::VarName) {
16021602 // A missing value is treated like '?'.
1603 Result.push_back(std::make_pair(UnsetInit::get(), Lex.getCurStrVal()));
1603 Result.emplace_back(UnsetInit::get(), Lex.getCurStrVal());
16041604 Lex.Lex();
16051605 } else {
16061606 // DagArg ::= Value (':' VARNAME)?
21732173 if (!Val) return std::vector();
21742174
21752175 // Now that we have everything, add the record.
2176 Result.push_back(LetRecord(Name, Bits, Val, NameLoc));
2176 Result.emplace_back(std::move(Name), std::move(Bits), Val, NameLoc);
21772177
21782178 if (Lex.getCode() != tgtok::comma)
21792179 return Result;
14641464 if (Erased) {
14651465 DEBUG(dbgs() << "Removed " << F->getName()
14661466 << " from set and deferred it.\n");
1467 Deferred.push_back(F);
1467 Deferred.emplace_back(F);
14681468 }
14691469 }
14701470
18421842
18431843 case Instruction::BitCast:
18441844 case Instruction::GetElementPtr:
1845 Users.push_back(I);
1845 Users.emplace_back(I);
18461846 Worklist.push_back(I);
18471847 continue;
18481848
18511851 // We can fold eq/ne comparisons with null to false/true, respectively.
18521852 if (!ICI->isEquality() || !isa(ICI->getOperand(1)))
18531853 return false;
1854 Users.push_back(I);
1854 Users.emplace_back(I);
18551855 continue;
18561856 }
18571857
18771877 case Intrinsic::lifetime_start:
18781878 case Intrinsic::lifetime_end:
18791879 case Intrinsic::objectsize:
1880 Users.push_back(I);
1880 Users.emplace_back(I);
18811881 continue;
18821882 }
18831883 }
18841884
18851885 if (isFreeCall(I, TLI)) {
1886 Users.push_back(I);
1886 Users.emplace_back(I);
18871887 continue;
18881888 }
18891889 return false;
18921892 StoreInst *SI = cast(I);
18931893 if (SI->isVolatile() || SI->getPointerOperand() != PI)
18941894 return false;
1895 Users.push_back(I);
1895 Users.emplace_back(I);
18961896 continue;
18971897 }
18981898 }
11011101 IRBuilder<> Builder(WidePhi->getParent()->getFirstInsertionPt());
11021102 Value *Trunc = Builder.CreateTrunc(WidePhi, DU.NarrowDef->getType());
11031103 UsePhi->replaceAllUsesWith(Trunc);
1104 DeadInsts.push_back(UsePhi);
1104 DeadInsts.emplace_back(UsePhi);
11051105 DEBUG(dbgs() << "INDVARS: Widen lcssa phi " << *UsePhi
11061106 << " to " << *WidePhi << "\n");
11071107 }
11341134 << " replaced by " << *DU.WideDef << "\n");
11351135 ++NumElimExt;
11361136 DU.NarrowUse->replaceAllUsesWith(NewDef);
1137 DeadInsts.push_back(DU.NarrowUse);
1137 DeadInsts.emplace_back(DU.NarrowUse);
11381138 }
11391139 // Now that the extend is gone, we want to expose it's uses for potential
11401140 // further simplification. We don't need to directly inform SimplifyIVUsers
11871187 if (WideAddRec != SE->getSCEV(WideUse)) {
11881188 DEBUG(dbgs() << "Wide use expression mismatch: " << *WideUse
11891189 << ": " << *SE->getSCEV(WideUse) << " != " << *WideAddRec << "\n");
1190 DeadInsts.push_back(WideUse);
1190 DeadInsts.emplace_back(WideUse);
11911191 return nullptr;
11921192 }
11931193
12841284
12851285 // WidenIVUse may have removed the def-use edge.
12861286 if (DU.NarrowDef->use_empty())
1287 DeadInsts.push_back(DU.NarrowDef);
1287 DeadInsts.emplace_back(DU.NarrowDef);
12881288 }
12891289 return WidePhi;
12901290 }
810810 if (Instruction *U = dyn_cast(O)) {
811811 O = nullptr;
812812 if (U->use_empty())
813 DeadInsts.push_back(U);
813 DeadInsts.emplace_back(U);
814814 }
815815
816816 I->eraseFromParent();
29162916 IVOper = Builder.CreateTruncOrBitCast(IVOper, OperTy, "lsr.chain");
29172917 }
29182918 Inc.UserInst->replaceUsesOfWith(Inc.IVOperand, IVOper);
2919 DeadInsts.push_back(Inc.IVOperand);
2919 DeadInsts.emplace_back(Inc.IVOperand);
29202920 }
29212921 // If LSR created a new, wider phi, we may also replace its postinc. We only
29222922 // do this if we also found a wide value for the head of the chain.
29382938 IVOper = Builder.CreatePointerCast(IVSrc, PostIncTy, "lsr.chain");
29392939 }
29402940 Phi->replaceUsesOfWith(PostIncV, IVOper);
2941 DeadInsts.push_back(PostIncV);
2941 DeadInsts.emplace_back(PostIncV);
29422942 }
29432943 }
29442944 }
45934593 // form, update the ICmp's other operand.
45944594 if (LU.Kind == LSRUse::ICmpZero) {
45954595 ICmpInst *CI = cast(LF.UserInst);
4596 DeadInsts.push_back(CI->getOperand(1));
4596 DeadInsts.emplace_back(CI->getOperand(1));
45974597 assert(!F.BaseGV && "ICmp does not support folding a global value and "
45984598 "a scale at the same time!");
45994599 if (F.Scale == -1) {
47364736 LF.UserInst->replaceUsesOfWith(LF.OperandValToReplace, FullV);
47374737 }
47384738
4739 DeadInsts.push_back(LF.OperandValToReplace);
4739 DeadInsts.emplace_back(LF.OperandValToReplace);
47404740 }
47414741
47424742 /// ImplementSolution - Rewrite all the fixup locations with new values,
732732 if (Ops.empty()) {
733733 Constant *Identity = ConstantExpr::getBinOpIdentity(Opcode, I->getType());
734734 assert(Identity && "Associative operation without identity!");
735 Ops.push_back(std::make_pair(Identity, APInt(Bitwidth, 1)));
735 Ops.emplace_back(Identity, APInt(Bitwidth, 1));
736736 }
737737
738738 return Changed;
635635 // and inserting the phi nodes we marked as necessary
636636 //
637637 std::vector RenamePassWorkList;
638 RenamePassWorkList.push_back(RenamePassData(F.begin(), nullptr, Values));
638 RenamePassWorkList.emplace_back(F.begin(), nullptr, std::move(Values));
639639 do {
640640 RenamePassData RPD;
641641 RPD.swap(RenamePassWorkList.back());
972972
973973 for (; I != E; ++I)
974974 if (VisitedSuccs.insert(*I).second)
975 Worklist.push_back(RenamePassData(*I, Pred, IncomingVals));
975 Worklist.emplace_back(*I, Pred, IncomingVals);
976976
977977 goto NextIteration;
978978 }
140140 ++NumElimOperand;
141141 Changed = true;
142142 if (IVOperand->use_empty())
143 DeadInsts.push_back(IVOperand);
143 DeadInsts.emplace_back(IVOperand);
144144 return IVSrc;
145145 }
146146
177177 DEBUG(dbgs() << "INDVARS: Eliminated comparison: " << *ICmp << '\n');
178178 ++NumElimCmp;
179179 Changed = true;
180 DeadInsts.push_back(ICmp);
180 DeadInsts.emplace_back(ICmp);
181181 }
182182
183183 /// SimplifyIVUsers helper for eliminating useless
228228 DEBUG(dbgs() << "INDVARS: Simplified rem: " << *Rem << '\n');
229229 ++NumElimRem;
230230 Changed = true;
231 DeadInsts.push_back(Rem);
231 DeadInsts.emplace_back(Rem);
232232 }
233233
234234 /// Eliminate an operation that consumes a simple IV and has
259259 UseInst->replaceAllUsesWith(IVOperand);
260260 ++NumElimIdentity;
261261 Changed = true;
262 DeadInsts.push_back(UseInst);
262 DeadInsts.emplace_back(UseInst);
263263 return true;
264264 }
265265
385385 "Bad add instruction created from overflow intrinsic.");
386386
387387 AddVal->replaceAllUsesWith(AddInst);
388 DeadInsts.push_back(AddVal);
388 DeadInsts.emplace_back(AddVal);
389389 return AddInst;
390390 }
391391
471471
472472 /// Create a new VectorizableTree entry.
473473 TreeEntry *newTreeEntry(ArrayRef VL, bool Vectorized) {
474 VectorizableTree.push_back(TreeEntry());
474 VectorizableTree.emplace_back();
475475 int idx = VectorizableTree.size() - 1;
476476 TreeEntry *Last = &VectorizableTree[idx];
477477 Last->Scalars.insert(Last->Scalars.begin(), VL.begin(), VL.end());
384384 std::vector > BlockInfo;
385385
386386 for (BasicBlock *BB : Blocks)
387 BlockInfo.push_back(std::make_pair(BB->getParent()->getName(),
388 BB->getName()));
387 BlockInfo.emplace_back(BB->getParent()->getName(), BB->getName());
389388
390389 // Now run the CFG simplify pass on the function...
391390 std::vector Passes;
385385 // that masked the error. Stop loop extraction now.
386386
387387 std::vector > MisCompFunctions;
388 for (unsigned i = 0, e = MiscompiledFunctions.size(); i != e; ++i) {
389 Function *F = MiscompiledFunctions[i];
390 MisCompFunctions.push_back(std::make_pair(F->getName(),
391 F->getFunctionType()));
388 for (Function *F : MiscompiledFunctions) {
389 MisCompFunctions.emplace_back(F->getName(), F->getFunctionType());
392390 }
393391
394392 if (Linker::LinkModules(ToNotOptimize, ToOptimizeLoopExtracted))
413411 for (Module::iterator I = ToOptimizeLoopExtracted->begin(),
414412 E = ToOptimizeLoopExtracted->end(); I != E; ++I)
415413 if (!I->isDeclaration())
416 MisCompFunctions.push_back(std::make_pair(I->getName(),
417 I->getFunctionType()));
414 MisCompFunctions.emplace_back(I->getName(), I->getFunctionType());
418415
419416 // Okay, great! Now we know that we extracted a loop and that loop
420417 // extraction both didn't break the program, and didn't mask the problem.
595592 for (Module::iterator I = Extracted->begin(), E = Extracted->end();
596593 I != E; ++I)
597594 if (!I->isDeclaration())
598 MisCompFunctions.push_back(std::make_pair(I->getName(),
599 I->getFunctionType()));
595 MisCompFunctions.emplace_back(I->getName(), I->getFunctionType());
600596
601597 if (Linker::LinkModules(ProgClone, Extracted.get()))
602598 exit(1);
115115 orc::CtorDtorRunner CtorRunner(std::move(CtorNames), H);
116116 CtorRunner.runViaLayer(CODLayer);
117117
118 IRStaticDestructorRunners.push_back(
119 orc::CtorDtorRunner(std::move(DtorNames), H));
118 IRStaticDestructorRunners.emplace_back(std::move(DtorNames), H);
120119
121120 return H;
122121 }
115115 error(EC.message(), SourceFile);
116116 return EC;
117117 }
118 LoadedSourceFiles.push_back(
119 std::make_pair(SourceFile, std::move(Buffer.get())));
118 LoadedSourceFiles.emplace_back(SourceFile, std::move(Buffer.get()));
120119 return *LoadedSourceFiles.back().second;
121120 }
122121
4040 void SetFilters(std::list &List, Iter Begin, Iter End) {
4141 List.clear();
4242 for (; Begin != End; ++Begin)
43 List.push_back(StringRef(*Begin));
43 List.emplace_back(StringRef(*Begin));
4444 }
4545
4646 raw_ostream &OS;
945945 }
946946
947947 // Okay, add the string we captured to the output vector and move on.
948 CheckStrings.push_back(CheckString(P,
949 UsedPrefix,
950 PatternLoc,
951 CheckTy));
948 CheckStrings.emplace_back(P, UsedPrefix, PatternLoc, CheckTy);
952949 std::swap(DagNotMatches, CheckStrings.back().DagNotStrings);
953950 DagNotMatches = ImplicitNegativeChecks;
954951 }
956953 // Add an EOF pattern for any trailing CHECK-DAG/-NOTs, and use the first
957954 // prefix as a filler for the error message.
958955 if (!DagNotMatches.empty()) {
959 CheckStrings.push_back(CheckString(Pattern(Check::CheckEOF),
960 *CheckPrefixes.begin(),
961 SMLoc::getFromPointer(Buffer.data()),
962 Check::CheckEOF));
956 CheckStrings.emplace_back(Pattern(Check::CheckEOF), *CheckPrefixes.begin(),
957 SMLoc::getFromPointer(Buffer.data()),
958 Check::CheckEOF);
963959 std::swap(DagNotMatches, CheckStrings.back().DagNotStrings);
964960 }
965961
17961796 getEnumNameForToken(AsmMatchConverter));
17971797
17981798 // Add the converter row for this instruction.
1799 ConversionTable.push_back(std::vector());
1799 ConversionTable.emplace_back();
18001800 ConversionTable.back().push_back(KindID);
18011801 ConversionTable.back().push_back(CVT_Done);
18021802
21602160 std::vector Matches;
21612161 for (const auto &CI : Infos) {
21622162 if (CI.Kind == ClassInfo::Token)
2163 Matches.push_back(
2164 StringMatcher::StringPair(CI.ValueName, "return " + CI.Name + ";"));
2163 Matches.emplace_back(CI.ValueName, "return " + CI.Name + ";");
21652164 }
21662165
21672166 OS << "static MatchClassKind matchTokenString(StringRef Name) {\n";
21832182 if (Reg.TheDef->getValueAsString("AsmName").empty())
21842183 continue;
21852184
2186 Matches.push_back(
2187 StringMatcher::StringPair(Reg.TheDef->getValueAsString("AsmName"),
2188 "return " + utostr(Reg.EnumValue) + ";"));
2185 Matches.emplace_back(Reg.TheDef->getValueAsString("AsmName"),
2186 "return " + utostr(Reg.EnumValue) + ";");
21892187 }
21902188
21912189 OS << "static unsigned MatchRegisterName(StringRef Name) {\n";
11041104 Record *AsmWriter = Target.getAsmWriter();
11051105 for (const CodeGenInstruction *I : Target.instructions())
11061106 if (!I->AsmString.empty() && I->TheDef->getName() != "PHI")
1107 Instructions.push_back(
1108 AsmWriterInst(*I, AsmWriter->getValueAsInt("Variant"),
1109 AsmWriter->getValueAsInt("PassSubtarget")));
1107 Instructions.emplace_back(*I, AsmWriter->getValueAsInt("Variant"),
1108 AsmWriter->getValueAsInt("PassSubtarget"));
11101109
11111110 // Get the instruction numbering.
11121111 NumberedInstructions = &Target.getInstructionsByEnumValue();
162162
163163 if (VarName.empty()) {
164164 // Just a modifier, pass this into PrintSpecial.
165 Operands.push_back(AsmWriterOperand("PrintSpecial",
166 ~0U,
167 ~0U,
168 Modifier,
169 PassSubtarget));
165 Operands.emplace_back("PrintSpecial", ~0U, ~0U, Modifier,
166 PassSubtarget);
170167 } else {
171168 // Otherwise, normal operand.
172169 unsigned OpNo = CGI.Operands.getOperandNamed(VarName);
173170 CGIOperandList::OperandInfo OpInfo = CGI.Operands[OpNo];
174171
175172 unsigned MIOp = OpInfo.MIOperandNo;
176 Operands.push_back(AsmWriterOperand(OpInfo.PrinterMethodName,
177 OpNo, MIOp, Modifier,
178 PassSubtarget));
173 Operands.emplace_back(OpInfo.PrinterMethodName, OpNo, MIOp, Modifier,
174 PassSubtarget);
179175 }
180176 LastEmitted = VarEnd;
181177 }
182178 }
183179
184 Operands.push_back(AsmWriterOperand("return;",
185 AsmWriterOperand::isLiteralStatementOperand));
180 Operands.emplace_back("return;", AsmWriterOperand::isLiteralStatementOperand);
186181 }
187182
188183 /// MatchesAllButOneOp - If this instruction is exactly identical to the
37973797 if (AlreadyExists) continue;
37983798
37993799 // Otherwise, add it to the list of patterns we have.
3800 PatternsToMatch.
3801 push_back(PatternToMatch(PatternsToMatch[i].getSrcRecord(),
3802 PatternsToMatch[i].getPredicates(),
3803 Variant, PatternsToMatch[i].getDstPattern(),
3804 PatternsToMatch[i].getDstRegs(),
3805 PatternsToMatch[i].getAddedComplexity(),
3806 Record::getNewUID()));
3800 PatternsToMatch.emplace_back(
3801 PatternsToMatch[i].getSrcRecord(), PatternsToMatch[i].getPredicates(),
3802 Variant, PatternsToMatch[i].getDstPattern(),
3803 PatternsToMatch[i].getDstRegs(),
3804 PatternsToMatch[i].getAddedComplexity(), Record::getNewUID());
38073805 }
38083806
38093807 DEBUG(errs() << "\n");
114114 PrintFatalError("In instruction '" + R->getName() + "', operand #" +
115115 Twine(i) + " has the same name as a previous operand!");
116116
117 OperandList.push_back(OperandInfo(Rec, ArgName, PrintMethod, EncoderMethod,
118 OperandNamespace + "::" + OperandType,
119 MIOperandNo, NumOps, MIOpInfo));
117 OperandList.emplace_back(Rec, ArgName, PrintMethod, EncoderMethod,
118 OperandNamespace + "::" + OperandType, MIOperandNo,
119 NumOps, MIOpInfo);
120120 MIOperandNo += NumOps;
121121 }
122122
641641
642642 // Take care to instantiate each of the suboperands with the correct
643643 // nomenclature: $foo.bar
644 ResultOperands.push_back(
645 ResultOperand(Result->getArgName(AliasOpNo) + "." +
646 MIOI->getArgName(SubOp), SubRec));
644 ResultOperands.emplace_back(Result->getArgName(AliasOpNo) + "." +
645 MIOI->getArgName(SubOp),
646 SubRec);
647647 ResultInstOperandIndex.push_back(std::make_pair(i, SubOp));
648648 }
649649 ++AliasOpNo;
993993
994994 // Allocate user-defined register classes.
995995 for (auto *RC : RCs) {
996 RegClasses.push_back(CodeGenRegisterClass(*this, RC));
996 RegClasses.emplace_back(*this, RC);
997997 addToMaps(&RegClasses.back());
998998 }
999999
10551055 return FoundI->second;
10561056
10571057 // Sub-class doesn't exist, create a new one.
1058 RegClasses.push_back(CodeGenRegisterClass(*this, Name, K));
1058 RegClasses.emplace_back(*this, Name, K);
10591059 addToMaps(&RegClasses.back());
10601060 return &RegClasses.back();
10611061 }
144144 // Use idx=0 for NoModel/NoItineraries.
145145 Record *NoModelDef = Records.getDef("NoSchedModel");
146146 Record *NoItinsDef = Records.getDef("NoItineraries");
147 ProcModels.push_back(CodeGenProcModel(0, "NoSchedModel",
148 NoModelDef, NoItinsDef));
147 ProcModels.emplace_back(0, "NoSchedModel", NoModelDef, NoItinsDef);
149148 ProcModelMap[NoModelDef] = 0;
150149
151150 // For each processor, find a unique machine model.
163162 std::string Name = ModelKey->getName();
164163 if (ModelKey->isSubClassOf("SchedMachineModel")) {
165164 Record *ItinsDef = ModelKey->getValueAsDef("Itineraries");
166 ProcModels.push_back(
167 CodeGenProcModel(ProcModels.size(), Name, ModelKey, ItinsDef));
165 ProcModels.emplace_back(ProcModels.size(), Name, ModelKey, ItinsDef);
168166 }
169167 else {
170168 // An itinerary is defined without a machine model. Infer a new model.
171169 if (!ModelKey->getValueAsListOfDefs("IID").empty())
172170 Name = Name + "Model";
173 ProcModels.push_back(
174 CodeGenProcModel(ProcModels.size(), Name,
175 ProcDef->getValueAsDef("SchedModel"), ModelKey));
171 ProcModels.emplace_back(ProcModels.size(), Name,
172 ProcDef->getValueAsDef("SchedModel"), ModelKey);
176173 }
177174 DEBUG(ProcModels.back().dump());
178175 }
280277 std::sort(SWDefs.begin(), SWDefs.end(), LessRecord());
281278 for (RecIter SWI = SWDefs.begin(), SWE = SWDefs.end(); SWI != SWE; ++SWI) {
282279 assert(!getSchedRWIdx(*SWI, /*IsRead=*/false) && "duplicate SchedWrite");
283 SchedWrites.push_back(CodeGenSchedRW(SchedWrites.size(), *SWI));
280 SchedWrites.emplace_back(SchedWrites.size(), *SWI);
284281 }
285282 std::sort(SRDefs.begin(), SRDefs.end(), LessRecord());
286283 for (RecIter SRI = SRDefs.begin(), SRE = SRDefs.end(); SRI != SRE; ++SRI) {
287284 assert(!getSchedRWIdx(*SRI, /*IsRead-*/true) && "duplicate SchedWrite");
288 SchedReads.push_back(CodeGenSchedRW(SchedReads.size(), *SRI));
285 SchedReads.emplace_back(SchedReads.size(), *SRI);
289286 }
290287 // Initialize WriteSequence vectors.
291288 for (std::vector::iterator WI = SchedWrites.begin(),
609609 TableInfo.Table.push_back(NumBits);
610610
611611 // A new filter entry begins a new scope for fixup resolution.
612 TableInfo.FixupStack.push_back(FixupList());
612 TableInfo.FixupStack.emplace_back();
613613
614614 DecoderTable &Table = TableInfo.Table;
615615
13321332
13331333 // complex singletons need predicate checks from the first singleton
13341334 // to refer forward to the variable filterchooser that follows.
1335 TableInfo.FixupStack.push_back(FixupList());
1335 TableInfo.FixupStack.emplace_back();
13361336
13371337 emitSingletonTableEntry(TableInfo, Opc);
13381338
13491349 void FilterChooser::runSingleFilter(unsigned startBit, unsigned numBit,
13501350 bool mixed) {
13511351 Filters.clear();
1352 Filters.push_back(Filter(*this, startBit, numBit, true));
1352 Filters.emplace_back(*this, startBit, numBit, true);
13531353 BestIndex = 0; // Sole Filter instance to choose from.
13541354 bestFilter().recurse();
13551355 }
13591359 void FilterChooser::reportRegion(bitAttr_t RA, unsigned StartBit,
13601360 unsigned BitIndex, bool AllowMixed) {
13611361 if (RA == ATTR_MIXED && AllowMixed)
1362 Filters.push_back(Filter(*this, StartBit, BitIndex - StartBit, true));
1362 Filters.emplace_back(*this, StartBit, BitIndex - StartBit, true);
13631363 else if (RA == ATTR_ALL_SET && !AllowMixed)
1364 Filters.push_back(Filter(*this, StartBit, BitIndex - StartBit, false));
1364 Filters.emplace_back(*this, StartBit, BitIndex - StartBit, false);
13651365 }
13661366
13671367 // FilterProcessor scans the well-known encoding bits of the instructions and
21782178 TableInfo.Table.clear();
21792179 TableInfo.FixupStack.clear();
21802180 TableInfo.Table.reserve(16384);
2181 TableInfo.FixupStack.push_back(FixupList());
2181 TableInfo.FixupStack.emplace_back();
21822182 FC.emitTableEntries(TableInfo);
21832183 // Any NumToSkip fixups in the top level scope can resolve to the
21842184 // OPC_Fail at the end of the table.
759759 E = BIM.end(); I != E; ++I) {
760760 std::string ResultCode =
761761 "return " + TargetPrefix + "Intrinsic::" + I->second + ";";
762 Results.push_back(StringMatcher::StringPair(I->first, ResultCode));
762 Results.emplace_back(I->first, ResultCode);
763763 }
764764
765765 StringMatcher("BuiltinName", Results, OS).Emit();