OSDN Git Service

* decl2.c (maybe_emit_vtables): Produce same comdat group when outputting
[pf3gnuchains/gcc-fork.git] / gcc / ada / g-ssvety.ads
index 4ad63d8..c407064 100644 (file)
@@ -2,7 +2,7 @@
 --                                                                          --
 --                         GNAT COMPILER COMPONENTS                         --
 --                                                                          --
---                 G N A T . S S E . V e c t o r _ T y p e s                --
+--                 G N A T . S S E . V E C T O R _ T Y P E S                --
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
 ------------------------------------------------------------------------------
 
 --  This unit exposes the Ada __m128 like data types to represent the contents
---  of SSE registers, for use by the SSE intrinsics.
+--  of SSE registers, for use by bindings to the SSE intrinsic operations.
+
+--  See GNAT.SSE for the list of targets where this facility is supported
 
 package GNAT.SSE.Vector_Types is
 
-   --  The reference guide states a few usage guidelines for the C types :
+   --  The reference guide states a few usage guidelines for the C types:
 
-   --  << Since these new data types are not basic ANSI C data types, you
-   --     must observe the following usage restrictions:
+   --    Since these new data types are not basic ANSI C data types, you
+   --    must observe the following usage restrictions:
    --
    --     * Use new data types only on either side of an assignment, as a
    --       return value, or as a parameter. You cannot use it with other
@@ -47,80 +49,57 @@ package GNAT.SSE.Vector_Types is
    --       access the byte elements and structures.
    --
    --     * Use new data types only with the respective intrinsics described
-   --       in this documentation. >>
+   --       in this documentation.
 
-   type M128 is private;   --  SSE >= 1
-   type M128d is private;  --  SSE >= 2
-   type M128i is private;  --  SSE >= 2
+   type m128  is private;  --  SSE >= 1
+   type m128d is private;  --  SSE >= 2
+   type m128i is private;  --  SSE >= 2
 
 private
+   --  Each of the m128 types maps to a specific vector_type with an extra
+   --  "may_alias" attribute as in GCC's definitions for C, for instance in
+   --  xmmintrin.h:
 
-   --  GCC'wise, vector operations operate on objects of vector modes,
-   --  conveyed through vector types obtained by setting an attribute on what
-   --  looks like a component typedef.  For example, in C (xmmintrin.h):
-   --
-   --    typedef float __v4sf __attribute__ ((__vector_size__ (16)));
-
-   --  We can obtain the same low level GCC effect in Ada with
-   --  Machine_Attribute pragmas, as in
-   --
-   --    type Vf is new Float;
-   --    pragma Machine_Attribute (Vf,  "vector_size", 16);
-   --
-   --  which makes Vf a 16bytes long V4SFmode type for GCC. The effect on the
-   --  type layout is not conveyed to the front-end, however, so the latter
-   --  still sees "Vf" as a 4bytes long single float. This leads to numerous
-   --  potential pitfalls if this type is directly exposed user land, so we
-   --  add wrapper records with rep clauses to compensate.
+   --  /* The Intel API is flexible enough that we must allow aliasing
+   --     with other vector types, and their scalar components.  */
+   --  typedef float __m128
+   --    __attribute__ ((__vector_size__ (16), __may_alias__));
 
-   --  The wrapper records all have a single component of the twisted low
-   --  level type, so they inherit the mode while the rep clauses convey the
-   --  size and alignment information to the front-end.
+   --  /* Internal data types for implementing the intrinsics.  */
+   --  typedef float __v4sf __attribute__ ((__vector_size__ (16)));
 
    ------------
-   --  M128  --
+   --  m128  --
    ------------
 
-   --  << The __m128 data type can hold four 32-bit floating-point values. >>
-
-   type V4sf is new Float32;
-   pragma Machine_Attribute (V4sf, "vector_size", VECTOR_BYTES);
+   --  The __m128 data type can hold four 32-bit floating-point values
 
-   type M128 is record
-      Value : V4sf;
-   end record;
-   for M128'Size use VECTOR_BYTES * 8;
-   for M128'Alignment use VECTOR_ALIGN;
+   type m128 is array (1 .. 4) of Float32;
+   for m128'Alignment use VECTOR_ALIGN;
+   pragma Machine_Attribute (m128, "vector_type");
+   pragma Machine_Attribute (m128, "may_alias");
 
    -------------
-   --  M128d  --
+   --  m128d  --
    -------------
 
-   --  << The __m128d data type can hold two 64-bit floating-point values. >>
+   --  The __m128d data type can hold two 64-bit floating-point values
 
-   type V2df is new Float64;
-   pragma Machine_Attribute (V2df, "vector_size", VECTOR_BYTES);
-
-   type M128d is record
-      Value : V2df;
-   end record;
-   for M128d'Size use VECTOR_BYTES * 8;
-   for M128d'Alignment use VECTOR_ALIGN;
+   type m128d is array (1 .. 2) of Float64;
+   for m128d'Alignment use VECTOR_ALIGN;
+   pragma Machine_Attribute (m128d, "vector_type");
+   pragma Machine_Attribute (m128d, "may_alias");
 
    -------------
-   --  M128i  --
+   --  m128i  --
    -------------
 
-   --  << The __m128i data type can hold sixteen 8-bit, eight 16-bit, four
-   --     32-bit, or two 64-bit integer values. >>
-
-   type V2di is new Integer64;
-   pragma Machine_Attribute (V2di, "vector_size", VECTOR_BYTES);
+   --  The __m128i data type can hold sixteen 8-bit, eight 16-bit, four 32-bit,
+   --  or two 64-bit integer values.
 
-   type M128i is record
-      Value : V2di;
-   end record;
-   for M128i'Size use VECTOR_BYTES * 8;
-   for M128i'Alignment use VECTOR_ALIGN;
+   type m128i is array (1 .. 2) of Integer64;
+   for m128i'Alignment use VECTOR_ALIGN;
+   pragma Machine_Attribute (m128i, "vector_type");
+   pragma Machine_Attribute (m128i, "may_alias");
 
 end GNAT.SSE.Vector_Types;