Skip to content

Commit

Permalink
Fix unused import in stdarch-gen
Browse files Browse the repository at this point in the history
  • Loading branch information
Licenser committed Apr 5, 2020
1 parent 6e1b7a2 commit 2dbeb2e
Showing 1 changed file with 95 additions and 88 deletions.
183 changes: 95 additions & 88 deletions crates/stdarch-gen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::fs::File;
use std::io::prelude::*;
use std::io::{self, BufReader};
use std::path::PathBuf;
use std::process::Command;

const IN: &str = "neon.spec";
const ARM_OUT: &str = "generated.rs";
Expand Down Expand Up @@ -139,35 +138,35 @@ fn type_to_global_type(t: &str) -> &str {
}
}

fn type_to_native_type(t: &str) -> &str {
match t {
"int8x8_t" => "i8",
"int8x16_t" => "i8",
"int16x4_t" => "i16",
"int16x8_t" => "i16",
"int32x2_t" => "i32",
"int32x4_t" => "i32",
"int64x1_t" => "i64",
"int64x2_t" => "i64",
"uint8x8_t" => "u8",
"uint8x16_t" => "u8",
"uint16x4_t" => "u16",
"uint16x8_t" => "u16",
"uint32x2_t" => "u32",
"uint32x4_t" => "u32",
"uint64x1_t" => "u64",
"uint64x2_t" => "u64",
"float16x4_t" => "f16",
"float16x8_t" => "f16",
"float32x2_t" => "f32",
"float32x4_t" => "f32",
"float64x1_t" => "f64",
"float64x2_t" => "f64",
"poly64x1_t" => "i64",
"poly64x2_t" => "i64",
_ => panic!("unknown type: {}", t),
}
}
// fn type_to_native_type(t: &str) -> &str {
// match t {
// "int8x8_t" => "i8",
// "int8x16_t" => "i8",
// "int16x4_t" => "i16",
// "int16x8_t" => "i16",
// "int32x2_t" => "i32",
// "int32x4_t" => "i32",
// "int64x1_t" => "i64",
// "int64x2_t" => "i64",
// "uint8x8_t" => "u8",
// "uint8x16_t" => "u8",
// "uint16x4_t" => "u16",
// "uint16x8_t" => "u16",
// "uint32x2_t" => "u32",
// "uint32x4_t" => "u32",
// "uint64x1_t" => "u64",
// "uint64x2_t" => "u64",
// "float16x4_t" => "f16",
// "float16x8_t" => "f16",
// "float32x2_t" => "f32",
// "float32x4_t" => "f32",
// "float64x1_t" => "f64",
// "float64x2_t" => "f64",
// "poly64x1_t" => "i64",
// "poly64x2_t" => "i64",
// _ => panic!("unknown type: {}", t),
// }
// }

fn type_to_ext(t: &str) -> &str {
match t {
Expand Down Expand Up @@ -461,76 +460,84 @@ pub unsafe fn {}(a: {}, b: {}) -> {} {{
{}{}(a, b)
}}
"#,
current_comment, expand_intrinsic(&current_arm, in_t), expand_intrinsic(&current_aarch64, in_t), name, in_t, in_t, out_t, ext_c, current_fn,
current_comment,
expand_intrinsic(&current_arm, in_t),
expand_intrinsic(&current_aarch64, in_t),
name,
in_t,
in_t,
out_t,
ext_c,
current_fn,
);
let test = gen_test(name, &in_t, &out_t, current_tests, type_len(in_t));

(function, test)
}

fn expand_intrinsic(intr: &str, t: &str) -> String {
if intr.ends_with(".") {
if intr.ends_with(".") {
let ext = match t {
"int8x8_t" => "i8",
"int8x16_t" => "i8",
"int16x4_t" => "i16",
"int16x8_t" => "i16",
"int32x2_t" => "i32",
"int32x4_t" => "i32",
"int64x1_t" => "i64",
"int64x2_t" => "i64",
"uint8x8_t" => "i8",
"uint8x16_t" => "i8",
"uint16x4_t" => "i16",
"uint16x8_t" => "i16",
"uint32x2_t" => "i32",
"uint32x4_t" => "i32",
"uint64x1_t" => "i64",
"uint64x2_t" => "i64",
"float16x4_t" => "f16",
"float16x8_t" => "f16",
"float32x2_t" => "f32",
"float32x4_t" => "f32",
"float64x1_t" => "f64",
"float64x2_t" => "f64",
/*
"poly64x1_t" => "i64x1",
"poly64x2_t" => "i64x2",
*/
_ => panic!("unknown type for extension: {}", t),
"int8x8_t" => "i8",
"int8x16_t" => "i8",
"int16x4_t" => "i16",
"int16x8_t" => "i16",
"int32x2_t" => "i32",
"int32x4_t" => "i32",
"int64x1_t" => "i64",
"int64x2_t" => "i64",
"uint8x8_t" => "i8",
"uint8x16_t" => "i8",
"uint16x4_t" => "i16",
"uint16x8_t" => "i16",
"uint32x2_t" => "i32",
"uint32x4_t" => "i32",
"uint64x1_t" => "i64",
"uint64x2_t" => "i64",
"float16x4_t" => "f16",
"float16x8_t" => "f16",
"float32x2_t" => "f32",
"float32x4_t" => "f32",
"float64x1_t" => "f64",
"float64x2_t" => "f64",
/*
"poly64x1_t" => "i64x1",
"poly64x2_t" => "i64x2",
*/
_ => panic!("unknown type for extension: {}", t),
};
format!(r#""{}{}""#, intr, ext)
} else if intr.ends_with(".s") {
} else if intr.ends_with(".s") {
let ext = match t {
"int8x8_t" => "s8",
"int8x16_t" => "s8",
"int16x4_t" => "s16",
"int16x8_t" => "s16",
"int32x2_t" => "s32",
"int32x4_t" => "s32",
"int64x1_t" => "s64",
"int64x2_t" => "s64",
"uint8x8_t" => "u8",
"uint8x16_t" => "u8",
"uint16x4_t" => "u16",
"uint16x8_t" => "u16",
"uint32x2_t" => "u32",
"uint32x4_t" => "u32",
"uint64x1_t" => "u64",
"uint64x2_t" => "u64",
"float16x4_t" => "f16",
"float16x8_t" => "f16",
"float32x2_t" => "f32",
"float32x4_t" => "f32",
"float64x1_t" => "f64",
"float64x2_t" => "f64",
/*
"poly64x1_t" => "i64x1",
"poly64x2_t" => "i64x2",
*/
_ => panic!("unknown type for extension: {}", t),
"int8x8_t" => "s8",
"int8x16_t" => "s8",
"int16x4_t" => "s16",
"int16x8_t" => "s16",
"int32x2_t" => "s32",
"int32x4_t" => "s32",
"int64x1_t" => "s64",
"int64x2_t" => "s64",
"uint8x8_t" => "u8",
"uint8x16_t" => "u8",
"uint16x4_t" => "u16",
"uint16x8_t" => "u16",
"uint32x2_t" => "u32",
"uint32x4_t" => "u32",
"uint64x1_t" => "u64",
"uint64x2_t" => "u64",
"float16x4_t" => "f16",
"float16x8_t" => "f16",
"float32x2_t" => "f32",
"float32x4_t" => "f32",
"float64x1_t" => "f64",
"float64x2_t" => "f64",
/*
"poly64x1_t" => "i64x1",
"poly64x2_t" => "i64x2",
*/
_ => panic!("unknown type for extension: {}", t),
};
format!(r#""{}{}""#, &intr[..intr.len()-1], ext)
format!(r#""{}{}""#, &intr[..intr.len() - 1], ext)
} else {
intr.to_string()
}
Expand Down

0 comments on commit 2dbeb2e

Please sign in to comment.