Enable structural analysis
authorYongjia Zhang <zhang_yong_jia@126.com>
Thu, 17 Jul 2014 18:14:41 +0000 (02:14 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Tue, 8 Jul 2014 06:45:07 +0000 (14:45 +0800)
enable structural analysis and use if, else and endif in the
generated asm.

Signed-off-by: Yongjia Zhang <yongjia.zhang@intel.com>
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
backend/src/llvm/llvm_to_gen.cpp

index 153b11d..328dbc1 100644 (file)
@@ -60,6 +60,8 @@
 #include "llvm/llvm_to_gen.hpp"
 #include "sys/cvar.hpp"
 #include "sys/platform.hpp"
+#include "ir/unit.hpp"
+#include "ir/structural_analysis.hpp"
 
 #include <clang/CodeGen/CodeGenAction.h>
 
@@ -244,6 +246,16 @@ namespace gbe
 #endif
     passes.run(mod);
 
+    const ir::Unit::FunctionSet& fs = unit.getFunctionSet();
+    ir::Unit::FunctionSet::const_iterator iter = fs.begin();
+    while(iter != fs.end())
+    {
+      analysis::ControlTree *ct = new analysis::ControlTree(iter->second);
+      ct->analyze();
+      delete ct;
+      iter++;
+    }
+
     return true;
   }
 } /* namespace gbe */