Skip to content
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

SVE types and intrinsics #1509

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ members = [
"crates/core_arch",
"crates/std_detect",
"crates/stdarch-gen",
"crates/stdarch-gen2",
"crates/intrinsic-test",
"examples/"
]
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/aarch64-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
lld

ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -L /usr/aarch64-linux-gnu" \
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER="qemu-aarch64 -cpu max,sve-default-vector-length=256 -L /usr/aarch64-linux-gnu" \
OBJDUMP=aarch64-linux-gnu-objdump
5 changes: 5 additions & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,16 @@ case ${TARGET} in
esac

if [ "${TARGET}" = "aarch64-unknown-linux-gnu" ]; then

(
CPPFLAGS="-fuse-ld=lld -I/usr/aarch64-linux-gnu/include/ -I/usr/aarch64-linux-gnu/include/c++/9/aarch64-linux-gnu/" \
RUSTFLAGS="$HOST_RUSTFLAGS" \
RUST_LOG=warn \
cargo run ${INTRINSIC_TEST} --release --bin intrinsic-test -- intrinsics_data/arm_intrinsics.json --runner "${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER}" --cppcompiler "clang++-15" --skip crates/intrinsic-test/missing_aarch64.txt
CPPFLAGS="-fuse-ld=lld -I/usr/aarch64-linux-gnu/include/ -I/usr/aarch64-linux-gnu/include/c++/9/aarch64-linux-gnu/" \
RUSTFLAGS="$HOST_RUSTFLAGS" \
RUST_LOG=warn \
cargo run ${INTRINSIC_TEST} --release --bin intrinsic-test -- intrinsics_data/arm_intrinsics.json --runner "${CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUNNER}" --cppcompiler "clang++-15" --skip crates/intrinsic-test/missing_aarch64.txt --sve
)
elif [ "${TARGET}" = "armv7-unknown-linux-gnueabihf" ]; then
(
Expand Down
2 changes: 1 addition & 1 deletion crates/assert-instr-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ test = false
[dependencies]
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "2.0", features = ["full"] }
syn = { version = "2.0", features = ["full", "extra-traits"] }
65 changes: 57 additions & 8 deletions crates/assert-instr-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ extern crate quote;

use proc_macro2::TokenStream;
use quote::ToTokens;
use syn::spanned::Spanned;

#[proc_macro_attribute]
pub fn assert_instr(
Expand Down Expand Up @@ -79,33 +80,63 @@ pub fn assert_instr(
let ret = &func.sig.output;
for arg in func.sig.inputs.iter() {
let capture = match *arg {
syn::FnArg::Typed(ref c) => c,
syn::FnArg::Typed(ref c) => c.to_owned(),
ref v => panic!(
"arguments must not have patterns: `{:?}`",
v.clone().into_token_stream()
),
};
let ident = match *capture.pat {
syn::Pat::Ident(ref i) => &i.ident,
let ident = match capture.pat.as_ref() {
syn::Pat::Ident(i) => i.ident.to_owned(),
_ => panic!("must have bare arguments"),
};
if let Some((_, tokens)) = invoc.args.iter().find(|a| *ident == a.0) {
if let Some(&(_, ref tokens)) = invoc.args.iter().find(|a| ident == a.0) {
input_vals.push(quote! { #tokens });
} else {
inputs.push(capture);
input_vals.push(quote! { #ident });
}
}
for arg in func.sig.generics.params.iter() {
let c = match *arg {
syn::GenericParam::Const(ref c) => c,
let (ident, is_ty) = match *arg {
syn::GenericParam::Const(ref c) => (&c.ident, false),
syn::GenericParam::Type(ref t) => (&t.ident, true),
ref v => panic!(
"only const generics are allowed: `{:?}`",
v.clone().into_token_stream()
),
};
if let Some((_, tokens)) = invoc.args.iter().find(|a| c.ident == a.0) {
const_vals.push(quote! { #tokens });
if let Some(&(_, ref tokens)) = invoc.args.iter().find(|a| ident == &a.0) {
if is_ty {
if let syn::Expr::Path(syn::ExprPath { qself, path, .. }) = tokens {
const_vals.push(syn::Ident::new("_", tokens.span()).to_token_stream());

let generic_ty_value = syn::TypePath {
qself: qself.clone(),
path: path.clone(),
};

inputs.iter_mut().for_each(|arg| {
update_type_path(arg.ty.as_mut(), |type_path: &mut syn::TypePath| {
if let Some(syn::PathSegment {
ident: last_ident, ..
}) = type_path.path.segments.last_mut()
{
if last_ident == ident {
*type_path = generic_ty_value.to_owned()
}
}
})
});
} else {
panic!(
"invalid generic type value {:?} given",
tokens.to_token_stream()
)
}
} else {
const_vals.push(quote! { #tokens });
}
} else {
panic!("const generics must have a value for tests");
}
Expand Down Expand Up @@ -258,3 +289,21 @@ where
}
}
}

fn update_type_path<F>(ty: &mut syn::Type, fn_ptr: F)
where
F: Fn(&mut syn::TypePath),
{
use syn::Type::*;
match ty {
Array(syn::TypeArray { elem, .. })
| Group(syn::TypeGroup { elem, .. })
| Paren(syn::TypeParen { elem, .. })
| Ptr(syn::TypePtr { elem, .. })
| Reference(syn::TypeReference { elem, .. })
| Slice(syn::TypeSlice { elem, .. }) => update_type_path(elem.as_mut(), fn_ptr),
Path(path @ syn::TypePath { .. }) => fn_ptr(path),
Tuple(..) => panic!("tuples and generic types together are not yet supported"),
_ => {}
}
}
3 changes: 3 additions & 0 deletions crates/core_arch/src/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ mod neon;
#[stable(feature = "neon_intrinsics", since = "1.59.0")]
pub use self::neon::*;

#[unstable(feature = "stdarch_aarch64_sve", issue = "99999999")]
pub mod sve;

mod tme;
#[unstable(feature = "stdarch_aarch64_tme", issue = "117216")]
pub use self::tme::*;
Expand Down
Loading
Loading