Skip to content

Commit 8a959c6

Browse files
committed
mark arm intrinsics as safe
1 parent b0ff457 commit 8a959c6

File tree

8 files changed

+17064
-23965
lines changed

8 files changed

+17064
-23965
lines changed

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

+7,899-10,728
Large diffs are not rendered by default.

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

+72-77
Large diffs are not rendered by default.

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

+7,238-10,433
Large diffs are not rendered by default.

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

+706-614
Large diffs are not rendered by default.

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

+684-1,287
Large diffs are not rendered by default.

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

+440-818
Large diffs are not rendered by default.

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

+11-3
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,18 @@ pub struct FnCall(
4242
/// Function turbofish arguments
4343
#[serde(default)]
4444
pub Vec<Expression>,
45+
/// Function requires unsafe wrapper
46+
#[serde(default)]
47+
pub bool,
4548
);
4649

4750
impl FnCall {
4851
pub fn new_expression(fn_ptr: Expression, arguments: Vec<Expression>) -> Expression {
49-
FnCall(Box::new(fn_ptr), arguments, Vec::new()).into()
52+
FnCall(Box::new(fn_ptr), arguments, Vec::new(), false).into()
53+
}
54+
55+
pub fn new_unsafe_expression(fn_ptr: Expression, arguments: Vec<Expression>) -> Expression {
56+
FnCall(Box::new(fn_ptr), arguments, Vec::new(), true).into()
5057
}
5158

5259
pub fn is_llvm_link_call(&self, llvm_link_name: &String) -> bool {
@@ -84,7 +91,7 @@ impl FnCall {
8491

8592
impl ToTokens for FnCall {
8693
fn to_tokens(&self, tokens: &mut TokenStream) {
87-
let FnCall(fn_ptr, arguments, turbofish) = self;
94+
let FnCall(fn_ptr, arguments, turbofish, _requires_unsafe_wrapper) = self;
8895

8996
fn_ptr.to_tokens(tokens);
9097

@@ -301,7 +308,7 @@ impl Expression {
301308
}
302309
Self::CastAs(exp, _ty) => exp.requires_unsafe_wrapper(ctx_fn),
303310
// Functions and macros can be unsafe, but can also contain other expressions.
304-
Self::FnCall(FnCall(fn_exp, args, turbo_args)) => {
311+
Self::FnCall(FnCall(fn_exp, args, turbo_args, requires_unsafe_wrapper)) => {
305312
let fn_name = fn_exp.to_string();
306313
fn_exp.requires_unsafe_wrapper(ctx_fn)
307314
|| fn_name.starts_with("_sv")
@@ -311,6 +318,7 @@ impl Expression {
311318
|| turbo_args
312319
.iter()
313320
.any(|exp| exp.requires_unsafe_wrapper(ctx_fn))
321+
|| *requires_unsafe_wrapper
314322
}
315323
Self::MethodCall(exp, fn_name, args) => match fn_name.as_str() {
316324
// `as_signed` and `as_unsigned` are unsafe because they're trait methods with

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

+14-5
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,10 @@ impl LLVMLink {
596596
})
597597
.try_collect()?;
598598

599-
Ok(FnCall::new_expression(link_sig.fn_name().into(), call_args))
599+
Ok(FnCall::new_unsafe_expression(
600+
link_sig.fn_name().into(),
601+
call_args,
602+
))
600603
}
601604

602605
/// Given a FnCall, apply all the predicate and unsigned conversions as required.
@@ -1241,7 +1244,7 @@ impl Intrinsic {
12411244
.iter()
12421245
.map(|sd| sd.try_into())
12431246
.try_collect()?;
1244-
let mut call: Expression = FnCall(Box::new(name), args, statics).into();
1247+
let mut call: Expression = FnCall(Box::new(name), args, statics, false).into();
12451248
call.build(self, ctx)?;
12461249
Ok(vec![call])
12471250
}
@@ -1310,7 +1313,7 @@ impl Intrinsic {
13101313
.iter()
13111314
.map(|sd| sd.try_into())
13121315
.try_collect()?;
1313-
let mut call: Expression = FnCall(Box::new(name), args, statics).into();
1316+
let mut call: Expression = FnCall(Box::new(name), args, statics, false).into();
13141317
call.build(self, ctx)?;
13151318
Ok(vec![call])
13161319
}
@@ -1403,7 +1406,7 @@ impl Intrinsic {
14031406
.iter()
14041407
.map(|sd| sd.try_into())
14051408
.try_collect()?;
1406-
let mut call: Expression = FnCall(Box::new(name), args, statics).into();
1409+
let mut call: Expression = FnCall(Box::new(name), args, statics, false).into();
14071410
call.build(self, ctx)?;
14081411

14091412
variant.compose = vec![call];
@@ -1653,7 +1656,13 @@ impl Intrinsic {
16531656
.return_type
16541657
.as_ref()
16551658
.and_then(|t| t.wildcard());
1656-
let call = FnCall(Box::new(target_signature.fn_name().into()), args, turbofish).into();
1659+
let call = FnCall(
1660+
Box::new(target_signature.fn_name().into()),
1661+
args,
1662+
turbofish,
1663+
false,
1664+
)
1665+
.into();
16571666

16581667
self.compose = vec![convert_if_required(
16591668
ret_wildcard,

0 commit comments

Comments
 (0)