1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

Revert r315148 [TableGen] Avoid unnecessary std::string creations

I'm about to commit a patch that makes them necessary for getPredCode() and
it would be strange for getPredCode() and getImmCode() to require different
usage.

llvm-svn: 315733
This commit is contained in:
Daniel Sanders 2017-10-13 19:00:01 +00:00
parent 79e4224a23
commit 7e5a45423e
2 changed files with 13 additions and 13 deletions

View File

@ -854,11 +854,11 @@ TreePredicateFn::TreePredicateFn(TreePattern *N) : PatFragRec(N) {
".td file corrupt: can't have a node predicate *and* an imm predicate");
}
StringRef TreePredicateFn::getPredCode() const {
std::string TreePredicateFn::getPredCode() const {
return PatFragRec->getRecord()->getValueAsString("PredicateCode");
}
StringRef TreePredicateFn::getImmCode() const {
std::string TreePredicateFn::getImmCode() const {
return PatFragRec->getRecord()->getValueAsString("ImmediateCode");
}
@ -880,16 +880,16 @@ std::string TreePredicateFn::getFnName() const {
/// appropriate.
std::string TreePredicateFn::getCodeToRunOnSDNode() const {
// Handle immediate predicates first.
StringRef ImmCode = getImmCode();
std::string ImmCode = getImmCode();
if (!ImmCode.empty()) {
std::string Result =
" int64_t Imm = cast<ConstantSDNode>(Node)->getSExtValue();\n";
return Result + ImmCode.str();
return Result + ImmCode;
}
// Handle arbitrary node predicates.
assert(!getPredCode().empty() && "Don't have any predicate code!");
StringRef ClassName;
std::string ClassName;
if (PatFragRec->getOnlyTree()->isLeaf())
ClassName = "SDNode";
else {
@ -900,9 +900,9 @@ std::string TreePredicateFn::getCodeToRunOnSDNode() const {
if (ClassName == "SDNode")
Result = " SDNode *N = Node;\n";
else
Result = " auto *N = cast<" + ClassName.str() + ">(Node);\n";
Result = " auto *N = cast<" + ClassName + ">(Node);\n";
return Result + getPredCode().str();
return Result + getPredCode();
}
//===----------------------------------------------------------------------===//
@ -2564,7 +2564,7 @@ CodeGenDAGPatterns::CodeGenDAGPatterns(RecordKeeper &R) :
VerifyInstructionFlags();
}
Record *CodeGenDAGPatterns::getSDNodeNamed(StringRef Name) const {
Record *CodeGenDAGPatterns::getSDNodeNamed(const std::string &Name) const {
Record *N = Records.getDef(Name);
if (!N || !N->isSubClassOf("SDNode"))
PrintFatalError("Error getting SDNode '" + Name + "'!");

View File

@ -452,8 +452,8 @@ public:
/// getImmediatePredicateCode - Return the code that evaluates this pattern if
/// this is an immediate predicate. It is an error to call this on a
/// non-immediate pattern.
StringRef getImmediatePredicateCode() const {
StringRef Result = getImmCode();
std::string getImmediatePredicateCode() const {
std::string Result = getImmCode();
assert(!Result.empty() && "Isn't an immediate pattern!");
return Result;
}
@ -476,8 +476,8 @@ public:
std::string getCodeToRunOnSDNode() const;
private:
StringRef getPredCode() const;
StringRef getImmCode() const;
std::string getPredCode() const;
std::string getImmCode() const;
};
@ -995,7 +995,7 @@ public:
const CodeGenTarget &getTargetInfo() const { return Target; }
const TypeSetByHwMode &getLegalTypes() const { return LegalVTS; }
Record *getSDNodeNamed(StringRef Name) const;
Record *getSDNodeNamed(const std::string &Name) const;
const SDNodeInfo &getSDNodeInfo(Record *R) const {
auto F = SDNodes.find(R);