2015-05-22 Eric Botcazou <ebotcazou@adacore.com>
[official-gcc.git] / gcc / ada / g-alvevi.ads
blob8d8d85608349b8dd1288c862486a699d94ff2de3
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-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 ------------------------------------------------------------------------------
32 -- This unit provides public 'View' data types from/to which private vector
33 -- representations can be converted via Altivec.Conversions. This allows
34 -- convenient access to individual vector elements and provides a simple way
35 -- to initialize vector objects.
37 -- Accessing vector contents with direct memory overlays should be avoided
38 -- because actual vector representations may vary across configurations, for
39 -- instance to accommodate different target endianness.
41 -- The natural representation of a vector is an array indexed by vector
42 -- component number, which is materialized by the Varray type definitions
43 -- below. The 16byte alignment constraint is unfortunately sometimes not
44 -- properly honored for constant array aggregates, so the View types are
45 -- actually records enclosing such arrays.
47 package GNAT.Altivec.Vector_Views is
49 ---------------------
50 -- char components --
51 ---------------------
53 type Vchar_Range is range 1 .. 16;
55 type Varray_unsigned_char is array (Vchar_Range) of unsigned_char;
56 for Varray_unsigned_char'Alignment use VECTOR_ALIGNMENT;
58 type VUC_View is record
59 Values : Varray_unsigned_char;
60 end record;
62 type Varray_signed_char is array (Vchar_Range) of signed_char;
63 for Varray_signed_char'Alignment use VECTOR_ALIGNMENT;
65 type VSC_View is record
66 Values : Varray_signed_char;
67 end record;
69 type Varray_bool_char is array (Vchar_Range) of bool_char;
70 for Varray_bool_char'Alignment use VECTOR_ALIGNMENT;
72 type VBC_View is record
73 Values : Varray_bool_char;
74 end record;
76 ----------------------
77 -- short components --
78 ----------------------
80 type Vshort_Range is range 1 .. 8;
82 type Varray_unsigned_short is array (Vshort_Range) of unsigned_short;
83 for Varray_unsigned_short'Alignment use VECTOR_ALIGNMENT;
85 type VUS_View is record
86 Values : Varray_unsigned_short;
87 end record;
89 type Varray_signed_short is array (Vshort_Range) of signed_short;
90 for Varray_signed_short'Alignment use VECTOR_ALIGNMENT;
92 type VSS_View is record
93 Values : Varray_signed_short;
94 end record;
96 type Varray_bool_short is array (Vshort_Range) of bool_short;
97 for Varray_bool_short'Alignment use VECTOR_ALIGNMENT;
99 type VBS_View is record
100 Values : Varray_bool_short;
101 end record;
103 --------------------
104 -- int components --
105 --------------------
107 type Vint_Range is range 1 .. 4;
109 type Varray_unsigned_int is array (Vint_Range) of unsigned_int;
110 for Varray_unsigned_int'Alignment use VECTOR_ALIGNMENT;
112 type VUI_View is record
113 Values : Varray_unsigned_int;
114 end record;
116 type Varray_signed_int is array (Vint_Range) of signed_int;
117 for Varray_signed_int'Alignment use VECTOR_ALIGNMENT;
119 type VSI_View is record
120 Values : Varray_signed_int;
121 end record;
123 type Varray_bool_int is array (Vint_Range) of bool_int;
124 for Varray_bool_int'Alignment use VECTOR_ALIGNMENT;
126 type VBI_View is record
127 Values : Varray_bool_int;
128 end record;
130 ----------------------
131 -- float components --
132 ----------------------
134 type Vfloat_Range is range 1 .. 4;
136 type Varray_float is array (Vfloat_Range) of C_float;
137 for Varray_float'Alignment use VECTOR_ALIGNMENT;
139 type VF_View is record
140 Values : Varray_float;
141 end record;
143 ----------------------
144 -- pixel components --
145 ----------------------
147 type Vpixel_Range is range 1 .. 8;
149 type Varray_pixel is array (Vpixel_Range) of pixel;
150 for Varray_pixel'Alignment use VECTOR_ALIGNMENT;
152 type VP_View is record
153 Values : Varray_pixel;
154 end record;
156 end GNAT.Altivec.Vector_Views;