From 75ff98e4d65862ff5b36b533b4f6e3ea71ede1d5 Mon Sep 17 00:00:00 2001 From: Tuowen Zhao Date: Sat, 17 Sep 2016 03:22:53 +0000 Subject: cmake build --- chill/src/ir_rose_utils.cc | 88 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 chill/src/ir_rose_utils.cc (limited to 'chill/src/ir_rose_utils.cc') diff --git a/chill/src/ir_rose_utils.cc b/chill/src/ir_rose_utils.cc new file mode 100644 index 0000000..fbce2f1 --- /dev/null +++ b/chill/src/ir_rose_utils.cc @@ -0,0 +1,88 @@ +/***************************************************************************** + Copyright (C) 2008 University of Southern California + Copyright (C) 2009 University of Utah + All Rights Reserved. + + Purpose: + SUIF interface utilities. + + Notes: + + Update history: + 01/2006 created by Chun Chen +*****************************************************************************/ + +//#include +//#include +//#include +//#include +//#include +#include "ir_rose_utils.hh" + + + +std::vector find_loops(SgNode *tnl) { + std::vector result; + + //tree_node_list_iter iter(tnl); + + /*while (!iter.is_empty()) { + tree_node *tn = iter.step(); + if (tn->kind() == TREE_FOR) + result.push_back(static_cast(tn)); + } + */ + + SgStatementPtrList& blockStatements = isSgBasicBlock(tnl)->get_statements(); + for(SgStatementPtrList::const_iterator j = blockStatements.begin(); j != blockStatements.end(); j++) + if(isSgForStatement(*j)) + result.push_back(isSgForStatement(*j)); + + return result; +} + +std::vector find_deepest_loops(SgStatementPtrList& tnl) { + + std::vector loops; + + + + for(SgStatementPtrList::const_iterator j = tnl.begin(); j != tnl.end(); j++) + { + std::vector t = find_deepest_loops(isSgNode(*j)); + if (t.size() > loops.size()) + loops = t; + } + + + + return loops; + +} + + + + + + + + +std::vector find_deepest_loops(SgNode *tn) { + if (isSgForStatement(tn)) { + std::vector loops; + + SgForStatement *tnf = static_cast(tn); + loops.insert(loops.end(), tnf); + std::vector t = find_deepest_loops(isSgNode(tnf->get_loop_body())); + std::copy(t.begin(), t.end(), std::back_inserter(loops)); + + return loops; + } + else if (isSgBasicBlock(tn)) { + SgBasicBlock *tnb = static_cast(tn); + return find_deepest_loops(tnb->get_statements()); + } + else + return std::vector(); +} + -- cgit v1.2.3-70-g09d2