Skip to content

Commit 52fd0e1

Browse files
usamoiAmanieu
authored andcommitted
mark arm intrinsics as safe
1 parent e9ca477 commit 52fd0e1

File tree

8 files changed

+17030
-23922
lines changed

8 files changed

+17030
-23922
lines changed

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

+7,907-10,744
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,180-10,365
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

+690-1,289
Large diffs are not rendered by default.

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

+450-825
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
@@ -598,7 +598,10 @@ impl LLVMLink {
598598
})
599599
.try_collect()?;
600600

601-
Ok(FnCall::new_expression(link_sig.fn_name().into(), call_args))
601+
Ok(FnCall::new_unsafe_expression(
602+
link_sig.fn_name().into(),
603+
call_args,
604+
))
602605
}
603606

604607
/// Given a FnCall, apply all the predicate and unsigned conversions as required.
@@ -1251,7 +1254,7 @@ impl Intrinsic {
12511254
.iter()
12521255
.map(|sd| sd.try_into())
12531256
.try_collect()?;
1254-
let mut call: Expression = FnCall(Box::new(name), args, statics).into();
1257+
let mut call: Expression = FnCall(Box::new(name), args, statics, false).into();
12551258
call.build(self, ctx)?;
12561259
Ok(vec![call])
12571260
}
@@ -1320,7 +1323,7 @@ impl Intrinsic {
13201323
.iter()
13211324
.map(|sd| sd.try_into())
13221325
.try_collect()?;
1323-
let mut call: Expression = FnCall(Box::new(name), args, statics).into();
1326+
let mut call: Expression = FnCall(Box::new(name), args, statics, false).into();
13241327
call.build(self, ctx)?;
13251328
Ok(vec![call])
13261329
}
@@ -1413,7 +1416,7 @@ impl Intrinsic {
14131416
.iter()
14141417
.map(|sd| sd.try_into())
14151418
.try_collect()?;
1416-
let mut call: Expression = FnCall(Box::new(name), args, statics).into();
1419+
let mut call: Expression = FnCall(Box::new(name), args, statics, false).into();
14171420
call.build(self, ctx)?;
14181421

14191422
variant.compose = vec![call];
@@ -1665,7 +1668,13 @@ impl Intrinsic {
16651668
.return_type
16661669
.as_ref()
16671670
.and_then(|t| t.wildcard());
1668-
let call = FnCall(Box::new(target_signature.fn_name().into()), args, turbofish).into();
1671+
let call = FnCall(
1672+
Box::new(target_signature.fn_name().into()),
1673+
args,
1674+
turbofish,
1675+
false,
1676+
)
1677+
.into();
16691678

16701679
self.compose = vec![convert_if_required(
16711680
ret_wildcard,

0 commit comments

Comments
 (0)