Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 61 additions & 6 deletions tests/auxiliary/minicore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,25 @@ macro_rules! compile_error {
pub trait Add<Rhs = Self> {
type Output;

fn add(self, _: Rhs) -> Self::Output;
fn add(self, rhs: Rhs) -> Self::Output;
}

impl Add<isize> for isize {
type Output = isize;
macro_rules! impl_add {
($($ty:ty),* $(,)?) => {
$(
impl Add for $ty {
type Output = Self;

fn add(self, other: isize) -> isize {
7 // avoid needing to add all of the overflow handling and panic language items
}
fn add(self, rhs: Self) -> Self {
self + rhs
}
}
)*
};
}

impl_add!(i8, u8, i32, u32, i64, u64, isize, usize);

#[lang = "neg"]
pub trait Neg {
type Output;
Expand Down Expand Up @@ -367,6 +375,7 @@ pub mod ptr {
}
}

#[expect(non_camel_case_types, reason = "equivalent of a C type")]
#[lang = "c_void"]
#[repr(u8)]
pub enum c_void {
Expand Down Expand Up @@ -405,3 +414,49 @@ pub enum SimdAlign {
}

impl ConstParamTy_ for SimdAlign {}

#[lang = "eq"]
pub trait PartialEq<Rhs: ?Sized = Self> {
fn eq(&self, other: &Rhs) -> bool;
fn ne(&self, other: &Rhs) -> bool;
}

macro_rules! impl_partial_eq {
($($ty:ty),* $(,)?) => {
$(
impl PartialEq for $ty {
fn eq(&self, other: &$ty) -> bool {
(*self) == (*other)
}

fn ne(&self, other: &$ty) -> bool {
(*self) != (*other)
}
}
)*
};
}

impl_partial_eq!(i8, u8, i32, u32, i64, u64, isize, usize);

#[lang = "index"]
pub trait Index<Idx: ?Sized> {
type Output: ?Sized;
fn index(&self, index: Idx) -> &Self::Output;
}

impl<T, const N: usize> Index<usize> for [T; N] {
type Output = T;

fn index(&self, index: usize) -> &Self::Output {
&self[index]
}
}

impl<T> Index<usize> for [T] {
type Output = T;

fn index(&self, index: usize) -> &Self::Output {
&self[index]
}
}
17 changes: 9 additions & 8 deletions tests/codegen-llvm/bpf-abi-indirect-return.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
// Checks that results larger than one register are returned indirectly
//@ only-bpf
//@ add-minicore
//@ needs-llvm-components: bpf
//@ compile-flags: --target bpfel-unknown-none

#![feature(lang_items, no_core)]
#![no_core]
#![no_std]
#![no_main]

extern crate minicore;
use minicore::Result::*;
use minicore::*;

#[no_mangle]
fn outer(a: u64) -> u64 {
let v = match inner_res(a) {
Expand All @@ -16,7 +22,7 @@ fn outer(a: u64) -> u64 {
inner_big(v).a[0] as u64
}

// CHECK-LABEL: define {{.*}} @_ZN{{.*}}inner_res{{.*}}E(
// CHECK-LABEL: define {{.*}} @_R{{.*}}inner_res(
// CHECK-SAME: ptr{{[^,]*}},
// CHECK-SAME: i64{{[^)]*}}
#[inline(never)]
Expand All @@ -29,15 +35,10 @@ struct Big {
b: u64,
}

// CHECK-LABEL: define {{.*}} @_ZN{{.*}}inner_big{{.*}}E(
// CHECK-LABEL: define {{.*}} @_R{{.*}}inner_big(
// CHECK-SAME: ptr{{[^,]*}},
// CHECK-SAME: i64{{[^)]*}}
#[inline(never)]
fn inner_big(a: u64) -> Big {
Big { a: [a as u16; 32], b: 42 }
}

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
Loading