本文整理汇总了C++中tl::Type::get_array_to方法的典型用法代码示例。如果您正苦于以下问题:C++ Type::get_array_to方法的具体用法?C++ Type::get_array_to怎么用?C++ Type::get_array_to使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tl::Type
的用法示例。
在下文中一共展示了Type::get_array_to方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_distribution
TL::Source LoopDistribution::do_distribution()
{
TL::Statement loop_body = _for_stmt.get_loop_body();
if (!loop_body.is_compound_statement())
{
return _for_stmt.prettyprint();
}
TL::Source result;
TL::Source distributed_loops, expanded_scalars;
result
<< "{"
<< expanded_scalars
<< distributed_loops
<< "}"
;
TL::ReplaceIdExpression escalar_expansion;
if (!_expand.empty())
{
if (!_for_stmt.is_regular_loop())
{
return _for_stmt.prettyprint();
}
expanded_scalars
<< "int __loop_trip = (" << _for_stmt.get_upper_bound() << ") - (" << _for_stmt.get_lower_bound() << " + 1);"
// Absolute value (calculated this way allows for conditional move instructions)
<< "__loop_trip = (__loop_trip < 0) ? (-__loop_trip) : __loop_trip;"
;
// We need this because of array nature
TL::AST_t array_expr;
{
TL::AST_t array_expr_ref_tree;
Source temporal_parse;
temporal_parse
<< "{"
<< expanded_scalars
<< statement_placeholder(array_expr_ref_tree)
<< "}"
;
temporal_parse.parse_statement(_for_stmt.get_ast(),
_for_stmt.get_scope_link());
array_expr = Source("__loop_trip").parse_expression(array_expr_ref_tree,
_for_stmt.get_scope_link());
}
for (TL::ObjectList<TL::Symbol>::iterator it = _expand.begin();
it != _expand.end();
it++)
{
TL::Symbol &sym(*it);
std::string expanded_scalar_name = "_" + sym.get_name();
TL::Type type = sym.get_type();
TL::Type array_type = type.get_array_to(array_expr,
_for_stmt.get_scope_link().get_scope(array_expr));
expanded_scalars
<< array_type.get_declaration(it->get_scope(), expanded_scalar_name) << ";";
escalar_expansion.add_replacement(sym,
expanded_scalar_name + "[" + _for_stmt.get_induction_variable().prettyprint() + "]" );
}
}
TL::ObjectList<TL::Statement> statement_list = loop_body.get_inner_statements();
for (TL::ObjectList<TL::Statement>::iterator it = statement_list.begin();
it != statement_list.end();
it++)
{
Statement &stmt(*it);
distributed_loops
<< "for ( " << _for_stmt.get_iterating_init().prettyprint() // This one already includes ';'
<< _for_stmt.get_iterating_condition() << ";"
<< _for_stmt.get_iterating_expression() << ")"
<< "{"
<< escalar_expansion.replace(stmt)
<< "}"
;
}
return result;
}