]> git.proxmox.com Git - rustc.git/blame - src/librustc_platform_intrinsics/lib.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / librustc_platform_intrinsics / lib.rs
CommitLineData
e9174d1e
SL
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
e9174d1e
SL
11#![crate_name = "rustc_platform_intrinsics"]
12#![unstable(feature = "rustc_private", issue = "27812")]
e9174d1e
SL
13#![crate_type = "dylib"]
14#![crate_type = "rlib"]
54a0048b 15#![feature(staged_api)]
7453a54e 16#![cfg_attr(not(stage0), deny(warnings))]
54a0048b 17#![allow(bad_style)]
e9174d1e
SL
18
19pub struct Intrinsic {
54a0048b
SL
20 pub inputs: &'static [&'static Type],
21 pub output: &'static Type,
e9174d1e
SL
22
23 pub definition: IntrinsicDef,
24}
25
26#[derive(Clone, Hash, Eq, PartialEq)]
27pub enum Type {
28 Void,
29 Integer(/* signed */ bool, u8, /* llvm width */ u8),
30 Float(u8),
54a0048b
SL
31 Pointer(&'static Type, Option<&'static Type>, /* const */ bool),
32 Vector(&'static Type, Option<&'static Type>, u8),
33 Aggregate(bool, &'static [&'static Type]),
e9174d1e
SL
34}
35
36pub enum IntrinsicDef {
37 Named(&'static str),
38}
39
54a0048b
SL
40static I8: Type = Type::Integer(true, 8, 8);
41static I16: Type = Type::Integer(true, 16, 16);
42static I32: Type = Type::Integer(true, 32, 32);
43static I64: Type = Type::Integer(true, 64, 64);
44static U8: Type = Type::Integer(false, 8, 8);
45static U16: Type = Type::Integer(false, 16, 16);
46static U32: Type = Type::Integer(false, 32, 32);
47static U64: Type = Type::Integer(false, 64, 64);
48static F32: Type = Type::Float(32);
49static F64: Type = Type::Float(64);
50
51static I32_8: Type = Type::Integer(true, 32, 8);
52
53static I8x8: Type = Type::Vector(&I8, None, 8);
54static U8x8: Type = Type::Vector(&U8, None, 8);
55static I8x16: Type = Type::Vector(&I8, None, 16);
56static U8x16: Type = Type::Vector(&U8, None, 16);
57static I8x32: Type = Type::Vector(&I8, None, 32);
58static U8x32: Type = Type::Vector(&U8, None, 32);
59
60static I16x4: Type = Type::Vector(&I16, None, 4);
61static U16x4: Type = Type::Vector(&U16, None, 4);
62static I16x8: Type = Type::Vector(&I16, None, 8);
63static U16x8: Type = Type::Vector(&U16, None, 8);
64static I16x16: Type = Type::Vector(&I16, None, 16);
65static U16x16: Type = Type::Vector(&U16, None, 16);
66
67static I32x2: Type = Type::Vector(&I32, None, 2);
68static U32x2: Type = Type::Vector(&U32, None, 2);
69static I32x4: Type = Type::Vector(&I32, None, 4);
70static U32x4: Type = Type::Vector(&U32, None, 4);
71static I32x8: Type = Type::Vector(&I32, None, 8);
72static U32x8: Type = Type::Vector(&U32, None, 8);
73
74static I64x1: Type = Type::Vector(&I64, None, 1);
75static U64x1: Type = Type::Vector(&U64, None, 1);
76static I64x2: Type = Type::Vector(&I64, None, 2);
77static U64x2: Type = Type::Vector(&U64, None, 2);
78static I64x4: Type = Type::Vector(&I64, None, 4);
79static U64x4: Type = Type::Vector(&U64, None, 4);
80
81static F32x2: Type = Type::Vector(&F32, None, 2);
82static F32x4: Type = Type::Vector(&F32, None, 4);
83static F32x8: Type = Type::Vector(&F32, None, 8);
84static F64x1: Type = Type::Vector(&F64, None, 1);
85static F64x2: Type = Type::Vector(&F64, None, 2);
86static F64x4: Type = Type::Vector(&F64, None, 4);
87
88static I32x4_F32: Type = Type::Vector(&I32, Some(&F32), 4);
89static I32x8_F32: Type = Type::Vector(&I32, Some(&F32), 8);
90static I64x2_F64: Type = Type::Vector(&I64, Some(&F64), 2);
91static I64x4_F64: Type = Type::Vector(&I64, Some(&F64), 4);
92
93static VOID: Type = Type::Void;
e9174d1e
SL
94
95mod x86;
96mod arm;
97mod aarch64;
98
99impl Intrinsic {
54a0048b 100 pub fn find(name: &str) -> Option<Intrinsic> {
e9174d1e 101 if name.starts_with("x86_") {
54a0048b 102 x86::find(name)
e9174d1e 103 } else if name.starts_with("arm_") {
54a0048b 104 arm::find(name)
e9174d1e 105 } else if name.starts_with("aarch64_") {
54a0048b 106 aarch64::find(name)
e9174d1e
SL
107 } else {
108 None
109 }
110 }
111}