mirror of
https://github.com/Noratrieb/intringen.git
synced 2026-01-16 14:45:04 +01:00
more intrinsics
This commit is contained in:
parent
9e4ce7913a
commit
10b9cefe24
4 changed files with 288 additions and 42 deletions
|
|
@ -154,21 +154,24 @@ fn generate_body_test(intr: &Intrinsic, rng: &mut SmallRng) -> Result<syn::Block
|
|||
}
|
||||
|
||||
fn random_value(ty: &str, rng: &mut SmallRng) -> Result<syn::Expr> {
|
||||
let quotei16 = |n| {
|
||||
fn quote(n: impl quote::ToTokens) -> syn::Expr {
|
||||
syn::parse_quote! { #n }
|
||||
};
|
||||
}
|
||||
Ok(match ty {
|
||||
"i16" => quotei16(rng.gen::<i16>()),
|
||||
"i8" => quote(rng.gen::<i8>()),
|
||||
"i16" => quote(rng.gen::<i16>()),
|
||||
"i32" => quote(rng.gen::<i32>()),
|
||||
"i64" => quote(rng.gen::<i64>()),
|
||||
"__m128i" => {
|
||||
let args = [
|
||||
quotei16(rng.gen::<i16>()),
|
||||
quotei16(rng.gen::<i16>()),
|
||||
quotei16(rng.gen::<i16>()),
|
||||
quotei16(rng.gen::<i16>()),
|
||||
quotei16(rng.gen::<i16>()),
|
||||
quotei16(rng.gen::<i16>()),
|
||||
quotei16(rng.gen::<i16>()),
|
||||
quotei16(rng.gen::<i16>()),
|
||||
quote(rng.gen::<i16>()),
|
||||
quote(rng.gen::<i16>()),
|
||||
quote(rng.gen::<i16>()),
|
||||
quote(rng.gen::<i16>()),
|
||||
quote(rng.gen::<i16>()),
|
||||
quote(rng.gen::<i16>()),
|
||||
quote(rng.gen::<i16>()),
|
||||
quote(rng.gen::<i16>()),
|
||||
];
|
||||
|
||||
syn::parse_quote! {
|
||||
|
|
@ -192,7 +195,10 @@ impl VariableType {
|
|||
fn of(etype: &str, ty: &str) -> Result<Self> {
|
||||
let (rawtype_signed, full_width) = match map_type_to_rust(ty) {
|
||||
"__m128i" => (false, 128),
|
||||
"i8" => (true, 8),
|
||||
"i16" => (true, 16),
|
||||
"i32" => (true, 32),
|
||||
"i64" => (true, 64),
|
||||
_ => bail!("unknown type: {ty}"),
|
||||
};
|
||||
let (is_signed, elem_width) = match etype {
|
||||
|
|
@ -201,6 +207,8 @@ impl VariableType {
|
|||
"SI32" => (true, 32),
|
||||
"UI8" => (false, 8),
|
||||
"UI16" => (false, 16),
|
||||
"UI32" => (false, 32),
|
||||
"UI64" => (false, 64),
|
||||
_ => bail!("unknown element type: {etype}"),
|
||||
};
|
||||
Ok(Self {
|
||||
|
|
@ -432,7 +440,11 @@ fn signature_soft_arch(intr: &Intrinsic, body: syn::Block) -> Result<syn::ItemFn
|
|||
|
||||
fn map_type_to_rust(ty: &str) -> &str {
|
||||
match ty {
|
||||
"__m128i" => ty,
|
||||
"char" => "i8",
|
||||
"short" => "i16",
|
||||
ty => ty,
|
||||
"int" => "i32",
|
||||
"__int64" => "i64",
|
||||
ty => panic!("unknown type: {ty}"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,9 +89,13 @@ fn main() -> Result<()> {
|
|||
}
|
||||
|
||||
const INTRINSICS_GENERATE: &[&str] = &[
|
||||
"_mm_setr_epi8",
|
||||
"_mm_setr_epi16",
|
||||
"_mm_setr_epi32",
|
||||
"_mm_set_epi64x",
|
||||
// packing instructions
|
||||
"_mm_packus_epi16",
|
||||
"_mm_packs_epi16",
|
||||
"_mm_packus_epi32",
|
||||
"_mm_packs_epi32",
|
||||
"_mm_setr_epi16",
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue