Make the implicit inputs and outputs of target-independent

ADDC/ADDE use MVT::i1 (later, whatever it gets legalized to)
instead of MVT::Flag.  Remove CARRY_FALSE in favor of 0; adjust
all target-independent code to use this format.

Most targets will still produce a Flag-setting target-dependent
version when selection is done.  X86 is converted to use i32
instead, which means TableGen needs to produce different code
in xxxGenDAGISel.inc.  This keys off the new supportsHasI1 bit
in xxxInstrInfo, currently set only for X86; in principle this
is temporary and should go away when all other targets have
been converted.  All relevant X86 instruction patterns are
modified to represent setting and using EFLAGS explicitly.  The
same can be done on other targets.

The immediate behavior change is that an ADC/ADD pair are no
longer tightly coupled in the X86 scheduler; they can be
separated by instructions that don't clobber the flags (MOV).
I will soon add some peephole optimizations based on using
other instructions that set the flags to feed into ADC.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72707 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dale Johannesen
2009-06-01 23:27:20 +00:00
parent 8313899851
commit 4150d83abe
17 changed files with 431 additions and 124 deletions

View File

@ -670,7 +670,8 @@ public:
HasChain = true;
FoldedChains.push_back(std::make_pair(RootName, CInfo.getNumResults()));
}
if (NodeHasProperty(Child, SDNPOutFlag, CGP)) {
if (NodeHasProperty(Child, SDNPOutFlag, CGP) ||
NodeHasProperty(Child, SDNPOutI1, CGP)) {
assert(FoldedFlag.first == "" && FoldedFlag.second == 0 &&
"Pattern folded multiple nodes which produce flags?");
FoldedFlag = std::make_pair(RootName,
@ -969,6 +970,10 @@ public:
PatternHasProperty(Pattern, SDNPInFlag, CGP);
bool NodeHasOutFlag = isRoot &&
PatternHasProperty(Pattern, SDNPOutFlag, CGP);
bool NodeHasInI1 = isRoot &&
PatternHasProperty(Pattern, SDNPInI1, CGP);
bool NodeHasOutI1 = isRoot &&
PatternHasProperty(Pattern, SDNPOutI1, CGP);
bool NodeHasChain = InstPatNode &&
PatternHasProperty(InstPatNode, SDNPHasChain, CGP);
bool InputHasChain = isRoot &&
@ -1054,10 +1059,13 @@ public:
// Emit all the chain and CopyToReg stuff.
bool ChainEmitted = NodeHasChain;
if (NodeHasInFlag || HasImpInputs)
// InFlag and InI1 cannot both be set (checked in
// CodeGenDAGPatterns), so use the same variables for both.
if (NodeHasInFlag || HasImpInputs || NodeHasInI1)
EmitInFlagSelectCode(Pattern, "N", ChainEmitted,
InFlagDecled, ResNodeDecled, true);
if (NodeHasOptInFlag || NodeHasInFlag || HasImpInputs) {
if (NodeHasOptInFlag || NodeHasInFlag || HasImpInputs ||
NodeHasInI1) {
if (!InFlagDecled) {
emitCode("SDValue InFlag(0, 0);");
InFlagDecled = true;
@ -1113,7 +1121,7 @@ public:
}
if (NodeHasChain)
Code += ", MVT::Other";
if (NodeHasOutFlag)
if (NodeHasOutFlag || (NodeHasOutI1 && !CGT.supportsHasI1()))
Code += ", MVT::Flag";
// Inputs.
@ -1173,7 +1181,8 @@ public:
}
Code += ", &Ops" + utostr(OpsNo) + "[0], Ops" + utostr(OpsNo) +
".size()";
} else if (NodeHasInFlag || NodeHasOptInFlag || HasImpInputs)
} else if (NodeHasInFlag || NodeHasOptInFlag || HasImpInputs ||
NodeHasInI1)
AllOps.push_back("InFlag");
unsigned NumOps = AllOps.size();
@ -1207,7 +1216,7 @@ public:
NodeOps.push_back("Tmp" + utostr(ResNo));
} else {
if (NodeHasOutFlag) {
if (NodeHasOutFlag || NodeHasOutI1) {
if (!InFlagDecled) {
After.push_back("SDValue InFlag(ResNode, " +
utostr(NumResults+NumDstRegs+(unsigned)NodeHasChain) +
@ -1228,13 +1237,15 @@ public:
utostr(NumResults+NumDstRegs) + ")");
}
if (NodeHasOutFlag) {
if (NodeHasOutFlag || NodeHasOutI1) {
if (FoldedFlag.first != "") {
ReplaceFroms.push_back("SDValue(" + FoldedFlag.first + ".getNode(), " +
ReplaceFroms.push_back("SDValue(" + FoldedFlag.first +
".getNode(), " +
utostr(FoldedFlag.second) + ")");
ReplaceTos.push_back("InFlag");
} else {
assert(NodeHasProperty(Pattern, SDNPOutFlag, CGP));
assert(NodeHasProperty(Pattern, SDNPOutFlag, CGP) ||
NodeHasProperty(Pattern, SDNPOutI1, CGP));
ReplaceFroms.push_back("SDValue(N.getNode(), " +
utostr(NumPatResults + (unsigned)InputHasChain)
+ ")");
@ -1251,7 +1262,8 @@ public:
}
// User does not expect the instruction would produce a chain!
if ((!InputHasChain && NodeHasChain) && NodeHasOutFlag) {
if ((!InputHasChain && NodeHasChain) &&
(NodeHasOutFlag || NodeHasOutI1)) {
;
} else if (InputHasChain && !NodeHasChain) {
// One of the inner node produces a chain.
@ -1391,6 +1403,8 @@ private:
unsigned OpNo =
(unsigned) NodeHasProperty(N, SDNPHasChain, CGP);
bool HasInFlag = NodeHasProperty(N, SDNPInFlag, CGP);
bool HasInI1 = NodeHasProperty(N, SDNPInI1, CGP);
bool InFlagDefined = false;
for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) {
TreePatternNode *Child = N->getChild(i);
if (!Child->isLeaf()) {
@ -1424,21 +1438,41 @@ private:
emitCode("SDValue InFlag(0, 0);");
InFlagDecled = true;
}
std::string Decl = (!ResNodeDecled) ? "SDNode *" : "";
emitCode(Decl + "ResNode = CurDAG->getCopyToReg(" + ChainName +
if (HasInI1) {
if (!ResNodeDecled) {
emitCode("SDNode * ResNode;");
}
if (T.supportsHasI1())
emitCode("ResNode = CurDAG->getCopyToReg(" + ChainName +
", " + RootName + ".getDebugLoc()" +
", " + getEnumName(RVT) +
", " + getQualifiedName(RR) +
", " + RootName + utostr(OpNo) + ").getNode();");
else
emitCode("ResNode = CurDAG->getCopyToReg(" + ChainName +
", " + RootName + ".getDebugLoc()" +
", " + getQualifiedName(RR) +
", " + RootName + utostr(OpNo) +
", InFlag).getNode();");
InFlagDefined = true;
} else {
std::string Decl = (!ResNodeDecled) ? "SDNode *" : "";
emitCode(Decl + "ResNode = CurDAG->getCopyToReg(" + ChainName +
", " + RootName + ".getDebugLoc()" +
", " + getQualifiedName(RR) +
", " + RootName + utostr(OpNo) + ", InFlag).getNode();");
ResNodeDecled = true;
", " + RootName + utostr(OpNo) +
", InFlag).getNode();");
}
emitCode(ChainName + " = SDValue(ResNode, 0);");
emitCode("InFlag = SDValue(ResNode, 1);");
ResNodeDecled = true;
}
}
}
}
}
if (HasInFlag) {
if (HasInFlag || (HasInI1 && !InFlagDefined)) {
if (!InFlagDecled) {
emitCode("SDValue InFlag = " + RootName +
".getOperand(" + utostr(OpNo) + ");");