-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ignacy Koper <[email protected]>
- Loading branch information
1 parent
7a627bd
commit 15b5bd2
Showing
8 changed files
with
283 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use serde::Deserialize; | ||
|
||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct SubExpressions { | ||
expression: Option<Vec<Expression>>, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct ValueType { | ||
#[serde(rename = "@Name")] | ||
name: String, | ||
|
||
#[serde(rename = "BaseType")] | ||
base_type: char, | ||
#[serde(rename = "Size")] | ||
size: i8, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct Expression { | ||
#[serde(rename = "@Type")] | ||
ty: Option<String>, | ||
|
||
operator: Option<String>, | ||
subexpressions: Option<SubExpressions>, | ||
label: Option<String>, | ||
value: Option<i8>, | ||
value_type: Option<ValueType>, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct ConditionExpression { | ||
expression: Expression, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct EncodingCondition { | ||
#[serde(rename = "ConditionName")] | ||
name: String, | ||
|
||
#[serde(rename = "CondtionExpression")] | ||
expression: ConditionExpression | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct EncodingConditions { | ||
#[serde(rename = "EncodingCondition")] | ||
condition: Vec<EncodingCondition>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use serde::Deserialize; | ||
|
||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct EncodingIdentifier { | ||
#[serde(rename = "@Radix")] | ||
radix: i8, | ||
#[serde(rename = "$text")] | ||
text: String, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct EncodingIdentifierMask { | ||
#[serde(rename = "@Radix")] | ||
radix: i8, | ||
#[serde(rename = "$text")] | ||
text: String, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct EncodingIdentifiers { | ||
#[serde(rename = "EncodingIdentifier")] | ||
identifier: Vec<EncodingIdentifier> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use serde::Deserialize; | ||
|
||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct Range { | ||
#[serde(rename = "@Order")] | ||
order: i8, | ||
#[serde(rename = "BitCount")] | ||
bit_count: i8, | ||
#[serde(rename = "BitOffset")] | ||
bit_offset: i8 | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct BitLayout { | ||
#[serde(rename = "@RangeCount")] | ||
range_count: i8, | ||
#[serde(rename = "Range")] | ||
range: Range, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct Field { | ||
#[serde(rename = "@IsConditional")] | ||
is_conditional: bool, | ||
|
||
#[serde(rename = "FieldName")] | ||
field_name: String, | ||
#[serde(rename = "Description")] | ||
description: String, | ||
#[serde(rename = "BitLayout")] | ||
bit_layout: BitLayout, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct BitMap { | ||
field: Vec<Field>, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct MicrocodeFormat { | ||
bit_map: BitMap, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
mod cond; | ||
mod ident; | ||
mod microcode; | ||
|
||
|
||
use serde::Deserialize; | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct Encoding { | ||
#[serde(rename = "@Order")] | ||
order: i8, | ||
|
||
#[serde(rename = "EncodingName")] | ||
name: String, | ||
#[serde(rename = "BitCount")] | ||
bit_count: i8, | ||
#[serde(rename = "EncodingIdentifierMask")] | ||
identifier_mask: ident::EncodingIdentifierMask, | ||
#[serde(rename = "EncodingIdentifiers")] | ||
identifiers: Vec<ident::EncodingIdentifiers>, | ||
#[serde(rename = "EncodingConditions")] | ||
conditions: Vec<cond::EncodingConditions>, | ||
|
||
#[serde(rename = "Description")] | ||
description: String, | ||
#[serde(rename = "MicrocodeFormat")] | ||
microcode_format: microcode::MicrocodeFormat, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
#[serde(rename_all = "PascalCase")] | ||
pub struct Encodings { | ||
encoding: Vec<Encoding>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
mod encodings; | ||
|
||
use serde::Deserialize; | ||
|
||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct Spec { | ||
#[serde(rename = "Document")] | ||
document: Document, | ||
#[serde(rename = "ISA")] | ||
isa: ISA, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
#[serde(default, rename_all = "PascalCase")] | ||
pub struct Document { | ||
copyright: String, | ||
sensitivity: String, | ||
// FIXME: figure out how to make it parse date... (returns None) | ||
// release_data: Option<time::Date>, | ||
schema_version: String, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
#[serde(default, rename_all = "PascalCase")] | ||
pub struct ISA { | ||
architecture: Architecture, | ||
encodings: encodings::Encodings, | ||
} | ||
|
||
#[derive(Debug, Default, PartialEq, Deserialize)] | ||
pub struct Architecture { | ||
#[serde(rename = "ArchitectureName")] | ||
name: String, | ||
#[serde(rename = "ArchitectureId")] | ||
id: String, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
mod decode; | ||
|
||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let spec: String = std::fs::read_to_string("./spec/amdgpu_isa_rdna3.xml")?; | ||
let path: String = std::fs::read_to_string( | ||
format!("{}/spec/amdgpu_isa_rdna3.xml", env!("CARGO_MANIFEST_DIR")) | ||
)?; | ||
|
||
let spec: decode::Spec = quick_xml::de::from_str(path.as_str())?; | ||
|
||
println!("{:?}", spec); | ||
println!("{:#?}", spec); | ||
|
||
return Ok(()); | ||
} |