OSDN Git Service

Minor reformatting.
[pf3gnuchains/gcc-fork.git] / gcc / ada / g-ssvety.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                 G N A T . S S E . V E C T O R _ T Y P E S                --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --             Copyright (C) 2009, Free Software Foundation, Inc.           --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
17 --                                                                          --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception,   --
20 -- version 3.1, as published by the Free Software Foundation.               --
21 --                                                                          --
22 -- You should have received a copy of the GNU General Public License and    --
23 -- a copy of the GCC Runtime Library Exception along with this program;     --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25 -- <http://www.gnu.org/licenses/>.                                          --
26 --                                                                          --
27 -- GNAT was originally developed  by the GNAT team at  New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
29 --                                                                          --
30 ------------------------------------------------------------------------------
31
32 --  This unit exposes the Ada __m128 like data types to represent the contents
33 --  of SSE registers, for use by the SSE intrinsics.
34
35 package GNAT.SSE.Vector_Types is
36
37    --  The reference guide states a few usage guidelines for the C types :
38
39    --  << Since these new data types are not basic ANSI C data types, you
40    --     must observe the following usage restrictions:
41    --
42    --     * Use new data types only on either side of an assignment, as a
43    --       return value, or as a parameter. You cannot use it with other
44    --       arithmetic expressions ("+", "-", and so on).
45    --
46    --     * Use new data types as objects in aggregates, such as unions to
47    --       access the byte elements and structures.
48    --
49    --     * Use new data types only with the respective intrinsics described
50    --       in this documentation. >>
51
52    type M128 is private;   --  SSE >= 1
53    type M128d is private;  --  SSE >= 2
54    type M128i is private;  --  SSE >= 2
55
56 private
57    --  GCC'wise, vector operations operate on objects of vector modes,
58    --  conveyed through vector types obtained by setting an attribute on what
59    --  looks like a component typedef.  For example, in C (xmmintrin.h):
60    --
61    --    typedef float __v4sf __attribute__ ((__vector_size__ (16)));
62
63    --  We can obtain the same low level GCC effect in Ada with
64    --  Machine_Attribute pragmas, as in
65    --
66    --    type Vf is new Float;
67    --    pragma Machine_Attribute (Vf,  "vector_size", 16);
68    --
69    --  which makes Vf a 16bytes long V4SFmode type for GCC. The effect on the
70    --  type layout is not conveyed to the front-end, however, so the latter
71    --  still sees "Vf" as a 4bytes long single float. This leads to numerous
72    --  potential pitfalls if this type is directly exposed user land, so we
73    --  add wrapper records with rep clauses to compensate.
74
75    --  The wrapper records all have a single component of the twisted low
76    --  level type, so they inherit the mode while the rep clauses convey the
77    --  size and alignment information to the front-end.
78
79    ------------
80    --  M128  --
81    ------------
82
83    --  << The __m128 data type can hold four 32-bit floating-point values. >>
84
85    type V4sf is new Float32;
86    pragma Machine_Attribute (V4sf, "vector_size", VECTOR_BYTES);
87
88    type M128 is record
89       Value : V4sf;
90    end record;
91    for M128'Size use VECTOR_BYTES * 8;
92    for M128'Alignment use VECTOR_ALIGN;
93
94    -------------
95    --  M128d  --
96    -------------
97
98    --  << The __m128d data type can hold two 64-bit floating-point values. >>
99
100    type V2df is new Float64;
101    pragma Machine_Attribute (V2df, "vector_size", VECTOR_BYTES);
102
103    type M128d is record
104       Value : V2df;
105    end record;
106    for M128d'Size use VECTOR_BYTES * 8;
107    for M128d'Alignment use VECTOR_ALIGN;
108
109    -------------
110    --  M128i  --
111    -------------
112
113    --  << The __m128i data type can hold sixteen 8-bit, eight 16-bit, four
114    --     32-bit, or two 64-bit integer values. >>
115
116    type V2di is new Integer64;
117    pragma Machine_Attribute (V2di, "vector_size", VECTOR_BYTES);
118
119    type M128i is record
120       Value : V2di;
121    end record;
122    for M128i'Size use VECTOR_BYTES * 8;
123    for M128i'Alignment use VECTOR_ALIGN;
124
125 end GNAT.SSE.Vector_Types;