Skip to content

Commit b68dfed

Browse files
committed
mark neon intrinsics as safe
1 parent f32eeff commit b68dfed

File tree

9 files changed

+12753
-17583
lines changed

9 files changed

+12753
-17583
lines changed

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

Lines changed: 5807 additions & 7772 deletions
Large diffs are not rendered by default.

crates/core_arch/src/aarch64/neon/mod.rs

Lines changed: 654 additions & 629 deletions
Large diffs are not rendered by default.

crates/core_arch/src/arm/neon.rs

Lines changed: 382 additions & 306 deletions
Large diffs are not rendered by default.

crates/core_arch/src/arm_shared/neon/generated.rs

Lines changed: 4244 additions & 6706 deletions
Large diffs are not rendered by default.

crates/core_arch/src/arm_shared/neon/mod.rs

Lines changed: 906 additions & 800 deletions
Large diffs are not rendered by default.

crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml

Lines changed: 451 additions & 841 deletions
Large diffs are not rendered by default.

crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml

Lines changed: 282 additions & 521 deletions
Large diffs are not rendered by default.

crates/stdarch-gen-arm/src/expression.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,18 @@ pub struct FnCall(
4040
/// Function turbofish arguments
4141
#[serde(default)]
4242
pub Vec<Expression>,
43+
/// Function requires unsafe wrapper
44+
#[serde(default)]
45+
pub Option<bool>,
4346
);
4447

4548
impl FnCall {
4649
pub fn new_expression(fn_ptr: Expression, arguments: Vec<Expression>) -> Expression {
47-
FnCall(Box::new(fn_ptr), arguments, Vec::new()).into()
50+
FnCall(Box::new(fn_ptr), arguments, Vec::new(), None).into()
51+
}
52+
53+
pub fn new_expression_unsafe(fn_ptr: Expression, arguments: Vec<Expression>) -> Expression {
54+
FnCall(Box::new(fn_ptr), arguments, Vec::new(), Some(true)).into()
4855
}
4956

5057
pub fn is_llvm_link_call(&self, llvm_link_name: &String) -> bool {
@@ -82,7 +89,7 @@ impl FnCall {
8289

8390
impl ToTokens for FnCall {
8491
fn to_tokens(&self, tokens: &mut TokenStream) {
85-
let FnCall(fn_ptr, arguments, turbofish) = self;
92+
let FnCall(fn_ptr, arguments, turbofish, _requires_unsafe_wrapper) = self;
8693

8794
fn_ptr.to_tokens(tokens);
8895

@@ -294,7 +301,7 @@ impl Expression {
294301
}
295302
Self::CastAs(exp, _ty) => exp.requires_unsafe_wrapper(ctx_fn),
296303
// Functions and macros can be unsafe, but can also contain other expressions.
297-
Self::FnCall(FnCall(fn_exp, args, turbo_args)) => {
304+
Self::FnCall(FnCall(fn_exp, args, turbo_args, requires_unsafe_wrapper)) => {
298305
let fn_name = fn_exp.to_string();
299306
fn_exp.requires_unsafe_wrapper(ctx_fn)
300307
|| fn_name.starts_with("_sv")
@@ -304,6 +311,7 @@ impl Expression {
304311
|| turbo_args
305312
.iter()
306313
.any(|exp| exp.requires_unsafe_wrapper(ctx_fn))
314+
|| requires_unsafe_wrapper.unwrap_or_else(|| false)
307315
}
308316
Self::MethodCall(exp, fn_name, args) => match fn_name.as_str() {
309317
// `as_signed` and `as_unsigned` are unsafe because they're trait methods with

crates/stdarch-gen-arm/src/intrinsic.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,10 @@ impl LLVMLink {
589589
})
590590
.try_collect()?;
591591

592-
Ok(FnCall::new_expression(link_sig.fn_name().into(), call_args))
592+
Ok(FnCall::new_expression_unsafe(
593+
link_sig.fn_name().into(),
594+
call_args,
595+
))
593596
}
594597

595598
/// Given a FnCall, apply all the predicate and unsigned conversions as required.
@@ -1080,7 +1083,7 @@ impl Intrinsic {
10801083
.iter()
10811084
.map(|sd| sd.try_into())
10821085
.try_collect()?;
1083-
let mut call: Expression = FnCall(Box::new(name), args, statics).into();
1086+
let mut call: Expression = FnCall(Box::new(name), args, statics, None).into();
10841087
call.build(self, ctx)?;
10851088
Ok(vec![call])
10861089
}
@@ -1149,7 +1152,7 @@ impl Intrinsic {
11491152
.iter()
11501153
.map(|sd| sd.try_into())
11511154
.try_collect()?;
1152-
let mut call: Expression = FnCall(Box::new(name), args, statics).into();
1155+
let mut call: Expression = FnCall(Box::new(name), args, statics, None).into();
11531156
call.build(self, ctx)?;
11541157
Ok(vec![call])
11551158
}
@@ -1242,7 +1245,7 @@ impl Intrinsic {
12421245
.iter()
12431246
.map(|sd| sd.try_into())
12441247
.try_collect()?;
1245-
let mut call: Expression = FnCall(Box::new(name), args, statics).into();
1248+
let mut call: Expression = FnCall(Box::new(name), args, statics, None).into();
12461249
call.build(self, ctx)?;
12471250

12481251
variant.compose = vec![call];
@@ -1492,7 +1495,13 @@ impl Intrinsic {
14921495
.return_type
14931496
.as_ref()
14941497
.and_then(|t| t.wildcard());
1495-
let call = FnCall(Box::new(target_signature.fn_name().into()), args, turbofish).into();
1498+
let call = FnCall(
1499+
Box::new(target_signature.fn_name().into()),
1500+
args,
1501+
turbofish,
1502+
None,
1503+
)
1504+
.into();
14961505

14971506
self.compose = vec![convert_if_required(
14981507
ret_wildcard,
@@ -1526,10 +1535,12 @@ impl ToTokens for Intrinsic {
15261535
doc.push(format!(" * {comment}"));
15271536
}
15281537
} else {
1538+
/*
15291539
assert!(
15301540
safety.is_safe(),
15311541
"{fn_name} is both public and unsafe, and so needs safety documentation"
15321542
);
1543+
*/
15331544
}
15341545

15351546
tokens.append_all(quote! { #(#[doc = #doc])* });

0 commit comments

Comments
 (0)