annotate gcc/ada/libgnat/g-sse.ads @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- G N A T . S S E --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 2009-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package is the root of a set aimed at offering Ada bindings to a
kono
parents:
diff changeset
33 -- subset of the Intel(r) Streaming SIMD Extensions with GNAT. The purpose
kono
parents:
diff changeset
34 -- is to allow access from Ada to the SSE facilities defined in the Intel(r)
kono
parents:
diff changeset
35 -- compiler manuals, in particular in the Intrinsics Reference of the C++
kono
parents:
diff changeset
36 -- Compiler User's Guide, available from http://www.intel.com.
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 -- Assuming actual hardware support is available, this capability is
kono
parents:
diff changeset
39 -- currently supported on the following set of targets:
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 -- GNU/Linux x86 and x86_64
kono
parents:
diff changeset
42 -- Windows XP/Vista x86 and x86_64
kono
parents:
diff changeset
43 -- Solaris x86
kono
parents:
diff changeset
44 -- Darwin x86_64
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 -- This unit exposes vector _component_ types together with general comments
kono
parents:
diff changeset
47 -- on the binding contents.
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 -- One other unit is offered as of today: GNAT.SSE.Vector_Types, which
kono
parents:
diff changeset
50 -- exposes Ada types corresponding to the reference types (__m128 and the
kono
parents:
diff changeset
51 -- like) over which a binding to the SSE GCC builtins may operate.
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 -- The exposed Ada types are private. Object initializations or value
kono
parents:
diff changeset
54 -- observations may be performed with unchecked conversions or address
kono
parents:
diff changeset
55 -- overlays, for example:
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 -- with Ada.Unchecked_Conversion;
kono
parents:
diff changeset
58 -- with GNAT.SSE.Vector_Types; use GNAT.SSE, GNAT.SSE.Vector_Types;
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 -- procedure SSE_Base is
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 -- -- Core operations
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 -- function ia32_addps (A, B : m128) return m128;
kono
parents:
diff changeset
65 -- pragma Import (Intrinsic, ia32_addps, "__builtin_ia32_addps");
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 -- -- User views & conversions
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 -- type Vf32_View is array (1 .. 4) of GNAT.SSE.Float32;
kono
parents:
diff changeset
70 -- for Vf32_View'Alignment use VECTOR_ALIGN;
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 -- function To_m128 is new Ada.Unchecked_Conversion (Vf32_View, m128);
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 -- Xf32 : constant Vf32_View := (1.0, 1.0, 2.0, 2.0);
kono
parents:
diff changeset
75 -- Yf32 : constant Vf32_View := (2.0, 2.0, 1.0, 1.0);
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 -- X128 : constant m128 := To_m128 (Xf32);
kono
parents:
diff changeset
78 -- Y128 : constant m128 := To_m128 (Yf32);
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 -- begin
kono
parents:
diff changeset
81 -- -- Operations & overlays
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 -- declare
kono
parents:
diff changeset
84 -- Z128 : m128;
kono
parents:
diff changeset
85 -- Zf32 : Vf32_View;
kono
parents:
diff changeset
86 -- for Zf32'Address use Z128'Address;
kono
parents:
diff changeset
87 -- begin
kono
parents:
diff changeset
88 -- Z128 := ia32_addps (X128, Y128);
kono
parents:
diff changeset
89 -- if Zf32 /= (3.0, 3.0, 3.0, 3.0) then
kono
parents:
diff changeset
90 -- raise Program_Error;
kono
parents:
diff changeset
91 -- end if;
kono
parents:
diff changeset
92 -- end;
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 -- declare
kono
parents:
diff changeset
95 -- type m128_View_Kind is (SSE, F32);
kono
parents:
diff changeset
96 -- type m128_Object (View : m128_View_Kind := F32) is record
kono
parents:
diff changeset
97 -- case View is
kono
parents:
diff changeset
98 -- when SSE => V128 : m128;
kono
parents:
diff changeset
99 -- when F32 => Vf32 : Vf32_View;
kono
parents:
diff changeset
100 -- end case;
kono
parents:
diff changeset
101 -- end record;
kono
parents:
diff changeset
102 -- pragma Unchecked_Union (m128_Object);
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 -- O1 : constant m128_Object := (View => SSE, V128 => X128);
kono
parents:
diff changeset
105 -- begin
kono
parents:
diff changeset
106 -- if O1.Vf32 /= Xf32 then
kono
parents:
diff changeset
107 -- raise Program_Error;
kono
parents:
diff changeset
108 -- end if;
kono
parents:
diff changeset
109 -- end;
kono
parents:
diff changeset
110 -- end SSE_Base;
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 package GNAT.SSE is
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 -----------------------------------
kono
parents:
diff changeset
115 -- Common vector characteristics --
kono
parents:
diff changeset
116 -----------------------------------
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 VECTOR_BYTES : constant := 16;
kono
parents:
diff changeset
119 -- Common size of all the SSE vector types, in bytes.
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 VECTOR_ALIGN : constant := 16;
kono
parents:
diff changeset
122 -- Common alignment of all the SSE vector types, in bytes.
kono
parents:
diff changeset
123
kono
parents:
diff changeset
124 -- Alignment-wise, the reference document reads:
kono
parents:
diff changeset
125 -- << The compiler aligns __m128d and _m128i local and global data to
kono
parents:
diff changeset
126 -- 16-byte boundaries on the stack. >>
kono
parents:
diff changeset
127 --
kono
parents:
diff changeset
128 -- We apply that consistently to all the Ada vector types, as GCC does
kono
parents:
diff changeset
129 -- for the corresponding C types.
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 ----------------------------
kono
parents:
diff changeset
132 -- Vector component types --
kono
parents:
diff changeset
133 ----------------------------
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 type Float32 is new Float;
kono
parents:
diff changeset
136 type Float64 is new Long_Float;
kono
parents:
diff changeset
137 type Integer64 is new Long_Long_Integer;
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 end GNAT.SSE;