File tree Expand file tree Collapse file tree 6 files changed +162
-0
lines changed Expand file tree Collapse file tree 6 files changed +162
-0
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,5 @@ pretty_env_logger = "0.5.0"
1919rayon = " 1.5.0"
2020diff = " 0.1.12"
2121itertools = " 0.14.0"
22+ quick-xml = { version = " 0.37.5" , features = [" serialize" , " overlapped-lists" ] }
23+ serde-xml-rs = " 0.8.0"
Original file line number Diff line number Diff line change @@ -3,10 +3,12 @@ extern crate log;
33
44mod arm;
55mod common;
6+ mod x86;
67
78use arm:: ArmArchitectureTest ;
89use common:: SupportedArchitectureTest ;
910use common:: cli:: { Cli , ProcessedCli } ;
11+ use x86:: X86ArchitectureTest ;
1012
1113fn main ( ) {
1214 pretty_env_logger:: init ( ) ;
@@ -20,6 +22,8 @@ fn main() {
2022 | "aarch64_be-unknown-linux-gnu" => {
2123 Some ( ArmArchitectureTest :: create ( processed_cli_options) )
2224 }
25+
26+ "x86_64-unknown-linux-gnu" => Some ( X86ArchitectureTest :: create ( processed_cli_options) ) ,
2327
2428 _ => None ,
2529 } ;
Original file line number Diff line number Diff line change 1+ use crate :: common:: argument:: ArgumentList ;
2+ use crate :: common:: indentation:: Indentation ;
3+ use crate :: common:: intrinsic:: { Intrinsic , IntrinsicDefinition } ;
4+ use crate :: common:: intrinsic_helpers:: IntrinsicType ;
5+ use std:: ops:: { Deref , DerefMut } ;
6+
7+ #[ derive( Debug , Clone , PartialEq ) ]
8+ pub struct X86IntrinsicType ( pub IntrinsicType ) ;
9+
10+ impl Deref for X86IntrinsicType {
11+ type Target = IntrinsicType ;
12+
13+ fn deref ( & self ) -> & Self :: Target {
14+ & self . 0
15+ }
16+ }
17+
18+ impl DerefMut for X86IntrinsicType {
19+ fn deref_mut ( & mut self ) -> & mut Self :: Target {
20+ & mut self . 0
21+ }
22+ }
23+
24+ impl IntrinsicDefinition < X86IntrinsicType > for Intrinsic < X86IntrinsicType > {
25+ fn arguments ( & self ) -> ArgumentList < X86IntrinsicType > {
26+ self . arguments . clone ( )
27+ }
28+
29+ fn results ( & self ) -> X86IntrinsicType {
30+ self . results . clone ( )
31+ }
32+
33+ fn name ( & self ) -> String {
34+ self . name . clone ( )
35+ }
36+
37+ /// Generates a std::cout for the intrinsics results that will match the
38+ /// rust debug output format for the return type. The generated line assumes
39+ /// there is an int i in scope which is the current pass number.
40+ fn print_result_c ( & self , _indentation : Indentation , _additional : & str ) -> String {
41+ todo ! ( "print_result_c in Intrinsic<X86IntrinsicType> needs to be implemented!" ) ;
42+ }
43+ }
Original file line number Diff line number Diff line change 1+ mod intrinsic;
2+ mod types;
3+ mod xml_parser;
4+
5+ use crate :: common:: SupportedArchitectureTest ;
6+ use crate :: common:: cli:: ProcessedCli ;
7+ use crate :: common:: intrinsic:: Intrinsic ;
8+ use intrinsic:: X86IntrinsicType ;
9+
10+ pub struct X86ArchitectureTest {
11+ intrinsics : Vec < Intrinsic < X86IntrinsicType > > ,
12+ cli_options : ProcessedCli ,
13+ }
14+
15+ impl SupportedArchitectureTest for X86ArchitectureTest {
16+ fn create ( cli_options : ProcessedCli ) -> Box < Self > {
17+ todo ! ( "create in X86ArchitectureTest is not implemented" )
18+ }
19+
20+ fn build_c_file ( & self ) -> bool {
21+ todo ! ( "build_c_file in X86ArchitectureTest is not implemented" )
22+ }
23+
24+ fn build_rust_file ( & self ) -> bool {
25+ todo ! ( "build_rust_file in X86ArchitectureTest is not implemented" )
26+ }
27+
28+ fn compare_outputs ( & self ) -> bool {
29+ todo ! ( "compare_outputs in X86ArchitectureTest is not implemented" )
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ use super :: intrinsic:: X86IntrinsicType ;
2+ use crate :: common:: cli:: Language ;
3+ use crate :: common:: intrinsic_helpers:: IntrinsicTypeDefinition ;
4+ use crate :: x86:: xml_parser:: Parameter ;
5+
6+ impl IntrinsicTypeDefinition for X86IntrinsicType {
7+ /// Gets a string containing the type in C format.
8+ /// This function assumes that this value is present in the metadata hashmap.
9+ fn c_type ( & self ) -> String {
10+ todo ! ( "c_type from IntrinsicTypeDefinition is not defined!" )
11+ }
12+
13+ fn c_single_vector_type ( & self ) -> String {
14+ // matches __m128, __m256 and similar types
15+ todo ! ( "c_type from IntrinsicTypeDefinition is not defined!" )
16+ }
17+
18+ /// Determines the load function for this type.
19+ fn get_load_function ( & self , _language : Language ) -> String {
20+ todo ! ( "get_load_function from IntrinsicTypeDefinition is not defined!" )
21+ }
22+
23+ /// Determines the get lane function for this type.
24+ fn get_lane_function ( & self ) -> String {
25+ todo ! ( "get_lane_function for X86IntrinsicType needs to be implemented!" ) ;
26+ }
27+
28+ fn from_c ( s : & str , target : & str ) -> Result < Self , String > {
29+ todo ! ( "from_c from IntrinsicTypeDefinition is not defined!" )
30+ }
31+ }
32+
33+ impl X86IntrinsicType {
34+ pub fn from_param ( param : & Parameter ) -> Result < Self , String > {
35+ todo ! ( "from_param from X86IntrinsicType is not defined!" )
36+ }
37+ }
Original file line number Diff line number Diff line change 1+ use serde:: { Deserialize , Deserializer } ;
2+
3+
4+ // Custom deserializer function to convert strings to u32
5+ fn string_to_u32 < ' de , D > ( deserializer : D ) -> Result < u32 , D :: Error >
6+ where
7+ D : Deserializer < ' de > ,
8+ {
9+ let s = String :: deserialize ( deserializer) ?;
10+ return s. as_str ( ) . parse :: < u32 > ( ) . or ( Ok ( 0u32 ) ) ;
11+ }
12+
13+ #[ derive( Deserialize ) ]
14+ struct Data {
15+ #[ serde( rename = "intrinsic" , default ) ]
16+ intrinsics : Vec < XMLIntrinsic > ,
17+ }
18+
19+ #[ derive( Deserialize ) ]
20+ struct XMLIntrinsic {
21+ #[ serde( rename = "return" ) ]
22+ return_data : Parameter ,
23+ #[ serde( rename = "@name" ) ]
24+ name : String ,
25+ // #[serde(rename = "@tech")]
26+ // tech: String,
27+ #[ serde( rename = "CPUID" , default ) ]
28+ cpuid : Vec < String > ,
29+ #[ serde( rename = "parameter" , default ) ]
30+ parameters : Vec < Parameter > ,
31+ }
32+
33+ #[ derive( Deserialize ) ]
34+ pub struct Parameter {
35+ #[ serde( rename = "@varname" ) ]
36+ pub var_name : String ,
37+ #[ serde( rename = "@type" ) ]
38+ pub type_data : String ,
39+ #[ serde( rename = "@etype" , default ) ]
40+ pub etype : String ,
41+ #[ serde( rename = "@memwidth" , default , deserialize_with = "string_to_u32" ) ]
42+ pub memwidth : u32 ,
43+ #[ serde( rename = "@immtype" , default ) ]
44+ pub imm_type : String ,
45+ }
You can’t perform that action at this time.
0 commit comments