RegionList ParallelSelector::getRegions(const core::NodePtr& node) const { RegionList res; auto parallel = node->getNodeManager().getLangBasic().getParallel(); core::visitDepthFirst(core::NodeAddress(node), [&](const core::CallExprAddress& cur)->bool { if (*cur.getAddressedNode()->getFunctionExpr() != *parallel) { return false; } core::JobExprAddress job = cur->getArgument(0).as<core::JobExprAddress>(); core::ExpressionAddress addr = job->getBody(); if(addr->getNodeType() == core::NT_BindExpr) { addr = addr.as<core::BindExprAddress>()->getCall()->getFunctionExpr(); } if (addr->getNodeType() == core::NT_LambdaExpr) { res.push_back(addr.as<core::LambdaExprAddress>()->getBody()); } return true; }, false); return res; }
RegionList PForSelector::getRegions(const core::NodePtr& node) const { RegionList res; auto pfor = node->getNodeManager().getLangExtension<lang::ParallelExtension>().getPFor(); core::visitDepthFirstPrunable(core::NodeAddress(node), [&](const core::CallExprAddress& cur) -> bool { if(*cur.getAddressedNode()->getFunctionExpr() != *pfor) { return false; } res.push_back(cur); return true; }, false); return res; }
RegionList PForBodySelector::getRegions(const core::NodePtr& node) const { RegionList res; auto pfor = node->getNodeManager().getLangExtension<lang::ParallelExtension>().getPFor(); core::visitDepthFirstPrunable(core::NodeAddress(node), [&](const core::CallExprAddress& cur) -> bool { if(*cur.getAddressedNode()->getFunctionExpr() != *pfor) { return false; } core::ExpressionAddress body = cur->getArgument(4); if(body->getNodeType() == core::NT_BindExpr) { body = body.as<core::BindExprAddress>()->getCall()->getFunctionExpr(); } if(body->getNodeType() == core::NT_LambdaExpr) { res.push_back(body.as<core::LambdaExprAddress>()->getBody()); } return true; }, false); return res; }