Skip to content

Commit 0204aca

Browse files
committed
Auto merge of #155385 - davidtwco:stdarch-sync-160426, r=davidtwco
stdarch subtree update Subtree update of `stdarch` to rust-lang/stdarch@0956462. Created using https://github.com/rust-lang/josh-sync. r? @ghost
2 parents 7af3402 + 9e4d2a7 commit 0204aca

57 files changed

Lines changed: 342366 additions & 38463 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

library/stdarch/.github/workflows/main.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,9 @@ jobs:
9696
os: ubuntu-latest
9797
- tuple: loongarch64-unknown-linux-gnu
9898
os: ubuntu-latest
99-
- tuple: hexagon-unknown-linux-musl
100-
os: ubuntu-latest
99+
# hexagon doesn't build at the moment due to a libc issue.
100+
# - tuple: hexagon-unknown-linux-musl
101+
# os: ubuntu-latest
101102
- tuple: wasm32-wasip1
102103
os: ubuntu-latest
103104

@@ -209,11 +210,12 @@ jobs:
209210
tuple: amdgcn-amd-amdhsa
210211
os: ubuntu-latest
211212
norun: true
212-
- target:
213-
tuple: hexagon-unknown-linux-musl
214-
os: ubuntu-latest
215-
norun: true
216-
build_std: true
213+
# hexagon doesn't build at the moment due to a libc issue.
214+
# - target:
215+
# tuple: hexagon-unknown-linux-musl
216+
# os: ubuntu-latest
217+
# norun: true
218+
# build_std: true
217219

218220
steps:
219221
- uses: actions/checkout@v6
@@ -270,7 +272,7 @@ jobs:
270272
intrinsic-test:
271273
needs: [style]
272274
name: Intrinsic Test
273-
runs-on: ubuntu-latest
275+
runs-on: ubuntu-latest
274276
strategy:
275277
matrix:
276278
target:
@@ -330,11 +332,33 @@ jobs:
330332
cargo run -p stdarch-gen-hexagon --release
331333
git diff --exit-code
332334
335+
# Run some tests with Miri. Most stdarch functions use platform-specific intrinsics
336+
# that Miri does not support. Also Miri is reltively slow.
337+
#
338+
# Below we run some tests where Miri might catch UB, for instance on intrinsics that read from
339+
# or write to pointers.
340+
miri:
341+
needs: [style]
342+
name: Run some tests with miri
343+
runs-on: ubuntu-latest
344+
steps:
345+
- uses: actions/checkout@v6
346+
- name: Install Rust
347+
run: rustup update nightly && rustup default nightly && rustup component add miri
348+
- name: Run miri tests
349+
env:
350+
TARGET: "aarch64-unknown-linux-gnu"
351+
run: |
352+
# read filters and join them with a space.
353+
FILTERS=$(cat aarch64-miri-tests.txt | tr '\n' ' ')
354+
cargo miri test -p core_arch --target aarch64-unknown-linux-gnu -- $FILTERS
355+
333356
conclusion:
334357
needs:
335358
- docs
336359
- verify
337360
- test
361+
- miri
338362
- intrinsic-test
339363
- check-stdarch-gen
340364
runs-on: ubuntu-latest

library/stdarch/.github/workflows/rustc-pull.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
uses: rust-lang/josh-sync/.github/workflows/rustc-pull.yml@main
1414
with:
1515
github-app-id: ${{ vars.APP_CLIENT_ID }}
16+
pr-author: "workflows-stdarch[bot]"
1617
# https://rust-lang.zulipchat.com/#narrow/channel/208962-t-libs.2Fstdarch/topic/Subtree.20sync.20automation/with/528461782
1718
zulip-stream-id: 208962
1819
zulip-bot-email: "stdarch-ci-bot@rust-lang.zulipchat.com"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test_vld3
2+
test_vld4
3+
neon::load_tests
4+
neon::store_tests

library/stdarch/ci/docker/mips64-unknown-linux-gnuabi64/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:25.10
1+
FROM ubuntu:25.04 # gcc-mips64-linux-gnuabi64 not available in 25.10
22

33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
gcc libc6-dev qemu-user ca-certificates \

library/stdarch/ci/docker/mips64el-unknown-linux-gnuabi64/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:25.10
1+
FROM ubuntu:25.04 # gcc-mips64el-linux-gnuabi64 not available in 25.10
22

33
RUN apt-get update && apt-get install -y --no-install-recommends \
44
gcc libc6-dev qemu-user ca-certificates \

library/stdarch/ci/docker/x86_64-unknown-linux-gnu/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
1212
build-essential \
1313
lld
1414

15-
RUN wget http://ci-mirrors.rust-lang.org/stdarch/sde-external-10.5.0-2026-01-13-lin.tar.xz -O sde.tar.xz
15+
RUN wget http://ci-mirrors.rust-lang.org/sde-external-10.8.0-2026-03-15-lin.tar.xz -O sde.tar.xz
1616
RUN mkdir intel-sde
1717
RUN tar -xJf sde.tar.xz --strip-components=1 -C intel-sde
1818
ENV CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER="/intel-sde/sde64 \

library/stdarch/ci/docker/x86_64-unknown-linux-gnu/cpuid.def

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (C) 2017-2025 Intel Corporation.
1+
# Copyright (C) 2017-2026 Intel Corporation.
22
#
33
# This software and the related documents are Intel copyrighted materials, and your
44
# use of them is governed by the express license under which they were provided to
@@ -23,8 +23,9 @@
2323
00000004 00000004 => 00000000 00000000 00000000 00000000
2424
00000005 ******** => 00000040 00000040 00000003 00042120 #MONITOR/MWAIT
2525
00000006 ******** => 00000077 00000002 00000001 00000000 #Thermal and Power
26-
00000007 00000000 => 00000001 f3bfbfbf bac05ffe 03d54130 #Extended Features
26+
00000007 00000000 => 00000002 f3bfbfbf bac05ffe 03d54130 #Extended Features
2727
00000007 00000001 => 98ee00bf 00000002 00000020 1d29cd3e
28+
00000007 00000002 => 00000000 00000000 00000000 00000010
2829
00000008 ******** => 00000000 00000000 00000000 00000000
2930
00000009 ******** => 00000000 00000000 00000000 00000000 #Direct Cache
3031
0000000a ******** => 07300403 00000000 00000000 00000603

library/stdarch/crates/assert-instr-macro/src/lib.rs

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern crate quote;
1414

1515
use proc_macro2::TokenStream;
1616
use quote::ToTokens;
17+
use syn::spanned::Spanned;
1718

1819
#[proc_macro_attribute]
1920
pub fn assert_instr(
@@ -67,40 +68,70 @@ pub fn assert_instr(
6768
);
6869
let mut inputs = Vec::new();
6970
let mut input_vals = Vec::new();
70-
let mut const_vals = Vec::new();
71+
let mut param_vals = Vec::new();
7172
let ret = &func.sig.output;
7273
for arg in func.sig.inputs.iter() {
7374
let capture = match *arg {
74-
syn::FnArg::Typed(ref c) => c,
75+
syn::FnArg::Typed(ref c) => c.to_owned(),
7576
ref v => panic!(
7677
"arguments must not have patterns: `{:?}`",
7778
v.clone().into_token_stream()
7879
),
7980
};
80-
let ident = match *capture.pat {
81-
syn::Pat::Ident(ref i) => &i.ident,
81+
let ident = match capture.pat.as_ref() {
82+
syn::Pat::Ident(i) => &i.ident.to_owned(),
8283
_ => panic!("must have bare arguments"),
8384
};
84-
if let Some((_, tokens)) = invoc.args.iter().find(|a| *ident == a.0) {
85+
if let Some(&(_, ref tokens)) = invoc.args.iter().find(|a| *ident == a.0) {
8586
input_vals.push(quote! { #tokens });
8687
} else {
8788
inputs.push(capture);
8889
input_vals.push(quote! { #ident });
8990
}
9091
}
9192
for arg in func.sig.generics.params.iter() {
92-
let c = match *arg {
93-
syn::GenericParam::Const(ref c) => c,
93+
match *arg {
94+
syn::GenericParam::Const(ref c) => {
95+
if let Some((_, tokens)) = invoc.args.iter().find(|a| c.ident == a.0) {
96+
param_vals.push(quote! { #tokens });
97+
} else {
98+
panic!("const generics must have a value for tests");
99+
}
100+
}
101+
syn::GenericParam::Type(ref t) => {
102+
if let Some((_, tokens)) = invoc.args.iter().find(|a| t.ident == a.0)
103+
&& let syn::Expr::Path(syn::ExprPath { qself, path, .. }) = tokens
104+
{
105+
param_vals.push(syn::Token![_](tokens.span()).to_token_stream());
106+
107+
let generic_ty_value = syn::TypePath {
108+
qself: qself.clone(),
109+
path: path.clone(),
110+
};
111+
112+
// Replace any function arguments that use generic parameters with the
113+
// instantiation provided in the macro invocation.
114+
inputs.iter_mut().for_each(|arg| {
115+
update_type_path(arg.ty.as_mut(), |type_path: &mut syn::TypePath| {
116+
if let Some(syn::PathSegment {
117+
ident: last_ident, ..
118+
}) = type_path.path.segments.last_mut()
119+
{
120+
if *last_ident == t.ident {
121+
*type_path = generic_ty_value.to_owned()
122+
}
123+
}
124+
})
125+
});
126+
} else {
127+
panic!("type generics must have a type for tests");
128+
}
129+
}
94130
ref v => panic!(
95-
"only const generics are allowed: `{:?}`",
131+
"only type and const generics are allowed: `{:?}`",
96132
v.clone().into_token_stream()
97133
),
98134
};
99-
if let Some((_, tokens)) = invoc.args.iter().find(|a| c.ident == a.0) {
100-
const_vals.push(quote! { #tokens });
101-
} else {
102-
panic!("const generics must have a value for tests");
103-
}
104135
}
105136

106137
let attrs = func
@@ -138,7 +169,7 @@ pub fn assert_instr(
138169
#[unsafe(no_mangle)]
139170
#[inline(never)]
140171
pub unsafe extern #abi fn #shim_name(#(#inputs),*) #ret {
141-
#name::<#(#const_vals),*>(#(#input_vals),*)
172+
#name::<#(#param_vals),*>(#(#input_vals),*)
142173
}
143174
};
144175

@@ -222,3 +253,23 @@ where
222253
}
223254
}
224255
}
256+
257+
/// Calls `update` on type paths so that type generics can be replaced with the instantiation from
258+
/// the attribute.
259+
fn update_type_path<F>(ty: &mut syn::Type, update: F)
260+
where
261+
F: Fn(&mut syn::TypePath),
262+
{
263+
use syn::Type::*;
264+
match ty {
265+
Array(syn::TypeArray { elem, .. })
266+
| Group(syn::TypeGroup { elem, .. })
267+
| Paren(syn::TypeParen { elem, .. })
268+
| Ptr(syn::TypePtr { elem, .. })
269+
| Reference(syn::TypeReference { elem, .. })
270+
| Slice(syn::TypeSlice { elem, .. }) => update_type_path(elem.as_mut(), update),
271+
Path(path @ syn::TypePath { .. }) => update(path),
272+
Tuple(..) => panic!("tuples and generic types together are not yet supported"),
273+
_ => {}
274+
}
275+
}

library/stdarch/crates/core_arch/src/aarch64/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ mod neon;
2525
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
2626
pub use self::neon::*;
2727

28+
// The rest of `core_arch::aarch64` is available on `arm64ec` but SVE is not supported on `arm64ec`.
29+
#[cfg(any(target_arch = "aarch64", doc))]
30+
mod sve;
31+
#[cfg(any(target_arch = "aarch64", doc))]
32+
#[unstable(feature = "stdarch_aarch64_sve", issue = "145052")]
33+
pub use self::sve::*;
34+
35+
// The rest of `core_arch::aarch64` is available on `arm64ec` but SVE is not supported on `arm64ec`.
36+
#[cfg(any(target_arch = "aarch64", doc))]
37+
mod sve2;
38+
#[cfg(any(target_arch = "aarch64", doc))]
39+
#[unstable(feature = "stdarch_aarch64_sve", issue = "145052")]
40+
pub use self::sve2::*;
41+
2842
mod prefetch;
2943
#[unstable(feature = "stdarch_aarch64_prefetch", issue = "117217")]
3044
pub use self::prefetch::*;

library/stdarch/crates/core_arch/src/aarch64/neon/generated.rs

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12127,14 +12127,7 @@ pub unsafe fn vld3q_dup_u64(a: *const u64) -> uint64x2x3_t {
1212712127
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
1212812128
#[cfg_attr(test, assert_instr(ld3))]
1212912129
pub unsafe fn vld3q_f64(a: *const f64) -> float64x2x3_t {
12130-
unsafe extern "unadjusted" {
12131-
#[cfg_attr(
12132-
any(target_arch = "aarch64", target_arch = "arm64ec"),
12133-
link_name = "llvm.aarch64.neon.ld3.v2f64.p0"
12134-
)]
12135-
fn _vld3q_f64(ptr: *const float64x2_t) -> float64x2x3_t;
12136-
}
12137-
_vld3q_f64(a as _)
12130+
crate::core_arch::macros::deinterleaving_load!(f64, 2, 3, a)
1213812131
}
1213912132
#[doc = "Load multiple 3-element structures to three registers"]
1214012133
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld3q_s64)"]
@@ -12145,14 +12138,7 @@ pub unsafe fn vld3q_f64(a: *const f64) -> float64x2x3_t {
1214512138
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
1214612139
#[cfg_attr(test, assert_instr(ld3))]
1214712140
pub unsafe fn vld3q_s64(a: *const i64) -> int64x2x3_t {
12148-
unsafe extern "unadjusted" {
12149-
#[cfg_attr(
12150-
any(target_arch = "aarch64", target_arch = "arm64ec"),
12151-
link_name = "llvm.aarch64.neon.ld3.v2i64.p0"
12152-
)]
12153-
fn _vld3q_s64(ptr: *const int64x2_t) -> int64x2x3_t;
12154-
}
12155-
_vld3q_s64(a as _)
12141+
crate::core_arch::macros::deinterleaving_load!(i64, 2, 3, a)
1215612142
}
1215712143
#[doc = "Load multiple 3-element structures to three registers"]
1215812144
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld3q_lane_f64)"]
@@ -12535,14 +12521,7 @@ pub unsafe fn vld4q_dup_u64(a: *const u64) -> uint64x2x4_t {
1253512521
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
1253612522
#[cfg_attr(test, assert_instr(ld4))]
1253712523
pub unsafe fn vld4q_f64(a: *const f64) -> float64x2x4_t {
12538-
unsafe extern "unadjusted" {
12539-
#[cfg_attr(
12540-
any(target_arch = "aarch64", target_arch = "arm64ec"),
12541-
link_name = "llvm.aarch64.neon.ld4.v2f64.p0"
12542-
)]
12543-
fn _vld4q_f64(ptr: *const float64x2_t) -> float64x2x4_t;
12544-
}
12545-
_vld4q_f64(a as _)
12524+
crate::core_arch::macros::deinterleaving_load!(f64, 2, 4, a)
1254612525
}
1254712526
#[doc = "Load multiple 4-element structures to four registers"]
1254812527
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld4q_s64)"]
@@ -12553,14 +12532,7 @@ pub unsafe fn vld4q_f64(a: *const f64) -> float64x2x4_t {
1255312532
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
1255412533
#[cfg_attr(test, assert_instr(ld4))]
1255512534
pub unsafe fn vld4q_s64(a: *const i64) -> int64x2x4_t {
12556-
unsafe extern "unadjusted" {
12557-
#[cfg_attr(
12558-
any(target_arch = "aarch64", target_arch = "arm64ec"),
12559-
link_name = "llvm.aarch64.neon.ld4.v2i64.p0"
12560-
)]
12561-
fn _vld4q_s64(ptr: *const int64x2_t) -> int64x2x4_t;
12562-
}
12563-
_vld4q_s64(a as _)
12535+
crate::core_arch::macros::deinterleaving_load!(i64, 2, 4, a)
1256412536
}
1256512537
#[doc = "Load multiple 4-element structures to four registers"]
1256612538
#[doc = "[Arm's documentation](https://developer.arm.com/architectures/instruction-sets/intrinsics/vld4q_lane_f64)"]

0 commit comments

Comments
 (0)