Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/AsmWriterEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1138,10 +1138,10 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
uint32_t UnescapedSize = 0;
std::string EncodedAsmString = IAP->formatAliasString(UnescapedSize);
auto Insertion =
AsmStringOffsets.insert({EncodedAsmString, AsmStringsSize});
AsmStringOffsets.try_emplace(EncodedAsmString, AsmStringsSize);
if (Insertion.second) {
// If the string is new, add it to the vector.
AsmStrings.push_back({AsmStringsSize, EncodedAsmString});
AsmStrings.emplace_back(AsmStringsSize, EncodedAsmString);
AsmStringsSize += UnescapedSize + 1;
}
unsigned AsmStrOffset = Insertion.first->second;
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/Basic/IntrinsicEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ void IntrinsicEmitter::EmitIntrinsicToBuiltinMap(
// Get the map for this target prefix.
auto &[Map, CommonPrefix] = BuiltinMap[Int.TargetPrefix];

if (!Map.insert({BuiltinName, Int.EnumName}).second)
if (!Map.try_emplace(BuiltinName, Int.EnumName).second)
PrintFatalError(Int.TheDef->getLoc(),
"Intrinsic '" + Int.TheDef->getName() + "': duplicate " +
CompilerName + " builtin name!");
Expand Down
6 changes: 3 additions & 3 deletions llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ bool TypeSetByHwMode::constrain(const TypeSetByHwMode &VTS) {
unsigned M = I.first;
if (M == DefaultMode || hasMode(M))
continue;
Map.insert({M, Map.at(DefaultMode)});
Map.try_emplace(M, Map.at(DefaultMode));
Changed = true;
}
}
Expand Down Expand Up @@ -3297,14 +3297,14 @@ void CodeGenDAGPatterns::ParseNodeTransforms() {
reverse(Records.getAllDerivedDefinitions("SDNodeXForm"))) {
const Record *SDNode = XFormNode->getValueAsDef("Opcode");
StringRef Code = XFormNode->getValueAsString("XFormFunction");
SDNodeXForms.insert({XFormNode, NodeXForm(SDNode, Code.str())});
SDNodeXForms.try_emplace(XFormNode, NodeXForm(SDNode, Code.str()));
}
}

void CodeGenDAGPatterns::ParseComplexPatterns() {
for (const Record *R :
reverse(Records.getAllDerivedDefinitions("ComplexPattern")))
ComplexPatterns.insert({R, R});
ComplexPatterns.try_emplace(R, R);
}

/// ParsePatternFragments - Parse all of the PatFrag definitions in the .td
Expand Down
6 changes: 3 additions & 3 deletions llvm/utils/TableGen/Common/CodeGenRegisters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ void CodeGenRegister::computeSecondarySubRegs(CodeGenRegBank &RegBank) {

std::queue<std::pair<CodeGenSubRegIndex *, CodeGenRegister *>> SubRegQueue;
for (auto [SRI, SubReg] : SubRegs)
SubRegQueue.push({SRI, SubReg});
SubRegQueue.emplace(SRI, SubReg);

// Look at the leading super-registers of each sub-register. Those are the
// candidates for new sub-registers, assuming they are fully contained in
Expand Down Expand Up @@ -1461,7 +1461,7 @@ void CodeGenRegBank::computeComposites() {
for (const CodeGenRegister &R : Registers) {
const CodeGenRegister::SubRegMap &SM = R.getSubRegs();
for (auto [SRI, SubReg] : SM)
SubRegAction[SRI].insert({&R, SubReg});
SubRegAction[SRI].try_emplace(&R, SubReg);
}

// Calculate the composition of two subregisters as compositions of their
Expand All @@ -1474,7 +1474,7 @@ void CodeGenRegBank::computeComposites() {
for (auto [R, SubReg] : Img1) {
auto F = Img2.find(SubReg);
if (F != Img2.end())
C.insert({R, F->second});
C.try_emplace(R, F->second);
}
return C;
};
Expand Down
8 changes: 4 additions & 4 deletions llvm/utils/TableGen/Common/InfoByHwMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ValueTypeByHwMode::ValueTypeByHwMode(const Record *R,
const CodeGenHwModes &CGH) {
const HwModeSelect &MS = CGH.getHwModeSelect(R);
for (const HwModeSelect::PairType &P : MS.Items) {
auto I = Map.insert({P.first, MVT(llvm::getValueType(P.second))});
auto I = Map.try_emplace(P.first, MVT(llvm::getValueType(P.second)));
assert(I.second && "Duplicate entry?");
(void)I;
}
Expand Down Expand Up @@ -142,7 +142,7 @@ RegSizeInfoByHwMode::RegSizeInfoByHwMode(const Record *R,
const CodeGenHwModes &CGH) {
const HwModeSelect &MS = CGH.getHwModeSelect(R);
for (const HwModeSelect::PairType &P : MS.Items) {
auto I = Map.insert({P.first, RegSizeInfo(P.second)});
auto I = Map.try_emplace(P.first, RegSizeInfo(P.second));
assert(I.second && "Duplicate entry?");
(void)I;
}
Expand Down Expand Up @@ -195,7 +195,7 @@ SubRegRangeByHwMode::SubRegRangeByHwMode(const Record *R,
const CodeGenHwModes &CGH) {
const HwModeSelect &MS = CGH.getHwModeSelect(R);
for (const HwModeSelect::PairType &P : MS.Items) {
auto I = Map.insert({P.first, SubRegRange(P.second)});
auto I = Map.try_emplace(P.first, SubRegRange(P.second));
assert(I.second && "Duplicate entry?");
(void)I;
}
Expand All @@ -207,7 +207,7 @@ EncodingInfoByHwMode::EncodingInfoByHwMode(const Record *R,
for (const HwModeSelect::PairType &P : MS.Items) {
assert(P.second && P.second->isSubClassOf("InstructionEncoding") &&
"Encoding must subclass InstructionEncoding");
auto I = Map.insert({P.first, P.second});
auto I = Map.try_emplace(P.first, P.second);
assert(I.second && "Duplicate entry?");
(void)I;
}
Expand Down
8 changes: 5 additions & 3 deletions llvm/utils/TableGen/Common/InfoByHwMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ template <typename InfoT> struct InfoByHwMode {

// Copy and insert the default mode which should be first.
assert(hasDefault());
auto P = Map.insert({Mode, Map.begin()->second});
auto P = Map.try_emplace(Mode, Map.begin()->second);
return P.first->second;
}
const InfoT &get(unsigned Mode) const {
Expand Down Expand Up @@ -154,7 +154,7 @@ template <typename InfoT> struct InfoByHwMode {
struct ValueTypeByHwMode : public InfoByHwMode<MVT> {
ValueTypeByHwMode(const Record *R, const CodeGenHwModes &CGH);
ValueTypeByHwMode(const Record *R, MVT T);
ValueTypeByHwMode(MVT T) { Map.insert({DefaultMode, T}); }
ValueTypeByHwMode(MVT T) { Map.try_emplace(DefaultMode, T); }
ValueTypeByHwMode() = default;

bool operator==(const ValueTypeByHwMode &T) const;
Expand Down Expand Up @@ -229,7 +229,9 @@ struct SubRegRange {

struct SubRegRangeByHwMode : public InfoByHwMode<SubRegRange> {
SubRegRangeByHwMode(const Record *R, const CodeGenHwModes &CGH);
SubRegRangeByHwMode(SubRegRange Range) { Map.insert({DefaultMode, Range}); }
SubRegRangeByHwMode(SubRegRange Range) {
Map.try_emplace(DefaultMode, Range);
}
SubRegRangeByHwMode() = default;

void insertSubRegRangeForMode(unsigned Mode, SubRegRange Info) {
Expand Down
8 changes: 4 additions & 4 deletions llvm/utils/TableGen/Common/VarLenCodeEmitterGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,21 @@ void VarLenCodeEmitterGen::run(raw_ostream &OS) {
const CodeGenHwModes &HWM = Target.getHwModes();
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
for (const auto [Mode, EncodingDef] : EBM) {
Modes.insert({Mode, "_" + HWM.getMode(Mode).Name.str()});
Modes.try_emplace(Mode, "_" + HWM.getMode(Mode).Name.str());
const RecordVal *RV = EncodingDef->getValue("Inst");
const DagInit *DI = cast<DagInit>(RV->getValue());
VarLenInsts[R].insert({Mode, VarLenInst(DI, RV)});
VarLenInsts[R].try_emplace(Mode, VarLenInst(DI, RV));
}
continue;
}
}
const RecordVal *RV = R->getValue("Inst");
const DagInit *DI = cast<DagInit>(RV->getValue());
VarLenInsts[R].insert({Universal, VarLenInst(DI, RV)});
VarLenInsts[R].try_emplace(Universal, VarLenInst(DI, RV));
}

if (Modes.empty())
Modes.insert({Universal, ""}); // Base case, skip suffix.
Modes.try_emplace(Universal, ""); // Base case, skip suffix.

// Emit function declaration
OS << "void " << Target.getName()
Expand Down
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/CompressInstEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,9 +541,9 @@ getReqFeatures(std::set<std::pair<bool, StringRef>> &FeaturesSet,
!cast<DefInit>(Arg)->getDef()->isSubClassOf("SubtargetFeature"))
PrintFatalError(R->getLoc(), "Invalid AssemblerCondDag!");
if (IsOr)
AnyOfSet.insert({IsNot, cast<DefInit>(Arg)->getDef()->getName()});
AnyOfSet.emplace(IsNot, cast<DefInit>(Arg)->getDef()->getName());
else
FeaturesSet.insert({IsNot, cast<DefInit>(Arg)->getDef()->getName()});
FeaturesSet.emplace(IsNot, cast<DefInit>(Arg)->getDef()->getName());
}

if (IsOr)
Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/DAGISelMatcherEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class MatcherTableEmitter {
Uses += PredicateUsage[TP];

// We only add the first predicate here since they are with the same code.
PredicateList.push_back({TPs[0], Uses});
PredicateList.emplace_back(TPs[0], Uses);
}

stable_sort(PredicateList, [](const auto &A, const auto &B) {
Expand Down
7 changes: 4 additions & 3 deletions llvm/utils/TableGen/InstrInfoEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ InstrInfoEmitter::CollectOperandInfo(OperandInfoListTy &OperandInfoList,
unsigned Offset = 0;
for (const CodeGenInstruction *Inst : Target.getInstructionsByEnumValue()) {
OperandInfoTy OperandInfo = GetOperandInfo(*Inst);
if (OperandInfoMap.insert({OperandInfo, Offset}).second) {
if (OperandInfoMap.try_emplace(OperandInfo, Offset).second) {
OperandInfoList.push_back(OperandInfo);
Offset += OperandInfo.size();
}
Expand Down Expand Up @@ -503,7 +503,8 @@ void InstrInfoEmitter::emitLogicalOperandSizeMappings(
LogicalOpListSize = std::max(LogicalOpList.size(), LogicalOpListSize);

auto I =
LogicalOpSizeMap.insert({LogicalOpList, LogicalOpSizeMap.size()}).first;
LogicalOpSizeMap.try_emplace(LogicalOpList, LogicalOpSizeMap.size())
.first;
InstMap[I->second].push_back(
(Namespace + "::" + Inst->TheDef->getName()).str());
}
Expand Down Expand Up @@ -850,7 +851,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) {

std::vector<const Record *> ImplicitOps = Inst->ImplicitUses;
llvm::append_range(ImplicitOps, Inst->ImplicitDefs);
if (EmittedLists.insert({ImplicitOps, ImplicitListSize}).second) {
if (EmittedLists.try_emplace(ImplicitOps, ImplicitListSize).second) {
ImplicitLists.push_back(ImplicitOps);
ImplicitListSize += ImplicitOps.size();
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/utils/TableGen/OptionParserEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,11 @@ static void emitOptionParser(const RecordKeeper &Records, raw_ostream &OS) {
typedef SmallVector<SmallString<2>, 2> PrefixKeyT;
typedef std::map<PrefixKeyT, unsigned> PrefixesT;
PrefixesT Prefixes;
Prefixes.insert({PrefixKeyT(), 0});
Prefixes.try_emplace(PrefixKeyT(), 0);
for (const Record &R : llvm::make_pointee_range(Opts)) {
std::vector<StringRef> RPrefixes = R.getValueAsListOfStrings("Prefixes");
PrefixKeyT PrefixKey(RPrefixes.begin(), RPrefixes.end());
Prefixes.insert({PrefixKey, 0});
Prefixes.try_emplace(PrefixKey, 0);
}

DenseSet<StringRef> PrefixesUnionSet;
Expand Down
Loading