]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_ssa/traits/intrinsic.rs
add spans to injected coverage counters
[rust.git] / src / librustc_codegen_ssa / traits / intrinsic.rs
1 use super::BackendTypes;
2 use crate::mir::operand::OperandRef;
3 use rustc_middle::mir::Operand;
4 use rustc_middle::ty::{self, Ty};
5 use rustc_span::Span;
6 use rustc_target::abi::call::FnAbi;
7
8 pub trait IntrinsicCallMethods<'tcx>: BackendTypes {
9     /// Remember to add all intrinsics here, in librustc_typeck/check/mod.rs,
10     /// and in libcore/intrinsics.rs; if you need access to any llvm intrinsics,
11     /// add them to librustc_codegen_llvm/context.rs
12     fn codegen_intrinsic_call(
13         &mut self,
14         instance: ty::Instance<'tcx>,
15         fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
16         args: &[OperandRef<'tcx, Self::Value>],
17         llresult: Self::Value,
18         span: Span,
19         caller_instance: ty::Instance<'tcx>,
20     );
21
22     /// Intrinsic-specific pre-codegen processing, if any is required. Some intrinsics are handled
23     /// at compile time and do not generate code. Returns true if codegen is required or false if
24     /// the intrinsic does not need code generation.
25     fn is_codegen_intrinsic(
26         &mut self,
27         intrinsic: &str,
28         args: &Vec<Operand<'tcx>>,
29         caller_instance: ty::Instance<'tcx>,
30     ) -> bool;
31
32     fn abort(&mut self);
33     fn assume(&mut self, val: Self::Value);
34     fn expect(&mut self, cond: Self::Value, expected: bool) -> Self::Value;
35     fn sideeffect(&mut self);
36     /// Trait method used to inject `va_start` on the "spoofed" `VaListImpl` in
37     /// Rust defined C-variadic functions.
38     fn va_start(&mut self, val: Self::Value) -> Self::Value;
39     /// Trait method used to inject `va_end` on the "spoofed" `VaListImpl` before
40     /// Rust defined C-variadic functions return.
41     fn va_end(&mut self, val: Self::Value) -> Self::Value;
42 }