mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-05-17 15:38:40 +00:00
When checking if a load can be folded, we check if there is any non-direct
way to reach the load via any nodes that would be folded. Start from the root of the matched sub-tree. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30956 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
30f73e78bd
commit
ce1381afd9
@ -2199,8 +2199,8 @@ public:
|
|||||||
/// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo
|
/// EmitMatchCode - Emit a matcher for N, going to the label for PatternNo
|
||||||
/// if the match fails. At this point, we already know that the opcode for N
|
/// if the match fails. At this point, we already know that the opcode for N
|
||||||
/// matches, and the SDNode for the result has the RootName specified name.
|
/// matches, and the SDNode for the result has the RootName specified name.
|
||||||
void EmitMatchCode(TreePatternNode *N, TreePatternNode *P,
|
void EmitMatchCode(TreePatternNode *Root, TreePatternNode *N,
|
||||||
const std::string &RootName,
|
TreePatternNode *P, const std::string &RootName,
|
||||||
const std::string &ChainSuffix, bool &FoundChain) {
|
const std::string &ChainSuffix, bool &FoundChain) {
|
||||||
bool isRoot = (P == NULL);
|
bool isRoot = (P == NULL);
|
||||||
// Emit instruction predicates. Each predicate is just a string for now.
|
// Emit instruction predicates. Each predicate is just a string for now.
|
||||||
@ -2284,13 +2284,14 @@ public:
|
|||||||
// | ^
|
// | ^
|
||||||
// [XX]-------|
|
// [XX]-------|
|
||||||
const SDNodeInfo &PInfo = ISE.getSDNodeInfo(P->getOperator());
|
const SDNodeInfo &PInfo = ISE.getSDNodeInfo(P->getOperator());
|
||||||
if (PInfo.getNumOperands() > 1 ||
|
if (P != Root ||
|
||||||
|
PInfo.getNumOperands() > 1 ||
|
||||||
PInfo.hasProperty(SDNPHasChain) ||
|
PInfo.hasProperty(SDNPHasChain) ||
|
||||||
PInfo.hasProperty(SDNPInFlag) ||
|
PInfo.hasProperty(SDNPInFlag) ||
|
||||||
PInfo.hasProperty(SDNPOptInFlag)) {
|
PInfo.hasProperty(SDNPOptInFlag)) {
|
||||||
std::string ParentName(RootName.begin(), RootName.end()-1);
|
std::string ParentName(RootName.begin(), RootName.end()-1);
|
||||||
emitCheck("CanBeFoldedBy(" + RootName + ".Val, " + ParentName +
|
emitCheck("CanBeFoldedBy(" + RootName + ".Val, " + ParentName +
|
||||||
".Val)");
|
".Val, N.Val)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2358,7 +2359,7 @@ public:
|
|||||||
emitCheck(MaskPredicate + RootName + "0, cast<ConstantSDNode>(" +
|
emitCheck(MaskPredicate + RootName + "0, cast<ConstantSDNode>(" +
|
||||||
RootName + "1), " + itostr(II->getValue()) + ")");
|
RootName + "1), " + itostr(II->getValue()) + ")");
|
||||||
|
|
||||||
EmitChildMatchCode(N->getChild(0), N, RootName + utostr(0),
|
EmitChildMatchCode(Root, N->getChild(0), N, RootName + utostr(0),
|
||||||
ChainSuffix + utostr(0), FoundChain);
|
ChainSuffix + utostr(0), FoundChain);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2369,7 +2370,7 @@ public:
|
|||||||
emitInit("SDOperand " + RootName + utostr(OpNo) + " = " +
|
emitInit("SDOperand " + RootName + utostr(OpNo) + " = " +
|
||||||
RootName + ".getOperand(" +utostr(OpNo) + ");");
|
RootName + ".getOperand(" +utostr(OpNo) + ");");
|
||||||
|
|
||||||
EmitChildMatchCode(N->getChild(i), N, RootName + utostr(OpNo),
|
EmitChildMatchCode(Root, N->getChild(i), N, RootName + utostr(OpNo),
|
||||||
ChainSuffix + utostr(OpNo), FoundChain);
|
ChainSuffix + utostr(OpNo), FoundChain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2400,15 +2401,15 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitChildMatchCode(TreePatternNode *Child, TreePatternNode *Parent,
|
void EmitChildMatchCode(TreePatternNode *Root, TreePatternNode *Child,
|
||||||
const std::string &RootName,
|
TreePatternNode *Parent, const std::string &RootName,
|
||||||
const std::string &ChainSuffix, bool &FoundChain) {
|
const std::string &ChainSuffix, bool &FoundChain) {
|
||||||
if (!Child->isLeaf()) {
|
if (!Child->isLeaf()) {
|
||||||
// If it's not a leaf, recursively match.
|
// If it's not a leaf, recursively match.
|
||||||
const SDNodeInfo &CInfo = ISE.getSDNodeInfo(Child->getOperator());
|
const SDNodeInfo &CInfo = ISE.getSDNodeInfo(Child->getOperator());
|
||||||
emitCheck(RootName + ".getOpcode() == " +
|
emitCheck(RootName + ".getOpcode() == " +
|
||||||
CInfo.getEnumName());
|
CInfo.getEnumName());
|
||||||
EmitMatchCode(Child, Parent, RootName, ChainSuffix, FoundChain);
|
EmitMatchCode(Root, Child, Parent, RootName, ChainSuffix, FoundChain);
|
||||||
if (NodeHasProperty(Child, SDNPHasChain, ISE))
|
if (NodeHasProperty(Child, SDNPHasChain, ISE))
|
||||||
FoldedChains.push_back(std::make_pair(RootName, CInfo.getNumResults()));
|
FoldedChains.push_back(std::make_pair(RootName, CInfo.getNumResults()));
|
||||||
} else {
|
} else {
|
||||||
@ -3098,7 +3099,8 @@ void DAGISelEmitter::GenerateCodeForPattern(PatternToMatch &Pattern,
|
|||||||
|
|
||||||
// Emit the matcher, capturing named arguments in VariableMap.
|
// Emit the matcher, capturing named arguments in VariableMap.
|
||||||
bool FoundChain = false;
|
bool FoundChain = false;
|
||||||
Emitter.EmitMatchCode(Pattern.getSrcPattern(), NULL, "N", "", FoundChain);
|
Emitter.EmitMatchCode(Pattern.getSrcPattern(), Pattern.getSrcPattern(), NULL,
|
||||||
|
"N", "", FoundChain);
|
||||||
|
|
||||||
// TP - Get *SOME* tree pattern, we don't care which.
|
// TP - Get *SOME* tree pattern, we don't care which.
|
||||||
TreePattern &TP = *PatternFragments.begin()->second;
|
TreePattern &TP = *PatternFragments.begin()->second;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user