1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- G N A T . S S E . I N T E R N A L _ T Y P E S --
9 -- Copyright (C) 2009, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- This unit exposes low level types to interface with the GCC vector
33 -- builtins directly. These are useful for the development of higher level
34 -- bindings to the reference Intel intrinsic operations.
36 -- See GNAT.SSE for the list of targets where this facility is supported.
38 package GNAT.SSE.Internal_Types is
46 -- GCC'wise, vector operations operate on objects of vector modes,
47 -- conveyed through vector types obtained in C by setting an attribute on
48 -- what looks like a component typedef. For example, in xmmintrin.h:
50 -- typedef float __v4sf __attribute__ ((__vector_size__ (16)));
52 -- Applying a 'vector_size' machine attribute in Ada, as in
54 -- type Vf is new Float;
55 -- pragma Machine_Attribute (Vf, "vector_size", 16);
57 -- makes Vf a 16bytes long V4SFmode GCC type but the effect on the type
58 -- layout is not conveyed to the front-end. The latter still sees "Vf"
59 -- as a 4bytes long single float, with numerous potential pitfalls.
61 -- We devised a 'vector_type' alternate machine attribute, which applies
62 -- to array types of the proper size and alignment from the front-end
65 type v4sf is array (1 .. 4) of GNAT.SSE.Float32;
66 for v4sf'Alignment use GNAT.SSE.VECTOR_ALIGN;
67 pragma Machine_Attribute (v4sf, "vector_type");
69 type v2di is array (1 .. 2) of GNAT.SSE.Integer64;
70 for v2di'Alignment use GNAT.SSE.VECTOR_ALIGN;
71 pragma Machine_Attribute (v2di, "vector_type");
73 type v2df is array (1 .. 2) of GNAT.SSE.Float64;
74 for v2df'Alignment use GNAT.SSE.VECTOR_ALIGN;
75 pragma Machine_Attribute (v2df, "vector_type");
77 end GNAT.SSE.Internal_Types;