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 abort(&mut self);
29 fn assume(&mut self, val: Self::Value);
30 fn expect(&mut self, cond: Self::Value, expected: bool) -> Self::Value;
31 /// Trait method used to load a function while testing if it is associated with a type
32 /// identifier.
33 fn type_checked_load(
34 &mut self,
35 llvtable: Self::Value,
36 vtable_byte_offset: u64,
37 typeid: Self::Metadata,
38 ) -> Self::Value;
39 /// Trait method used to inject `va_start` on the "spoofed" `VaListImpl` in
40 /// Rust defined C-variadic functions.
41 fn va_start(&mut self, val: Self::Value) -> Self::Value;
42 /// Trait method used to inject `va_end` on the "spoofed" `VaListImpl` before
43 /// Rust defined C-variadic functions return.
44 fn va_end(&mut self, val: Self::Value) -> Self::Value;
45}