Skip to content

Commit 259367b

Browse files
feat: updated intrinsics creation
1 parent 8438fb5 commit 259367b

File tree

3 files changed

+79
-6
lines changed

3 files changed

+79
-6
lines changed

Cargo.lock

Lines changed: 51 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/intrinsic-test/src/x86/mod.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ mod intrinsic;
33
mod types;
44
mod xml_parser;
55

6-
use crate::common::SupportedArchitectureTest;
76
use crate::common::cli::ProcessedCli;
8-
use crate::common::intrinsic::Intrinsic;
7+
use crate::common::intrinsic::{Intrinsic, IntrinsicDefinition};
8+
use crate::common::intrinsic_helpers::TypeKind;
9+
use crate::common::SupportedArchitectureTest;
910
use intrinsic::X86IntrinsicType;
11+
use xml_parser::get_xml_intrinsics;
1012

1113
pub struct X86ArchitectureTest {
1214
intrinsics: Vec<Intrinsic<X86IntrinsicType>>,
@@ -15,7 +17,28 @@ pub struct X86ArchitectureTest {
1517

1618
impl SupportedArchitectureTest for X86ArchitectureTest {
1719
fn create(cli_options: ProcessedCli) -> Box<Self> {
18-
todo!("create in X86ArchitectureTest is not implemented")
20+
let intrinsics =
21+
get_xml_intrinsics(&cli_options.filename).expect("Error parsing input file");
22+
23+
let mut intrinsics = intrinsics
24+
.into_iter()
25+
// Not sure how we would compare intrinsic that returns void.
26+
.filter(|i| i.results.kind() != TypeKind::Void)
27+
.filter(|i| i.results.kind() != TypeKind::BFloat)
28+
.filter(|i| i.arguments().args.len() > 0)
29+
.filter(|i| !i.arguments.iter().any(|a| a.ty.kind() == TypeKind::BFloat))
30+
// Skip pointers for now, we would probably need to look at the return
31+
// type to work out how many elements we need to point to.
32+
.filter(|i| !i.arguments.iter().any(|a| a.is_ptr()))
33+
.filter(|i| !i.arguments.iter().any(|a| a.ty.inner_size() == 128))
34+
.filter(|i| !cli_options.skip.contains(&i.name))
35+
.collect::<Vec<_>>();
36+
37+
intrinsics.sort_by(|a, b| a.name.cmp(&b.name));
38+
Box::new(Self {
39+
intrinsics: intrinsics,
40+
cli_options: cli_options,
41+
})
1942
}
2043

2144
fn build_c_file(&self) -> bool {

crates/intrinsic-test/src/x86/xml_parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ struct Data {
2626
#[derive(Deserialize)]
2727
struct XMLIntrinsic {
2828
#[serde(rename = "return")]
29-
return_data: Parameter,
29+
pub return_data: Parameter,
3030
#[serde(rename = "@name")]
31-
name: String,
31+
pub name: String,
3232
// #[serde(rename = "@tech")]
3333
// tech: String,
3434
#[serde(rename = "CPUID", default)]

0 commit comments

Comments
 (0)