]> git.lizzy.rs Git - rust.git/blob - src/librustc_platform_intrinsics/aarch64.rs
fix spacing issue in trpl/documentation doc
[rust.git] / src / librustc_platform_intrinsics / aarch64.rs
1 // Copyright 2015 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 use {Intrinsic, i, f, v};
12 use rustc::middle::ty;
13
14 macro_rules! p {
15     ($name: expr, ($($inputs: tt),*) -> $output: tt) => {
16         plain!(concat!("llvm.aarch64.neon.", $name), ($($inputs),*) -> $output)
17     }
18 }
19 pub fn find<'tcx>(_tcx: &ty::ctxt<'tcx>, name: &str) -> Option<Intrinsic> {
20     Some(match name {
21         "vmaxvq_u8" => p!("umaxv.i8.v16i8", (i8x16) -> i8),
22         "vmaxvq_u16" => p!("umaxv.i16.v8i16", (i16x8) -> i16),
23         "vmaxvq_u32" => p!("umaxv.i32.v4i32", (i32x4) -> i32),
24
25         "vmaxvq_s8" => p!("smaxv.i8.v16i8", (i8x16) -> i8),
26         "vmaxvq_s16" => p!("smaxv.i16.v8i16", (i16x8) -> i16),
27         "vmaxvq_s32" => p!("smaxv.i32.v4i32", (i32x4) -> i32),
28
29         "vminvq_u8" => p!("uminv.i8.v16i8", (i8x16) -> i8),
30         "vminvq_u16" => p!("uminv.i16.v8i16", (i16x8) -> i16),
31         "vminvq_u32" => p!("uminv.i32.v4i32", (i32x4) -> i32),
32         "vminvq_s8" => p!("sminv.i8.v16i8", (i8x16) -> i8),
33         "vminvq_s16" => p!("sminv.i16.v8i16", (i16x8) -> i16),
34         "vminvq_s32" => p!("sminv.i32.v4i32", (i32x4) -> i32),
35
36         "vsqrtq_f32" => plain!("llvm.sqrt.v4f32", (f32x4) -> f32x4),
37         "vsqrtq_f64" => plain!("llvm.sqrt.v2f64", (f64x2) -> f64x2),
38
39         "vrsqrteq_f32" => p!("vrsqrte.v4f32", (f32x4) -> f32x4),
40         "vrsqrteq_f64" => p!("vrsqrte.v2f64", (f64x2) -> f64x2),
41         "vrecpeq_f32" => p!("vrecpe.v4f32", (f32x4) -> f32x4),
42         "vrecpeq_f64" => p!("vrecpe.v2f64", (f64x2) -> f64x2),
43
44         "vmaxq_f32" => p!("fmax.v4f32", (f32x4, f32x4) -> f32x4),
45         "vmaxq_f64" => p!("fmax.v2f64", (f64x2, f64x2) -> f64x2),
46
47         "vminq_f32" => p!("fmin.v4f32", (f32x4, f32x4) -> f32x4),
48         "vminq_f64" => p!("fmin.v2f64", (f64x2, f64x2) -> f64x2),
49         _ => return None,
50     })
51 }