]> git.lizzy.rs Git - rust.git/blob - src/test/codegen/simd-intrinsic-float-log.rs
Enable emission of alignment attrs for pointer params
[rust.git] / src / test / codegen / simd-intrinsic-float-log.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-emscripten
12
13 // compile-flags: -C no-prepopulate-passes
14
15 #![crate_type = "lib"]
16
17 #![feature(repr_simd, platform_intrinsics)]
18 #![allow(non_camel_case_types)]
19
20 #[repr(simd)]
21 #[derive(Copy, Clone, PartialEq, Debug)]
22 pub struct f32x2(pub f32, pub f32);
23
24 #[repr(simd)]
25 #[derive(Copy, Clone, PartialEq, Debug)]
26 pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
27
28 #[repr(simd)]
29 #[derive(Copy, Clone, PartialEq, Debug)]
30 pub struct f32x8(pub f32, pub f32, pub f32, pub f32,
31                  pub f32, pub f32, pub f32, pub f32);
32
33 #[repr(simd)]
34 #[derive(Copy, Clone, PartialEq, Debug)]
35 pub struct f32x16(pub f32, pub f32, pub f32, pub f32,
36                   pub f32, pub f32, pub f32, pub f32,
37                   pub f32, pub f32, pub f32, pub f32,
38                   pub f32, pub f32, pub f32, pub f32);
39
40 extern "platform-intrinsic" {
41     fn simd_flog<T>(x: T) -> T;
42 }
43
44 // CHECK-LABEL: @log_32x2
45 #[no_mangle]
46 pub unsafe fn log_32x2(a: f32x2) -> f32x2 {
47     // CHECK: call fast <2 x float> @llvm.log.v2f32
48     simd_flog(a)
49 }
50
51 // CHECK-LABEL: @log_32x4
52 #[no_mangle]
53 pub unsafe fn log_32x4(a: f32x4) -> f32x4 {
54     // CHECK: call fast <4 x float> @llvm.log.v4f32
55     simd_flog(a)
56 }
57
58 // CHECK-LABEL: @log_32x8
59 #[no_mangle]
60 pub unsafe fn log_32x8(a: f32x8) -> f32x8 {
61     // CHECK: call fast <8 x float> @llvm.log.v8f32
62     simd_flog(a)
63 }
64
65 // CHECK-LABEL: @log_32x16
66 #[no_mangle]
67 pub unsafe fn log_32x16(a: f32x16) -> f32x16 {
68     // CHECK: call fast <16 x float> @llvm.log.v16f32
69     simd_flog(a)
70 }
71
72 #[repr(simd)]
73 #[derive(Copy, Clone, PartialEq, Debug)]
74 pub struct f64x2(pub f64, pub f64);
75
76 #[repr(simd)]
77 #[derive(Copy, Clone, PartialEq, Debug)]
78 pub struct f64x4(pub f64, pub f64, pub f64, pub f64);
79
80 #[repr(simd)]
81 #[derive(Copy, Clone, PartialEq, Debug)]
82 pub struct f64x8(pub f64, pub f64, pub f64, pub f64,
83                  pub f64, pub f64, pub f64, pub f64);
84
85 // CHECK-LABEL: @log_64x4
86 #[no_mangle]
87 pub unsafe fn log_64x4(a: f64x4) -> f64x4 {
88     // CHECK: call fast <4 x double> @llvm.log.v4f64
89     simd_flog(a)
90 }
91
92 // CHECK-LABEL: @log_64x2
93 #[no_mangle]
94 pub unsafe fn log_64x2(a: f64x2) -> f64x2 {
95     // CHECK: call fast <2 x double> @llvm.log.v2f64
96     simd_flog(a)
97 }
98
99 // CHECK-LABEL: @log_64x8
100 #[no_mangle]
101 pub unsafe fn log_64x8(a: f64x8) -> f64x8 {
102     // CHECK: call fast <8 x double> @llvm.log.v8f64
103     simd_flog(a)
104 }