Ejemplo n.º 1
0
bool casting_needs_reinterpr_or_pack(TL::Type& casted_type, TL::Type& cast_type) 
{
    if (casted_type.is_float())
    {
        if (cast_type.is_float())
            return false;
        else
            return true;
    }
    else if (casted_type.is_double())
    {
        if (cast_type.is_double())
            return false;
        else
            return true;
    }
    else if (casted_type.is_signed_int()
            || casted_type.is_unsigned_int())
    {
        if (cast_type.is_signed_int()
                || cast_type.is_unsigned_int())
            return false;
        else
            return true;
    }
    else if (casted_type.is_signed_short_int()
            || casted_type.is_unsigned_short_int())
    {
        if (cast_type.is_signed_short_int()
                || cast_type.is_unsigned_short_int())
            return false;
        else
            return true;
    }
    else if (casted_type.is_signed_char()
            || casted_type.is_unsigned_char()
            || casted_type.is_char())
    {
        if (cast_type.is_signed_char()
                || cast_type.is_unsigned_char()
                || cast_type.is_char())
            return false;
        else
            return true;
    }
    else
    {
        fatal_error("error: casting_needs_reinterpr_or_pack does not support this casting in HLT SIMD.\n");
    }
}
Ejemplo n.º 2
0
        void NeonVectorBackend::visit(const Nodecl::VectorAdd& n)
        {
            walk(n.get_lhs());
            walk(n.get_rhs());

            TL::Type t = n.get_type();
            ERROR_CONDITION(!t.is_vector(), "Invalid type", 0);
            TL::Type element = t.vector_element();
            ERROR_CONDITION(!element.is_float(), "Not implemented: %s", print_declarator(element.get_internal_type()));

            TL::Symbol builtin_fun = TL::Scope::get_global_scope().get_symbol_from_name("vaddq_f32");
            ERROR_CONDITION(!builtin_fun.is_valid(), "Symbol not found", 0);

            n.replace(
                    Nodecl::FunctionCall::make(
                        builtin_fun.make_nodecl(/* set_ref_type */ true),
                        Nodecl::List::make(
                            n.get_lhs(),
                            n.get_rhs()),
                        /* alternate-name */ Nodecl::NodeclBase::null(),
                        /* function-form */ Nodecl::NodeclBase::null(),
                        n.get_type(),
                        n.get_locus()
                        )
                    );
        }
Ejemplo n.º 3
0
    void KNCModuleVisitor::visit(const Nodecl::VectorBitwiseXor& node) 
    { 
        TL::Type type = node.get_type().basic_type();

        // Intrinsic name
        file << "_mm512_xor";
        
        // Postfix
        if (type.is_float()) 
        { 
            file << "_ps"; 
        } 
        else if (type.is_integral_type())
        { 
            file << "_si128"; 
        }
        else
        {
            running_error("KNC Codegen: Node %s at %s has an unsupported type.", 
                    ast_print_node_type(node.get_kind()),
                    node.get_locus_str().c_str());
        }      

        file << "("; 
        walk(node.get_lhs());
        file << ", ";
        walk(node.get_rhs());
        file << ")"; 
    }   
Ejemplo n.º 4
0
    void KNCModuleVisitor::visit(const Nodecl::VectorMinus& node) 
    { 
        TL::Type type = node.get_type().basic_type();

        // Intrinsic name
        file << "_mm512_sub";
        
        // Postfix
        if (type.is_float()) 
        { 
            file << "_ps"; 
        } 
        else if (type.is_double()) 
        { 
            file << "_pd"; 
        } 
        else if (type.is_signed_int() ||
            type.is_unsigned_int()) 
        { 
            file << "_epi32"; 
        } 
        else if (type.is_signed_short_int() ||
            type.is_unsigned_short_int()) 
        { 
            file << "_epi16"; 
        } 
        else if (type.is_char() || 
            type.is_signed_char() ||
            type.is_unsigned_char()) 
        { 
            file << "_epi8"; 
        } 
        else
        {
            running_error("KNC Codegen: Node %s at %s has an unsupported type.", 
                    ast_print_node_type(node.get_kind()),
                    node.get_locus_str().c_str());
        }      

        file << "("; 
        walk(node.get_lhs());
        file << ", ";
        walk(node.get_rhs());
        file << ")"; 
    }                                                 
Ejemplo n.º 5
0
        bool VectorizerVectorReduction::is_supported_reduction(bool is_builtin,
                const std::string& reduction_name,
                const TL::Type& reduction_type)
        {
            if(is_builtin)
            {
                if(_environment._device.compare("smp") == 0)
                {
                    if(reduction_name.compare("+") == 0)
                    {
                        if(reduction_type.is_signed_int())
                        {
                            return true;
                        }
                    }
                }
                else if(_environment._device.compare("knc") == 0)
                {
                    if((reduction_name.compare("+") == 0) ||
                            (reduction_name.compare("-") == 0))
                    {
                        if(reduction_type.is_signed_int())
                        {
                            return true;
                        }
                        else if(reduction_type.is_float())
                        {
                            return true;
                        }
                        else if (reduction_type.is_double())
                        {
                            return true;
                        }
                    }
                }
            }

            return false;
        }