Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump version #126

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 53 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions spirq-spvasm/scripts/generate_operand_enum_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@

out += [
"use anyhow::{bail, Result};",
"use num_traits::FromPrimitive;",
"use spirq_core::spirv::Op;",
"",
"",
"fn unknown_operand_index(i: usize) -> Result<&'static str> {",
' bail!("Unknown operand index: {}", i)',
"fn unknown_operand_index(opcode: u32, i: usize) -> Result<&'static str> {",
' let opname = Op::from_u32(opcode).map(|op| format!("{:?}", op)).unwrap_or("<unknown>".to_owned());',
' bail!("Unknown op {} ({}) operand index: {}", opname, opcode, i)',
"}",
"",
"pub fn operand_enum_type(opcode: u32, i: usize) -> Result<&'static str> {",
Expand All @@ -53,8 +55,8 @@
f' {i} => "{kind}",',
]
out += [
" _ => return unknown_operand_index(i),",
" }",
" _ => return unknown_operand_index(opcode, i),",
" },",
]

out += [
Expand Down
158 changes: 94 additions & 64 deletions spirq-spvasm/src/generated/decorate_parameter_enum_type.rs
Original file line number Diff line number Diff line change
@@ -1,78 +1,108 @@
use anyhow::{bail, Result};
use anyhow::{ bail, Result };
use num_traits::FromPrimitive;
use spirq_core::spirv::Op;

fn unknown_decorate_parameter_index(decoration: u32, i: usize) -> Result<&'static str> {
let opname = Op::from_u32(decoration)
.map(|op| format!("{:?}", op))
.unwrap_or("<unknown>".to_owned());
bail!(
"Unknown op {} ({}) parameter index: {}",
opname,
decoration,
i
)
bail!("Unknown op {} ({}) parameter index: {}", opname, decoration, i)
}

pub fn decorate_parameter_enum_type(decoration: u32, i: usize) -> Result<&'static str> {
let out: &'static str = match decoration {
11 => match i {
0 => "BuiltIn",
_ => return unknown_decorate_parameter_index(decoration, i),
},
38 => match i {
0 => "FunctionParameterAttribute",
_ => return unknown_decorate_parameter_index(decoration, i),
},
39 => match i {
0 => "FPRoundingMode",
_ => return unknown_decorate_parameter_index(decoration, i),
},
40 => match i {
0 => "FPFastMathMode",
_ => return unknown_decorate_parameter_index(decoration, i),
},
41 => match i {
1 => "LinkageType",
_ => return unknown_decorate_parameter_index(decoration, i),
},
5822 => match i {
1 => "FPRoundingMode",
_ => return unknown_decorate_parameter_index(decoration, i),
},
5823 => match i {
1 => "FPDenormMode",
_ => return unknown_decorate_parameter_index(decoration, i),
},
6080 => match i {
1 => "FPOperationMode",
_ => return unknown_decorate_parameter_index(decoration, i),
},
6180 => match i {
0 => "AccessQualifier",
_ => return unknown_decorate_parameter_index(decoration, i),
},
6188 => match i {
0 => "HostAccessQualifier",
_ => return unknown_decorate_parameter_index(decoration, i),
},
6190 => match i {
0 => "InitializationModeQualifier",
_ => return unknown_decorate_parameter_index(decoration, i),
},
6442 => match i {
1 => "LoadCacheControl",
_ => return unknown_decorate_parameter_index(decoration, i),
},
6443 => match i {
1 => "StoreCacheControl",
_ => return unknown_decorate_parameter_index(decoration, i),
},
_ => bail!(
"{}-th parameter of decoration {} is not a enum",
i,
decoration
),
11 =>
match i {
0 => "BuiltIn",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
38 =>
match i {
0 => "FunctionParameterAttribute",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
39 =>
match i {
0 => "FPRoundingMode",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
40 =>
match i {
0 => "FPFastMathMode",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
41 =>
match i {
1 => "LinkageType",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
5822 =>
match i {
1 => "FPRoundingMode",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
5823 =>
match i {
1 => "FPDenormMode",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
6080 =>
match i {
1 => "FPOperationMode",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
6180 =>
match i {
0 => "AccessQualifier",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
6188 =>
match i {
0 => "HostAccessQualifier",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
6190 =>
match i {
0 => "InitializationModeQualifier",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
6442 =>
match i {
1 => "LoadCacheControl",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
6443 =>
match i {
1 => "StoreCacheControl",
_ => {
return unknown_decorate_parameter_index(decoration, i);
}
}
_ => bail!("{}-th parameter of decoration {} is not a enum", i, decoration),
};
Ok(out)
}
2 changes: 2 additions & 0 deletions spirq-spvasm/src/generated/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod op_has_result_type_id;
mod op_to_str;
mod operand_enum_type;
mod print_operand;
mod decorate_parameter_enum_type;

pub use decorate_parameter_enum_type::decorate_parameter_enum_type;
pub use enum_from_str::enum_from_str;
Expand All @@ -17,3 +18,4 @@ pub use op_has_result_type_id::op_has_result_type_id;
pub use op_to_str::op_to_str;
pub use operand_enum_type::operand_enum_type;
pub use print_operand::print_operand;
pub use decorate_parameter_enum_type::decorate_parameter_enum_type;
Loading
Loading