improve comments on OPC_Record to say what we're recording a node.
authorChris Lattner <sabre@nondot.org>
Wed, 17 Feb 2010 01:03:09 +0000 (01:03 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 17 Feb 2010 01:03:09 +0000 (01:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96433 91177308-0d34-0410-b5e6-96231b3b80d8

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

index b5dabafa5240dc9b0c9df1b0d43d0a7a66848953..e20a00ee313e258d9f166b0ae50ac194fe45453d 100644 (file)
@@ -127,8 +127,14 @@ public:
 
 /// RecordMatcherNode - Save the current node in the operand list.
 class RecordMatcherNode : public MatcherNodeWithChild {
+  /// WhatFor - This is a string indicating why we're recording this.  This
+  /// should only be used for comment generation not anything semantic.
+  std::string WhatFor;
 public:
-  RecordMatcherNode() : MatcherNodeWithChild(Record) {}
+  RecordMatcherNode(StringRef whatfor)
+    : MatcherNodeWithChild(Record), WhatFor(whatfor) {}
+  
+  StringRef getWhatFor() const { return WhatFor; }
   
   static inline bool classof(const MatcherNode *N) {
     return N->getKind() == Record;
index af75d7d71ec2708191478ea1158dca5ed702a2e1..9b37254cbdde575efd9fcf391d4a7fa305a27f35 100644 (file)
@@ -126,7 +126,9 @@ EmitMatcher(const MatcherNode *N, unsigned Indent) {
     OS.PadToColumn(Indent*2) << "OPC_Emit, /*XXX*/\n\n";
     return 1;
   case MatcherNode::Record:
-    OS << "OPC_Record,\n";
+    OS << "OPC_Record,";
+    OS.PadToColumn(CommentIndent) << "// "
+       << cast<RecordMatcherNode>(N)->getWhatFor() << '\n';
     return 1;
   case MatcherNode::MoveChild:
     OS << "OPC_MoveChild, "
index c44be1cad02f99d95ab9b91fbbe07d120862f7c2..5591cfb2a8823100d9f57aac81b3f20d1114c4ed 100644 (file)
@@ -288,7 +288,7 @@ void MatcherGen::EmitMatchCode(const TreePatternNode *N,
           NumRecorded += 2; // Input and output chains.
       } else {
         // If it is a normal named node, we must emit a 'Record' opcode.
-        AddMatcherNode(new RecordMatcherNode());
+        AddMatcherNode(new RecordMatcherNode(N->getName()));
         NumRecorded = 1;
       }
       NextRecordedOperandNo += NumRecorded;