diff --git a/llvm/include/llvm/TableGen/Record.h b/llvm/include/llvm/TableGen/Record.h index 982cc255553a2..c486154544dcf 100644 --- a/llvm/include/llvm/TableGen/Record.h +++ b/llvm/include/llvm/TableGen/Record.h @@ -745,9 +745,7 @@ class StringInit final : public TypedInit { return "[{" + Value.str() + "}]"; } - std::string getAsUnquotedString() const override { - return std::string(Value); - } + std::string getAsUnquotedString() const override { return Value.str(); } const Init *getBit(unsigned Bit) const override { llvm_unreachable("Illegal bit reference off string"); diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index fe2f000e2e49c..704c623d0524c 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -1788,22 +1788,21 @@ const Init *TernOpInit::Fold(const Record *CurRec) const { return Val->getDefInit(); } if (LHSv && MHSv && RHSv) { - std::string Val = std::string(RHSv->getName()); + std::string Val = RHSv->getName().str(); if (LHSv->getAsString() == RHSv->getAsString()) - Val = std::string(MHSv->getName()); + Val = MHSv->getName().str(); return VarInit::get(Val, getType()); } if (LHSs && MHSs && RHSs) { - std::string Val = std::string(RHSs->getValue()); + std::string Val = RHSs->getValue().str(); std::string::size_type found; std::string::size_type idx = 0; while (true) { - found = Val.find(std::string(LHSs->getValue()), idx); + found = Val.find(LHSs->getValue().str(), idx); if (found == std::string::npos) break; - Val.replace(found, LHSs->getValue().size(), - std::string(MHSs->getValue())); + Val.replace(found, LHSs->getValue().size(), MHSs->getValue().str()); idx = found + MHSs->getValue().size(); } @@ -2418,7 +2417,7 @@ const RecTy *DefInit::getFieldType(const StringInit *FieldName) const { return nullptr; } -std::string DefInit::getAsString() const { return std::string(Def->getName()); } +std::string DefInit::getAsString() const { return Def->getName().str(); } static void ProfileVarDefInit(FoldingSetNodeID &ID, const Record *Class, ArrayRef Args) { diff --git a/llvm/lib/TableGen/SetTheory.cpp b/llvm/lib/TableGen/SetTheory.cpp index fefe03b440c85..80c2a558c3562 100644 --- a/llvm/lib/TableGen/SetTheory.cpp +++ b/llvm/lib/TableGen/SetTheory.cpp @@ -191,7 +191,7 @@ struct SequenceOp : public SetTheory::Operator { std::string Format; if (const auto *SI = dyn_cast(Expr->arg_begin()[0])) - Format = std::string(SI->getValue()); + Format = SI->getValue().str(); else PrintFatalError(Loc, "Format must be a string: " + Expr->getAsString()); diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp index 5cad9e74c10bd..87a1fb64943c4 100644 --- a/llvm/lib/TableGen/TGParser.cpp +++ b/llvm/lib/TableGen/TGParser.cpp @@ -4327,7 +4327,7 @@ bool TGParser::ParseDefm(MultiClass *CurMultiClass) { // through its template argument names. Substs contains a substitution // value for each argument, either the value specified or the default. // Then we can resolve the template arguments. - MultiClass *MC = MultiClasses[std::string(Ref.Rec->getName())].get(); + MultiClass *MC = MultiClasses[Ref.Rec->getName().str()].get(); assert(MC && "Didn't lookup multiclass correctly?"); SubstStack Substs; diff --git a/llvm/lib/TableGen/TGParser.h b/llvm/lib/TableGen/TGParser.h index 6094bba84fa55..017cc5fff683a 100644 --- a/llvm/lib/TableGen/TGParser.h +++ b/llvm/lib/TableGen/TGParser.h @@ -131,7 +131,7 @@ class TGVarScope { } void addVar(StringRef Name, const Init *I) { - bool Ins = Vars.try_emplace(std::string(Name), I).second; + bool Ins = Vars.try_emplace(Name.str(), I).second; (void)Ins; assert(Ins && "Local variable already exists"); } diff --git a/llvm/utils/TableGen/AsmMatcherEmitter.cpp b/llvm/utils/TableGen/AsmMatcherEmitter.cpp index cd2223ca74111..1e8f3ed01635f 100644 --- a/llvm/utils/TableGen/AsmMatcherEmitter.cpp +++ b/llvm/utils/TableGen/AsmMatcherEmitter.cpp @@ -1114,7 +1114,7 @@ bool MatchableInfo::validate(StringRef CommentDelimiter, bool IsAlias) const { // Verify that any operand is only mentioned once. // We reject aliases and ignore instructions for now. if (!IsAlias && TheDef->getValueAsString("AsmMatchConverter").empty() && - Tok[0] == '$' && !OperandNames.insert(std::string(Tok)).second) { + Tok[0] == '$' && !OperandNames.insert(Tok.str()).second) { LLVM_DEBUG({ errs() << "warning: '" << TheDef->getName() << "': " << "ignoring instruction with tied operand '" << Tok << "'\n"; @@ -1170,7 +1170,7 @@ static std::string getEnumNameForToken(StringRef Str) { } ClassInfo *AsmMatcherInfo::getTokenClass(StringRef Token) { - ClassInfo *&Entry = TokenClasses[std::string(Token)]; + ClassInfo *&Entry = TokenClasses[Token.str()]; if (!Entry) { Classes.emplace_front(); @@ -1178,7 +1178,7 @@ ClassInfo *AsmMatcherInfo::getTokenClass(StringRef Token) { Entry->Kind = ClassInfo::Token; Entry->ClassName = "Token"; Entry->Name = "MCK_" + getEnumNameForToken(Token); - Entry->ValueName = std::string(Token); + Entry->ValueName = Token.str(); Entry->PredicateMethod = ""; Entry->RenderMethod = ""; Entry->ParserMethod = ""; @@ -1353,11 +1353,11 @@ void AsmMatcherInfo::buildRegisterClasses( const Init *DiagnosticType = Def->getValueInit("DiagnosticType"); if (const StringInit *SI = dyn_cast(DiagnosticType)) - CI->DiagnosticType = std::string(SI->getValue()); + CI->DiagnosticType = SI->getValue().str(); const Init *DiagnosticString = Def->getValueInit("DiagnosticString"); if (const StringInit *SI = dyn_cast(DiagnosticString)) - CI->DiagnosticString = std::string(SI->getValue()); + CI->DiagnosticString = SI->getValue().str(); // If we have a diagnostic string but the diagnostic type is not specified // explicitly, create an anonymous diagnostic type. @@ -1377,9 +1377,9 @@ void AsmMatcherInfo::buildRegisterClasses( assert(CI && "Missing singleton register class info!"); if (CI->ValueName.empty()) { - CI->ClassName = std::string(Rec->getName()); + CI->ClassName = Rec->getName().str(); CI->Name = "MCK_" + Rec->getName().str(); - CI->ValueName = std::string(Rec->getName()); + CI->ValueName = Rec->getName().str(); } else { CI->ValueName = CI->ValueName + "," + Rec->getName().str(); } @@ -1415,14 +1415,14 @@ void AsmMatcherInfo::buildOperandClasses() { else CI->SuperClasses.push_back(SC); } - CI->ClassName = std::string(Rec->getValueAsString("Name")); + CI->ClassName = Rec->getValueAsString("Name").str(); CI->Name = "MCK_" + CI->ClassName; - CI->ValueName = std::string(Rec->getName()); + CI->ValueName = Rec->getName().str(); // Get or construct the predicate method name. const Init *PMName = Rec->getValueInit("PredicateMethod"); if (const StringInit *SI = dyn_cast(PMName)) { - CI->PredicateMethod = std::string(SI->getValue()); + CI->PredicateMethod = SI->getValue().str(); } else { assert(isa(PMName) && "Unexpected PredicateMethod field!"); CI->PredicateMethod = "is" + CI->ClassName; @@ -1431,7 +1431,7 @@ void AsmMatcherInfo::buildOperandClasses() { // Get or construct the render method name. const Init *RMName = Rec->getValueInit("RenderMethod"); if (const StringInit *SI = dyn_cast(RMName)) { - CI->RenderMethod = std::string(SI->getValue()); + CI->RenderMethod = SI->getValue().str(); } else { assert(isa(RMName) && "Unexpected RenderMethod field!"); CI->RenderMethod = "add" + CI->ClassName + "Operands"; @@ -1440,15 +1440,15 @@ void AsmMatcherInfo::buildOperandClasses() { // Get the parse method name or leave it as empty. const Init *PRMName = Rec->getValueInit("ParserMethod"); if (const StringInit *SI = dyn_cast(PRMName)) - CI->ParserMethod = std::string(SI->getValue()); + CI->ParserMethod = SI->getValue().str(); // Get the diagnostic type and string or leave them as empty. const Init *DiagnosticType = Rec->getValueInit("DiagnosticType"); if (const StringInit *SI = dyn_cast(DiagnosticType)) - CI->DiagnosticType = std::string(SI->getValue()); + CI->DiagnosticType = SI->getValue().str(); const Init *DiagnosticString = Rec->getValueInit("DiagnosticString"); if (const StringInit *SI = dyn_cast(DiagnosticString)) - CI->DiagnosticString = std::string(SI->getValue()); + CI->DiagnosticString = SI->getValue().str(); // If we have a DiagnosticString, we need a DiagnosticType for use within // the matcher. if (!CI->DiagnosticString.empty() && CI->DiagnosticType.empty()) @@ -1461,7 +1461,7 @@ void AsmMatcherInfo::buildOperandClasses() { // Get or construct the default method name. const Init *DMName = Rec->getValueInit("DefaultMethod"); if (const StringInit *SI = dyn_cast(DMName)) { - CI->DefaultMethod = std::string(SI->getValue()); + CI->DefaultMethod = SI->getValue().str(); } else { assert(isa(DMName) && "Unexpected DefaultMethod field!"); CI->DefaultMethod = "default" + CI->ClassName + "Operands"; @@ -3057,7 +3057,7 @@ static void emitAsmTiedOperandConstraints(CodeGenTarget &Target, AsmMatcherInfo &Info, raw_ostream &OS, bool HasOptionalOperands) { std::string AsmParserName = - std::string(Info.AsmParser->getValueAsString("AsmParserClassName")); + Info.AsmParser->getValueAsString("AsmParserClassName").str(); OS << "static bool "; OS << "checkAsmTiedOperandConstraints(const " << Target.getName() << AsmParserName << "&AsmParser,\n"; diff --git a/llvm/utils/TableGen/AsmWriterEmitter.cpp b/llvm/utils/TableGen/AsmWriterEmitter.cpp index 6c0d67f6d6076..3ecbd88b1d9f3 100644 --- a/llvm/utils/TableGen/AsmWriterEmitter.cpp +++ b/llvm/utils/TableGen/AsmWriterEmitter.cpp @@ -192,7 +192,7 @@ void AsmWriterEmitter::FindUniqueOperandCommands( InstIdxs[idx].push_back(i); } else { UniqueOperandCommands.push_back(std::move(Command)); - InstrsForCase.push_back(std::string(Inst.CGI->TheDef->getName())); + InstrsForCase.push_back(Inst.CGI->TheDef->getName().str()); InstIdxs.emplace_back(); InstIdxs.back().push_back(i); @@ -592,9 +592,9 @@ emitRegisterNameString(raw_ostream &O, StringRef AltName, // "NoRegAltName" is special. We don't need to do a lookup for that, // as it's just a reference to the default register name. if (AltName == "" || AltName == "NoRegAltName") { - AsmName = std::string(Reg.TheDef->getValueAsString("AsmName")); + AsmName = Reg.TheDef->getValueAsString("AsmName").str(); if (AsmName.empty()) - AsmName = std::string(Reg.getName()); + AsmName = Reg.getName().str(); } else { // Make sure the register has an alternate name for this index. std::vector AltNameList = @@ -612,7 +612,7 @@ emitRegisterNameString(raw_ostream &O, StringRef AltName, PrintFatalError(Reg.TheDef->getLoc(), "Register definition missing alt name for '" + AltName + "'."); - AsmName = std::string(AltNames[Idx]); + AsmName = AltNames[Idx].str(); } } StringTable.add(AsmName); @@ -940,7 +940,7 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) { }) - PrintMethods.begin(); if (static_cast(PrintMethodIdx) == PrintMethods.size()) - PrintMethods.emplace_back(std::string(PrintMethod), IsPCRel); + PrintMethods.emplace_back(PrintMethod.str(), IsPCRel); } } diff --git a/llvm/utils/TableGen/CodeEmitterGen.cpp b/llvm/utils/TableGen/CodeEmitterGen.cpp index 475699ae3e78e..83c0330f7d3eb 100644 --- a/llvm/utils/TableGen/CodeEmitterGen.cpp +++ b/llvm/utils/TableGen/CodeEmitterGen.cpp @@ -309,8 +309,7 @@ CodeEmitterGen::getInstructionCases(const Record *R, " case " + itostr(DefaultMode) + ": InstBitsByHw = InstBits"; } else { Case += " case " + itostr(ModeId) + - ": InstBitsByHw = InstBits_" + - std::string(HWM.getMode(ModeId).Name); + ": InstBitsByHw = InstBits_" + HWM.getMode(ModeId).Name.str(); } Case += "; break;\n"; } @@ -362,7 +361,7 @@ void CodeEmitterGen::addInstructionCasesForEncoding( if (RV.isNonconcreteOK() || RV.getValue()->isComplete()) continue; - Success &= addCodeToMergeInOperand(R, BI, std::string(RV.getName()), Case, + Success &= addCodeToMergeInOperand(R, BI, RV.getName().str(), Case, BitOffsetCase, Target); } // Avoid empty switches. diff --git a/llvm/utils/TableGen/CodeGenMapTable.cpp b/llvm/utils/TableGen/CodeGenMapTable.cpp index 2641e713c0c85..bce7278bf901c 100644 --- a/llvm/utils/TableGen/CodeGenMapTable.cpp +++ b/llvm/utils/TableGen/CodeGenMapTable.cpp @@ -103,7 +103,7 @@ class InstrMap { public: InstrMap(const Record *MapRec) { - Name = std::string(MapRec->getName()); + Name = MapRec->getName().str(); // FilterClass - It's used to reduce the search space only to the // instructions that define the kind of relationship modeled by @@ -133,8 +133,8 @@ class InstrMap { // Each instruction map must specify at least one column for it to be valid. if (ColValList->empty()) - PrintFatalError(MapRec->getLoc(), "InstrMapping record `" + - MapRec->getName() + "' has empty " + + PrintFatalError(MapRec->getLoc(), "InstrMapping record `" + Name + + "' has empty " + "`ValueCols' field!"); for (const Init *I : ColValList->getValues()) { @@ -144,7 +144,7 @@ class InstrMap { // elements as the fields in 'ColFields'. if (ColI->size() != ColFields->size()) PrintFatalError(MapRec->getLoc(), - "Record `" + MapRec->getName() + + "Record `" + Name + "', field `ValueCols' entries don't match with " + " the entries in 'ColFields'!"); ValueCols.push_back(ColI); diff --git a/llvm/utils/TableGen/Common/AsmWriterInst.h b/llvm/utils/TableGen/Common/AsmWriterInst.h index 7c21eb6abad95..26745a8459570 100644 --- a/llvm/utils/TableGen/Common/AsmWriterInst.h +++ b/llvm/utils/TableGen/Common/AsmWriterInst.h @@ -38,7 +38,7 @@ struct AsmWriterOperand { unsigned MIOpNo = 0; /// Str - For isLiteralTextOperand, this IS the literal text. For - /// isMachineInstrOperand, this is the PrinterMethodName for the operand.. + /// isMachineInstrOperand, this is the PrinterMethodName for the operand. /// For isLiteralStatementOperand, this is the code to insert verbatim /// into the asm writer. std::string Str; diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp index 5d60de79b72ca..b6bc52888d7e2 100644 --- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp @@ -1149,7 +1149,7 @@ std::string TreePredicateFn::getPredCode() const { Code += "if (!N->hasNUsesOfValue(1, 0)) return false;\n"; std::string PredicateCode = - std::string(PatFragRec->getRecord()->getValueAsString("PredicateCode")); + PatFragRec->getRecord()->getValueAsString("PredicateCode").str(); Code += PredicateCode; @@ -1164,8 +1164,7 @@ bool TreePredicateFn::hasImmCode() const { } std::string TreePredicateFn::getImmCode() const { - return std::string( - PatFragRec->getRecord()->getValueAsString("ImmediateCode")); + return PatFragRec->getRecord()->getValueAsString("ImmediateCode").str(); } bool TreePredicateFn::immCodeUsesAPInt() const { @@ -1286,11 +1285,13 @@ const Record *TreePredicateFn::getScalarMemoryVT() const { return nullptr; return R->getValueAsDef("ScalarMemoryVT"); } + bool TreePredicateFn::hasGISelPredicateCode() const { return !PatFragRec->getRecord() ->getValueAsString("GISelPredicateCode") .empty(); } + std::string TreePredicateFn::getGISelPredicateCode() const { return std::string( PatFragRec->getRecord()->getValueAsString("GISelPredicateCode")); @@ -2916,7 +2917,7 @@ TreePatternNodePtr TreePattern::ParseTreePattern(const Init *TheInit, if (R->getName() == "node" && !OpName.empty()) { if (OpName.empty()) error("'node' argument requires a name to match with operand list"); - Args.push_back(std::string(OpName)); + Args.push_back(OpName.str()); } Res->setName(OpName); @@ -2928,7 +2929,7 @@ TreePatternNodePtr TreePattern::ParseTreePattern(const Init *TheInit, if (OpName.empty()) error("'?' argument requires a name to match with operand list"); TreePatternNodePtr Res = makeIntrusiveRefCnt(TheInit, 1); - Args.push_back(std::string(OpName)); + Args.push_back(OpName.str()); Res->setName(OpName); return Res; } @@ -3168,7 +3169,7 @@ bool TreePattern::InferAllTypes( if (InNamedTypes) { auto InIter = InNamedTypes->find(Entry.getKey()); if (InIter == InNamedTypes->end()) { - error("Node '" + std::string(Entry.getKey()) + + error("Node '" + Entry.getKey().str() + "' in output pattern but not input pattern"); return true; } @@ -3300,7 +3301,7 @@ void CodeGenDAGPatterns::ParseNodeTransforms() { reverse(Records.getAllDerivedDefinitions("SDNodeXForm"))) { const Record *SDNode = XFormNode->getValueAsDef("Opcode"); StringRef Code = XFormNode->getValueAsString("XFormFunction"); - SDNodeXForms.insert({XFormNode, NodeXForm(SDNode, std::string(Code))}); + SDNodeXForms.insert({XFormNode, NodeXForm(SDNode, Code.str())}); } } @@ -3359,7 +3360,7 @@ void CodeGenDAGPatterns::ParsePatternFragments(bool OutFrags) { if (!OperandsSet.erase(ArgNameStr)) P->error("'" + ArgNameStr + "' does not occur in pattern or was multiply specified!"); - Args.push_back(std::string(ArgNameStr)); + Args.push_back(ArgNameStr.str()); } if (!OperandsSet.empty()) diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h index 328700cd0d163..364c82e1233bd 100644 --- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h +++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.h @@ -406,7 +406,7 @@ class ScopedName { public: ScopedName(unsigned Scope, StringRef Identifier) - : Scope(Scope), Identifier(std::string(Identifier)) { + : Scope(Scope), Identifier(Identifier.str()) { assert(Scope != 0 && "Scope == 0 is used to indicate predicates without arguments"); } diff --git a/llvm/utils/TableGen/Common/CodeGenHwModes.cpp b/llvm/utils/TableGen/Common/CodeGenHwModes.cpp index 9996b5a4451f0..09765113a4e7b 100644 --- a/llvm/utils/TableGen/Common/CodeGenHwModes.cpp +++ b/llvm/utils/TableGen/Common/CodeGenHwModes.cpp @@ -20,7 +20,7 @@ StringRef CodeGenHwModes::DefaultModeName = "DefaultMode"; HwMode::HwMode(const Record *R) { Name = R->getName(); - Features = std::string(R->getValueAsString("Features")); + Features = R->getValueAsString("Features").str(); SmallString<128> PredicateCheck; raw_svector_ostream OS(PredicateCheck); diff --git a/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp b/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp index 94c0d51faf2e9..f33deb00dd7ba 100644 --- a/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp +++ b/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp @@ -40,8 +40,7 @@ bool CodeGenInstAlias::tryAliasOpMatch(const DagInit *Result, if (!Result->getArgName(AliasOpNo)) PrintFatalError(Loc, "result argument #" + Twine(AliasOpNo) + " must have a name!"); - ResOp = ResultOperand(std::string(Result->getArgNameStr(AliasOpNo)), - ResultRecord); + ResOp = ResultOperand(Result->getArgNameStr(AliasOpNo).str(), ResultRecord); return true; } @@ -59,8 +58,7 @@ bool CodeGenInstAlias::tryAliasOpMatch(const DagInit *Result, if (!T.getRegisterClass(InstOpRec).hasSubClass( &T.getRegisterClass(ADI->getDef()))) return false; - ResOp = ResultOperand(std::string(Result->getArgNameStr(AliasOpNo)), - ResultRecord); + ResOp = ResultOperand(Result->getArgNameStr(AliasOpNo).str(), ResultRecord); return true; } @@ -141,8 +139,8 @@ bool CodeGenInstAlias::tryAliasOpMatch(const DagInit *Result, // MIOperandInfo perhaps? if (InstOpRec->getValueInit("Type") != ADI->getDef()->getValueInit("Type")) return false; - ResOp = ResultOperand(std::string(Result->getArgNameStr(AliasOpNo)), - ADI->getDef()); + ResOp = + ResultOperand(Result->getArgNameStr(AliasOpNo).str(), ADI->getDef()); return true; } @@ -169,7 +167,7 @@ unsigned CodeGenInstAlias::ResultOperand::getMINumOperands() const { CodeGenInstAlias::CodeGenInstAlias(const Record *R, const CodeGenTarget &T) : TheDef(R) { Result = R->getValueAsDag("ResultInst"); - AsmString = std::string(R->getValueAsString("AsmString")); + AsmString = R->getValueAsString("AsmString"); // Verify that the root of the result is an instruction. const DefInit *DI = dyn_cast(Result->getOperator()); diff --git a/llvm/utils/TableGen/Common/CodeGenInstruction.cpp b/llvm/utils/TableGen/Common/CodeGenInstruction.cpp index a7d9516a26682..281df2302605e 100644 --- a/llvm/utils/TableGen/Common/CodeGenInstruction.cpp +++ b/llvm/utils/TableGen/Common/CodeGenInstruction.cpp @@ -85,16 +85,16 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) { unsigned NumOps = 1; const DagInit *MIOpInfo = nullptr; if (Rec->isSubClassOf("RegisterOperand")) { - PrintMethod = std::string(Rec->getValueAsString("PrintMethod")); - OperandType = std::string(Rec->getValueAsString("OperandType")); - OperandNamespace = std::string(Rec->getValueAsString("OperandNamespace")); - EncoderMethod = std::string(Rec->getValueAsString("EncoderMethod")); + PrintMethod = Rec->getValueAsString("PrintMethod").str(); + OperandType = Rec->getValueAsString("OperandType").str(); + OperandNamespace = Rec->getValueAsString("OperandNamespace").str(); + EncoderMethod = Rec->getValueAsString("EncoderMethod").str(); } else if (Rec->isSubClassOf("Operand")) { - PrintMethod = std::string(Rec->getValueAsString("PrintMethod")); - OperandType = std::string(Rec->getValueAsString("OperandType")); - OperandNamespace = std::string(Rec->getValueAsString("OperandNamespace")); + PrintMethod = Rec->getValueAsString("PrintMethod").str(); + OperandType = Rec->getValueAsString("OperandType").str(); + OperandNamespace = Rec->getValueAsString("OperandNamespace").str(); // If there is an explicit encoder method, use it. - EncoderMethod = std::string(Rec->getValueAsString("EncoderMethod")); + EncoderMethod = Rec->getValueAsString("EncoderMethod").str(); MIOpInfo = Rec->getValueAsDag("MIOperandInfo"); // Verify that MIOpInfo has an 'ops' root value. @@ -132,14 +132,14 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) { PrintFatalError(R->getLoc(), "In instruction '" + R->getName() + "', operand #" + Twine(i) + " has no name!"); - if (!OperandNames.insert(std::string(ArgName)).second) + if (!OperandNames.insert(ArgName.str()).second) PrintFatalError(R->getLoc(), "In instruction '" + R->getName() + "', operand #" + Twine(i) + " has the same name as a previous operand!"); OperandInfo &OpInfo = OperandList.emplace_back( - Rec, std::string(ArgName), std::string(std::move(PrintMethod)), + Rec, ArgName.str(), std::string(std::move(PrintMethod)), OperandNamespace + "::" + OperandType, MIOperandNo, NumOps, MIOpInfo); if (SubArgDag) { @@ -163,7 +163,7 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) { PrintFatalError(R->getLoc(), "In instruction '" + R->getName() + "', operand #" + Twine(i) + " has no name!"); - if (!OperandNames.insert(std::string(SubArgName)).second) + if (!OperandNames.insert(SubArgName.str()).second) PrintFatalError(R->getLoc(), "In instruction '" + R->getName() + "', operand #" + Twine(i) + " sub-arg #" + Twine(j) + @@ -435,7 +435,7 @@ void CGIOperandList::ProcessDisableEncoding(StringRef DisableEncoding) { CodeGenInstruction::CodeGenInstruction(const Record *R) : TheDef(R), Operands(R), InferredFrom(nullptr) { Namespace = R->getValueAsString("Namespace"); - AsmString = std::string(R->getValueAsString("AsmString")); + AsmString = R->getValueAsString("AsmString").str(); isPreISelOpcode = R->getValueAsBit("isPreISelOpcode"); isReturn = R->getValueAsBit("isReturn"); @@ -503,8 +503,7 @@ CodeGenInstruction::CodeGenInstruction(const Record *R) // First check for a ComplexDeprecationPredicate. if (R->getValue("ComplexDeprecationPredicate")) { HasComplexDeprecationPredicate = true; - DeprecatedReason = - std::string(R->getValueAsString("ComplexDeprecationPredicate")); + DeprecatedReason = R->getValueAsString("ComplexDeprecationPredicate").str(); } else if (const RecordVal *Dep = R->getValue("DeprecatedFeatureMask")) { // Check if we have a Subtarget feature mask. HasComplexDeprecationPredicate = false; diff --git a/llvm/utils/TableGen/Common/CodeGenSchedule.cpp b/llvm/utils/TableGen/Common/CodeGenSchedule.cpp index acf38d1d661d8..8cd8fb6ba90c1 100644 --- a/llvm/utils/TableGen/Common/CodeGenSchedule.cpp +++ b/llvm/utils/TableGen/Common/CodeGenSchedule.cpp @@ -121,7 +121,7 @@ struct InstRegexOp : public SetTheory::Operator { StringRef PatStr = Original.substr(FirstMeta); if (!PatStr.empty()) { // For the rest use a python-style prefix match. - std::string pat = std::string(PatStr); + std::string pat = PatStr.str(); // Add ^ anchor. If we had one originally, don't need the group. if (HadAnchor) { pat.insert(0, "^"); @@ -544,7 +544,7 @@ void CodeGenSchedModels::addProcModel(const Record *ProcDef) { if (!ProcModelMap.try_emplace(ModelKey, ProcModels.size()).second) return; - std::string Name = std::string(ModelKey->getName()); + std::string Name = ModelKey->getName().str(); if (ModelKey->isSubClassOf("SchedMachineModel")) { const Record *ItinsDef = ModelKey->getValueAsDef("Itineraries"); ProcModels.emplace_back(ProcModels.size(), Name, ModelKey, ItinsDef); @@ -938,7 +938,7 @@ CodeGenSchedModels::createSchedClassName(const Record *ItinClassDef, ArrayRef OperReads) { std::string Name; if (ItinClassDef && ItinClassDef->getName() != "NoItinerary") - Name = std::string(ItinClassDef->getName()); + Name = ItinClassDef->getName().str(); for (unsigned Idx : OperWrites) { if (!Name.empty()) Name += '_'; diff --git a/llvm/utils/TableGen/Common/CodeGenSchedule.h b/llvm/utils/TableGen/Common/CodeGenSchedule.h index 8343257b458dd..697a1ce8f75ac 100644 --- a/llvm/utils/TableGen/Common/CodeGenSchedule.h +++ b/llvm/utils/TableGen/Common/CodeGenSchedule.h @@ -64,7 +64,7 @@ struct CodeGenSchedRW { HasVariants(false), IsVariadic(false), IsSequence(false) {} CodeGenSchedRW(unsigned Idx, const Record *Def) : Index(Idx), TheDef(Def), IsAlias(false), IsVariadic(false) { - Name = std::string(Def->getName()); + Name = Def->getName().str(); IsRead = Def->isSubClassOf("SchedRead"); HasVariants = Def->isSubClassOf("SchedVariant"); if (HasVariants) diff --git a/llvm/utils/TableGen/Common/CodeGenTarget.cpp b/llvm/utils/TableGen/Common/CodeGenTarget.cpp index e8286d295587f..3169019bbd5b6 100644 --- a/llvm/utils/TableGen/Common/CodeGenTarget.cpp +++ b/llvm/utils/TableGen/Common/CodeGenTarget.cpp @@ -394,7 +394,7 @@ bool CodeGenTarget::guessInstructionProperties() const { ComplexPattern::ComplexPattern(const Record *R) { Ty = R->getValueAsDef("Ty"); NumOperands = R->getValueAsInt("NumOperands"); - SelectFunc = std::string(R->getValueAsString("SelectFunc")); + SelectFunc = R->getValueAsString("SelectFunc").str(); RootNodes = R->getValueAsListOfDefs("RootNodes"); // FIXME: This is a hack to statically increase the priority of patterns which diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h index 77c8bc290faaf..9f17882cdae4f 100644 --- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h +++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.h @@ -1285,7 +1285,7 @@ class OperandMatcher : public PredicateListMatcher { StringRef getSymbolicName() const { return SymbolicName; } void setSymbolicName(StringRef Name) { assert(SymbolicName.empty() && "Operand already has a symbolic name"); - SymbolicName = std::string(Name); + SymbolicName = Name.str(); } /// Construct a new operand predicate and add it to the matcher. @@ -2321,8 +2321,7 @@ class DebugCommentAction : public MatchAction { std::string S; public: - DebugCommentAction(StringRef S) - : MatchAction(AK_DebugComment), S(std::string(S)) {} + DebugCommentAction(StringRef S) : MatchAction(AK_DebugComment), S(S.str()) {} static bool classof(const MatchAction *A) { return A->getKind() == AK_DebugComment; diff --git a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp index 82e47fd8932b3..13ab21630c695 100644 --- a/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp +++ b/llvm/utils/TableGen/DAGISelMatcherEmitter.cpp @@ -1241,8 +1241,7 @@ void MatcherTableEmitter::EmitPredicateFunctions(raw_ostream &OS) { OS << "// " << NodeXForms[i]->getName(); OS << '\n'; - std::string ClassName = - std::string(CGP.getSDNodeInfo(SDNode).getSDClassName()); + std::string ClassName = CGP.getSDNodeInfo(SDNode).getSDClassName().str(); if (ClassName == "SDNode") OS << " SDNode *N = V.getNode();\n"; else diff --git a/llvm/utils/TableGen/DAGISelMatcherGen.cpp b/llvm/utils/TableGen/DAGISelMatcherGen.cpp index 55213b74ffb0d..aec9a8796870b 100644 --- a/llvm/utils/TableGen/DAGISelMatcherGen.cpp +++ b/llvm/utils/TableGen/DAGISelMatcherGen.cpp @@ -306,7 +306,7 @@ void MatcherGen::EmitOperatorMatchCode(const TreePatternNode &N, // The "name" of a non-leaf complex pattern (MY_PAT $op1, $op2) is // "MY_PAT:op1:op2". We should already have validated that the uses are // consistent. - std::string PatternName = std::string(N.getOperator()->getName()); + std::string PatternName = N.getOperator()->getName().str(); for (const TreePatternNode &Child : N.children()) { PatternName += ":"; PatternName += Child.getName(); diff --git a/llvm/utils/TableGen/DFAEmitter.cpp b/llvm/utils/TableGen/DFAEmitter.cpp index eb0b0b4480747..0b90af2ea99fc 100644 --- a/llvm/utils/TableGen/DFAEmitter.cpp +++ b/llvm/utils/TableGen/DFAEmitter.cpp @@ -257,7 +257,7 @@ void Automaton::emit(raw_ostream &OS) { StringRef Name = R->getName(); - CustomDfaEmitter Emitter(Actions, std::string(Name) + "Action"); + CustomDfaEmitter Emitter(Actions, Name.str() + "Action"); // Starting from the initial state, build up a list of possible states and // transitions. std::deque Worklist(1, 0); @@ -322,7 +322,7 @@ Transition::Transition(const Record *R, Automaton *Parent) { Actions.emplace_back(static_cast(R->getValueAsInt(A))); Types.emplace_back("unsigned"); } else if (isa(SymbolV->getType())) { - Actions.emplace_back(std::string(R->getValueAsString(A))); + Actions.emplace_back(R->getValueAsString(A).str()); Types.emplace_back("std::string"); } else { report_fatal_error("Unhandled symbol type!"); @@ -330,7 +330,7 @@ Transition::Transition(const Record *R, Automaton *Parent) { StringRef TypeOverride = Parent->getActionSymbolType(A); if (!TypeOverride.empty()) - Types.back() = std::string(TypeOverride); + Types.back() = TypeOverride.str(); } } diff --git a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp index a6c0d09f69ba3..8cb2c22736f8a 100644 --- a/llvm/utils/TableGen/DFAPacketizerEmitter.cpp +++ b/llvm/utils/TableGen/DFAPacketizerEmitter.cpp @@ -92,7 +92,7 @@ class DFAPacketizerEmitter { } // end anonymous namespace DFAPacketizerEmitter::DFAPacketizerEmitter(const RecordKeeper &R) - : TargetName(std::string(CodeGenTarget(R).getName())), Records(R) {} + : TargetName(CodeGenTarget(R).getName().str()), Records(R) {} int DFAPacketizerEmitter::collectAllFuncUnits( ArrayRef ProcModels) { @@ -119,7 +119,7 @@ int DFAPacketizerEmitter::collectAllFuncUnits( assert((j < DFA_MAX_RESOURCES) && "Exceeded maximum number of representable resources"); uint64_t FuncResources = 1ULL << j; - FUNameToBitsMap[std::string(FUs[j]->getName())] = FuncResources; + FUNameToBitsMap[FUs[j]->getName().str()] = FuncResources; LLVM_DEBUG(dbgs() << " " << FUs[j]->getName() << ":0x" << Twine::utohexstr(FuncResources)); } @@ -152,13 +152,13 @@ int DFAPacketizerEmitter::collectAllComboFuncs( const Record *ComboFunc = FuncData->getValueAsDef("TheComboFunc"); const std::vector FuncList = FuncData->getValueAsListOfDefs("FuncList"); - const std::string &ComboFuncName = std::string(ComboFunc->getName()); + const std::string &ComboFuncName = ComboFunc->getName().str(); uint64_t ComboBit = FUNameToBitsMap[ComboFuncName]; uint64_t ComboResources = ComboBit; LLVM_DEBUG(dbgs() << " combo: " << ComboFuncName << ":0x" << Twine::utohexstr(ComboResources) << "\n"); for (const Record *K : FuncList) { - std::string FuncName = std::string(K->getName()); + std::string FuncName = K->getName().str(); uint64_t FuncResources = FUNameToBitsMap[FuncName]; LLVM_DEBUG(dbgs() << " " << FuncName << ":0x" << Twine::utohexstr(FuncResources) << "\n"); @@ -181,7 +181,7 @@ DFAPacketizerEmitter::getResourcesForItinerary(const Record *Itinerary) { for (const Record *StageDef : Itinerary->getValueAsListOfDefs("Stages")) { uint64_t StageResources = 0; for (const Record *Unit : StageDef->getValueAsListOfDefs("Units")) { - StageResources |= FUNameToBitsMap[std::string(Unit->getName())]; + StageResources |= FUNameToBitsMap[Unit->getName().str()]; } if (StageResources != 0) Resources.push_back(StageResources); @@ -220,7 +220,7 @@ void DFAPacketizerEmitter::run(raw_ostream &OS) { for (const CodeGenProcModel &ProcModel : CGS.procModels()) { if (ProcModel.hasItineraries()) { auto NS = ProcModel.ItinsDef->getValueAsString("PacketizerNamespace"); - ItinsByNamespace[std::string(NS)].push_back(&ProcModel); + ItinsByNamespace[NS.str()].push_back(&ProcModel); } } diff --git a/llvm/utils/TableGen/DecoderEmitter.cpp b/llvm/utils/TableGen/DecoderEmitter.cpp index eb3b30018da8a..4536d3d9d4084 100644 --- a/llvm/utils/TableGen/DecoderEmitter.cpp +++ b/llvm/utils/TableGen/DecoderEmitter.cpp @@ -1791,7 +1791,7 @@ static std::string findOperandDecoderMethod(const Record *Record) { const StringInit *String = DecoderString ? dyn_cast(DecoderString->getValue()) : nullptr; if (String) { - Decoder = std::string(String->getValue()); + Decoder = String->getValue().str(); if (!Decoder.empty()) return Decoder; } @@ -1917,7 +1917,7 @@ static void addOneOperandFields(const Record &EncodingDef, const BitsInit &Bits, Var = dyn_cast(Bits.getBit(J)); } if (!Var || (Var->getName() != OpName && - Var->getName() != TiedNames[std::string(OpName)])) + Var->getName() != TiedNames[OpName.str()])) break; } if (I == J) @@ -2354,7 +2354,7 @@ static void collectHwModesReferencedForEncodings( for (const HwModeSelect::PairType &P : MS.second.Items) { if (P.second->isSubClassOf("InstructionEncoding")) { std::string DecoderNamespace = - std::string(P.second->getValueAsString("DecoderNamespace")); + P.second->getValueAsString("DecoderNamespace").str(); if (P.first == DefaultMode) { NamespacesWithHwModes[DecoderNamespace].insert(""); } else { @@ -2387,7 +2387,7 @@ handleHwModesUnrelatedEncodings(const CodeGenInstruction *Instr, } case SUPPRESSION_LEVEL1: { std::string DecoderNamespace = - std::string(InstDef->getValueAsString("DecoderNamespace")); + InstDef->getValueAsString("DecoderNamespace").str(); auto It = NamespacesWithHwModes.find(DecoderNamespace); if (It != NamespacesWithHwModes.end()) { for (StringRef HwModeName : It->second) @@ -2506,10 +2506,9 @@ namespace { InstrLen[NEI] = Len; } std::string DecoderNamespace = - std::string(EncodingDef->getValueAsString("DecoderNamespace")); + EncodingDef->getValueAsString("DecoderNamespace").str(); if (!NumberedEncoding.HwModeName.empty()) - DecoderNamespace += - std::string("_") + NumberedEncoding.HwModeName.str(); + DecoderNamespace += "_" + NumberedEncoding.HwModeName.str(); OpcMap[{DecoderNamespace, Size}].emplace_back( NEI, Target.getInstrIntValue(Def)); } else { diff --git a/llvm/utils/TableGen/ExegesisEmitter.cpp b/llvm/utils/TableGen/ExegesisEmitter.cpp index a5dd2994b3753..1b4b0729a5fcc 100644 --- a/llvm/utils/TableGen/ExegesisEmitter.cpp +++ b/llvm/utils/TableGen/ExegesisEmitter.cpp @@ -103,7 +103,7 @@ ExegesisEmitter::ExegesisEmitter(const RecordKeeper &RK) PrintFatalError("No 'Target' subclasses defined!"); if (Targets.size() != 1) PrintFatalError("Multiple subclasses of Target defined!"); - Target = std::string(Targets[0]->getName()); + Target = Targets[0]->getName().str(); } struct ValidationCounterInfo { diff --git a/llvm/utils/TableGen/FastISelEmitter.cpp b/llvm/utils/TableGen/FastISelEmitter.cpp index 3818660cce5fb..9aa6ec1064276 100644 --- a/llvm/utils/TableGen/FastISelEmitter.cpp +++ b/llvm/utils/TableGen/FastISelEmitter.cpp @@ -418,7 +418,7 @@ class FastISelMap { static std::string getOpcodeName(const Record *Op, const CodeGenDAGPatterns &CGP) { - return std::string(CGP.getSDNodeInfo(Op).getEnumName()); + return CGP.getSDNodeInfo(Op).getEnumName().str(); } static std::string getLegalCName(std::string OpName) { @@ -716,20 +716,19 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) { const PredMap &PM = RI.second; OS << "Register fastEmit_" << getLegalCName(Opcode) << "_" - << getLegalCName(std::string(getEnumName(VT))) << "_" - << getLegalCName(std::string(getEnumName(RetVT))) << "_"; + << getLegalCName(getEnumName(VT).str()) << "_" + << getLegalCName(getEnumName(RetVT).str()) << "_"; Operands.PrintManglingSuffix(OS, ImmediatePredicates); OS << "("; Operands.PrintParameters(OS); OS << ") {\n"; - emitInstructionCode(OS, Operands, PM, - std::string(getEnumName(RetVT))); + emitInstructionCode(OS, Operands, PM, getEnumName(RetVT).str()); } // Emit one function for the type that demultiplexes on return type. OS << "Register fastEmit_" << getLegalCName(Opcode) << "_" - << getLegalCName(std::string(getEnumName(VT))) << "_"; + << getLegalCName(getEnumName(VT).str()) << "_"; Operands.PrintManglingSuffix(OS, ImmediatePredicates); OS << "(MVT RetVT"; if (!Operands.empty()) @@ -740,8 +739,8 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) { MVT::SimpleValueType RetVT = RI.first; OS << " case " << getEnumName(RetVT) << ": return fastEmit_" << getLegalCName(Opcode) << "_" - << getLegalCName(std::string(getEnumName(VT))) << "_" - << getLegalCName(std::string(getEnumName(RetVT))) << "_"; + << getLegalCName(getEnumName(VT).str()) << "_" + << getLegalCName(getEnumName(RetVT).str()) << "_"; Operands.PrintManglingSuffix(OS, ImmediatePredicates); OS << "("; Operands.PrintArguments(OS); @@ -752,7 +751,7 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) { } else { // Non-variadic return type. OS << "Register fastEmit_" << getLegalCName(Opcode) << "_" - << getLegalCName(std::string(getEnumName(VT))) << "_"; + << getLegalCName(getEnumName(VT).str()) << "_"; Operands.PrintManglingSuffix(OS, ImmediatePredicates); OS << "(MVT RetVT"; if (!Operands.empty()) @@ -780,7 +779,7 @@ void FastISelMap::printFunctionDefinitions(raw_ostream &OS) { OS << " switch (VT.SimpleTy) {\n"; for (const auto &TI : TM) { MVT::SimpleValueType VT = TI.first; - std::string TypeName = std::string(getEnumName(VT)); + std::string TypeName = getEnumName(VT).str(); OS << " case " << TypeName << ": return fastEmit_" << getLegalCName(Opcode) << "_" << getLegalCName(TypeName) << "_"; Operands.PrintManglingSuffix(OS, ImmediatePredicates); diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp index ecd7997871273..092dba58ad8b5 100644 --- a/llvm/utils/TableGen/GlobalISelEmitter.cpp +++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp @@ -889,7 +889,7 @@ Expected GlobalISelEmitter::createAndImportSelDAGMatcher( : CCDef->getValueAsString("ICmpPredicate"); if (!PredType.empty()) { - OM.addPredicate(std::string(PredType)); + OM.addPredicate(PredType.str()); // Process the other 2 operands normally. --NumChildren; } @@ -990,12 +990,12 @@ Error GlobalISelEmitter::importChildMatcher( bool OperandIsImmArg, unsigned OpIdx, unsigned &TempOpIdx) { const Record *PhysReg = nullptr; - std::string SrcChildName = std::string(getSrcChildName(SrcChild, PhysReg)); + std::string SrcChildName = getSrcChildName(SrcChild, PhysReg).str(); if (!SrcChild.isLeaf() && SrcChild.getOperator()->isSubClassOf("ComplexPattern")) { // The "name" of a non-leaf complex pattern (MY_PAT $op1, $op2) is // "MY_PAT:op1:op2" and the ones with same "name" represent same operand. - std::string PatternName = std::string(SrcChild.getOperator()->getName()); + std::string PatternName = SrcChild.getOperator()->getName().str(); for (const TreePatternNode &Child : SrcChild.children()) { PatternName += ":"; PatternName += Child.getName(); diff --git a/llvm/utils/TableGen/InstrDocsEmitter.cpp b/llvm/utils/TableGen/InstrDocsEmitter.cpp index 54ca7d8ae40da..a8a234675dec1 100644 --- a/llvm/utils/TableGen/InstrDocsEmitter.cpp +++ b/llvm/utils/TableGen/InstrDocsEmitter.cpp @@ -67,7 +67,7 @@ static void EmitInstrDocs(const RecordKeeper &RK, raw_ostream &OS) { unsigned VariantCount = Target.getAsmParserVariantCount(); // Page title. - std::string Title = std::string(Target.getName()); + std::string Title = Target.getName().str(); Title += " Instructions"; writeTitle(Title, OS); OS << "\n"; diff --git a/llvm/utils/TableGen/OptionParserEmitter.cpp b/llvm/utils/TableGen/OptionParserEmitter.cpp index 3aede8df0dc55..ba99015657796 100644 --- a/llvm/utils/TableGen/OptionParserEmitter.cpp +++ b/llvm/utils/TableGen/OptionParserEmitter.cpp @@ -24,9 +24,9 @@ using namespace llvm; static std::string getOptionName(const Record &R) { // Use the record name unless EnumName is defined. if (isa(R.getValueInit("EnumName"))) - return std::string(R.getName()); + return R.getName().str(); - return std::string(R.getValueAsString("EnumName")); + return R.getValueAsString("EnumName").str(); } static raw_ostream &writeStrTableOffset(raw_ostream &OS, diff --git a/llvm/utils/TableGen/RegisterInfoEmitter.cpp b/llvm/utils/TableGen/RegisterInfoEmitter.cpp index 98f0d7eaaff38..e283f1c492d42 100644 --- a/llvm/utils/TableGen/RegisterInfoEmitter.cpp +++ b/llvm/utils/TableGen/RegisterInfoEmitter.cpp @@ -937,7 +937,7 @@ void RegisterInfoEmitter::runMCDesc(raw_ostream &OS) { unsigned i = 0; for (auto I = Regs.begin(), E = Regs.end(); I != E; ++I, ++i) { const auto &Reg = *I; - RegStrings.add(std::string(Reg.getName())); + RegStrings.add(Reg.getName().str()); // Compute the ordered sub-register list. SetVector SR; @@ -974,7 +974,7 @@ void RegisterInfoEmitter::runMCDesc(raw_ostream &OS) { OS << "namespace llvm {\n\n"; - const std::string &TargetName = std::string(Target.getName()); + const std::string &TargetName = Target.getName().str(); // Emit the shared table of differential lists. OS << "extern const int16_t " << TargetName << "RegDiffLists[] = {\n"; @@ -1009,7 +1009,7 @@ void RegisterInfoEmitter::runMCDesc(raw_ostream &OS) { constexpr unsigned RegUnitBits = 12; assert(isUInt(FirstRU) && "Too many regunits"); assert(isUInt<32 - RegUnitBits>(Offset) && "Offset is too big"); - OS << " { " << RegStrings.get(std::string(Reg.getName())) << ", " + OS << " { " << RegStrings.get(Reg.getName().str()) << ", " << DiffSeqs.get(SubRegLists[i]) << ", " << DiffSeqs.get(SuperRegLists[i]) << ", " << SubRegIdxSeqs.get(SubRegIdxLists[i]) << ", " << (Offset << RegUnitBits | FirstRU) << ", " @@ -1144,7 +1144,7 @@ void RegisterInfoEmitter::runTargetHeader(raw_ostream &OS) { OS << "\n#ifdef GET_REGINFO_HEADER\n"; OS << "#undef GET_REGINFO_HEADER\n\n"; - const std::string &TargetName = std::string(Target.getName()); + const std::string &TargetName = Target.getName().str(); std::string ClassName = TargetName + "GenRegisterInfo"; OS << "#include \"llvm/CodeGen/TargetRegisterInfo.h\"\n\n"; @@ -1472,7 +1472,7 @@ void RegisterInfoEmitter::runTargetDesc(raw_ostream &OS) { OS << "} // end anonymous namespace\n"; // Emit extra information about registers. - const std::string &TargetName = std::string(Target.getName()); + const std::string &TargetName = Target.getName().str(); const auto &Regs = RegBank.getRegisters(); unsigned NumRegCosts = 1; for (const auto &Reg : Regs) diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp index 2efa04d35faa4..76475f6bee36a 100644 --- a/llvm/utils/TableGen/SearchableTableEmitter.cpp +++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp @@ -62,7 +62,7 @@ struct GenericField { bool IsInstruction = false; GenericEnum *Enum = nullptr; - GenericField(StringRef Name) : Name(std::string(Name)) {} + GenericField(StringRef Name) : Name(Name.str()) {} }; struct SearchIndex { @@ -118,7 +118,7 @@ class SearchableTableEmitter { const Init *I) { if (const StringInit *SI = dyn_cast(I)) { if (Field.IsCode || SI->hasCodeFormat()) - return std::string(SI->getValue()); + return SI->getValue().str(); else return SI->getAsString(); } else if (const BitsInit *BI = dyn_cast(I)) @@ -134,7 +134,7 @@ class SearchableTableEmitter { if (!Entry) PrintFatalError(Loc, Twine("Entry for field '") + Field.Name + "' is null"); - return std::string(Entry->first); + return Entry->first.str(); } PrintFatalError(Loc, Twine("invalid field type for field '") + Field.Name + "'; expected: bit, bits, string, or code"); @@ -300,7 +300,7 @@ bool SearchableTableEmitter::compareBy(const Record *LHS, const Record *RHS, void SearchableTableEmitter::emitIfdef(StringRef Guard, raw_ostream &OS) { OS << "#ifdef " << Guard << "\n"; - PreprocessorGuards.insert(std::string(Guard)); + PreprocessorGuards.insert(Guard.str()); } /// Emit a generic enum. @@ -597,7 +597,7 @@ std::unique_ptr SearchableTableEmitter::parseSearchIndex( GenericTable &Table, const RecordVal *KeyRecVal, StringRef Name, ArrayRef Key, bool EarlyOut, bool ReturnRange) { auto Index = std::make_unique(); - Index->Name = std::string(Name); + Index->Name = Name.str(); Index->Loc = KeyRecVal->getLoc(); Index->EarlyOut = EarlyOut; Index->ReturnRange = ReturnRange; @@ -728,8 +728,8 @@ void SearchableTableEmitter::run(raw_ostream &OS) { ValueField = EnumRec->getValueAsString("ValueField"); auto Enum = std::make_unique(); - Enum->Name = std::string(EnumRec->getName()); - Enum->PreprocessorGuard = std::string(EnumRec->getName()); + Enum->Name = EnumRec->getName().str(); + Enum->PreprocessorGuard = EnumRec->getName().str(); StringRef FilterClass = EnumRec->getValueAsString("FilterClass"); Enum->Class = Records.getClass(FilterClass); @@ -747,10 +747,10 @@ void SearchableTableEmitter::run(raw_ostream &OS) { for (const auto *TableRec : Records.getAllDerivedDefinitions("GenericTable")) { auto Table = std::make_unique(); - Table->Name = std::string(TableRec->getName()); + Table->Name = TableRec->getName().str(); Table->Locs = TableRec->getLoc(); - Table->PreprocessorGuard = std::string(TableRec->getName()); - Table->CppTypeName = std::string(TableRec->getValueAsString("CppTypeName")); + Table->PreprocessorGuard = TableRec->getName().str(); + Table->CppTypeName = TableRec->getValueAsString("CppTypeName").str(); std::vector Fields = TableRec->getValueAsListOfStrings("Fields"); for (const auto &FieldName : Fields) { @@ -861,10 +861,10 @@ void SearchableTableEmitter::run(raw_ostream &OS) { Table->Name = (Twine(Class->getName()) + "sList").str(); Table->Locs = Class->getLoc(); Table->PreprocessorGuard = Class->getName().upper(); - Table->CppTypeName = std::string(Class->getName()); + Table->CppTypeName = Class->getName().str(); for (const RecordVal &Field : Class->getValues()) { - std::string FieldName = std::string(Field.getName()); + std::string FieldName = Field.getName().str(); // Skip uninteresting fields: either special to us, or injected // template parameters (if they contain a ':'). diff --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp index 18cb78196cfae..9c67424615551 100644 --- a/llvm/utils/TableGen/SubtargetEmitter.cpp +++ b/llvm/utils/TableGen/SubtargetEmitter.cpp @@ -579,7 +579,7 @@ void SubtargetEmitter::emitStageAndOperandCycleData( std::string ItinStageString; unsigned NStages = 0; if (ItinData) - formItineraryStageString(std::string(Name), ItinData, ItinStageString, + formItineraryStageString(Name.str(), ItinData, ItinStageString, NStages); // Get string and operand cycle count @@ -590,7 +590,7 @@ void SubtargetEmitter::emitStageAndOperandCycleData( formItineraryOperandCycleString(ItinData, ItinOperandCycleString, NOperandCycles); - formItineraryBypassString(std::string(Name), ItinData, ItinBypassString, + formItineraryBypassString(Name.str(), ItinData, ItinBypassString, NOperandCycles); } @@ -1382,7 +1382,7 @@ void SubtargetEmitter::genSchedClassTables(const CodeGenProcModel &ProcModel, for (unsigned I = 0, E = WriteLatencies.size(); I < E; ++I) if (SchedTables.WriterNames[Idx + I].find(WriterNames[I]) == std::string::npos) { - SchedTables.WriterNames[Idx + I] += std::string("_") + WriterNames[I]; + SchedTables.WriterNames[Idx + I] += "_" + WriterNames[I]; } } else { SCDesc.WriteLatencyIdx = SchedTables.WriteLatencies.size(); diff --git a/llvm/utils/TableGen/X86RecognizableInstr.cpp b/llvm/utils/TableGen/X86RecognizableInstr.cpp index dbfb926b16ff7..402fc93703228 100644 --- a/llvm/utils/TableGen/X86RecognizableInstr.cpp +++ b/llvm/utils/TableGen/X86RecognizableInstr.cpp @@ -458,12 +458,12 @@ void RecognizableInstr::handleOperand( StringRef typeName = (*Operands)[operandIndex].Rec->getName(); - OperandEncoding encoding = encodingFromString(std::string(typeName), OpSize); + OperandEncoding encoding = encodingFromString(typeName.str(), OpSize); // Adjust the encoding type for an operand based on the instruction. adjustOperandEncoding(encoding); Spec->operands[operandIndex].encoding = encoding; Spec->operands[operandIndex].type = - typeFromString(std::string(typeName), HasREX_W, OpSize); + typeFromString(typeName.str(), HasREX_W, OpSize); ++operandIndex; ++physicalOperandIndex;