Commit 7948ae37 by Olivier Hainque

ada-tree.h (TYPE_REPRESENTATIVE_ARRAY): New language specific node.

        ada/
        * gcc-interface/ada-tree.h (TYPE_REPRESENTATIVE_ARRAY): New language
        specific node.  Representative array type for VECTOR_TYPE entities.
        * gcc-interface/utils.c (handle_vector_type_attribute): New handler.
        Turn an ARRAY_TYPE entity into a VECTOR_TYPE.
        (gnat_types_compatible_p): Handle VECTOR_TYPEs.
        (convert): Likewise.  Arrange to produce VECTOR_CST out of constant
        array aggregates for VECTOR_TYPE entities.
        (unchecked_convert): Likewise.
        (maybe_vector_array): New function. If EXP has VECTOR_TYPE, return EXP
        converted to the associated TYPE_REPRESENTATIVE_ARRAY.
        (handle_pure_attribute, handle_sentinel_attribute,
        handle_noreturn_attribute, handle_malloc_attribute,
        handle_vector_size_attribute): Replace uses of qE format by qs.
        Remove GCC_DIAG_STYLE definition.
        * gcc-interface/trans.c (gnat_to_gnu) <N_Indexed_Component>: Convert
        vector input to representative array type on entry.
        <N_Op_Eq, etc>: Likewise.
        * gcc-interface/gigi.h (maybe_vector_array): Declare.
        (VECTOR_TYPE_P): New predicate.
        * gcc-interface/misc.c (gnat_print_type): Handle VECTOR_TYPE.

        testsuite/
        * gnat.dg/sse_nolib.adb: New testcase.

From-SVN: r152165
parent 6e1ee24b
2009-09-22 Olivier Hainquqe <hainque@adacore.com>
Eric Botcazou <botcazou@adacore.com>
* gcc-interface/ada-tree.h (TYPE_REPRESENTATIVE_ARRAY): New language
specific node. Representative array type for VECTOR_TYPE entities.
* gcc-interface/utils.c (handle_vector_type_attribute): New handler.
Turn an ARRAY_TYPE entity into a VECTOR_TYPE.
(gnat_types_compatible_p): Handle VECTOR_TYPEs.
(convert): Likewise. Arrange to produce VECTOR_CST out of constant
array aggregates for VECTOR_TYPE entities.
(unchecked_convert): Likewise.
(maybe_vector_array): New function. If EXP has VECTOR_TYPE, return EXP
converted to the associated TYPE_REPRESENTATIVE_ARRAY.
(handle_pure_attribute, handle_sentinel_attribute,
handle_noreturn_attribute, handle_malloc_attribute,
handle_vector_size_attribute): Replace uses of qE format by qs.
Remove GCC_DIAG_STYLE definition.
* gcc-interface/trans.c (gnat_to_gnu) <N_Indexed_Component>: Convert
vector input to representative array type on entry.
<N_Op_Eq, etc>: Likewise.
* gcc-interface/gigi.h (maybe_vector_array): Declare.
(VECTOR_TYPE_P): New predicate.
* gcc-interface/misc.c (gnat_print_type): Handle VECTOR_TYPE.
2009-09-24 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/ada.h: Fix outdated comment.
......
......@@ -195,6 +195,10 @@ do { \
refer to the routine gnat_to_gnu_entity. */
#define TYPE_CI_CO_LIST(NODE) TYPE_LANG_SLOT_1 (FUNCTION_TYPE_CHECK (NODE))
/* For a VECTOR_TYPE, this is the representative array type. */
#define TYPE_REPRESENTATIVE_ARRAY(NODE) \
TYPE_LANG_SLOT_1 (VECTOR_TYPE_CHECK (NODE))
/* For numerical types, this holds various RM-defined values. */
#define TYPE_RM_VALUES(NODE) TYPE_LANG_SLOT_1 (NUMERICAL_TYPE_CHECK (NODE))
......
......@@ -750,6 +750,10 @@ extern tree remove_conversions (tree exp, bool true_address);
likewise return an expression pointing to the underlying array. */
extern tree maybe_unconstrained_array (tree exp);
/* If EXP's type is a VECTOR_TYPE, return EXP converted to the associated
TYPE_REPRESENTATIVE_ARRAY. */
extern tree maybe_vector_array (tree exp);
/* Return an expression that does an unchecked conversion of EXPR to TYPE.
If NOTRUNC_P is true, truncation operations should be suppressed. */
extern tree unchecked_convert (tree type, tree expr, bool notrunc_p);
......@@ -951,3 +955,6 @@ extern Nat get_target_double_scalar_alignment (void);
#ifndef TARGET_MALLOC64
#define TARGET_MALLOC64 0
#endif
/* Convenient shortcuts. */
#define VECTOR_TYPE_P(TYPE) (TREE_CODE (TYPE) == VECTOR_TYPE)
......@@ -521,6 +521,11 @@ gnat_print_type (FILE *file, tree node, int indent)
print_node (file,"actual bounds", TYPE_ACTUAL_BOUNDS (node), indent + 4);
break;
case VECTOR_TYPE:
print_node (file,"representative array",
TYPE_REPRESENTATIVE_ARRAY (node), indent + 4);
break;
case RECORD_TYPE:
if (TYPE_IS_FAT_POINTER_P (node) || TYPE_CONTAINS_TEMPLATE_P (node))
print_node (file, "unconstrained array",
......
......@@ -3832,6 +3832,11 @@ gnat_to_gnu (Node_Id gnat_node)
Node_Id *gnat_expr_array;
gnu_array_object = maybe_implicit_deref (gnu_array_object);
/* Convert vector inputs to their representative array type, to fit
what the code below expects. */
gnu_array_object = maybe_vector_array (gnu_array_object);
gnu_array_object = maybe_unconstrained_array (gnu_array_object);
/* If we got a padded type, remove it too. */
......@@ -4077,6 +4082,8 @@ gnat_to_gnu (Node_Id gnat_node)
&& TYPE_CONTAINS_TEMPLATE_P (gnu_result_type))
gnu_aggr_type
= TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (gnu_result_type)));
else if (TREE_CODE (gnu_result_type) == VECTOR_TYPE)
gnu_aggr_type = TYPE_REPRESENTATIVE_ARRAY (gnu_result_type);
if (Null_Record_Present (gnat_node))
gnu_result = gnat_build_constructor (gnu_aggr_type, NULL_TREE);
......@@ -4272,6 +4279,12 @@ gnat_to_gnu (Node_Id gnat_node)
gnu_rhs = gnat_to_gnu (Right_Opnd (gnat_node));
gnu_type = gnu_result_type = get_unpadded_type (Etype (gnat_node));
/* Pending generic support for efficient vector logical operations in
GCC, convert vectors to their representative array type view and
fallthrough. */
gnu_lhs = maybe_vector_array (gnu_lhs);
gnu_rhs = maybe_vector_array (gnu_rhs);
/* If this is a comparison operator, convert any references to
an unconstrained array value into a reference to the
actual array. */
......
2009-09-25 Olivier Hainque <hainque@adacore.com>
* gnat.dg/sse_nolib.adb: New testcase.
2009-09-25 Revital Eres <ERES@il.ibm.com>
* gcc.target/powerpc/vsx-vectorize-8.c: New test.
......
-- { dg-do run { target i?86-*-* x86_64-*-* } }
-- { dg-options "-O1 -msse" }
with Ada.Unchecked_Conversion;
procedure SSE_Nolib is
-- Base vector type definitions
package SSE_Types is
VECTOR_ALIGN : constant := 16;
VECTOR_BYTES : constant := 16;
type m128 is private;
private
type m128 is array (1 .. 4) of Float;
for m128'Alignment use VECTOR_ALIGN;
pragma Machine_Attribute (m128, "vector_type");
pragma Machine_Attribute (m128, "may_alias");
end SSE_Types;
use SSE_Types;
-- Core operations
function mm_add_ss (A, B : m128) return m128;
pragma Import (Intrinsic, mm_add_ss, "__builtin_ia32_addss");
-- User views / conversions or overlays
type Vf32_View is array (1 .. 4) of Float;
for Vf32_View'Alignment use VECTOR_ALIGN;
function To_m128 is new Ada.Unchecked_Conversion (Vf32_View, m128);
function To_m128 is new Ada.Unchecked_Conversion (m128, Vf32_View);
X, Y, Z : M128;
Vz : Vf32_View;
for Vz'Address use Z'Address;
begin
X := To_m128 ((1.0, 1.0, 2.0, 2.0));
Y := To_m128 ((2.0, 2.0, 1.0, 1.0));
Z := mm_add_ss (X, Y);
if Vz /= (3.0, 1.0, 2.0, 2.0) then
raise Program_Error;
end if;
end SSE_Nolib;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment