OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [ada/] [g-sse.ads] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--                             G N A T . S S E                              --
6
--                                                                          --
7
--                                 S p e c                                  --
8
--                                                                          --
9
--             Copyright (C) 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
------------------------------------------------------------------------------
31
 
32
--  This package is the root of a set aimed at offering Ada bindings to a
33
--  subset of the Intel(r) Streaming SIMD Extensions with GNAT. The purpose
34
--  is to allow access from Ada to the SSE facilities defined in the Intel(r)
35
--  compiler manuals, in particular in the Intrinsics Reference of the C++
36
--  Compiler User's Guide, available from http://www.intel.com.
37
 
38
--  Assuming actual hardware support is available, this capability is
39
--  currently supported on the following set of targets:
40
 
41
--     GNU/Linux x86 and x86_64
42
--     Windows XP/Vista x86 and x86_64
43
 
44
--  This unit exposes vector _component_ types together with general comments
45
--  on the binding contents.
46
 
47
--  One other unit is offered as of today: GNAT.SSE.Vector_Types, which
48
--  exposes Ada types corresponding to the reference types (__m128 and the
49
--  like) over which a binding to the SSE GCC builtins may operate.
50
 
51
--  The exposed Ada types are private. Object initializations or value
52
--  observations may be performed with unchecked conversions or address
53
--  overlays, for example:
54
 
55
--  with Ada.Unchecked_Conversion;
56
--  with GNAT.SSE.Vector_Types; use GNAT.SSE, GNAT.SSE.Vector_Types;
57
 
58
--  procedure SSE_Base is
59
 
60
--     --  Core operations
61
 
62
--     function ia32_addps (A, B : m128) return m128;
63
--     pragma Import (Intrinsic, ia32_addps, "__builtin_ia32_addps");
64
 
65
--     --  User views & conversions
66
 
67
--     type Vf32_View is array (1 .. 4) of GNAT.SSE.Float32;
68
--     for Vf32_View'Alignment use VECTOR_ALIGN;
69
 
70
--     function To_m128 is new Ada.Unchecked_Conversion (Vf32_View, m128);
71
 
72
--     Xf32 : constant Vf32_View := (1.0, 1.0, 2.0, 2.0);
73
--     Yf32 : constant Vf32_View := (2.0, 2.0, 1.0, 1.0);
74
 
75
--     X128 : constant m128 := To_m128 (Xf32);
76
--     Y128 : constant m128 := To_m128 (Yf32);
77
 
78
--  begin
79
--     --  Operations & overlays
80
 
81
--     declare
82
--        Z128 : m128;
83
--        Zf32 : Vf32_View;
84
--        for Zf32'Address use Z128'Address;
85
--     begin
86
--        Z128 := ia32_addps (X128, Y128);
87
--        if Zf32 /= (3.0, 3.0, 3.0, 3.0) then
88
--           raise Program_Error;
89
--        end if;
90
--     end;
91
 
92
--     declare
93
--        type m128_View_Kind is (SSE, F32);
94
--        type m128_Object (View : m128_View_Kind := F32) is record
95
--           case View is
96
--              when SSE  => V128 : m128;
97
--              when F32  => Vf32 : Vf32_View;
98
--           end case;
99
--        end record;
100
--        pragma Unchecked_Union (m128_Object);
101
 
102
--        O1 : constant m128_Object := (View => SSE, V128 => X128);
103
--     begin
104
--        if O1.Vf32 /= Xf32 then
105
--           raise Program_Error;
106
--        end if;
107
--     end;
108
--  end SSE_Base;
109
 
110
package GNAT.SSE is
111
 
112
   -----------------------------------
113
   -- Common vector characteristics --
114
   -----------------------------------
115
 
116
   VECTOR_BYTES : constant := 16;
117
   --  Common size of all the SSE vector types, in bytes.
118
 
119
   VECTOR_ALIGN : constant := 16;
120
   --  Common alignment of all the SSE vector types, in bytes.
121
 
122
   --  Alignment-wise, the reference document reads:
123
   --  << The compiler aligns __m128d and _m128i local and global data to
124
   --     16-byte boundaries on the stack. >>
125
   --
126
   --  We apply that consistently to all the Ada vector types, as GCC does
127
   --  for the corresponding C types.
128
 
129
   ----------------------------
130
   -- Vector component types --
131
   ----------------------------
132
 
133
   type Float32 is new Float;
134
   type Float64 is new Long_Float;
135
   type Integer64 is new Long_Long_Integer;
136
 
137
end GNAT.SSE;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.