2016-10-26 François Dumont <fdumont@gcc.gnu.org>
[official-gcc.git] / gcc / ada / g-alvety.ads
blob06e824eb18ae4bdc8affb6a62e0babf2e1859f44
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 _ T Y P E S --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2004-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 exposes the various vector types part of the Ada binding to
33 -- Altivec facilities.
35 with GNAT.Altivec.Low_Level_Vectors;
37 package GNAT.Altivec.Vector_Types is
39 use GNAT.Altivec.Low_Level_Vectors;
41 ---------------------------------------------------
42 -- Vector type declarations [PIM-2.1 Data Types] --
43 ---------------------------------------------------
45 -- Except for assignments and pointer creation/dereference, operations
46 -- on vectors are only performed via subprograms. The vector types are
47 -- then private, and non-limited since assignments are allowed.
49 -- The Hard/Soft binding type-structure differentiation is achieved in
50 -- Low_Level_Vectors. Each version only exposes private vector types, that
51 -- we just sub-type here. This is fine from the design standpoint and
52 -- reduces the amount of explicit conversion required in various places
53 -- internally.
55 subtype vector_unsigned_char is Low_Level_Vectors.LL_VUC;
56 subtype vector_signed_char is Low_Level_Vectors.LL_VSC;
57 subtype vector_bool_char is Low_Level_Vectors.LL_VBC;
59 subtype vector_unsigned_short is Low_Level_Vectors.LL_VUS;
60 subtype vector_signed_short is Low_Level_Vectors.LL_VSS;
61 subtype vector_bool_short is Low_Level_Vectors.LL_VBS;
63 subtype vector_unsigned_int is Low_Level_Vectors.LL_VUI;
64 subtype vector_signed_int is Low_Level_Vectors.LL_VSI;
65 subtype vector_bool_int is Low_Level_Vectors.LL_VBI;
67 subtype vector_float is Low_Level_Vectors.LL_VF;
68 subtype vector_pixel is Low_Level_Vectors.LL_VP;
70 -- [PIM-2.1] shows groups of declarations with exact same component types,
71 -- e.g. vector unsigned short together with vector unsigned short int. It
72 -- so appears tempting to define subtypes for those matches here.
74 -- [PIM-2.1] does not qualify items in those groups as "the same types",
75 -- though, and [PIM-2.4.2 Assignments] reads: "if either the left hand
76 -- side or the right hand side of an expression has a vector type, then
77 -- both sides of the expression must be of the same vector type".
79 -- Not so clear what is exactly right, then. We go with subtypes for now
80 -- and can adjust later if need be.
82 subtype vector_unsigned_short_int is vector_unsigned_short;
83 subtype vector_signed_short_int is vector_signed_short;
85 subtype vector_char is vector_signed_char;
86 subtype vector_short is vector_signed_short;
87 subtype vector_int is vector_signed_int;
89 --------------------------------
90 -- Corresponding access types --
91 --------------------------------
93 type vector_unsigned_char_ptr is access all vector_unsigned_char;
94 type vector_signed_char_ptr is access all vector_signed_char;
95 type vector_bool_char_ptr is access all vector_bool_char;
97 type vector_unsigned_short_ptr is access all vector_unsigned_short;
98 type vector_signed_short_ptr is access all vector_signed_short;
99 type vector_bool_short_ptr is access all vector_bool_short;
101 type vector_unsigned_int_ptr is access all vector_unsigned_int;
102 type vector_signed_int_ptr is access all vector_signed_int;
103 type vector_bool_int_ptr is access all vector_bool_int;
105 type vector_float_ptr is access all vector_float;
106 type vector_pixel_ptr is access all vector_pixel;
108 --------------------------------------------------------------------
109 -- Additional access types, for the sake of some argument passing --
110 --------------------------------------------------------------------
112 -- ... because some of the operations expect pointers to possibly
113 -- constant objects.
115 type const_vector_bool_char_ptr is access constant vector_bool_char;
116 type const_vector_signed_char_ptr is access constant vector_signed_char;
117 type const_vector_unsigned_char_ptr is access constant vector_unsigned_char;
119 type const_vector_bool_short_ptr is access constant vector_bool_short;
120 type const_vector_signed_short_ptr is access constant vector_signed_short;
121 type const_vector_unsigned_short_ptr is access
122 constant vector_unsigned_short;
124 type const_vector_bool_int_ptr is access constant vector_bool_int;
125 type const_vector_signed_int_ptr is access constant vector_signed_int;
126 type const_vector_unsigned_int_ptr is access constant vector_unsigned_int;
128 type const_vector_float_ptr is access constant vector_float;
129 type const_vector_pixel_ptr is access constant vector_pixel;
131 ----------------------
132 -- Useful shortcuts --
133 ----------------------
135 subtype VUC is vector_unsigned_char;
136 subtype VSC is vector_signed_char;
137 subtype VBC is vector_bool_char;
139 subtype VUS is vector_unsigned_short;
140 subtype VSS is vector_signed_short;
141 subtype VBS is vector_bool_short;
143 subtype VUI is vector_unsigned_int;
144 subtype VSI is vector_signed_int;
145 subtype VBI is vector_bool_int;
147 subtype VP is vector_pixel;
148 subtype VF is vector_float;
150 end GNAT.Altivec.Vector_Types;