| 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-2025, 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 |
------------------------------------------------------------------------------ |
| 31 |
|
| 32 |
-- This unit exposes the various vector types part of the Ada binding to |
| 33 |
-- Altivec facilities. |
| 34 |
|
| 35 |
with GNAT.Altivec.Low_Level_Vectors; |
| 36 |
|
| 37 |
package GNAT.Altivec.Vector_Types is |
| 38 |
|
| 39 |
--------------------------------------------------- |
| 40 |
-- Vector type declarations [PIM-2.1 Data Types] -- |
| 41 |
--------------------------------------------------- |
| 42 |
|
| 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. |
| 46 |
|
| 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 |
| 51 |
-- internally. |
| 52 |
|
| 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; |
| 56 |
|
| 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; |
| 60 |
|
| 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; |
| 64 |
|
| 65 |
subtype vector_float is Low_Level_Vectors.LL_VF; |
| 66 |
subtype vector_pixel is Low_Level_Vectors.LL_VP; |
| 67 |
|
| 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. |
| 71 |
-- |
| 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". |
| 76 |
-- |
| 77 |
-- Not so clear what is exactly right, then. We go with subtypes for now |
| 78 |
-- and can adjust later if need be. |
| 79 |
|
| 80 |
subtype vector_unsigned_short_int is vector_unsigned_short; |
| 81 |
subtype vector_signed_short_int is vector_signed_short; |
| 82 |
|
| 83 |
subtype vector_char is vector_signed_char; |
| 84 |
subtype vector_short is vector_signed_short; |
| 85 |
subtype vector_int is vector_signed_int; |
| 86 |
|
| 87 |
-------------------------------- |
| 88 |
-- Corresponding access types -- |
| 89 |
-------------------------------- |
| 90 |
|
| 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; |
| 94 |
|
| 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; |
| 98 |
|
| 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; |
| 102 |
|
| 103 |
type vector_float_ptr is access all vector_float; |
| 104 |
type vector_pixel_ptr is access all vector_pixel; |
| 105 |
|
| 106 |
-------------------------------------------------------------------- |
| 107 |
-- Additional access types, for the sake of some argument passing -- |
| 108 |
-------------------------------------------------------------------- |
| 109 |
|
| 110 |
-- ... because some of the operations expect pointers to possibly |
| 111 |
-- constant objects. |
| 112 |
|
| 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; |
| 116 |
|
| 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; |
| 121 |
|
| 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; |
| 125 |
|
| 126 |
type const_vector_float_ptr is access constant vector_float; |
| 127 |
type const_vector_pixel_ptr is access constant vector_pixel; |
| 128 |
|
| 129 |
---------------------- |
| 130 |
-- Useful shortcuts -- |
| 131 |
---------------------- |
| 132 |
|
| 133 |
subtype VUC is vector_unsigned_char; |
| 134 |
subtype VSC is vector_signed_char; |
| 135 |
subtype VBC is vector_bool_char; |
| 136 |
|
| 137 |
subtype VUS is vector_unsigned_short; |
| 138 |
subtype VSS is vector_signed_short; |
| 139 |
subtype VBS is vector_bool_short; |
| 140 |
|
| 141 |
subtype VUI is vector_unsigned_int; |
| 142 |
subtype VSI is vector_signed_int; |
| 143 |
subtype VBI is vector_bool_int; |
| 144 |
|
| 145 |
subtype VP is vector_pixel; |
| 146 |
subtype VF is vector_float; |
| 147 |
|
| 148 |
end GNAT.Altivec.Vector_Types; |