// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 or the MIT license // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![cfg_attr(stage0, feature(custom_attribute))] #![crate_name = "rustc_platform_intrinsics"] #![unstable(feature = "rustc_private", issue = "27812")] #![staged_api] #![crate_type = "dylib"] #![crate_type = "rlib"] #![feature(staged_api, rustc_private)] extern crate rustc_llvm as llvm; extern crate rustc; use rustc::middle::ty; pub struct Intrinsic { pub inputs: Vec, pub output: Type, pub definition: IntrinsicDef, } #[derive(Clone, Hash, Eq, PartialEq)] pub enum Type { Integer(/* signed */ bool, u8, /* llvm width */ u8), Float(u8), Pointer(Box), Vector(Box, u8), Aggregate(bool, Vec), } pub enum IntrinsicDef { Named(&'static str), } fn i(width: u8) -> Type { Type::Integer(true, width, width) } fn i_(width: u8, llvm_width: u8) -> Type { Type::Integer(true, width, llvm_width) } fn u(width: u8) -> Type { Type::Integer(false, width, width) } #[allow(dead_code)] fn u_(width: u8, llvm_width: u8) -> Type { Type::Integer(false, width, llvm_width) } fn f(width: u8) -> Type { Type::Float(width) } fn v(x: Type, length: u8) -> Type { Type::Vector(Box::new(x), length) } fn agg(flatten: bool, types: Vec) -> Type { Type::Aggregate(flatten, types) } mod x86; mod arm; mod aarch64; impl Intrinsic { pub fn find<'tcx>(tcx: &ty::ctxt<'tcx>, name: &str) -> Option { if name.starts_with("x86_") { x86::find(tcx, name) } else if name.starts_with("arm_") { arm::find(tcx, name) } else if name.starts_with("aarch64_") { aarch64::find(tcx, name) } else { None } } }