// SPDX-License-Identifier: GPL-2.012//! Our own `compiler_builtins`.3//!4//! Rust provides [`compiler_builtins`] as a port of LLVM's [`compiler-rt`].5//! Since we do not need the vast majority of them, we avoid the dependency6//! by providing this file.7//!8//! At the moment, some builtins are required that should not be. For instance,9//! [`core`] has 128-bit integers functionality which we should not be compiling10//! in. We will work with upstream [`core`] to provide feature flags to disable11//! the parts we do not need. For the moment, we define them to [`panic!`] at12//! runtime for simplicity to catch mistakes, instead of performing surgery13//! on `core.o`.14//!15//! In any case, all these symbols are weakened to ensure we do not override16//! those that may be provided by the rest of the kernel.17//!18//! [`compiler_builtins`]: https://github.com/rust-lang/compiler-builtins19//! [`compiler-rt`]: https://compiler-rt.llvm.org/2021#![allow(internal_features)]22#![feature(compiler_builtins)]23#![compiler_builtins]24#![no_builtins]25#![no_std]2627macro_rules! define_panicking_intrinsics(28($reason: tt, { $($ident: ident, )* }) => {29$(30#[doc(hidden)]31#[export_name = concat!("__rust", stringify!($ident))]32pub extern "C" fn $ident() {33panic!($reason);34}35)*36}37);3839define_panicking_intrinsics!("`f32` should not be used", {40__addsf3,41__eqsf2,42__extendsfdf2,43__gesf2,44__lesf2,45__ltsf2,46__mulsf3,47__nesf2,48__truncdfsf2,49__unordsf2,50});5152define_panicking_intrinsics!("`f64` should not be used", {53__adddf3,54__eqdf2,55__ledf2,56__ltdf2,57__muldf3,58__unorddf2,59});6061define_panicking_intrinsics!("`i128` should not be used", {62__ashrti3,63__muloti4,64__multi3,65});6667define_panicking_intrinsics!("`u128` should not be used", {68__ashlti3,69__lshrti3,70__udivmodti4,71__udivti3,72__umodti3,73});7475#[cfg(target_arch = "arm")]76define_panicking_intrinsics!("`f32` should not be used", {77__aeabi_fadd,78__aeabi_fmul,79__aeabi_fcmpeq,80__aeabi_fcmple,81__aeabi_fcmplt,82__aeabi_fcmpun,83});8485#[cfg(target_arch = "arm")]86define_panicking_intrinsics!("`f64` should not be used", {87__aeabi_dadd,88__aeabi_dmul,89__aeabi_dcmple,90__aeabi_dcmplt,91__aeabi_dcmpun,92});9394#[cfg(target_arch = "arm")]95define_panicking_intrinsics!("`u64` division/modulo should not be used", {96__aeabi_uldivmod,97});9899// NOTE: if you are adding a new intrinsic here, you should also add it to100// `redirect-intrinsics` in `rust/Makefile`.101102103