Merge pull request #1878 from madhav-madhusoodanan/intrinsic-test-box-removing-and-more

`intrinsic-test`: Implemented DerefMut for ArmIntrinsicTest
This commit is contained in:
Folkert de Vries 2025-07-18 10:20:35 +00:00 committed by GitHub
commit a657eb29e2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 12 deletions

View file

@ -2,7 +2,7 @@ use crate::common::argument::ArgumentList;
use crate::common::indentation::Indentation;
use crate::common::intrinsic::{Intrinsic, IntrinsicDefinition};
use crate::common::intrinsic_helpers::{IntrinsicType, IntrinsicTypeDefinition, Sign, TypeKind};
use std::ops::Deref;
use std::ops::{Deref, DerefMut};
#[derive(Debug, Clone, PartialEq)]
pub struct ArmIntrinsicType(pub IntrinsicType);
@ -15,6 +15,12 @@ impl Deref for ArmIntrinsicType {
}
}
impl DerefMut for ArmIntrinsicType {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl IntrinsicDefinition<ArmIntrinsicType> for Intrinsic<ArmIntrinsicType> {
fn arguments(&self) -> ArgumentList<ArmIntrinsicType> {
self.arguments.clone()

View file

@ -110,7 +110,7 @@ fn json_to_intrinsic(
Ok(Intrinsic {
name,
arguments,
results: *results,
results: results,
arch_tags: intr.architectures,
})
}

View file

@ -121,7 +121,7 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
}
}
fn from_c(s: &str, target: &str) -> Result<Box<Self>, String> {
fn from_c(s: &str, target: &str) -> Result<Self, String> {
const CONST_STR: &str = "const";
if let Some(s) = s.strip_suffix('*') {
let (s, constant) = match s.trim().strip_suffix(CONST_STR) {
@ -131,9 +131,8 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
let s = s.trim_end();
let temp_return = ArmIntrinsicType::from_c(s, target);
temp_return.map(|mut op| {
let edited = op.as_mut();
edited.0.ptr = true;
edited.0.ptr_constant = constant;
op.ptr = true;
op.ptr_constant = constant;
op
})
} else {
@ -163,7 +162,7 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
),
None => None,
};
Ok(Box::new(ArmIntrinsicType(IntrinsicType {
Ok(ArmIntrinsicType(IntrinsicType {
ptr: false,
ptr_constant: false,
constant,
@ -172,14 +171,14 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
simd_len,
vec_len,
target: target.to_string(),
})))
}))
} else {
let kind = start.parse::<TypeKind>()?;
let bit_len = match kind {
TypeKind::Int(_) => Some(32),
_ => None,
};
Ok(Box::new(ArmIntrinsicType(IntrinsicType {
Ok(ArmIntrinsicType(IntrinsicType {
ptr: false,
ptr_constant: false,
constant,
@ -188,7 +187,7 @@ impl IntrinsicTypeDefinition for ArmIntrinsicType {
simd_len: None,
vec_len: None,
target: target.to_string(),
})))
}))
}
}
}

View file

@ -76,7 +76,7 @@ where
Argument {
pos,
name: String::from(var_name),
ty: *ty,
ty: ty,
constraint,
}
}

View file

@ -322,7 +322,9 @@ pub trait IntrinsicTypeDefinition: Deref<Target = IntrinsicType> {
fn get_lane_function(&self) -> String;
/// can be implemented in an `impl` block
fn from_c(_s: &str, _target: &str) -> Result<Box<Self>, String>;
fn from_c(_s: &str, _target: &str) -> Result<Self, String>
where
Self: Sized;
/// Gets a string containing the typename for this type in C format.
/// can be directly defined in `impl` blocks