rustc_codegen_ssa/traits/
intrinsic.rs

1use rustc_middle::ty;
2use rustc_span::Span;
3
4use super::BackendTypes;
5use crate::mir::operand::OperandRef;
6use crate::mir::place::PlaceRef;
7
8pub trait IntrinsicCallBuilderMethods<'tcx>: BackendTypes {
9    /// Higher-level interface to emitting calls to intrinsics
10    ///
11    /// Remember to add all intrinsics here, in `compiler/rustc_hir_analysis/src/check/mod.rs`,
12    /// and in `library/core/src/intrinsics.rs`; if you need access to any LLVM intrinsics,
13    /// add them to `compiler/rustc_codegen_llvm/src/context.rs`.
14    /// Returns `Err` if another instance should be called instead. This is used to invoke
15    /// intrinsic default bodies in case an intrinsic is not implemented by the backend.
16    ///
17    /// NOTE: allowed to call [`BuilderMethods::call`]
18    ///
19    /// [`BuilderMethods::call`]: super::builder::BuilderMethods::call
20    fn codegen_intrinsic_call(
21        &mut self,
22        instance: ty::Instance<'tcx>,
23        args: &[OperandRef<'tcx, Self::Value>],
24        result_dest: PlaceRef<'tcx, Self::Value>,
25        span: Span,
26    ) -> Result<(), ty::Instance<'tcx>>;
27
28    fn codegen_llvm_intrinsic_call(
29        &mut self,
30        instance: ty::Instance<'tcx>,
31        args: &[OperandRef<'tcx, Self::Value>],
32        is_cleanup: bool,
33    ) -> Self::Value;
34
35    fn abort(&mut self);
36    fn assume(&mut self, val: Self::Value);
37    fn expect(&mut self, cond: Self::Value, expected: bool) -> Self::Value;
38    /// Trait method used to load a function while testing if it is associated with a type
39    /// identifier.
40    fn type_checked_load(
41        &mut self,
42        llvtable: Self::Value,
43        vtable_byte_offset: u64,
44        typeid: Self::Metadata,
45    ) -> Self::Value;
46    /// Trait method used to inject `va_start` on the "spoofed" `VaList` in
47    /// Rust defined C-variadic functions.
48    fn va_start(&mut self, val: Self::Value) -> Self::Value;
49    /// Trait method used to inject `va_end` on the "spoofed" `VaList` before
50    /// Rust defined C-variadic functions return.
51    fn va_end(&mut self, val: Self::Value) -> Self::Value;
52}