1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- G N A T . A L T I V E C . V E C T O R _ T Y P E S --
9 -- Copyright (C) 2004-2023, 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 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 ---------------------------------------------------
40 -- Vector type declarations [PIM-2.1 Data Types] --
41 ---------------------------------------------------
43 -- Except for assignments and pointer creation/dereference, operations
44 -- on vectors are only performed via subprograms. The vector types are
45 -- then private, and non-limited since assignments are allowed.
47 -- The Hard/Soft binding type-structure differentiation is achieved in
48 -- Low_Level_Vectors. Each version only exposes private vector types, that
49 -- we just sub-type here. This is fine from the design standpoint and
50 -- reduces the amount of explicit conversion required in various places
53 subtype vector_unsigned_char
is Low_Level_Vectors
.LL_VUC
;
54 subtype vector_signed_char
is Low_Level_Vectors
.LL_VSC
;
55 subtype vector_bool_char
is Low_Level_Vectors
.LL_VBC
;
57 subtype vector_unsigned_short
is Low_Level_Vectors
.LL_VUS
;
58 subtype vector_signed_short
is Low_Level_Vectors
.LL_VSS
;
59 subtype vector_bool_short
is Low_Level_Vectors
.LL_VBS
;
61 subtype vector_unsigned_int
is Low_Level_Vectors
.LL_VUI
;
62 subtype vector_signed_int
is Low_Level_Vectors
.LL_VSI
;
63 subtype vector_bool_int
is Low_Level_Vectors
.LL_VBI
;
65 subtype vector_float
is Low_Level_Vectors
.LL_VF
;
66 subtype vector_pixel
is Low_Level_Vectors
.LL_VP
;
68 -- [PIM-2.1] shows groups of declarations with exact same component types,
69 -- e.g. vector unsigned short together with vector unsigned short int. It
70 -- so appears tempting to define subtypes for those matches here.
72 -- [PIM-2.1] does not qualify items in those groups as "the same types",
73 -- though, and [PIM-2.4.2 Assignments] reads: "if either the left hand
74 -- side or the right hand side of an expression has a vector type, then
75 -- both sides of the expression must be of the same vector type".
77 -- Not so clear what is exactly right, then. We go with subtypes for now
78 -- and can adjust later if need be.
80 subtype vector_unsigned_short_int
is vector_unsigned_short
;
81 subtype vector_signed_short_int
is vector_signed_short
;
83 subtype vector_char
is vector_signed_char
;
84 subtype vector_short
is vector_signed_short
;
85 subtype vector_int
is vector_signed_int
;
87 --------------------------------
88 -- Corresponding access types --
89 --------------------------------
91 type vector_unsigned_char_ptr
is access all vector_unsigned_char
;
92 type vector_signed_char_ptr
is access all vector_signed_char
;
93 type vector_bool_char_ptr
is access all vector_bool_char
;
95 type vector_unsigned_short_ptr
is access all vector_unsigned_short
;
96 type vector_signed_short_ptr
is access all vector_signed_short
;
97 type vector_bool_short_ptr
is access all vector_bool_short
;
99 type vector_unsigned_int_ptr
is access all vector_unsigned_int
;
100 type vector_signed_int_ptr
is access all vector_signed_int
;
101 type vector_bool_int_ptr
is access all vector_bool_int
;
103 type vector_float_ptr
is access all vector_float
;
104 type vector_pixel_ptr
is access all vector_pixel
;
106 --------------------------------------------------------------------
107 -- Additional access types, for the sake of some argument passing --
108 --------------------------------------------------------------------
110 -- ... because some of the operations expect pointers to possibly
113 type const_vector_bool_char_ptr
is access constant vector_bool_char
;
114 type const_vector_signed_char_ptr
is access constant vector_signed_char
;
115 type const_vector_unsigned_char_ptr
is access constant vector_unsigned_char
;
117 type const_vector_bool_short_ptr
is access constant vector_bool_short
;
118 type const_vector_signed_short_ptr
is access constant vector_signed_short
;
119 type const_vector_unsigned_short_ptr
is access
120 constant vector_unsigned_short
;
122 type const_vector_bool_int_ptr
is access constant vector_bool_int
;
123 type const_vector_signed_int_ptr
is access constant vector_signed_int
;
124 type const_vector_unsigned_int_ptr
is access constant vector_unsigned_int
;
126 type const_vector_float_ptr
is access constant vector_float
;
127 type const_vector_pixel_ptr
is access constant vector_pixel
;
129 ----------------------
130 -- Useful shortcuts --
131 ----------------------
133 subtype VUC
is vector_unsigned_char
;
134 subtype VSC
is vector_signed_char
;
135 subtype VBC
is vector_bool_char
;
137 subtype VUS
is vector_unsigned_short
;
138 subtype VSS
is vector_signed_short
;
139 subtype VBS
is vector_bool_short
;
141 subtype VUI
is vector_unsigned_int
;
142 subtype VSI
is vector_signed_int
;
143 subtype VBI
is vector_bool_int
;
145 subtype VP
is vector_pixel
;
146 subtype VF
is vector_float
;
148 end GNAT
.Altivec
.Vector_Types
;