OSDN Git Service

2005-06-14 Pascal Obry <obry@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-veboop.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                 GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS                 --
4 --                                                                          --
5 --    S Y S T E M . V E C T O R S . B O O L E A N _ O P E R A T I O N S     --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --           Copyright (C) 2002-2005 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 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.                                                      --
21 --                                                                          --
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.                                      --
28 --                                                                          --
29 -- GNAT was originally developed  by the GNAT team at  New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34 --  This package contains functions for runtime operations on boolean vectors
35
36 package System.Vectors.Boolean_Operations is
37 pragma Pure (Boolean_Operations);
38
39    --  Although in general the boolean operations on arrays of booleans are
40    --  identical to operations on arrays of unsigned words of the same size,
41    --  for the "not" operator this is not the case as False is typically
42    --  represented by 0 and true by 1.
43
44    function "not" (Item : Vectors.Vector) return Vectors.Vector;
45
46    --  The three boolean operations "nand", "nor" and "nxor" are needed
47    --  for cases where the compiler moves boolean array operations into
48    --  the body of the loop that iterates over the array elements.
49
50    --  Note the following equivalences:
51    --    (not X) or  (not Y)  =  not (X and Y)  =  Nand (X, Y)
52    --    (not X) and (not Y)  =  not (X or Y)   =  Nor  (X, Y)
53    --    (not X) xor (not Y)  =  X xor Y
54    --    X       xor (not Y)  =  not (X xor Y)  =  Nxor (X, Y)
55
56    function Nand (Left, Right : Boolean) return Boolean;
57    function Nor  (Left, Right : Boolean) return Boolean;
58    function Nxor (Left, Right : Boolean) return Boolean;
59
60    function Nand (Left, Right : Vectors.Vector) return Vectors.Vector;
61    function Nor (Left, Right : Vectors.Vector) return Vectors.Vector;
62    function Nxor (Left, Right : Vectors.Vector) return Vectors.Vector;
63
64    pragma Inline_Always ("not");
65    pragma Inline_Always (Nand);
66    pragma Inline_Always (Nor);
67    pragma Inline_Always (Nxor);
68 end System.Vectors.Boolean_Operations;