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    /// Remember to add all intrinsics here, in `compiler/rustc_hir_analysis/src/check/mod.rs`,
10    /// and in `library/core/src/intrinsics.rs`; if you need access to any LLVM intrinsics,
11    /// add them to `compiler/rustc_codegen_llvm/src/context.rs`.
12    /// Returns `Err` if another instance should be called instead. This is used to invoke
13    /// intrinsic default bodies in case an intrinsic is not implemented by the backend.
14    fn codegen_intrinsic_call(
15        &mut self,
16        instance: ty::Instance<'tcx>,
17        args: &[OperandRef<'tcx, Self::Value>],
18        result: PlaceRef<'tcx, Self::Value>,
19        span: Span,
20    ) -> Result<(), ty::Instance<'tcx>>;
21
22    fn abort(&mut self);
23    fn assume(&mut self, val: Self::Value);
24    fn expect(&mut self, cond: Self::Value, expected: bool) -> Self::Value;
25    /// Trait method used to load a function while testing if it is associated with a type
26    /// identifier.
27    fn type_checked_load(
28        &mut self,
29        llvtable: Self::Value,
30        vtable_byte_offset: u64,
31        typeid: Self::Metadata,
32    ) -> Self::Value;
33    /// Trait method used to inject `va_start` on the "spoofed" `VaListImpl` in
34    /// Rust defined C-variadic functions.
35    fn va_start(&mut self, val: Self::Value) -> Self::Value;
36    /// Trait method used to inject `va_end` on the "spoofed" `VaListImpl` before
37    /// Rust defined C-variadic functions return.
38    fn va_end(&mut self, val: Self::Value) -> Self::Value;
39}