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-2005, 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 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. --
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. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 -- This unit exposes the various vector types part of the Ada binding to
35 -- Altivec facilities.
37 with GNAT
.Altivec
.Low_Level_Vectors
;
39 package GNAT
.Altivec
.Vector_Types
is
41 use GNAT
.Altivec
.Low_Level_Vectors
;
43 ---------------------------------------------------
44 -- Vector type declarations [PIM-2.1 Data Types] --
45 ---------------------------------------------------
47 -- Except for assignments and pointer creation/dereference, operations
48 -- on vectors are only performed via subprograms. The vector types are
49 -- then private, and non-limited since assignments are allowed.
51 -- The Hard/Soft binding type-structure differentiation is achieved in
52 -- Low_Level_Vectors. Each version only exposes private vector types, that
53 -- we just sub-type here. This is fine from the design standpoint and
54 -- reduces the amount of explicit conversion required in various places
57 subtype vector_unsigned_char
is Low_Level_Vectors
.LL_VUC
;
58 subtype vector_signed_char
is Low_Level_Vectors
.LL_VSC
;
59 subtype vector_bool_char
is Low_Level_Vectors
.LL_VBC
;
61 subtype vector_unsigned_short
is Low_Level_Vectors
.LL_VUS
;
62 subtype vector_signed_short
is Low_Level_Vectors
.LL_VSS
;
63 subtype vector_bool_short
is Low_Level_Vectors
.LL_VBS
;
65 subtype vector_unsigned_int
is Low_Level_Vectors
.LL_VUI
;
66 subtype vector_signed_int
is Low_Level_Vectors
.LL_VSI
;
67 subtype vector_bool_int
is Low_Level_Vectors
.LL_VBI
;
69 subtype vector_float
is Low_Level_Vectors
.LL_VF
;
70 subtype vector_pixel
is Low_Level_Vectors
.LL_VP
;
72 -- [PIM-2.1] shows groups of declarations with exact same component types,
73 -- e.g. vector unsigned short together with vector unsigned short int. It
74 -- so appears tempting to define subtypes for those matches here.
76 -- [PIM-2.1] does not qualify items in those groups as "the same types",
77 -- though, and [PIM-2.4.2 Assignments] reads: "if either the left hand
78 -- side or the right hand side of an expression has a vector type, then
79 -- both sides of the expression must be of the same vector type".
81 -- Not so clear what is exactly right, then. We go with subtypes for now
82 -- and can adjust later if need be.
84 subtype vector_unsigned_short_int
is vector_unsigned_short
;
85 subtype vector_signed_short_int
is vector_signed_short
;
87 subtype vector_char
is vector_signed_char
;
88 subtype vector_short
is vector_signed_short
;
89 subtype vector_int
is vector_signed_int
;
91 --------------------------------
92 -- Corresponding access types --
93 --------------------------------
95 type vector_unsigned_char_ptr
is access all vector_unsigned_char
;
96 type vector_signed_char_ptr
is access all vector_signed_char
;
97 type vector_bool_char_ptr
is access all vector_bool_char
;
99 type vector_unsigned_short_ptr
is access all vector_unsigned_short
;
100 type vector_signed_short_ptr
is access all vector_signed_short
;
101 type vector_bool_short_ptr
is access all vector_bool_short
;
103 type vector_unsigned_int_ptr
is access all vector_unsigned_int
;
104 type vector_signed_int_ptr
is access all vector_signed_int
;
105 type vector_bool_int_ptr
is access all vector_bool_int
;
107 type vector_float_ptr
is access all vector_float
;
108 type vector_pixel_ptr
is access all vector_pixel
;
110 --------------------------------------------------------------------
111 -- Additional access types, for the sake of some argument passing --
112 --------------------------------------------------------------------
114 -- ... because some of the operations expect pointers to possibly
117 type const_vector_bool_char_ptr
is access constant vector_bool_char
;
118 type const_vector_signed_char_ptr
is access constant vector_signed_char
;
119 type const_vector_unsigned_char_ptr
is access constant vector_unsigned_char
;
121 type const_vector_bool_short_ptr
is access constant vector_bool_short
;
122 type const_vector_signed_short_ptr
is access constant vector_signed_short
;
123 type const_vector_unsigned_short_ptr
is access
124 constant vector_unsigned_short
;
126 type const_vector_bool_int_ptr
is access constant vector_bool_int
;
127 type const_vector_signed_int_ptr
is access constant vector_signed_int
;
128 type const_vector_unsigned_int_ptr
is access constant vector_unsigned_int
;
130 type const_vector_float_ptr
is access constant vector_float
;
131 type const_vector_pixel_ptr
is access constant vector_pixel
;
133 ----------------------
134 -- Useful shortcuts --
135 ----------------------
137 subtype VUC
is vector_unsigned_char
;
138 subtype VSC
is vector_signed_char
;
139 subtype VBC
is vector_bool_char
;
141 subtype VUS
is vector_unsigned_short
;
142 subtype VSS
is vector_signed_short
;
143 subtype VBS
is vector_bool_short
;
145 subtype VUI
is vector_unsigned_int
;
146 subtype VSI
is vector_signed_int
;
147 subtype VBI
is vector_bool_int
;
149 subtype VP
is vector_pixel
;
150 subtype VF
is vector_float
;
152 end GNAT
.Altivec
.Vector_Types
;