rustc_codegen_ssa/traits/intrinsic.rs
1use rustc_middle::ty::{self, Ty};
2use rustc_span::Span;
3use rustc_target::callconv::FnAbi;
4
5use super::BackendTypes;
6use crate::mir::operand::OperandRef;
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 fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
18 args: &[OperandRef<'tcx, Self::Value>],
19 llresult: Self::Value,
20 span: Span,
21 ) -> Result<(), ty::Instance<'tcx>>;
22
23 fn abort(&mut self);
24 fn assume(&mut self, val: Self::Value);
25 fn expect(&mut self, cond: Self::Value, expected: bool) -> Self::Value;
26 /// Trait method used to test whether a given pointer is associated with a type identifier.
27 fn type_test(&mut self, pointer: Self::Value, typeid: Self::Metadata) -> Self::Value;
28 /// Trait method used to load a function while testing if it is associated with a type
29 /// identifier.
30 fn type_checked_load(
31 &mut self,
32 llvtable: Self::Value,
33 vtable_byte_offset: u64,
34 typeid: Self::Metadata,
35 ) -> Self::Value;
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}