Nodecl::Symbol Symbol::make_nodecl(bool set_ref_type, const locus_t* locus) const { Nodecl::Symbol sym = Nodecl::Symbol::make(*this, locus); if (set_ref_type) { TL::Type t = this->get_type(); if (!t.is_any_reference()) t = t.get_lvalue_reference_to(); sym.set_type(t); } else { sym.set_type(this->get_type()); } // Set constant (currently only for variables) if (this->is_variable() && this->get_type().is_const() && !this->is_parameter() // avoid 'void f(const int n = 3)' && !this->get_value().is_null() && this->get_value().is_constant()) { sym.set_constant(this->get_value().get_constant()); } return sym; }
virtual void visit(const Nodecl::Symbol& node) { TL::Symbol sym = node.get_symbol(); auto it = _m.find(sym); if (it != _m.end()) { node.replace(Source(it->second).parse_expression(_scope)); } }
void visit(const Nodecl::Symbol& node) { TL::Symbol sym = node.get_symbol(); std::map<TL::Symbol, Nodecl::NodeclBase>::const_iterator it = _reduction_symbol_to_nodecl_map.find(sym); if (it == _reduction_symbol_to_nodecl_map.end()) return; node.replace(it->second.shallow_copy()); }
void visit(const Nodecl::Symbol& node) { TL::Symbol sym = node.get_symbol(); if ((_data_sharing.get_data_sharing(sym, /* check_enclosing */ false) & ~DS_IMPLICIT) == DS_UNDEFINED) { // Mark this as an implicit firstprivate _data_sharing.set_data_sharing(sym, TL::OpenMP::DataSharingAttribute( DS_FIRSTPRIVATE | DS_IMPLICIT) ); std::cerr << node.get_locus_str() << ": warning: assuming '" << sym.get_qualified_name() << "' as firstprivate" << std::endl; } }
Nodecl::Symbol Symbol::make_nodecl(bool set_ref_type, const locus_t* locus) const { Nodecl::Symbol sym = Nodecl::Symbol::make(*this, locus); if (set_ref_type) { TL::Type t = this->get_type(); if (!t.is_any_reference()) t = t.get_lvalue_reference_to(); sym.set_type(t); } return sym; }
int SuitableAlignmentVisitor::visit( const Nodecl::Symbol& n ) { if (is_suitable_expression(n)) { return 0; } else if( n.is_constant( ) ) { int value = const_value_cast_to_signed_int( n.get_constant( )) * _type_size; if(is_suitable_constant(value)) return 0; else return value; } else if( Utils::induction_variable_list_contains_variable( _induction_variables, n ) ) { Utils::InductionVariableData* iv = Utils::get_induction_variable_from_list( _induction_variables, n ); Nodecl::Utils::ReduceExpressionVisitor v; Nodecl::NodeclBase lb = iv->get_lb( ).shallow_copy( ); v.walk( lb ); if( lb.is_constant( ) ) { Nodecl::NodeclBase incr = iv->get_increment( ).shallow_copy( ); v.walk( incr ); if( incr.is_constant( ) ) { return (const_value_cast_to_signed_int( lb.get_constant( ) ) + ( const_value_cast_to_signed_int( incr.get_constant( ) ) * _unroll_factor)) * _type_size; } } } return -1; }
virtual void visit(const Nodecl::Symbol& node) { TL::Symbol sym = node.get_symbol(); if (_sym == sym) exist = true; }
void VectorizerVisitorExpression::visit(const Nodecl::Symbol& n) { TL::Type sym_type = n.get_type(); //std::cerr << "scalar_type: " << n.prettyprint() << std::endl; if (!sym_type.is_vector()) { // Vectorize BASIC induction variable if (Vectorizer::_analysis_info->is_basic_induction_variable( Vectorizer::_analysis_scopes->back(), n)) { std::cerr << "Basic IV: " << n.prettyprint() << "\n"; // Computing IV offset {0, 1, 2, 3} TL::ObjectList<Nodecl::NodeclBase> literal_list; const_value_t *ind_var_increment = Vectorizer::_analysis_info->get_induction_variable_increment( Vectorizer::_analysis_scopes->back(), n); for(const_value_t *i = const_value_get_zero(4, 0); const_value_is_nonzero(const_value_lt(i, const_value_get_unsigned_int(_unroll_factor))); i = const_value_add(i, ind_var_increment)) { literal_list.prepend(const_value_to_nodecl(i)); } Nodecl::List offset = Nodecl::List::make(literal_list); // IV cannot be a reference TL::Type ind_var_type = get_qualified_vector_to(n.get_type(), _vector_length).no_ref(); TL::Type offset_type = ind_var_type; Nodecl::ParenthesizedExpression vector_induction_var = Nodecl::ParenthesizedExpression::make( Nodecl::VectorAdd::make( Nodecl::VectorPromotion::make( n.shallow_copy(), ind_var_type, n.get_locus()), Nodecl::VectorLiteral::make( offset, offset_type, n.get_locus()), get_qualified_vector_to(n.get_type(), _vector_length), n.get_locus()), get_qualified_vector_to(n.get_type(), _vector_length), n.get_locus()); n.replace(vector_induction_var); } // Vectorize symbols declared in the SIMD scope else if (is_declared_in_scope( _simd_inner_scope.get_decl_context().current_scope, n.get_symbol().get_scope().get_decl_context().current_scope)) { //std::cerr << "NS scalar_type: " << n.prettyprint() << std::endl; TL::Symbol tl_sym = n.get_symbol(); TL::Type tl_sym_type = tl_sym.get_type(); //TL::Symbol if (tl_sym_type.is_scalar_type()) { //std::cerr << "TS scalar_type: " << n.prettyprint() << std::endl; tl_sym.set_type(get_qualified_vector_to(tl_sym_type, _vector_length)); tl_sym_type = tl_sym.get_type(); } //Nodecl::Symbol Nodecl::Symbol new_sym = Nodecl::Symbol::make(tl_sym, n.get_locus()); new_sym.set_type(tl_sym_type.get_lvalue_reference_to()); n.replace(new_sym); } // Vectorize constants else if (Vectorizer::_analysis_info->is_constant( Vectorizer::_analysis_scopes->back(), n)) { const Nodecl::VectorPromotion vector_prom = Nodecl::VectorPromotion::make( n.shallow_copy(), get_qualified_vector_to(sym_type, _vector_length), n.get_locus()); n.replace(vector_prom); } else { //TODO: If you are from outside of the loop -> Vector local copy. running_error("Vectorizer: Loop is not vectorizable. '%s' is not IV or Constant or Local.", n.get_symbol().get_name().c_str()); } } }