Skip to content

Subtree update for rustc_codegen_cranelift #117779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bad4be6
interpret: call caller_location logic the same way codegen does, and …
RalfJung Oct 28, 2023
c6f5090
share the track_caller handling within a mir::Body
RalfJung Oct 28, 2023
41dcb52
Merge commit 'dde58803fd6cbb270c7a437f36a8a3a29fbef679' into sync_cg_…
bjorn3 Oct 29, 2023
51f6ac7
Merge branch 'sync_from_rust'
bjorn3 Oct 29, 2023
9a33f82
Remove inline asm support from the list of limitations
bjorn3 Oct 30, 2023
aed0ed2
Rollup merge of #117317 - RalfJung:track-caller, r=oli-obk
GuillaumeGomez Oct 30, 2023
48ca2d9
Implement llvm.fma.v* intrinsics
bjorn3 Oct 31, 2023
03c9acd
Support enum variants in offset_of!
GKFX Aug 15, 2023
361585e
Sync from rust 75b064d26970ca8e7a487072f51835ebb057d575
bjorn3 Nov 2, 2023
04f1024
Rustup to rustc 1.75.0-nightly (75b064d26 2023-11-01)
bjorn3 Nov 2, 2023
c04ceb4
Fix workaround for the `int $$0x29` issue to not crash on empty inlin…
bjorn3 Nov 2, 2023
ef37036
Disable a couple of rustc tests which are broken due to a rustc bug
bjorn3 Nov 2, 2023
909513e
Use Value instead of CValue in CInlineAsmOperand
bjorn3 Nov 2, 2023
f6a8c3a
Add real implementation of _xgetbv()
bjorn3 Nov 2, 2023
8eca01f
Remove support for compiler plugins.
nnethercote Oct 3, 2023
1f09bae
Implement min/max neon intrisics
afonso360 Nov 4, 2023
88c2e78
Implement aarch64 addp intrinsics
afonso360 Nov 4, 2023
70a6abf
Add unsigned saturating add/sub intrinsics for aarch64
afonso360 Nov 4, 2023
f824da6
Make neon example build in all arches
afonso360 Nov 4, 2023
209476e
Only import aarch64 intrinsics on aarch64
afonso360 Nov 4, 2023
6a53ace
Implement _mm256_permute2f128_ps and _mm256_permute2f128_pd intrinsics
bjorn3 Nov 5, 2023
4381949
Implement all avx2 intrinsics used by the image crate
bjorn3 Nov 5, 2023
61e38ce
Implement all SSE intrinsics used by the jpeg-decoder crate
bjorn3 Nov 7, 2023
0a35232
Implement all vendor intrinsics used by the httparse crate
bjorn3 Nov 7, 2023
ecf79a3
Implement all vendor intrinsics used by the fimg crate
bjorn3 Nov 7, 2023
9f426ce
Merge pull request #1416 from afonso360/aarch64-intrinsics-1
bjorn3 Nov 7, 2023
8649731
Implement all vendor intrinsics used by the simd-json crate
bjorn3 Nov 7, 2023
82487a9
Merge pull request #1417 from rust-lang/implement_xgetbv
bjorn3 Nov 7, 2023
6e7961a
Sync from rust 0f44eb32f1123ac93ab404d74c295263ce468343
bjorn3 Nov 10, 2023
c84d187
Rustup to rustc 1.75.0-nightly (0f44eb32f 2023-11-09)
bjorn3 Nov 10, 2023
d186b49
Merge commit 'c84d1871dc4456539b7b578830268ab3539915d0' into sync_cg_…
bjorn3 Nov 10, 2023
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
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_cranelift/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ configuration options.

## Not yet supported

* Inline assembly ([no cranelift support](https://github.com/bytecodealliance/wasmtime/issues/1041))
* On UNIX there is support for invoking an external assembler for `global_asm!` and `asm!`.
* SIMD ([tracked here](https://github.com/rust-lang/rustc_codegen_cranelift/issues/171), `std::simd` fully works, `std::arch` is partially supported)
* Unwinding on panics ([no cranelift support](https://github.com/bytecodealliance/wasmtime/issues/1677), `-Cpanic=abort` is enabled by default)

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/build_system/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
TestCase::build_bin_and_run("aot.mod_bench", "example/mod_bench.rs", &[]),
TestCase::build_bin_and_run("aot.issue-72793", "example/issue-72793.rs", &[]),
TestCase::build_bin("aot.issue-59326", "example/issue-59326.rs"),
TestCase::build_bin_and_run("aot.neon", "example/neon.rs", &[]),
];

pub(crate) static RAND_REPO: GitRepo = GitRepo::github(
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ aot.float-minmax-pass
aot.mod_bench
aot.issue-72793
aot.issue-59326
aot.neon

testsuite.extended_sysroot
test.rust-random/rand
Expand Down
234 changes: 234 additions & 0 deletions compiler/rustc_codegen_cranelift/example/neon.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
// Most of these tests are copied from https://github.com/japaric/stdsimd/blob/0f4413d01c4f0c3ffbc5a69e9a37fbc7235b31a9/coresimd/arm/neon.rs

#![feature(portable_simd)]

#[cfg(target_arch = "aarch64")]
use std::arch::aarch64::*;
use std::mem::transmute;
use std::simd::*;

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmin_s8() {
let a = i8x8::from([1, -2, 3, -4, 5, 6, 7, 8]);
let b = i8x8::from([0, 3, 2, 5, 4, 7, 6, 9]);
let e = i8x8::from([-2, -4, 5, 7, 0, 2, 4, 6]);
let r: i8x8 = transmute(vpmin_s8(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmin_s16() {
let a = i16x4::from([1, 2, 3, -4]);
let b = i16x4::from([0, 3, 2, 5]);
let e = i16x4::from([1, -4, 0, 2]);
let r: i16x4 = transmute(vpmin_s16(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmin_s32() {
let a = i32x2::from([1, -2]);
let b = i32x2::from([0, 3]);
let e = i32x2::from([-2, 0]);
let r: i32x2 = transmute(vpmin_s32(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmin_u8() {
let a = u8x8::from([1, 2, 3, 4, 5, 6, 7, 8]);
let b = u8x8::from([0, 3, 2, 5, 4, 7, 6, 9]);
let e = u8x8::from([1, 3, 5, 7, 0, 2, 4, 6]);
let r: u8x8 = transmute(vpmin_u8(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmin_u16() {
let a = u16x4::from([1, 2, 3, 4]);
let b = u16x4::from([0, 3, 2, 5]);
let e = u16x4::from([1, 3, 0, 2]);
let r: u16x4 = transmute(vpmin_u16(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmin_u32() {
let a = u32x2::from([1, 2]);
let b = u32x2::from([0, 3]);
let e = u32x2::from([1, 0]);
let r: u32x2 = transmute(vpmin_u32(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmin_f32() {
let a = f32x2::from([1., -2.]);
let b = f32x2::from([0., 3.]);
let e = f32x2::from([-2., 0.]);
let r: f32x2 = transmute(vpmin_f32(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmax_s8() {
let a = i8x8::from([1, -2, 3, -4, 5, 6, 7, 8]);
let b = i8x8::from([0, 3, 2, 5, 4, 7, 6, 9]);
let e = i8x8::from([1, 3, 6, 8, 3, 5, 7, 9]);
let r: i8x8 = transmute(vpmax_s8(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmax_s16() {
let a = i16x4::from([1, 2, 3, -4]);
let b = i16x4::from([0, 3, 2, 5]);
let e = i16x4::from([2, 3, 3, 5]);
let r: i16x4 = transmute(vpmax_s16(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmax_s32() {
let a = i32x2::from([1, -2]);
let b = i32x2::from([0, 3]);
let e = i32x2::from([1, 3]);
let r: i32x2 = transmute(vpmax_s32(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmax_u8() {
let a = u8x8::from([1, 2, 3, 4, 5, 6, 7, 8]);
let b = u8x8::from([0, 3, 2, 5, 4, 7, 6, 9]);
let e = u8x8::from([2, 4, 6, 8, 3, 5, 7, 9]);
let r: u8x8 = transmute(vpmax_u8(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmax_u16() {
let a = u16x4::from([1, 2, 3, 4]);
let b = u16x4::from([0, 3, 2, 5]);
let e = u16x4::from([2, 4, 3, 5]);
let r: u16x4 = transmute(vpmax_u16(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmax_u32() {
let a = u32x2::from([1, 2]);
let b = u32x2::from([0, 3]);
let e = u32x2::from([2, 3]);
let r: u32x2 = transmute(vpmax_u32(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpmax_f32() {
let a = f32x2::from([1., -2.]);
let b = f32x2::from([0., 3.]);
let e = f32x2::from([1., 3.]);
let r: f32x2 = transmute(vpmax_f32(transmute(a), transmute(b)));
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vpadd_s16() {
let a = i16x4::from([1, 2, 3, 4]);
let b = i16x4::from([0, -1, -2, -3]);
let r: i16x4 = transmute(vpadd_s16(transmute(a), transmute(b)));
let e = i16x4::from([3, 7, -1, -5]);
assert_eq!(r, e);
}
#[cfg(target_arch = "aarch64")]
unsafe fn test_vpadd_s32() {
let a = i32x2::from([1, 2]);
let b = i32x2::from([0, -1]);
let r: i32x2 = transmute(vpadd_s32(transmute(a), transmute(b)));
let e = i32x2::from([3, -1]);
assert_eq!(r, e);
}
#[cfg(target_arch = "aarch64")]
unsafe fn test_vpadd_s8() {
let a = i8x8::from([1, 2, 3, 4, 5, 6, 7, 8]);
let b = i8x8::from([0, -1, -2, -3, -4, -5, -6, -7]);
let r: i8x8 = transmute(vpadd_s8(transmute(a), transmute(b)));
let e = i8x8::from([3, 7, 11, 15, -1, -5, -9, -13]);
assert_eq!(r, e);
}
#[cfg(target_arch = "aarch64")]
unsafe fn test_vpadd_u16() {
let a = u16x4::from([1, 2, 3, 4]);
let b = u16x4::from([30, 31, 32, 33]);
let r: u16x4 = transmute(vpadd_u16(transmute(a), transmute(b)));
let e = u16x4::from([3, 7, 61, 65]);
assert_eq!(r, e);
}
#[cfg(target_arch = "aarch64")]
unsafe fn test_vpadd_u32() {
let a = u32x2::from([1, 2]);
let b = u32x2::from([30, 31]);
let r: u32x2 = transmute(vpadd_u32(transmute(a), transmute(b)));
let e = u32x2::from([3, 61]);
assert_eq!(r, e);
}
#[cfg(target_arch = "aarch64")]
unsafe fn test_vpadd_u8() {
let a = u8x8::from([1, 2, 3, 4, 5, 6, 7, 8]);
let b = u8x8::from([30, 31, 32, 33, 34, 35, 36, 37]);
let r: u8x8 = transmute(vpadd_u8(transmute(a), transmute(b)));
let e = u8x8::from([3, 7, 11, 15, 61, 65, 69, 73]);
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vqsub_u8() {
let a = u8x8::from([1, 2, 3, 4, 5, 6, 7, 0xff]);
let b = u8x8::from([30, 1, 1, 1, 34, 0xff, 36, 37]);
let r: u8x8 = transmute(vqsub_u8(transmute(a), transmute(b)));
let e = u8x8::from([0, 1, 2, 3, 0, 0, 0, 218]);
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
unsafe fn test_vqadd_u8() {
let a = u8x8::from([1, 2, 3, 4, 5, 6, 7, 0xff]);
let b = u8x8::from([30, 1, 1, 1, 34, 0xff, 36, 37]);
let r: u8x8 = transmute(vqadd_u8(transmute(a), transmute(b)));
let e = u8x8::from([31, 3, 4, 5, 39, 0xff, 43, 0xff]);
assert_eq!(r, e);
}

#[cfg(target_arch = "aarch64")]
fn main() {
unsafe {
test_vpmin_s8();
test_vpmin_s16();
test_vpmin_s32();
test_vpmin_u8();
test_vpmin_u16();
test_vpmin_u32();
test_vpmin_f32();
test_vpmax_s8();
test_vpmax_s16();
test_vpmax_s32();
test_vpmax_u8();
test_vpmax_u16();
test_vpmax_u32();
test_vpmax_f32();

test_vpadd_s16();
test_vpadd_s32();
test_vpadd_s8();
test_vpadd_u16();
test_vpadd_u32();
test_vpadd_u8();

test_vqsub_u8();
test_vqadd_u8();
}
}

#[cfg(not(target_arch = "aarch64"))]
fn main() {}
9 changes: 4 additions & 5 deletions compiler/rustc_codegen_cranelift/patches/stdlib-lock.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.100"
version = "0.1.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6c0f24437059853f0fa64afc51f338f93647a3de4cf3358ba1bb4171a199775"
checksum = "a3b73c3443a5fd2438d7ba4853c64e4c8efc2404a9e28a9234cc2d5eebc6c242"
dependencies = [
"cc",
"rustc-std-workspace-core",
Expand Down Expand Up @@ -158,9 +158,9 @@ dependencies = [

[[package]]
name = "libc"
version = "0.2.149"
version = "0.2.150"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
dependencies = [
"rustc-std-workspace-core",
]
Expand Down Expand Up @@ -415,7 +415,6 @@ dependencies = [
name = "unwind"
version = "0.0.0"
dependencies = [
"cc",
"cfg-if",
"compiler_builtins",
"core",
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-10-29"
channel = "nightly-2023-11-10"
components = ["rust-src", "rustc-dev", "llvm-tools"]
5 changes: 5 additions & 0 deletions compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ rm tests/ui/process/nofile-limit.rs # TODO some AArch64 linking issue

rm tests/ui/stdio-is-blocking.rs # really slow with unoptimized libstd

# rustc bugs
# ==========
# https://github.com/rust-lang/rust/pull/116447#issuecomment-1790451463
rm tests/ui/coroutine/gen_block_*.rs

cp ../dist/bin/rustdoc-clif ../dist/bin/rustdoc # some tests expect bin/rustdoc to exist

# prevent $(RUSTDOC) from picking up the sysroot built by x.py. It conflicts with the one used by
Expand Down
Loading