Commit Graph

4182 Commits

Author SHA1 Message Date
Nilstrieb
6fea128f8c Use rust-analyzer.rustc.source to get r-a working with rustc 2024-01-04 15:24:51 +01:00
bjorn3
b3b36e91c6
Merge pull request #1443 from Nilstrieb/x86-signed-pack
Restructure x86 signed pack instructions
2024-01-03 20:43:24 +01:00
Nilstrieb
22019dbac8 Mention correctness test 2024-01-03 20:28:08 +01:00
Nilstrieb
c8f5d35508 Restructure x86 signed pack instructions
This reduces the amount of duplicated code and the chance for bugs.

I validated the new code for correctness against LLVM using the
following script. It found many bugs in the implementation until I was
finally able to get it correct and passing.

```rust
//! Test for x86 pack instructions. Prints deterministic results, use it to compare backends.
use std::arch::x86_64::{self, __m128i, __m256i};
use rand::{rngs::SmallRng, Rng, SeedableRng};
fn main() {
    let rng = &mut SmallRng::seed_from_u64(123);
    for _ in 0..100_000 {
        unsafe {
            sse_test(rng);
            avx_test(rng);
        }
    }
}
unsafe fn sse_test(rng: &mut SmallRng) {
    print_sse_8(x86_64::_mm_packus_epi16(sse16(rng), sse16(rng)));
    print_sse_8(x86_64::_mm_packs_epi16(sse16(rng), sse16(rng)));
    print_sse_16(x86_64::_mm_packus_epi32(sse32(rng), sse32(rng)));
    print_sse_16(x86_64::_mm_packs_epi32(sse32(rng), sse32(rng)));
}
unsafe fn avx_test(rng: &mut SmallRng) {
    print_avx_8(x86_64::_mm256_packs_epi16(avx16(rng), avx16(rng)));
    print_avx_8(x86_64::_mm256_packs_epi16(avx16(rng), avx16(rng)));
    print_avx_16(x86_64::_mm256_packus_epi32(avx32(rng), avx32(rng)));
    print_avx_16(x86_64::_mm256_packs_epi32(avx32(rng), avx32(rng)));
}
fn print_sse_8(t: __m128i) {
    let ints = unsafe { std::mem::transmute::<_, [i8; 16]>(t) };
    println!("{ints:?}");
}
fn print_sse_16(t: __m128i) {
    let ints = unsafe { std::mem::transmute::<_, [i16; 8]>(t) };
    println!("{ints:?}");
}
fn print_avx_8(t: __m256i) {
    let ints = unsafe { std::mem::transmute::<_, [i8; 32]>(t) };
    println!("{ints:?}");
}
fn print_avx_16(t: __m256i) {
    let ints = unsafe { std::mem::transmute::<_, [i16; 16]>(t) };
    println!("{ints:?}");
}
fn sse16(rand: &mut SmallRng) -> __m128i {
    unsafe { std::mem::transmute([(); 8].map(|()| i16(rand))) }
}
fn sse32(rand: &mut SmallRng) -> __m128i {
    unsafe { std::mem::transmute([(); 4].map(|()| i32(rand))) }
}
fn avx16(rand: &mut SmallRng) -> __m256i {
    unsafe { std::mem::transmute([(); 16].map(|()| i16(rand))) }
}
fn avx32(rand: &mut SmallRng) -> __m256i {
    unsafe { std::mem::transmute([(); 8].map(|()| i32(rand))) }
}
fn i16(rand: &mut SmallRng) -> i16 {
    if rand.gen() {
        rand.gen::<i16>()
    } else {
        rand.gen::<i8>() as i16
    }
}
fn i32(rand: &mut SmallRng) -> i32 {
    if rand.gen() {
        rand.gen::<i32>()
    } else {
        rand.gen::<i16>() as i32
    }
}
```
2024-01-03 20:25:44 +01:00
bjorn3
3b8794edf4 Fix xmm operands in inline assembly 2024-01-03 11:08:32 +00:00
bjorn3
45d8c121ba Return architecturally mandated target features to rustc
In the future the actual target features that Cranelift enables should
be returned here, but for now this works.

Fixes rust-lang/rustc_codegen_cranelift#1438
2024-01-02 21:17:00 +00:00
bjorn3
c427754b52 Add platform support matrix
Fixes rust-lang/rustc_codegen_cranelift#1441
2024-01-02 20:39:31 +00:00
bjorn3
0c72b43614 Merge branch 'sync_from_rust' 2023-12-31 13:31:46 +00:00
bjorn3
0cfbc47b9a Merge commit '6d355f6844323db03bfd608899613e363e701951' into sync_cg_clif-2023-12-31 2023-12-31 13:29:53 +00:00
bjorn3
6d355f6844
Merge pull request #1440 from rust-lang/ci_speedup_and_cleanup
Slightly reduce CI runtime and reduce log verbosity
2023-12-31 14:26:48 +01:00
bjorn3
c55aaa55a7 Remove no longer needed config option from setup_rust_fork.sh 2023-12-31 12:39:20 +00:00
bjorn3
02183f79e4 Suppress default config change warnings 2023-12-31 12:22:38 +00:00
bjorn3
d58de3ea81 Suppress progress notifications for all git commands 2023-12-31 11:53:42 +00:00
bjorn3
3fa4efffb0 Install ripgrep using the system package manager 2023-12-31 11:14:50 +00:00
bjorn3
e2502acd15 Update the GHA artifacts actions to v4 2023-12-31 11:04:53 +00:00
bjorn3
4b239facd7 Install hyperfine using the system package manager 2023-12-31 11:01:07 +00:00
bjorn3
75f1c2b5a7 Rustup to rustc 1.77.0-nightly (2a3e63551 2023-12-30) 2023-12-31 10:46:02 +00:00
bjorn3
5c95200e96 Rustup to rustc 1.77.0-nightly (3cdd004e5 2023-12-29) 2023-12-30 12:06:21 +00:00
bjorn3
fa9cce061e Sync from rust 3cdd004e55 2023-12-30 11:00:12 +00:00
Michael Goulet
6b1a3ad4a6 Remove movability from TyKind::Coroutine 2023-12-28 16:35:01 +00:00
bjorn3
1dbb249844 Rustup to rustc 1.77.0-nightly (89e2160c4 2023-12-27) 2023-12-28 16:26:57 +00:00
bjorn3
4c0ad606d0 Sync from rust 89e2160c4c 2023-12-28 15:55:42 +00:00
bjorn3
e101a1bbb7 Avoid warning about the jobserver fd not being open for recursive rustc calls for inline asm
Fixes rust-lang/rustc_codegen_cranelift#1437
2023-12-26 11:25:52 +00:00
bors
bcae781754 Auto merge of #119146 - nnethercote:rm-DiagCtxt-api-duplication, r=compiler-errors
Remove `DiagCtxt` API duplication

`DiagCtxt` defines the internal API for creating and emitting diagnostics: methods like `struct_err`, `struct_span_warn`, `note`, `create_fatal`, `emit_bug`. There are over 50 methods.

Some of these methods are then duplicated across several other types: `Session`, `ParseSess`, `Parser`, `ExtCtxt`, and `MirBorrowckCtxt`. `Session` duplicates the most, though half the ones it does are unused. Each duplicated method just calls forward to the corresponding method in `DiagCtxt`. So this duplication exists to (in the best case) shorten chains like `ecx.tcx.sess.parse_sess.dcx.emit_err()` to `ecx.emit_err()`.

This API duplication is ugly and has been bugging me for a while. And it's inconsistent: there's no real logic about which methods are duplicated, and the use of `#[rustc_lint_diagnostic]` and `#[track_caller]` attributes vary across the duplicates.

This PR removes the duplicated API methods and makes all diagnostic creation and emission go through `DiagCtxt`. It also adds `dcx` getter methods to several types to shorten chains. This approach scales *much* better than API duplication; indeed, the PR adds `dcx()` to numerous types that didn't have API duplication: `TyCtxt`, `LoweringCtxt`, `ConstCx`, `FnCtxt`, `TypeErrCtxt`, `InferCtxt`, `CrateLoader`, `CheckAttrVisitor`, and `Resolver`. These result in a lot of changes from `foo.tcx.sess.emit_err()` to `foo.dcx().emit_err()`. (You could do this with more types, but it gets into diminishing returns territory for types that don't emit many diagnostics.)

After all these changes, some call sites are more verbose, some are less verbose, and many are the same. The total number of lines is reduced, mostly because of the removed API duplication. And consistency is increased, because calls to `emit_err` and friends are always preceded with `.dcx()` or `.dcx`.

r? `@compiler-errors`
2023-12-26 02:24:39 +00:00
bjorn3
653121cd38 Fix borked subtree syncs 2023-12-24 14:38:37 +00:00
bjorn3
39f0dac77d Merge branch 'sync_from_rust' 2023-12-24 14:37:13 +00:00
bjorn3
7325d0de63 Merge commit '26c02eb2904da9a53d2220d4f3069b19a3c81d3d' into sync_cg_clif-2023-12-24 2023-12-24 14:35:19 +00:00
bjorn3
26c02eb290 Rustup to rustc 1.77.0-nightly (2d7be7393 2023-12-23) 2023-12-24 14:26:46 +00:00
bjorn3
23e26ca386 Sync from rust 2d7be73931 2023-12-24 14:20:28 +00:00
Nicholas Nethercote
93c86f78b2 Remove more Session methods that duplicate DiagCtxt methods. 2023-12-24 08:17:47 +11:00
Nicholas Nethercote
7e213fe428 Remove Session methods that duplicate DiagCtxt methods.
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier
access.
2023-12-24 08:05:28 +11:00
Michael Goulet
bfda19d5bd Rollup merge of #119171 - nnethercote:cleanup-errors-4, r=compiler-errors
Cleanup error handlers: round 4

More `rustc_errors` cleanups. A sequel to #118933.

r? `@compiler-errors`
2023-12-22 21:41:03 -05:00
Nicholas Nethercote
b94a2a1991 Rename EarlyDiagCtxt methods to match DiagCtxt.
- `early_error_no_abort` -> `early_err`
- `early_error` -> `early_fatal`
- `early_struct_error` -> `early_struct_fatal`
2023-12-23 13:23:28 +11:00
bjorn3
289a274036 Disable a rustc test that depends on -Cpanic=unwind 2023-12-22 11:58:54 +00:00
bjorn3
e935766d57 Ignore a rustc test that needs LTO support 2023-12-22 11:37:25 +00:00
bjorn3
3847a018d5 Update Cranelift to 0.103 2023-12-22 11:07:03 +00:00
Pietro Albini
71899c3e23 update cfg(bootstrap)s 2023-12-22 11:14:11 +01:00
bjorn3
dab8395deb Implement simd_masked_store 2023-12-19 19:04:40 +00:00
bjorn3
c7b4e03945 Merge branch 'sync_from_rust' 2023-12-19 13:51:33 +00:00
bjorn3
a4be90ed16 Merge commit '3a9bf729322fb5035518f99b9d76a742bf7c124e' into sync_cg_clif-2023-12-19 2023-12-19 12:46:39 +00:00
bjorn3
3a9bf72932 Rustup to rustc 1.76.0-nightly (3f28fe133 2023-12-18) 2023-12-19 12:37:20 +00:00
bjorn3
4a1466ad7a Sync from rust 3f28fe1334 2023-12-19 12:29:54 +00:00
bjorn3
9d98f79c53 Rustup to rustc 1.76.0-nightly (6a6287132 2023-12-17) 2023-12-18 18:31:49 +00:00
bjorn3
f6c0006b2a Sync from rust 6a62871320 2023-12-18 18:24:49 +00:00
bjorn3
973dd562e8 fix computing the offset of an unsized field in a packed struct
cc rust-lang/rust#118540
Fixes rust-lang/rustc_codegen_cranelift#1435
2023-12-18 18:12:29 +00:00
bjorn3
1ab05b6cbe fix dynamic size/align computation logic for packed types with dyn trait tail
cc rust-lang/rust#118538
2023-12-18 16:13:54 +00:00
bjorn3
c4567c1841 Implement has_ptr_meta without computing type layout
This matches type_has_metadata in cg_ssa and doesn't require computing
the layout of the type. It is also a bit faster.
2023-12-18 15:24:06 +00:00
bjorn3
697aa0a320 Fix test for size_of_val and align_of_val panicking on extern types 2023-12-18 15:15:35 +00:00
bjorn3
fdcf56c5b7 Panic for size_of_val and align_of_val of extern type
cc rust-lang/rust#118534
2023-12-18 15:09:41 +00:00
Nicholas Nethercote
eeb3db1130 Rename many DiagCtxt and EarlyDiagCtxt locals. 2023-12-18 16:06:22 +11:00