mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-13 14:47:00 +00:00
[tablegen] Avoid creating temporary strings
If a method / function returns a StringRef but the variable is of type const std::string& a temporary string is created (StringRef has a cast operator to std::string), which is a suboptimal behavior. Differential revision: https://reviews.llvm.org/D34994 Test plan: make check-all git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307195 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a6a29d93c8
commit
18b16185df
@ -1691,9 +1691,7 @@ void FilterChooser::emitTableEntries(DecoderTableInfo &TableInfo) const {
|
||||
dumpStack(errs(), "\t\t");
|
||||
|
||||
for (unsigned i = 0; i < Opcodes.size(); ++i) {
|
||||
const std::string &Name = nameWithID(Opcodes[i]);
|
||||
|
||||
errs() << '\t' << Name << " ";
|
||||
errs() << '\t' << nameWithID(Opcodes[i]) << " ";
|
||||
dumpBits(errs(),
|
||||
getBitsField(*AllInstructions[Opcodes[i]]->TheDef, "Inst"));
|
||||
errs() << '\n';
|
||||
|
@ -230,7 +230,7 @@ void SearchableTableEmitter::emitLookupDeclaration(StringRef Name,
|
||||
|
||||
void SearchableTableEmitter::emitMapping(Record *InstanceClass,
|
||||
raw_ostream &OS) {
|
||||
const std::string &TableName = InstanceClass->getName();
|
||||
StringRef TableName = InstanceClass->getName();
|
||||
std::vector<Record *> Items = Records.getAllDerivedDefinitions(TableName);
|
||||
|
||||
// Gather all the records we're going to need for this particular mapping.
|
||||
@ -265,8 +265,8 @@ void SearchableTableEmitter::emitMapping(Record *InstanceClass,
|
||||
++Idx;
|
||||
}
|
||||
|
||||
OS << "#ifdef GET_" << StringRef(TableName).upper() << "_DECL\n";
|
||||
OS << "#undef GET_" << StringRef(TableName).upper() << "_DECL\n";
|
||||
OS << "#ifdef GET_" << TableName.upper() << "_DECL\n";
|
||||
OS << "#undef GET_" << TableName.upper() << "_DECL\n";
|
||||
|
||||
// Next emit the enum containing the top-level names for use in C++ code if
|
||||
// requested
|
||||
@ -281,8 +281,8 @@ void SearchableTableEmitter::emitMapping(Record *InstanceClass,
|
||||
|
||||
OS << "#endif\n\n";
|
||||
|
||||
OS << "#ifdef GET_" << StringRef(TableName).upper() << "_IMPL\n";
|
||||
OS << "#undef GET_" << StringRef(TableName).upper() << "_IMPL\n";
|
||||
OS << "#ifdef GET_" << TableName.upper() << "_IMPL\n";
|
||||
OS << "#undef GET_" << TableName.upper() << "_IMPL\n";
|
||||
|
||||
// The primary data table contains all the fields defined for this map.
|
||||
emitPrimaryTable(TableName, FieldNames, SearchFieldNames, SearchTables, Items,
|
||||
|
@ -375,7 +375,7 @@ EmitStageAndOperandCycleData(raw_ostream &OS,
|
||||
if (FUs.empty())
|
||||
continue;
|
||||
|
||||
const std::string &Name = ProcModel.ItinsDef->getName();
|
||||
StringRef Name = ProcModel.ItinsDef->getName();
|
||||
OS << "\n// Functional units for \"" << Name << "\"\n"
|
||||
<< "namespace " << Name << "FU {\n";
|
||||
|
||||
@ -429,7 +429,7 @@ EmitStageAndOperandCycleData(raw_ostream &OS,
|
||||
if (!ProcModel.hasItineraries())
|
||||
continue;
|
||||
|
||||
const std::string &Name = ProcModel.ItinsDef->getName();
|
||||
StringRef Name = ProcModel.ItinsDef->getName();
|
||||
|
||||
ItinList.resize(SchedModels.numInstrSchedClasses());
|
||||
assert(ProcModel.ItinDefList.size() == ItinList.size() && "bad Itins");
|
||||
@ -546,9 +546,6 @@ EmitItineraries(raw_ostream &OS,
|
||||
if (!ItinsDefSet.insert(ItinsDef).second)
|
||||
continue;
|
||||
|
||||
// Get processor itinerary name
|
||||
const std::string &Name = ItinsDef->getName();
|
||||
|
||||
// Get the itinerary list for the processor.
|
||||
assert(ProcItinListsIter != ProcItinLists.end() && "bad iterator");
|
||||
std::vector<InstrItinerary> &ItinList = *ProcItinListsIter;
|
||||
@ -562,7 +559,7 @@ EmitItineraries(raw_ostream &OS,
|
||||
OS << "static const llvm::InstrItinerary ";
|
||||
|
||||
// Begin processor itinerary table
|
||||
OS << Name << "[] = {\n";
|
||||
OS << ItinsDef->getName() << "[] = {\n";
|
||||
|
||||
// For each itinerary class in CodeGenSchedClass::Index order.
|
||||
for (unsigned j = 0, M = ItinList.size(); j < M; ++j) {
|
||||
|
@ -367,7 +367,7 @@ void RecognizableInstr::handleOperand(bool optional, unsigned &operandIndex,
|
||||
++operandIndex;
|
||||
}
|
||||
|
||||
const std::string &typeName = (*Operands)[operandIndex].Rec->getName();
|
||||
StringRef typeName = (*Operands)[operandIndex].Rec->getName();
|
||||
|
||||
OperandEncoding encoding = encodingFromString(typeName, OpSize);
|
||||
// Adjust the encoding type for an operand based on the instruction.
|
||||
|
Loading…
Reference in New Issue
Block a user