Skip to content
Open
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
264 changes: 144 additions & 120 deletions crates/core_arch/src/aarch64/neon/generated.rs

Large diffs are not rendered by default.

1,470 changes: 759 additions & 711 deletions crates/core_arch/src/arm_shared/neon/generated.rs

Large diffs are not rendered by default.

120 changes: 60 additions & 60 deletions crates/stdarch-gen-arm/spec/neon/aarch64.spec.yml

Large diffs are not rendered by default.

82 changes: 42 additions & 40 deletions crates/stdarch-gen-arm/spec/neon/arm_shared.spec.yml

Large diffs are not rendered by default.

36 changes: 16 additions & 20 deletions crates/stdarch-gen-arm/src/big_endian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ fn create_single_wild_string(name: &str) -> WildString {
/// Creates an Identifier with name `name` with no wildcards. This, for example,
/// can be used to create variables, function names or arbitrary input. Is is
/// extremely flexible.
pub fn create_symbol_identifier(arbitrary_string: &str) -> Expression {
pub fn create_symbol_identifier(arbitrary_string: &str, kind: IdentifierType) -> Expression {
let identifier_name = create_single_wild_string(arbitrary_string);
Expression::Identifier(identifier_name, IdentifierType::Symbol)
Expression::Identifier(identifier_name, kind)
}

/// To compose the simd_shuffle! call we need:
Expand Down Expand Up @@ -101,7 +101,6 @@ pub fn make_variable_mutable(variable_name: &str, type_kind: &TypeKind) -> Expre
fn create_shuffle_internal(
variable_name: &String,
type_kind: &TypeKind,
fmt_tuple: fn(variable_name: &String, idx: u32, array_lanes: &String) -> String,
fmt: fn(variable_name: &String, type_kind: &TypeKind, array_lanes: &String) -> String,
) -> Option<Expression> {
let TypeKind::Vector(vector_type) = type_kind else {
Expand All @@ -120,14 +119,21 @@ fn create_shuffle_internal(

/* <var_name>.idx = simd_shuffle!(<var_name>.idx, <var_name>.idx, [<indexes>]) */
for idx in 0..tuple_count {
let formatted = fmt_tuple(variable_name, idx, &array_lanes);
let formatted =
create_assigned_tuple_shuffle_call_fmt(variable_name, idx, &array_lanes);
string_builder += formatted.as_str();
}
Some(create_symbol_identifier(&string_builder))
Some(create_symbol_identifier(
&string_builder,
IdentifierType::UnsafeSymbol,
))
} else {
/* Generate a list of shuffles for each tuple */
let expression = fmt(variable_name, type_kind, &array_lanes);
Some(create_symbol_identifier(&expression))
Some(create_symbol_identifier(
&expression,
IdentifierType::UnsafeSymbol,
))
}
}

Expand All @@ -137,7 +143,7 @@ fn create_assigned_tuple_shuffle_call_fmt(
array_lanes: &String,
) -> String {
format!(
"{variable_name}.{idx} = unsafe {{ simd_shuffle!({variable_name}.{idx}, {variable_name}.{idx}, {array_lanes}) }};\n"
"{variable_name}.{idx} = simd_shuffle!({variable_name}.{idx}, {variable_name}.{idx}, {array_lanes});\n"
)
}

Expand All @@ -147,7 +153,7 @@ fn create_assigned_shuffle_call_fmt(
array_lanes: &String,
) -> String {
format!(
"let {variable_name}: {type_kind} = unsafe {{ simd_shuffle!({variable_name}, {variable_name}, {array_lanes}) }}"
"let {variable_name}: {type_kind} = simd_shuffle!({variable_name}, {variable_name}, {array_lanes})"
)
}

Expand All @@ -165,20 +171,10 @@ pub fn create_assigned_shuffle_call(
variable_name: &String,
type_kind: &TypeKind,
) -> Option<Expression> {
create_shuffle_internal(
variable_name,
type_kind,
create_assigned_tuple_shuffle_call_fmt,
create_assigned_shuffle_call_fmt,
)
create_shuffle_internal(variable_name, type_kind, create_assigned_shuffle_call_fmt)
}

/// Create a `simd_shuffle!(<...>, [...])` call
pub fn create_shuffle_call(variable_name: &String, type_kind: &TypeKind) -> Option<Expression> {
create_shuffle_internal(
variable_name,
type_kind,
create_assigned_tuple_shuffle_call_fmt,
create_shuffle_call_fmt,
)
create_shuffle_internal(variable_name, type_kind, create_shuffle_call_fmt)
}
13 changes: 10 additions & 3 deletions crates/stdarch-gen-arm/src/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::{
pub enum IdentifierType {
Variable,
Symbol,
UnsafeSymbol,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -65,7 +66,11 @@ impl FnCall {
}

pub fn is_expected_call(&self, fn_call_name: &str) -> bool {
if let Expression::Identifier(fn_name, IdentifierType::Symbol) = self.0.as_ref() {
if let Expression::Identifier(
fn_name,
IdentifierType::Symbol | IdentifierType::UnsafeSymbol,
) = self.0.as_ref()
{
fn_name.to_string() == fn_call_name
} else {
false
Expand Down Expand Up @@ -298,13 +303,15 @@ impl Expression {
match self {
// The call will need to be unsafe, but the declaration does not.
Self::LLVMLink(..) => false,
// Identifiers, literals and type names are never unsafe.
Self::Identifier(..) => false,
// literals and type names are never unsafe.
Self::IntConstant(..) => false,
Self::FloatConstant(..) => false,
Self::BoolConstant(..) => false,
Self::Type(..) => false,
Self::ConvertConst(..) => false,
// Only unsafe `Symbol` identifiers are unsafe
Self::Identifier(_, IdentifierType::UnsafeSymbol) => true,
Self::Identifier(..) => false,
// Nested structures that aren't inherently unsafe, but could contain other expressions
// that might be.
Self::Assign(_var, exp) => exp.requires_unsafe_wrapper(ctx_fn),
Expand Down
7 changes: 4 additions & 3 deletions crates/stdarch-gen-arm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,9 +1191,10 @@ impl Intrinsic {
* re-assigning each tuple however those generated calls do
* not make the parent function return. So we add the return
* value here */
variant
.big_endian_compose
.push(create_symbol_identifier(&ret_val_name));
variant.big_endian_compose.push(create_symbol_identifier(
&ret_val_name,
IdentifierType::Symbol,
));
}
}
}
Expand Down