aboutsummaryrefslogtreecommitdiffstats
path: root/utils/TableGen
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2005-12-12 19:37:43 +0000
committerEvan Cheng <evan.cheng@apple.com>2005-12-12 19:37:43 +0000
commit8621789fccec5a89eab3c94c0a7e3e048964dfe0 (patch)
treefb0caf05a4383bb524d81b98cc83a36d63f7a6b7 /utils/TableGen
parent361f45a5572e8be309fa71c6f677ac4e4233ea04 (diff)
downloadexternal_llvm-8621789fccec5a89eab3c94c0a7e3e048964dfe0.zip
external_llvm-8621789fccec5a89eab3c94c0a7e3e048964dfe0.tar.gz
external_llvm-8621789fccec5a89eab3c94c0a7e3e048964dfe0.tar.bz2
Bug fix: finding the correct incoming chain for pattern with nested src operand. And a minor change to make output code slightly more readible.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24669 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen')
-rw-r--r--utils/TableGen/DAGISelEmitter.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/utils/TableGen/DAGISelEmitter.cpp b/utils/TableGen/DAGISelEmitter.cpp
index 05a9c62..bcb28a6 100644
--- a/utils/TableGen/DAGISelEmitter.cpp
+++ b/utils/TableGen/DAGISelEmitter.cpp
@@ -1040,14 +1040,15 @@ FindPatternInputsAndOutputs(TreePattern *I, TreePatternNode *Pat,
for (unsigned i = 0; i != NumValues; ++i) {
TreePatternNode *Dest = Pat->getChild(i);
if (!Dest->isLeaf())
- I->error("set destination should be a virtual register!");
+ I->error("set destination should be a register!");
DefInit *Val = dynamic_cast<DefInit*>(Dest->getLeafValue());
if (!Val)
- I->error("set destination should be a virtual register!");
+ I->error("set destination should be a register!");
- if (!Val->getDef()->isSubClassOf("RegisterClass"))
- I->error("set destination should be a virtual register!");
+ if (!Val->getDef()->isSubClassOf("RegisterClass") &&
+ !Val->getDef()->isSubClassOf("Register"))
+ I->error("set destination should be a register!");
if (Dest->getName().empty())
I->error("set destination must have a name!");
if (InstResults.count(Dest->getName()))
@@ -1726,10 +1727,9 @@ private:
std::ostream &OS;
// Node to name mapping
std::map<std::string,std::string> VariableMap;
- // Name of the inner most node which produces a chain.
- std::string InnerChain;
// Names of all the folded nodes which produce chains.
std::vector<std::string> FoldedChains;
+ bool FoundChain;
bool InFlag;
unsigned TmpNo;
@@ -1737,7 +1737,7 @@ public:
PatternCodeEmitter(DAGISelEmitter &ise, TreePatternNode *lhs,
unsigned PatNum, std::ostream &os) :
ISE(ise), LHS(lhs), PatternNo(PatNum), OS(os),
- InFlag(false), TmpNo(0) {};
+ FoundChain(false), InFlag(false), TmpNo(0) {};
/// 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
@@ -1776,7 +1776,8 @@ public:
// Emit code to load the child nodes and match their contents recursively.
unsigned OpNo = 0;
- if (NodeHasChain(N, ISE)) {
+ bool HasChain = NodeHasChain(N, ISE);
+ if (HasChain) {
OpNo = 1;
if (!isRoot) {
const SDNodeInfo &CInfo = ISE.getSDNodeInfo(N->getOperator());
@@ -1786,11 +1787,6 @@ public:
<< ".getValue(" << CInfo.getNumResults() << "))) goto P"
<< PatternNo << "Fail; // Already selected for a chain use?\n";
}
- if (InnerChain.empty()) {
- OS << " SDOperand " << RootName << "0 = " << RootName
- << ".getOperand(0);\n";
- InnerChain = RootName + "0";
- }
}
for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i, ++OpNo) {
@@ -1862,6 +1858,13 @@ public:
}
}
+ if (HasChain) {
+ if (!FoundChain) {
+ OS << " SDOperand Chain = " << RootName << ".getOperand(0);\n";
+ FoundChain = true;
+ }
+ }
+
// If there is a node predicate for this, emit the call.
if (!N->getPredicateFn().empty())
OS << " if (!" << N->getPredicateFn() << "(" << RootName
@@ -1988,7 +1991,7 @@ public:
// Emit all the chain and CopyToReg stuff.
if (II.hasCtrlDep)
- OS << " SDOperand Chain = Select(" << InnerChain << ");\n";
+ OS << " Chain = Select(Chain);\n";
EmitCopyToRegs(LHS, "N", II.hasCtrlDep);
const DAGInstruction &Inst = ISE.getInstruction(Op);