OSDN Git Service

* gnat.dg/lto6.adb: Remove superfluous -gnat05 switch.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gnat.dg / sse_nolib.adb
1 --  { dg-do run { target i?86-*-* x86_64-*-* } }
2 --  { dg-options "-O1 -msse" }
3
4 with Ada.Unchecked_Conversion;
5
6 procedure SSE_Nolib is
7
8    --  Base vector type definitions
9
10    package SSE_Types is
11       VECTOR_ALIGN : constant := 16;
12       VECTOR_BYTES : constant := 16;
13             
14       type m128 is private;
15    private
16       type m128 is array (1 .. 4) of Float;
17       for m128'Alignment use VECTOR_ALIGN;
18       pragma Machine_Attribute (m128, "vector_type");
19       pragma Machine_Attribute (m128, "may_alias");
20    end SSE_Types;
21
22    use SSE_Types;
23
24    --  Core operations
25
26    function mm_add_ss (A, B : m128) return m128;
27    pragma Import (Intrinsic, mm_add_ss, "__builtin_ia32_addss");
28
29    --  User views / conversions or overlays
30
31    type Vf32_View is array (1 .. 4) of Float;
32    for Vf32_View'Alignment use VECTOR_ALIGN;
33
34    function To_m128 is new Ada.Unchecked_Conversion (Vf32_View, m128);
35    function To_m128 is new Ada.Unchecked_Conversion (m128, Vf32_View);
36
37    X, Y, Z : M128;
38
39    Vz : Vf32_View;
40    for Vz'Address use Z'Address;
41 begin
42    X := To_m128 ((1.0, 1.0, 2.0, 2.0));
43    Y := To_m128 ((2.0, 2.0, 1.0, 1.0));
44    Z := mm_add_ss (X, Y);
45
46    if Vz /= (3.0, 1.0, 2.0, 2.0) then
47       raise Program_Error;
48    end if;
49 end SSE_Nolib;