OSDN Git Service

2009-04-08 Thomas Quinot <quinot@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / g-alvevi.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --            G N A T . A L T I V E C . V E C T O R _ V I E W S             --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --         Copyright (C) 2005-2008, 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 2,  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.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
20 -- MA 02111-1307, USA.                                                      --
21 --                                                                          --
22 -- As a special exception,  if other files  instantiate  generics from this --
23 -- unit, or you link  this unit with other files  to produce an executable, --
24 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
25 -- covered  by the  GNU  General  Public  License.  This exception does not --
26 -- however invalidate  any other reasons why  the executable file  might be --
27 -- covered by the  GNU Public License.                                      --
28 --                                                                          --
29 -- GNAT was originally developed  by the GNAT team at  New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34 --  This unit provides public 'View' data types from/to which private vector
35 --  representations can be converted via Altivec.Conversions. This allows
36 --  convenient access to individual vector elements and provides a simple way
37 --  to initialize vector objects.
38
39 --  Accessing vector contents with direct memory overlays should be avoided
40 --  because actual vector representations may vary across configurations, for
41 --  instance to accommodate different target endianness.
42
43 --  The natural representation of a vector is an array indexed by vector
44 --  component number, which is materialized by the Varray type definitions
45 --  below. The 16byte alignment constraint is unfortunately sometimes not
46 --  properly honored for constant array aggregates, so the View types are
47 --  actually records enclosing such arrays.
48
49 package GNAT.Altivec.Vector_Views is
50
51    ---------------------
52    -- char components --
53    ---------------------
54
55    type Vchar_Range is range 1 .. 16;
56
57    type Varray_unsigned_char is array (Vchar_Range) of unsigned_char;
58    for Varray_unsigned_char'Alignment use VECTOR_ALIGNMENT;
59
60    type VUC_View is record
61       Values : Varray_unsigned_char;
62    end record;
63
64    type Varray_signed_char is array (Vchar_Range) of signed_char;
65    for Varray_signed_char'Alignment use VECTOR_ALIGNMENT;
66
67    type VSC_View is record
68       Values : Varray_signed_char;
69    end record;
70
71    type Varray_bool_char is array (Vchar_Range) of bool_char;
72    for Varray_bool_char'Alignment use VECTOR_ALIGNMENT;
73
74    type VBC_View is record
75       Values : Varray_bool_char;
76    end record;
77
78    ----------------------
79    -- short components --
80    ----------------------
81
82    type Vshort_Range is range 1 .. 8;
83
84    type Varray_unsigned_short is array (Vshort_Range) of unsigned_short;
85    for Varray_unsigned_short'Alignment use VECTOR_ALIGNMENT;
86
87    type VUS_View is record
88       Values : Varray_unsigned_short;
89    end record;
90
91    type Varray_signed_short is array (Vshort_Range) of signed_short;
92    for Varray_signed_short'Alignment use VECTOR_ALIGNMENT;
93
94    type VSS_View is record
95       Values : Varray_signed_short;
96    end record;
97
98    type Varray_bool_short is array (Vshort_Range) of bool_short;
99    for Varray_bool_short'Alignment use VECTOR_ALIGNMENT;
100
101    type VBS_View is record
102       Values : Varray_bool_short;
103    end record;
104
105    --------------------
106    -- int components --
107    --------------------
108
109    type Vint_Range is range 1 .. 4;
110
111    type Varray_unsigned_int is array (Vint_Range) of unsigned_int;
112    for Varray_unsigned_int'Alignment use VECTOR_ALIGNMENT;
113
114    type VUI_View is record
115       Values : Varray_unsigned_int;
116    end record;
117
118    type Varray_signed_int is array (Vint_Range) of signed_int;
119    for Varray_signed_int'Alignment use VECTOR_ALIGNMENT;
120
121    type VSI_View is record
122       Values : Varray_signed_int;
123    end record;
124
125    type Varray_bool_int is array (Vint_Range) of bool_int;
126    for Varray_bool_int'Alignment use VECTOR_ALIGNMENT;
127
128    type VBI_View is record
129       Values : Varray_bool_int;
130    end record;
131
132    ----------------------
133    -- float components --
134    ----------------------
135
136    type Vfloat_Range is range 1 .. 4;
137
138    type Varray_float is array (Vfloat_Range) of C_float;
139    for Varray_float'Alignment use VECTOR_ALIGNMENT;
140
141    type VF_View is record
142       Values : Varray_float;
143    end record;
144
145    ----------------------
146    -- pixel components --
147    ----------------------
148
149    type Vpixel_Range is range 1 .. 8;
150
151    type Varray_pixel is array (Vpixel_Range) of pixel;
152    for Varray_pixel'Alignment use VECTOR_ALIGNMENT;
153
154    type VP_View is record
155       Values : Varray_pixel;
156    end record;
157
158 end GNAT.Altivec.Vector_Views;