Index: llvm/utils/TableGen/DecoderEmitter.cpp =================================================================== --- llvm/utils/TableGen/DecoderEmitter.cpp +++ llvm/utils/TableGen/DecoderEmitter.cpp @@ -1957,24 +1957,22 @@ // Search for tied operands, so that we can correctly instantiate // operands that are not explicitly represented in the encoding. - std::map TiedNames; + std::map TiedNames; for (unsigned i = 0; i < CGI.Operands.size(); ++i) { int tiedTo = CGI.Operands[i].getTiedRegister(); if (tiedTo != -1) { std::pair SO = CGI.Operands.getSubOperandNumber(tiedTo); - TiedNames[std::string(InOutOperands[i].second)] = - std::string(InOutOperands[SO.first].second); - TiedNames[std::string(InOutOperands[SO.first].second)] = - std::string(InOutOperands[i].second); + TiedNames[InOutOperands[i].second] = InOutOperands[SO.first].second; + TiedNames[InOutOperands[SO.first].second] = InOutOperands[i].second; } } if (IsVarLenInst) { parseVarLenInstOperand(EncodingDef, InsnOperands, CGI); } else { - std::map> NumberedInsnOperands; - std::set NumberedInsnOperandsNoTie; + std::map> NumberedInsnOperands; + std::set NumberedInsnOperandsNoTie; if (Target.getInstructionSet()->getValueAsBit( "decodePositionallyEncodedOperands")) { const std::vector &Vals = Def.getValues(); @@ -2120,17 +2118,14 @@ // For each operand, see if we can figure out where it is encoded. for (const auto &Op : InOutOperands) { - if (!NumberedInsnOperands[std::string(Op.second)].empty()) { - llvm::append_range(InsnOperands, - NumberedInsnOperands[std::string(Op.second)]); + if (!NumberedInsnOperands[Op.second].empty()) { + llvm::append_range(InsnOperands, NumberedInsnOperands[Op.second]); continue; } - if (!NumberedInsnOperands[TiedNames[std::string(Op.second)]].empty()) { - if (!NumberedInsnOperandsNoTie.count( - TiedNames[std::string(Op.second)])) { + if (!NumberedInsnOperands[TiedNames[Op.second]].empty()) { + if (!NumberedInsnOperandsNoTie.count(TiedNames[Op.second])) { // Figure out to which (sub)operand we're tied. - unsigned i = - CGI.Operands.getOperandNamed(TiedNames[std::string(Op.second)]); + unsigned i = CGI.Operands.getOperandNamed(TiedNames[Op.second]); int tiedTo = CGI.Operands[i].getTiedRegister(); if (tiedTo == -1) { i = CGI.Operands.getOperandNamed(Op.second); @@ -2142,8 +2137,7 @@ CGI.Operands.getSubOperandNumber(tiedTo); InsnOperands.push_back( - NumberedInsnOperands[TiedNames[std::string(Op.second)]] - [SO.second]); + NumberedInsnOperands[TiedNames[Op.second]][SO.second]); } } continue; @@ -2169,6 +2163,8 @@ unsigned Width = 0; unsigned Offset = 0; + auto It = TiedNames.find(Op.second); + StringRef TiedName = It == TiedNames.end() ? It->second : ""; for (unsigned bi = 0; bi < Bits.getNumBits(); ++bi) { VarInit *Var = nullptr; VarBitInit *BI = dyn_cast(Bits.getBit(bi)); @@ -2187,8 +2183,7 @@ continue; } - if ((Var->getName() != Op.second && - Var->getName() != TiedNames[std::string(Op.second)])) { + if ((Var->getName() != Op.second && Var->getName() != TiedName)) { if (Base != ~0U) { OpInfo.addField(Base, Width, Offset); Base = ~0U;