forked from OSchip/llvm-project
Passing isel root and use operands to ComplexPattern functions, these should do the usual load folding checks as well.
llvm-svn: 30972
This commit is contained in:
parent
ff20ba3f51
commit
a74965f15a
|
@ -2199,9 +2199,9 @@ 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 *Root, TreePatternNode *N,
|
void EmitMatchCode(TreePatternNode *N, TreePatternNode *P,
|
||||||
TreePatternNode *P, const std::string &RootName,
|
const std::string &RootName, const std::string &ChainSuffix,
|
||||||
const std::string &ChainSuffix, bool &FoundChain) {
|
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.
|
||||||
if (isRoot) {
|
if (isRoot) {
|
||||||
|
@ -2283,12 +2283,22 @@ public:
|
||||||
// / [YY]
|
// / [YY]
|
||||||
// | ^
|
// | ^
|
||||||
// [XX]-------|
|
// [XX]-------|
|
||||||
const SDNodeInfo &PInfo = ISE.getSDNodeInfo(P->getOperator());
|
bool NeedCheck = false;
|
||||||
if (P != Root ||
|
if (P != Pattern)
|
||||||
|
NeedCheck = true;
|
||||||
|
else {
|
||||||
|
const SDNodeInfo &PInfo = ISE.getSDNodeInfo(P->getOperator());
|
||||||
|
NeedCheck =
|
||||||
|
P->getOperator() == ISE.get_intrinsic_void_sdnode() ||
|
||||||
|
P->getOperator() == ISE.get_intrinsic_w_chain_sdnode() ||
|
||||||
|
P->getOperator() == ISE.get_intrinsic_wo_chain_sdnode() ||
|
||||||
PInfo.getNumOperands() > 1 ||
|
PInfo.getNumOperands() > 1 ||
|
||||||
PInfo.hasProperty(SDNPHasChain) ||
|
PInfo.hasProperty(SDNPHasChain) ||
|
||||||
PInfo.hasProperty(SDNPInFlag) ||
|
PInfo.hasProperty(SDNPInFlag) ||
|
||||||
PInfo.hasProperty(SDNPOptInFlag)) {
|
PInfo.hasProperty(SDNPOptInFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NeedCheck) {
|
||||||
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, N.Val)");
|
".Val, N.Val)");
|
||||||
|
@ -2359,7 +2369,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(Root, N->getChild(0), N, RootName + utostr(0),
|
EmitChildMatchCode(N->getChild(0), N, RootName + utostr(0),
|
||||||
ChainSuffix + utostr(0), FoundChain);
|
ChainSuffix + utostr(0), FoundChain);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2370,7 +2380,7 @@ public:
|
||||||
emitInit("SDOperand " + RootName + utostr(OpNo) + " = " +
|
emitInit("SDOperand " + RootName + utostr(OpNo) + " = " +
|
||||||
RootName + ".getOperand(" +utostr(OpNo) + ");");
|
RootName + ".getOperand(" +utostr(OpNo) + ");");
|
||||||
|
|
||||||
EmitChildMatchCode(Root, N->getChild(i), N, RootName + utostr(OpNo),
|
EmitChildMatchCode(N->getChild(i), N, RootName + utostr(OpNo),
|
||||||
ChainSuffix + utostr(OpNo), FoundChain);
|
ChainSuffix + utostr(OpNo), FoundChain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2401,15 +2411,15 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitChildMatchCode(TreePatternNode *Root, TreePatternNode *Child,
|
void EmitChildMatchCode(TreePatternNode *Child, TreePatternNode *Parent,
|
||||||
TreePatternNode *Parent, const std::string &RootName,
|
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(Root, Child, Parent, RootName, ChainSuffix, FoundChain);
|
EmitMatchCode(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 {
|
||||||
|
@ -2457,7 +2467,12 @@ public:
|
||||||
emitCode("SDOperand " + ChainName + ";");
|
emitCode("SDOperand " + ChainName + ";");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Code = Fn + "(" + RootName;
|
std::string Code = Fn + "(";
|
||||||
|
if (CP->hasProperty(SDNPHasChain)) {
|
||||||
|
std::string ParentName(RootName.begin(), RootName.end()-1);
|
||||||
|
Code += "N, " + ParentName + ", ";
|
||||||
|
}
|
||||||
|
Code += RootName;
|
||||||
for (unsigned i = 0; i < NumOps; i++)
|
for (unsigned i = 0; i < NumOps; i++)
|
||||||
Code += ", CPTmp" + utostr(i);
|
Code += ", CPTmp" + utostr(i);
|
||||||
if (CP->hasProperty(SDNPHasChain))
|
if (CP->hasProperty(SDNPHasChain))
|
||||||
|
@ -3099,8 +3114,7 @@ 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(), Pattern.getSrcPattern(), NULL,
|
Emitter.EmitMatchCode(Pattern.getSrcPattern(), NULL, "N", "", FoundChain);
|
||||||
"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…
Reference in New Issue