本文整理汇总了C++中tl::Type::no_ref方法的典型用法代码示例。如果您正苦于以下问题:C++ Type::no_ref方法的具体用法?C++ Type::no_ref怎么用?C++ Type::no_ref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tl::Type
的用法示例。
在下文中一共展示了Type::no_ref方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReferenceScope
static TL::Symbol create_initializer_function_c(
OpenMP::Reduction* red,
TL::Type reduction_type,
Nodecl::NodeclBase construct)
{
std::string fun_name;
{
std::stringstream ss;
ss << "nanos_ini_" << red << "_" << reduction_type.get_internal_type() << "_" << simple_hash_str(construct.get_filename().c_str());
fun_name = ss.str();
}
Nodecl::NodeclBase function_body;
Source src;
src << "void " << fun_name << "("
<< as_type(reduction_type.no_ref().get_lvalue_reference_to()) << " omp_priv,"
<< as_type(reduction_type.no_ref().get_lvalue_reference_to()) << " omp_orig)"
<< "{"
<< statement_placeholder(function_body)
<< "}"
;
Nodecl::NodeclBase function_code = src.parse_global(construct.retrieve_context().get_global_scope());
TL::Scope inside_function = ReferenceScope(function_body).get_scope();
TL::Symbol param_omp_priv = inside_function.get_symbol_from_name("omp_priv");
ERROR_CONDITION(!param_omp_priv.is_valid(), "Symbol omp_priv not found", 0);
TL::Symbol param_omp_orig = inside_function.get_symbol_from_name("omp_orig");
ERROR_CONDITION(!param_omp_orig.is_valid(), "Symbol omp_orig not found", 0);
TL::Symbol function_sym = inside_function.get_symbol_from_name(fun_name);
ERROR_CONDITION(!function_sym.is_valid(), "Symbol %s not found", fun_name.c_str());
Nodecl::NodeclBase initializer = red->get_initializer().shallow_copy();
if (initializer.is<Nodecl::StructuredValue>())
{
Nodecl::StructuredValue structured_value = initializer.as<Nodecl::StructuredValue>();
if (structured_value.get_form().is<Nodecl::StructuredValueBracedImplicit>())
{
structured_value.set_form(Nodecl::StructuredValueCompoundLiteral::make());
}
}
Nodecl::Utils::SimpleSymbolMap translation_map;
translation_map.add_map(red->get_omp_priv(), param_omp_priv);
translation_map.add_map(red->get_omp_orig(), param_omp_orig);
Nodecl::NodeclBase new_initializer = Nodecl::Utils::deep_copy(initializer, inside_function, translation_map);
if (red->get_is_initialization())
{
// The original initializer was something like 'omp_priv = expr1', but the
// new_initializer only represents the lhs expression (in our example, expr1).
// For this reason we create manually an assignment expression.
Nodecl::NodeclBase param_omp_priv_ref = Nodecl::Symbol::make(param_omp_priv);
param_omp_priv_ref.set_type(param_omp_priv.get_type());
function_body.replace(
Nodecl::List::make(
Nodecl::ExpressionStatement::make(
Nodecl::Assignment::make(
param_omp_priv_ref,
new_initializer,
param_omp_priv_ref.get_type().no_ref())
)));
}
else
{
function_body.replace(
Nodecl::List::make(Nodecl::ExpressionStatement::make(new_initializer)));
}
// As the initializer function is needed during the instantiation of
// the task, this function should be inserted before the construct
Nodecl::Utils::prepend_to_enclosing_top_level_location(construct,
function_code);
return function_sym;
}