]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_llvm/interfaces/intrinsic.rs
Moved Backend interface into rustc_codegen_utils
[rust.git] / src / librustc_codegen_llvm / interfaces / intrinsic.rs
1 // Copyright 2018 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 super::Backend;
12 use super::HasCodegen;
13 use abi::FnType;
14 use mir::operand::OperandRef;
15 use rustc::ty::Ty;
16 use syntax_pos::Span;
17
18 pub trait IntrinsicCallMethods<'tcx>: HasCodegen<'tcx> {
19     /// Remember to add all intrinsics here, in librustc_typeck/check/mod.rs,
20     /// and in libcore/intrinsics.rs; if you need access to any llvm intrinsics,
21     /// add them to librustc_codegen_llvm/context.rs
22     fn codegen_intrinsic_call(
23         &self,
24         callee_ty: Ty<'tcx>,
25         fn_ty: &FnType<'tcx, Ty<'tcx>>,
26         args: &[OperandRef<'tcx, Self::Value>],
27         llresult: Self::Value,
28         span: Span,
29     );
30 }
31
32 pub trait IntrinsicDeclarationMethods<'tcx>: Backend<'tcx> {
33     fn get_intrinsic(&self, key: &str) -> Self::Value;
34
35     /// Declare any llvm intrinsics that you might need
36     fn declare_intrinsic(&self, key: &str) -> Option<Self::Value>;
37 }