<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Jul 6, 2017 at 11:22 PM Craig Topper via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ctopper<br>
Date: Thu Jul 6 23:22:35 2017<br>
New Revision: 307362<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=307362&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=307362&view=rev</a><br>
Log:<br>
[TableGen] Use StringRef instead of std::string for CodeGenInstruction namespace. NFC<br>
<br>
Modified:<br>
llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp<br>
llvm/trunk/utils/TableGen/CodeGenInstruction.h<br>
llvm/trunk/utils/TableGen/CodeGenMapTable.cpp<br>
llvm/trunk/utils/TableGen/CodeGenTarget.cpp<br>
llvm/trunk/utils/TableGen/CodeGenTarget.h<br>
llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp<br>
llvm/trunk/utils/TableGen/FastISelEmitter.cpp<br>
llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp<br>
<br>
Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=307362&r1=307361&r2=307362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=307362&r1=307361&r2=307362&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Thu Jul 6 23:22:35 2017<br>
@@ -137,12 +137,12 @@ static void EmitInstructions(std::vector<br>
O << " switch (MI->getOpcode()) {\n";<br>
O << " default: llvm_unreachable(\"Unexpected opcode.\");\n";<br>
std::vector<std::pair<std::string, AsmWriterOperand>> OpsToPrint;<br>
- OpsToPrint.push_back(std::make_pair(FirstInst.CGI->Namespace + "::" +<br>
+ OpsToPrint.push_back(std::make_pair(FirstInst.CGI->Namespace.str() + "::" +<br>
FirstInst.CGI->TheDef->getName().str(),<br></blockquote><div><br>Might be marginally more efficient to do (x + y + z).str() rather than x.str() + y.str() ?<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
FirstInst.Operands[i]));<br>
<br>
for (const AsmWriterInst &AWI : SimilarInsts) {<br>
- OpsToPrint.push_back(std::make_pair(AWI.CGI->Namespace+"::" +<br>
+ OpsToPrint.push_back(std::make_pair(AWI.CGI->Namespace.str()+"::" +<br>
AWI.CGI->TheDef->getName().str(),<br>
AWI.Operands[i]));<br>
}<br>
<br>
Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.h?rev=307362&r1=307361&r2=307362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.h?rev=307362&r1=307361&r2=307362&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/CodeGenInstruction.h (original)<br>
+++ llvm/trunk/utils/TableGen/CodeGenInstruction.h Thu Jul 6 23:22:35 2017<br>
@@ -206,7 +206,7 @@ template <typename T> class ArrayRef;<br>
class CodeGenInstruction {<br>
public:<br>
Record *TheDef; // The actual record defining this instruction.<br>
- std::string Namespace; // The namespace the instruction is in.<br>
+ StringRef Namespace; // The namespace the instruction is in.<br>
<br>
/// AsmString - The format string used to emit a .s file for the<br>
/// instruction.<br>
<br>
Modified: llvm/trunk/utils/TableGen/CodeGenMapTable.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenMapTable.cpp?rev=307362&r1=307361&r2=307362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenMapTable.cpp?rev=307362&r1=307361&r2=307362&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/CodeGenMapTable.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/CodeGenMapTable.cpp Thu Jul 6 23:22:35 2017<br>
@@ -367,7 +367,7 @@ unsigned MapTableEmitter::emitBinSearchT<br>
<br>
ArrayRef<const CodeGenInstruction*> NumberedInstructions =<br>
Target.getInstructionsByEnumValue();<br>
- std::string Namespace = Target.getInstNamespace();<br>
+ StringRef Namespace = Target.getInstNamespace();<br>
const std::vector<ListInit*> &ValueCols = InstrMapDesc.getValueCols();<br>
unsigned NumCol = ValueCols.size();<br>
unsigned TotalNumInstr = NumberedInstructions.size();<br>
@@ -567,7 +567,7 @@ namespace llvm {<br>
//===----------------------------------------------------------------------===//<br>
void EmitMapTable(RecordKeeper &Records, raw_ostream &OS) {<br>
CodeGenTarget Target(Records);<br>
- std::string NameSpace = Target.getInstNamespace();<br>
+ StringRef NameSpace = Target.getInstNamespace();<br>
std::vector<Record*> InstrMapVec;<br>
InstrMapVec = Records.getAllDerivedDefinitions("InstrMapping");<br>
<br>
<br>
Modified: llvm/trunk/utils/TableGen/CodeGenTarget.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.cpp?rev=307362&r1=307361&r2=307362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.cpp?rev=307362&r1=307361&r2=307362&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/CodeGenTarget.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/CodeGenTarget.cpp Thu Jul 6 23:22:35 2017<br>
@@ -207,7 +207,7 @@ const StringRef CodeGenTarget::getName()<br>
return TargetRec->getName();<br>
}<br>
<br>
-std::string CodeGenTarget::getInstNamespace() const {<br>
+StringRef CodeGenTarget::getInstNamespace() const {<br>
for (const CodeGenInstruction *Inst : getInstructionsByEnumValue()) {<br>
// Make sure not to pick up "TargetOpcode" by accidentally getting<br>
// the namespace off the PHI instruction or something.<br>
<br>
Modified: llvm/trunk/utils/TableGen/CodeGenTarget.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.h?rev=307362&r1=307361&r2=307362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.h?rev=307362&r1=307361&r2=307362&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/CodeGenTarget.h (original)<br>
+++ llvm/trunk/utils/TableGen/CodeGenTarget.h Thu Jul 6 23:22:35 2017<br>
@@ -86,7 +86,7 @@ public:<br>
<br>
/// getInstNamespace - Return the target-specific instruction namespace.<br>
///<br>
- std::string getInstNamespace() const;<br>
+ StringRef getInstNamespace() const;<br>
<br>
/// getInstructionSet - Return the InstructionSet object.<br>
///<br>
<br>
Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=307362&r1=307361&r2=307362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=307362&r1=307361&r2=307362&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Thu Jul 6 23:22:35 2017<br>
@@ -886,7 +886,7 @@ EmitResultInstructionAsOperand(const Tre<br>
assert((!ResultVTs.empty() || TreeHasOutGlue || NodeHasChain) &&<br>
"Node has no result");<br>
<br>
- AddMatcher(new EmitNodeMatcher(II.Namespace+"::"+II.TheDef->getName().str(),<br>
+ AddMatcher(new EmitNodeMatcher(II.Namespace.str()+"::"+II.TheDef->getName().str(),<br>
ResultVTs, InstOps,<br>
NodeHasChain, TreeHasInGlue, TreeHasOutGlue,<br>
NodeHasMemRefs, NumFixedArityOperands,<br>
<br>
Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=307362&r1=307361&r2=307362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=307362&r1=307361&r2=307362&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Thu Jul 6 23:22:35 2017<br>
@@ -441,7 +441,7 @@ void FastISelMap::collectPatterns(CodeGe<br>
const CodeGenTarget &Target = CGP.getTargetInfo();<br>
<br>
// Determine the target's namespace name.<br>
- InstNS = Target.getInstNamespace() + "::";<br>
+ InstNS = Target.getInstNamespace().str() + "::";<br>
assert(InstNS.size() > 2 && "Can't determine target-specific namespace!");<br>
<br>
// Scan through all the patterns and record the simple ones.<br>
@@ -873,7 +873,7 @@ void EmitFastISel(RecordKeeper &RK, raw_<br>
Target.getName().str() + " target", OS);<br>
<br>
// Determine the target's namespace name.<br>
- std::string InstNS = Target.getInstNamespace() + "::";<br>
+ std::string InstNS = Target.getInstNamespace().str() + "::";<br>
assert(InstNS.size() > 2 && "Can't determine target-specific namespace!");<br>
<br>
FastISelMap F(InstNS);<br>
<br>
Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=307362&r1=307361&r2=307362&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=307362&r1=307361&r2=307362&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Thu Jul 6 23:22:35 2017<br>
@@ -67,7 +67,7 @@ private:<br>
void emitOperandTypesEnum(raw_ostream &OS, const CodeGenTarget &Target);<br>
void initOperandMapData(<br>
ArrayRef<const CodeGenInstruction *> NumberedInstructions,<br>
- const std::string &Namespace,<br>
+ StringRef Namespace,<br>
std::map<std::string, unsigned> &Operands,<br>
OpNameMapTy &OperandMap);<br>
void emitOperandNameMappings(raw_ostream &OS, const CodeGenTarget &Target,<br>
@@ -207,7 +207,7 @@ void InstrInfoEmitter::EmitOperandInfo(r<br>
/// well as the getNamedOperandIdx() function.<br>
void InstrInfoEmitter::initOperandMapData(<br>
ArrayRef<const CodeGenInstruction *> NumberedInstructions,<br>
- const std::string &Namespace,<br>
+ StringRef Namespace,<br>
std::map<std::string, unsigned> &Operands,<br>
OpNameMapTy &OperandMap) {<br>
unsigned NumOperands = 0;<br>
@@ -224,7 +224,7 @@ void InstrInfoEmitter::initOperandMapDat<br>
}<br>
OpList[I->second] = Info.MIOperandNo;<br>
}<br>
- OperandMap[OpList].push_back(Namespace + "::" +<br>
+ OperandMap[OpList].push_back(Namespace.str() + "::" +<br>
Inst->TheDef->getName().str());<br>
}<br>
}<br>
@@ -243,7 +243,7 @@ void InstrInfoEmitter::initOperandMapDat<br>
void InstrInfoEmitter::emitOperandNameMappings(raw_ostream &OS,<br>
const CodeGenTarget &Target,<br>
ArrayRef<const CodeGenInstruction*> NumberedInstructions) {<br>
- const std::string &Namespace = Target.getInstNamespace();<br>
+ StringRef Namespace = Target.getInstNamespace();<br>
std::string OpNameNS = "OpName";<br>
// Map of operand names to their enumeration value. This will be used to<br>
// generate the OpName enum.<br>
@@ -315,7 +315,7 @@ void InstrInfoEmitter::emitOperandNameMa<br>
void InstrInfoEmitter::emitOperandTypesEnum(raw_ostream &OS,<br>
const CodeGenTarget &Target) {<br>
<br>
- const std::string &Namespace = Target.getInstNamespace();<br>
+ StringRef Namespace = Target.getInstNamespace();<br>
std::vector<Record *> Operands = Records.getAllDerivedDefinitions("Operand");<br>
<br>
OS << "#ifdef GET_INSTRINFO_OPERAND_TYPES_ENUM\n";<br>
@@ -576,7 +576,7 @@ void InstrInfoEmitter::emitEnums(raw_ost<br>
CodeGenTarget Target(Records);<br>
<br>
// We must emit the PHI opcode first...<br>
- std::string Namespace = Target.getInstNamespace();<br>
+ StringRef Namespace = Target.getInstNamespace();<br>
<br>
if (Namespace.empty())<br>
PrintFatalError("No instructions defined!");<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div></div>