Skip to content

Commit 0cc5181

Browse files
committed
Draft: Add all extinst
1 parent 3e8814d commit 0cc5181

File tree

10 files changed

+1137
-259
lines changed

10 files changed

+1137
-259
lines changed

autogen/src/main.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,12 @@ fn main() {
129129
};
130130

131131
let extended_instruction_sets = [
132-
("GLSL.std.450", "GLOp", "https://www.khronos.org/registry/spir-v/specs/unified1/GLSL.std.450.html"),
133-
("OpenCL.std.100", "CLOp", "https://www.khronos.org/registry/spir-v/specs/unified1/OpenCL.ExtendedInstructionSet.100.html"),
134-
("NonSemantic.DebugPrintF", "DebugPrintFOp", "https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/master/docs/debug_printf.md"),
132+
("GLSL.std.450", "GLOp", "https://registry.khronos.org/SPIR-V/specs/unified1/GLSL.std.450.html"),
133+
("OpenCL.std.100", "CLOp", "https://registry.khronos.org/SPIR-V/specs/unified1/OpenCL.ExtendedInstructionSet.100.html"),
134+
("OpenCL.debuginfo.100", "CLDebugInfoOp", "https://registry.khronos.org/SPIR-V/specs/unified1/OpenCL.DebugInfo.100.html"),
135+
("NonSemantic.DebugPrintF", "DebugPrintFOp", "https://github.khronos.org/SPIRV-Registry/nonsemantic/NonSemantic.DebugPrintf.html"),
136+
("NonSemantic.DebugBreak", "DebugBreakOp", "https://github.khronos.org/SPIRV-Registry/nonsemantic/NonSemantic.DebugBreak.html"),
137+
("DebugInfo", "DebugInfoOp", "https://registry.khronos.org/SPIR-V/specs/unified1/DebugInfo.html"),
135138
];
136139
let extended_instruction_sets = extended_instruction_sets.map(|(ext, op, url)| {
137140
let grammar: structs::ExtInstSetGrammar = serde_json::from_str(
@@ -172,14 +175,15 @@ fn main() {
172175
table::gen_grammar_inst_table_operand_kinds(&grammar),
173176
);
174177
// Extended instruction sets
175-
for (ext, _, _, grammar) in extended_instruction_sets {
178+
for (ext, spirv_op, _, grammar) in extended_instruction_sets {
176179
write_formatted(
177180
&autogen_src_dir.join(format!(
178181
"../rspirv/grammar/autogen_{}.rs",
179182
ext.replace(".", "_").to_lowercase()
180183
)),
181184
table::gen_instruction_table(
182185
&grammar.instructions,
186+
spirv_op,
183187
&format!("{}_INSTRUCTION_TABLE", ext.replace(".", "_").to_uppercase()),
184188
true,
185189
),

autogen/src/table.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ fn convert_quantifier(quantifier: structs::Quantifier) -> Ident {
2121
/// `is_ext` indicates whether the grammar is for an extended instruction set.
2222
pub(crate) fn gen_instruction_table(
2323
grammar: &[structs::Instruction],
24+
spirv_op: &str,
2425
name: &str,
2526
is_ext: bool,
2627
) -> TokenStream {
28+
let spirv_op = as_ident(spirv_op);
2729
// Vector for strings for all instructions.
2830
let instructions = grammar.iter().map(|inst| {
2931
// Vector of strings for all operands.
@@ -36,9 +38,9 @@ pub(crate) fn gen_instruction_table(
3638
let exts = &inst.extensions;
3739
if is_ext {
3840
let opname = as_ident(&inst.opname);
39-
let opcode = inst.opcode;
41+
// let opcode = inst.opcode;
4042
quote! {
41-
ext_inst!(#opname, #opcode, [#(#caps),*], [#(#exts),*], [#(#operands),*])
43+
ext_inst!(#spirv_op, #opname, [#(#caps),*], [#(#exts),*], [#(#operands),*])
4244
}
4345
} else {
4446
let opname = as_ident(inst.opname.strip_prefix("Op").unwrap());
@@ -68,7 +70,7 @@ pub fn gen_grammar_inst_table_operand_kinds(grammar: &structs::Grammar) -> Token
6870
.map(|kind| as_ident(&kind.kind));
6971

7072
// Instruction table.
71-
let table = gen_instruction_table(&grammar.instructions, "INSTRUCTION_TABLE", false);
73+
let table = gen_instruction_table(&grammar.instructions, "WIE", "INSTRUCTION_TABLE", false);
7274

7375
quote! {
7476
#[doc = "All operand kinds in the SPIR-V grammar."]

0 commit comments

Comments
 (0)