summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2008-12-07 16:42:22 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2008-12-07 16:42:22 +0000
commit35a46f808be50f59e9b73f95913bc5028f7496b7 (patch)
tree3d38ef9671dc89efbf941e0da74c33ae8ea393b1
parent7429d925f02182f357969683d0ba69c412057c34 (diff)
downloadbcm5719-llvm-35a46f808be50f59e9b73f95913bc5028f7496b7.tar.gz
bcm5719-llvm-35a46f808be50f59e9b73f95913bc5028f7496b7.zip
Add a (progn)-like construct for (actions). Implemented as a DAG list.
llvm-svn: 60658
-rw-r--r--llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp47
1 files changed, 37 insertions, 10 deletions
diff --git a/llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp b/llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp
index 175de459259..3456b9abce4 100644
--- a/llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp
+++ b/llvm/utils/TableGen/LLVMCConfigurationEmitter.cpp
@@ -802,11 +802,8 @@ void WalkCase(Init* Case, F1 TestCallback, F2 StatementCallback) {
/// 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 @@ public:
}
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 @@ void EmitForwardOptionPropertyHandlingCode (const OptionDescription& D,
/// 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 @@ class EmitActionHandler {
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
OpenPOWER on IntegriCloud