mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 13:11:39 +01:00
[TableGen] Avoid unnecessary std::string creations
Avoid unnecessary std::string creations in the TreePredicateFn getters and in CodeGenDAGPatterns::getSDNodeNamed Differential Revision: https://reviews.llvm.org/D38624 llvm-svn: 315148
This commit is contained in:
parent
e5846681e6
commit
cb879b3644
@ -854,11 +854,11 @@ TreePredicateFn::TreePredicateFn(TreePattern *N) : PatFragRec(N) {
|
||||
".td file corrupt: can't have a node predicate *and* an imm predicate");
|
||||
}
|
||||
|
||||
std::string TreePredicateFn::getPredCode() const {
|
||||
StringRef TreePredicateFn::getPredCode() const {
|
||||
return PatFragRec->getRecord()->getValueAsString("PredicateCode");
|
||||
}
|
||||
|
||||
std::string TreePredicateFn::getImmCode() const {
|
||||
StringRef 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.
|
||||
std::string ImmCode = getImmCode();
|
||||
StringRef ImmCode = getImmCode();
|
||||
if (!ImmCode.empty()) {
|
||||
std::string Result =
|
||||
" int64_t Imm = cast<ConstantSDNode>(Node)->getSExtValue();\n";
|
||||
return Result + ImmCode;
|
||||
return Result + ImmCode.str();
|
||||
}
|
||||
|
||||
// Handle arbitrary node predicates.
|
||||
assert(!getPredCode().empty() && "Don't have any predicate code!");
|
||||
std::string ClassName;
|
||||
StringRef 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 + ">(Node);\n";
|
||||
Result = " auto *N = cast<" + ClassName.str() + ">(Node);\n";
|
||||
|
||||
return Result + getPredCode();
|
||||
return Result + getPredCode().str();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -2564,7 +2564,7 @@ CodeGenDAGPatterns::CodeGenDAGPatterns(RecordKeeper &R) :
|
||||
VerifyInstructionFlags();
|
||||
}
|
||||
|
||||
Record *CodeGenDAGPatterns::getSDNodeNamed(const std::string &Name) const {
|
||||
Record *CodeGenDAGPatterns::getSDNodeNamed(StringRef Name) const {
|
||||
Record *N = Records.getDef(Name);
|
||||
if (!N || !N->isSubClassOf("SDNode"))
|
||||
PrintFatalError("Error getting SDNode '" + Name + "'!");
|
||||
|
@ -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.
|
||||
std::string getImmediatePredicateCode() const {
|
||||
std::string Result = getImmCode();
|
||||
StringRef getImmediatePredicateCode() const {
|
||||
StringRef Result = getImmCode();
|
||||
assert(!Result.empty() && "Isn't an immediate pattern!");
|
||||
return Result;
|
||||
}
|
||||
@ -476,8 +476,8 @@ public:
|
||||
std::string getCodeToRunOnSDNode() const;
|
||||
|
||||
private:
|
||||
std::string getPredCode() const;
|
||||
std::string getImmCode() const;
|
||||
StringRef getPredCode() const;
|
||||
StringRef getImmCode() const;
|
||||
};
|
||||
|
||||
|
||||
@ -995,7 +995,7 @@ public:
|
||||
const CodeGenTarget &getTargetInfo() const { return Target; }
|
||||
const TypeSetByHwMode &getLegalTypes() const { return LegalVTS; }
|
||||
|
||||
Record *getSDNodeNamed(const std::string &Name) const;
|
||||
Record *getSDNodeNamed(StringRef Name) const;
|
||||
|
||||
const SDNodeInfo &getSDNodeInfo(Record *R) const {
|
||||
assert(SDNodes.count(R) && "Unknown node!");
|
||||
|
Loading…
x
Reference in New Issue
Block a user