forked from OSchip/llvm-project
[TableGen] Avoid unnecessary std::string creations
Avoid unnecessary std::string creations in the TreePredicateFn getters. llvm-svn: 315826
This commit is contained in:
parent
36fe00ee17
commit
6ecae9fc97
|
@ -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");
|
||||
}
|
||||
|
||||
|
@ -873,7 +873,7 @@ bool TreePredicateFn::immCodeUsesAPFloat() const {
|
|||
Unset);
|
||||
}
|
||||
|
||||
std::string TreePredicateFn::getImmType() const {
|
||||
StringRef TreePredicateFn::getImmType() const {
|
||||
if (immCodeUsesAPInt())
|
||||
return "const APInt &";
|
||||
if (immCodeUsesAPFloat())
|
||||
|
@ -881,7 +881,7 @@ std::string TreePredicateFn::getImmType() const {
|
|||
return "int64_t";
|
||||
}
|
||||
|
||||
std::string TreePredicateFn::getImmTypeIdentifier() const {
|
||||
StringRef TreePredicateFn::getImmTypeIdentifier() const {
|
||||
if (immCodeUsesAPInt())
|
||||
return "APInt";
|
||||
else if (immCodeUsesAPFloat())
|
||||
|
@ -906,21 +906,21 @@ 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 = " " + getImmType() + " Imm = ";
|
||||
std::string Result = " " + getImmType().str() + " Imm = ";
|
||||
if (immCodeUsesAPFloat())
|
||||
Result += "cast<ConstantFPSDNode>(Node)->getValueAPF();\n";
|
||||
else if (immCodeUsesAPInt())
|
||||
Result += "cast<ConstantSDNode>(Node)->getAPIntValue();\n";
|
||||
else
|
||||
Result += "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 {
|
||||
|
@ -931,9 +931,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();
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -452,13 +452,12 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
bool operator==(const TreePredicateFn &RHS) const {
|
||||
return PatFragRec == RHS.PatFragRec;
|
||||
}
|
||||
|
@ -476,15 +475,15 @@ public:
|
|||
std::string getCodeToRunOnSDNode() const;
|
||||
|
||||
/// Get the data type of the argument to getImmediatePredicateCode().
|
||||
std::string getImmType() const;
|
||||
StringRef getImmType() const;
|
||||
|
||||
/// Get a string that describes the type returned by getImmType() but is
|
||||
/// usable as part of an identifier.
|
||||
std::string getImmTypeIdentifier() const;
|
||||
StringRef getImmTypeIdentifier() const;
|
||||
|
||||
private:
|
||||
std::string getPredCode() const;
|
||||
std::string getImmCode() const;
|
||||
StringRef getPredCode() const;
|
||||
StringRef getImmCode() const;
|
||||
bool immCodeUsesAPInt() const;
|
||||
bool immCodeUsesAPFloat() const;
|
||||
};
|
||||
|
|
|
@ -68,13 +68,13 @@ namespace {
|
|||
|
||||
/// Get the name of the enum value used to number the predicate function.
|
||||
std::string getEnumNameForPredicate(const TreePredicateFn &Predicate) {
|
||||
return "GIPFP_" + Predicate.getImmTypeIdentifier() + "_" +
|
||||
return "GIPFP_" + Predicate.getImmTypeIdentifier().str() + "_" +
|
||||
Predicate.getFnName();
|
||||
}
|
||||
|
||||
/// Get the opcode used to check this predicate.
|
||||
std::string getMatchOpcodeForPredicate(const TreePredicateFn &Predicate) {
|
||||
return "GIM_Check" + Predicate.getImmTypeIdentifier() + "ImmPredicate";
|
||||
return "GIM_Check" + Predicate.getImmTypeIdentifier().str() + "ImmPredicate";
|
||||
}
|
||||
|
||||
/// This class stands in for LLT wherever we want to tablegen-erate an
|
||||
|
|
Loading…
Reference in New Issue