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