[llvm-commits] [llvm] r60658 - /llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp

Mikhail Glushenkov foldr at codedgers.com
Sun Dec 7 08:42:22 PST 2008


Author: foldr
Date: Sun Dec  7 10:42:22 2008
New Revision: 60658

URL: http://llvm.org/viewvc/llvm-project?rev=60658&view=rev
Log:
Add a (progn)-like construct for (actions). Implemented as a DAG list.

Modified:
    llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp

Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=60658&r1=60657&r2=60658&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Sun Dec  7 10:42:22 2008
@@ -802,11 +802,8 @@
 /// CheckForSuperfluousOptions() to walk the 'case' DAG.
 class ExtractOptionNames {
   llvm::StringSet<>& OptionNames_;
-public:
-  ExtractOptionNames(llvm::StringSet<>& OptionNames) : OptionNames_(OptionNames)
-  {}
 
-  void operator()(const Init* Statement) {
+  void processDag(const Init* Statement) {
     const DagInit& Stmt = InitPtrToDag(Statement);
     const std::string& ActionName = Stmt.getOperator()->getAsString();
     if (ActionName == "forward" || ActionName == "forward_as" ||
@@ -819,10 +816,26 @@
     }
     else if (ActionName == "and" || ActionName == "or") {
       for (unsigned i = 0, NumArgs = Stmt.getNumArgs(); i < NumArgs; ++i) {
-        this->operator()(Stmt.getArg(i));
+        this->processDag(Stmt.getArg(i));
       }
     }
   }
+
+public:
+  ExtractOptionNames(llvm::StringSet<>& OptionNames) : OptionNames_(OptionNames)
+  {}
+
+  void operator()(const Init* Statement) {
+    if (typeid(*Statement) == typeid(ListInit)) {
+      const ListInit& DagList = *static_cast<const ListInit*>(Statement);
+      for (ListInit::const_iterator B = DagList.begin(), E = DagList.end();
+           B != E; ++B)
+        this->processDag(*B);
+    }
+    else {
+      this->processDag(Statement);
+    }
+  }
 };
 
 /// CheckForSuperfluousOptions - Check that there are no side
@@ -1185,12 +1198,9 @@
 /// EmitCaseConstructHandler().
 class EmitActionHandler {
   const OptionDescriptions& OptDescs;
- public:
-  EmitActionHandler(const OptionDescriptions& OD)
-    : OptDescs(OD) {}
 
-  void operator()(const Init* Statement, const char* IndentLevel,
-                  std::ostream& O) const
+  void processActionDag(const Init* Statement, const char* IndentLevel,
+                        std::ostream& O) const
   {
     const DagInit& Dag = InitPtrToDag(Statement);
     const std::string& ActionName = Dag.getOperator()->getAsString();
@@ -1246,6 +1256,23 @@
       throw "Unknown action name: " + ActionName + "!";
     }
   }
+ public:
+  EmitActionHandler(const OptionDescriptions& OD)
+    : OptDescs(OD) {}
+
+  void operator()(const Init* Statement, const char* IndentLevel,
+                  std::ostream& O) const
+  {
+    if (typeid(*Statement) == typeid(ListInit)) {
+      const ListInit& DagList = *static_cast<const ListInit*>(Statement);
+      for (ListInit::const_iterator B = DagList.begin(), E = DagList.end();
+           B != E; ++B)
+        this->processActionDag(*B, IndentLevel, O);
+    }
+    else {
+      this->processActionDag(Statement, IndentLevel, O);
+    }
+  }
 };
 
 // EmitGenerateActionMethod - Emit one of two versions of the





More information about the llvm-commits mailing list