rename the child field to 'next'. This is not a parent/child
authorChris Lattner <sabre@nondot.org>
Thu, 18 Feb 2010 02:53:41 +0000 (02:53 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 18 Feb 2010 02:53:41 +0000 (02:53 +0000)
relationship, this is a linear list relationship.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96561 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/DAGISelMatcher.cpp
utils/TableGen/DAGISelMatcher.h
utils/TableGen/DAGISelMatcherEmitter.cpp
utils/TableGen/DAGISelMatcherGen.cpp

index c6d18ce7dd276d3406efb566bf2320440a5ae98b..8b8c9bf98a104efb3465c5f22bb62b5feb6fc1f5 100644 (file)
@@ -22,98 +22,98 @@ void EmitNodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "EmitNode: Dst = " << *Pattern.getDstPattern() << "\n";
 }
 
-void MatcherNode::printChild(raw_ostream &OS, unsigned indent) const {
-  if (Child)
-    return Child->print(OS, indent);
-  OS.indent(indent) << "<null child>\n";
+void MatcherNode::printNext(raw_ostream &OS, unsigned indent) const {
+  if (Next)
+    return Next->print(OS, indent);
+  OS.indent(indent) << "<null next field>\n";
 }
 
 
 void PushMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "Push\n";
-  printChild(OS, indent+2);
+  printNext(OS, indent+2);
   Failure->print(OS, indent);
 }
 
 void RecordMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "Record\n";
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void MoveChildMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "MoveChild " << ChildNo << '\n';
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void MoveParentMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "MoveParent\n";
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckSameMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "CheckSame " << MatchNumber << '\n';
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckPatternPredicateMatcherNode::
 print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "CheckPatternPredicate " << Predicate << '\n';
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckPredicateMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "CheckPredicate " << PredName << '\n';
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckOpcodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "CheckOpcode " << OpcodeName << '\n';
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "CheckType " << getEnumName(Type) << '\n';
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckIntegerMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "CheckInteger " << Value << '\n';
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckCondCodeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "CheckCondCode ISD::" << CondCodeName << '\n';
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckValueTypeMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "CheckValueType MVT::" << TypeName << '\n';
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckComplexPatMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "CheckComplexPat " << Pattern.getSelectFunc() << '\n';
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckAndImmMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "CheckAndImm " << Value << '\n';
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckOrImmMatcherNode::print(raw_ostream &OS, unsigned indent) const {
   OS.indent(indent) << "CheckOrImm " << Value << '\n';
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckFoldableChainNodeMatcherNode::print(raw_ostream &OS,
                                               unsigned indent) const {
   OS.indent(indent) << "CheckFoldableChainNode\n";
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
 
 void CheckChainCompatibleMatcherNode::print(raw_ostream &OS,
                                               unsigned indent) const {
   OS.indent(indent) << "CheckChainCompatibleMatcherNode " << PreviousOp << "\n";
-  printChild(OS, indent);
+  printNext(OS, indent);
 }
index 4eb11010de90dd4728aeb982db4ef447f6f6fe20..41fbcb4c84a7680bb3b9113ae343be948a1f01ac 100644 (file)
@@ -31,7 +31,9 @@ void EmitMatcherTable(const MatcherNode *Matcher, raw_ostream &OS);
 /// MatcherNode - Base class for all the the DAG ISel Matcher representation
 /// nodes.
 class MatcherNode {
-  OwningPtr<MatcherNode> Child;
+  // The next matcher node that is executed after this one.  Null if this is the
+  // last stage of a match.
+  OwningPtr<MatcherNode> Next;
 public:
   enum KindTy {
     EmitNode,
@@ -63,16 +65,16 @@ public:
   
   KindTy getKind() const { return Kind; }
 
-  MatcherNode *getChild() { return Child.get(); }
-  const MatcherNode *getChild() const { return Child.get(); }
-  void setChild(MatcherNode *C) { Child.reset(C); }
+  MatcherNode *getNext() { return Next.get(); }
+  const MatcherNode *getNext() const { return Next.get(); }
+  void setNext(MatcherNode *C) { Next.reset(C); }
   
   static inline bool classof(const MatcherNode *) { return true; }
   
   virtual void print(raw_ostream &OS, unsigned indent = 0) const = 0;
   void dump() const;
 protected:
-  void printChild(raw_ostream &OS, unsigned indent) const;
+  void printNext(raw_ostream &OS, unsigned indent) const;
 };
   
 /// EmitNodeMatcherNode - This signals a successful match and generates a node.
@@ -93,14 +95,14 @@ public:
 
 
 /// PushMatcherNode - This pushes a failure scope on the stack and evaluates
-/// 'child'.  If 'child' fails to match, it pops its scope and attempts to
+/// 'Next'.  If 'Next' fails to match, it pops its scope and attempts to
 /// match 'Failure'.
 class PushMatcherNode : public MatcherNode {
   OwningPtr<MatcherNode> Failure;
 public:
-  PushMatcherNode(MatcherNode *child = 0, MatcherNode *failure = 0)
+  PushMatcherNode(MatcherNode *next = 0, MatcherNode *failure = 0)
     : MatcherNode(Push), Failure(failure) {
-    setChild(child);
+    setNext(next);
   }
   
   MatcherNode *getFailure() { return Failure.get(); }
index ea134fe9d2f344293020a208c0b7ec2728ba5814..5d468194d79aa31a6d9e2a14afa03e4c578d5863 100644 (file)
@@ -76,7 +76,7 @@ class MatcherTableEmitter {
 public:
   MatcherTableEmitter(formatted_raw_ostream &os) : OS(os) {}
 
-  unsigned EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent);
+  unsigned EmitMatcherList(const MatcherNode *N, unsigned Indent);
   
   void EmitPredicateFunctions();
 private:
@@ -217,9 +217,9 @@ EmitMatcher(const MatcherNode *N, unsigned Indent) {
   return 0;
 }
 
-/// EmitMatcherAndChildren - Emit the bytes for the specified matcher subtree.
+/// EmitMatcherList - Emit the bytes for the specified matcher subtree.
 unsigned MatcherTableEmitter::
-EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent) {
+EmitMatcherList(const MatcherNode *N, unsigned Indent) {
   unsigned Size = 0;
   while (N) {
     // Push is a special case since it is binary.
@@ -228,25 +228,25 @@ EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent) {
       // emitting either of them.  Handle this by buffering the output into a
       // string while we get the size.
       SmallString<128> TmpBuf;
-      unsigned ChildSize;
+      unsigned NextSize;
       {
         raw_svector_ostream OS(TmpBuf);
         formatted_raw_ostream FOS(OS);
-        ChildSize = 
-          EmitMatcherAndChildren(cast<PushMatcherNode>(N)->getChild(),Indent+1);
+        NextSize = EmitMatcherList(cast<PushMatcherNode>(N)->getNext(),
+                                   Indent+1);
       }
       
-      if (ChildSize > 255) {
+      if (NextSize > 255) {
         errs() <<
           "Tblgen internal error: can't handle predicate this complex yet\n";
         exit(1);
       }
       
       OS.PadToColumn(Indent*2);
-      OS << "OPC_Push, " << ChildSize << ",\n";
+      OS << "OPC_Push, " << NextSize << ",\n";
       OS << TmpBuf.str();
       
-      Size += 2 + ChildSize;
+      Size += 2 + NextSize;
       
       N = PMN->getFailure();
       continue;
@@ -254,9 +254,9 @@ EmitMatcherAndChildren(const MatcherNode *N, unsigned Indent) {
   
     Size += EmitMatcher(N, Indent);
     
-    // If there are children of this node, iterate to them, otherwise we're
+    // If there are other nodes in this list, iterate to them, otherwise we're
     // done.
-    N = N->getChild();
+    N = N->getNext();
   }
   return Size;
 }
@@ -311,7 +311,7 @@ void llvm::EmitMatcherTable(const MatcherNode *Matcher, raw_ostream &O) {
   MatcherTableEmitter MatcherEmitter(OS);
 
   OS << "  static const unsigned char MatcherTable[] = {\n";
-  unsigned TotalSize = MatcherEmitter.EmitMatcherAndChildren(Matcher, 2);
+  unsigned TotalSize = MatcherEmitter.EmitMatcherList(Matcher, 2);
   OS << "    0\n  }; // Total Array size is " << (TotalSize+1) << " bytes\n\n";
   OS << "  return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n";
   OS << "\n";
index abe0d2a6f84a67b2cf2c6d8b61ebf7df0500d2f8..53f248e69233740da11802cb26d0ff3a5b8e20c8 100644 (file)
@@ -38,7 +38,7 @@ namespace {
     MatcherNode *Matcher;
     
     /// CurPredicate - As we emit matcher nodes, this points to the latest check
-    /// which should have future checks stuck into its child position.
+    /// which should have future checks stuck into its Next position.
     MatcherNode *CurPredicate;
   public:
     MatcherGen(const PatternToMatch &pattern, const CodeGenDAGPatterns &cgp);
@@ -109,7 +109,7 @@ void MatcherGen::InferPossibleTypes() {
 /// AddMatcherNode - Add a matcher node to the current graph we're building. 
 void MatcherGen::AddMatcherNode(MatcherNode *NewNode) {
   if (CurPredicate != 0)
-    CurPredicate->setChild(NewNode);
+    CurPredicate->setNext(NewNode);
   else
     Matcher = NewNode;
   CurPredicate = NewNode;
@@ -389,7 +389,7 @@ MatcherNode *llvm::ConvertPatternToMatcher(const PatternToMatch &Pattern,
   
   // Link it into the pattern.
   if (MatcherNode *Pred = Gen.GetCurPredicate()) {
-    Pred->setChild(Result);
+    Pred->setNext(Result);
     return Gen.GetMatcher();
   }