]> git.lizzy.rs Git - rust.git/blob - src/librustc_platform_intrinsics/lib.rs
Auto merge of #42495 - alexcrichton:new-stage0, r=Mark-Simulacrum
[rust.git] / src / librustc_platform_intrinsics / lib.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 #![crate_name = "rustc_platform_intrinsics"]
12 #![crate_type = "dylib"]
13 #![crate_type = "rlib"]
14 #![deny(warnings)]
15 #![allow(bad_style)]
16
17 pub struct Intrinsic {
18     pub inputs: &'static [&'static Type],
19     pub output: &'static Type,
20
21     pub definition: IntrinsicDef,
22 }
23
24 #[derive(Clone, Hash, Eq, PartialEq)]
25 pub enum Type {
26     Void,
27     Integer(/* signed */ bool, u8, /* llvm width */ u8),
28     Float(u8),
29     Pointer(&'static Type, Option<&'static Type>, /* const */ bool),
30     Vector(&'static Type, Option<&'static Type>, u16),
31     Aggregate(bool, &'static [&'static Type]),
32 }
33
34 pub enum IntrinsicDef {
35     Named(&'static str),
36 }
37
38 static I8: Type = Type::Integer(true, 8, 8);
39 static I16: Type = Type::Integer(true, 16, 16);
40 static I32: Type = Type::Integer(true, 32, 32);
41 static I64: Type = Type::Integer(true, 64, 64);
42 static U8: Type = Type::Integer(false, 8, 8);
43 static U16: Type = Type::Integer(false, 16, 16);
44 static U32: Type = Type::Integer(false, 32, 32);
45 static U64: Type = Type::Integer(false, 64, 64);
46 static F32: Type = Type::Float(32);
47 static F64: Type = Type::Float(64);
48
49 static I32_8: Type = Type::Integer(true, 32, 8);
50
51 static I8x8: Type = Type::Vector(&I8, None, 8);
52 static U8x8: Type = Type::Vector(&U8, None, 8);
53 static I8x16: Type = Type::Vector(&I8, None, 16);
54 static U8x16: Type = Type::Vector(&U8, None, 16);
55 static I8x32: Type = Type::Vector(&I8, None, 32);
56 static U8x32: Type = Type::Vector(&U8, None, 32);
57 static I8x64: Type = Type::Vector(&I8, None, 64);
58 static U8x64: Type = Type::Vector(&U8, None, 64);
59 static I8x128: Type = Type::Vector(&I8, None, 128);
60 static U8x128: Type = Type::Vector(&U8, None, 128);
61 static I8x256: Type = Type::Vector(&I8, None, 256);
62 static U8x256: Type = Type::Vector(&U8, None, 256);
63
64 static I16x4: Type = Type::Vector(&I16, None, 4);
65 static U16x4: Type = Type::Vector(&U16, None, 4);
66 static I16x8: Type = Type::Vector(&I16, None, 8);
67 static U16x8: Type = Type::Vector(&U16, None, 8);
68 static I16x16: Type = Type::Vector(&I16, None, 16);
69 static U16x16: Type = Type::Vector(&U16, None, 16);
70 static I16x32: Type = Type::Vector(&I16, None, 32);
71 static U16x32: Type = Type::Vector(&U16, None, 32);
72 static I16x64: Type = Type::Vector(&I16, None, 64);
73 static U16x64: Type = Type::Vector(&U16, None, 64);
74 static I16x128: Type = Type::Vector(&I16, None, 128);
75 static U16x128: Type = Type::Vector(&U16, None, 128);
76
77 static I32x2: Type = Type::Vector(&I32, None, 2);
78 static U32x2: Type = Type::Vector(&U32, None, 2);
79 static I32x4: Type = Type::Vector(&I32, None, 4);
80 static U32x4: Type = Type::Vector(&U32, None, 4);
81 static I32x8: Type = Type::Vector(&I32, None, 8);
82 static U32x8: Type = Type::Vector(&U32, None, 8);
83 static I32x16: Type = Type::Vector(&I32, None, 16);
84 static U32x16: Type = Type::Vector(&U32, None, 16);
85 static I32x32: Type = Type::Vector(&I32, None, 32);
86 static U32x32: Type = Type::Vector(&U32, None, 32);
87 static I32x64: Type = Type::Vector(&I32, None, 64);
88 static U32x64: Type = Type::Vector(&U32, None, 64);
89
90 static I64x1: Type = Type::Vector(&I64, None, 1);
91 static U64x1: Type = Type::Vector(&U64, None, 1);
92 static I64x2: Type = Type::Vector(&I64, None, 2);
93 static U64x2: Type = Type::Vector(&U64, None, 2);
94 static I64x4: Type = Type::Vector(&I64, None, 4);
95 static U64x4: Type = Type::Vector(&U64, None, 4);
96
97 static F32x2: Type = Type::Vector(&F32, None, 2);
98 static F32x4: Type = Type::Vector(&F32, None, 4);
99 static F32x8: Type = Type::Vector(&F32, None, 8);
100 static F64x1: Type = Type::Vector(&F64, None, 1);
101 static F64x2: Type = Type::Vector(&F64, None, 2);
102 static F64x4: Type = Type::Vector(&F64, None, 4);
103
104 static I32x4_F32: Type = Type::Vector(&I32, Some(&F32), 4);
105 static I32x8_F32: Type = Type::Vector(&I32, Some(&F32), 8);
106 static I64x2_F64: Type = Type::Vector(&I64, Some(&F64), 2);
107 static I64x4_F64: Type = Type::Vector(&I64, Some(&F64), 4);
108
109 static VOID: Type = Type::Void;
110
111 mod x86;
112 mod arm;
113 mod aarch64;
114 mod nvptx;
115 mod hexagon;
116
117 impl Intrinsic {
118     pub fn find(name: &str) -> Option<Intrinsic> {
119         if name.starts_with("x86_") {
120             x86::find(name)
121         } else if name.starts_with("arm_") {
122             arm::find(name)
123         } else if name.starts_with("aarch64_") {
124             aarch64::find(name)
125         } else if name.starts_with("nvptx_") {
126             nvptx::find(name)
127         } else if name.starts_with("Q6_") {
128             hexagon::find(name)
129         } else {
130             None
131         }
132     }
133 }