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

[WIP] Structured items #46

Closed
wants to merge 9 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
10 changes: 10 additions & 0 deletions Cargo.lock

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

28 changes: 24 additions & 4 deletions codegen/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![recursion_limit="128"]

mod binary;
mod header;
mod mr;
Expand Down Expand Up @@ -197,19 +199,37 @@ fn main() {
let c = sr::gen_sr_decoration(&grammar);
fmt_write!(c, path);
}

let (type_enums, type_structs, type_lifts) = sr::gen_sr_types(&grammar);
{
let path = codegen_src_dir.join("../rspirv/sr/autogen_type_lift.rs");
fmt_write!(type_lifts, path);
}
{
let path = codegen_src_dir.join("../rspirv/sr/autogen_type_struct.rs");
fmt_write!(type_structs, path);
}
{
let path = codegen_src_dir.join("../rspirv/sr/autogen_type_enum_check.rs");
let c = sr::gen_sr_type_check(&grammar);
fmt_write!(c, path);
fmt_write!(type_enums, path);
}
{
let path = codegen_src_dir.join("../rspirv/sr/autogen_type_creation.rs");
let c = sr::gen_sr_type_creation(&grammar);
fmt_write!(c, path);
}

let (inst_enums, inst_structs, inst_lifts) = sr::gen_sr_instructions(&grammar);
{
let path = codegen_src_dir.join("../rspirv/sr/autogen_instruction_lift.rs");
fmt_write!(inst_lifts, path);
}
{
let path = codegen_src_dir.join("../rspirv/sr/autogen_instruction_struct.rs");
fmt_write!(inst_structs, path);
}
{
let path = codegen_src_dir.join("../rspirv/sr/autogen_instruction.rs");
let c = sr::gen_sr_instruction(&grammar);
fmt_write!(c, path);
fmt_write!(inst_enums, path);
}
}
3 changes: 3 additions & 0 deletions codegen/external/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ repository, with some modifications to spirv.core.grammar.json. So there is
a copy of it in this directory.

[spirv-headers]: https://github.com/KhronosGroup/SPIRV-Headers

Modifications are:
- "class" field
11 changes: 6 additions & 5 deletions codegen/external/spirv.core.grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2278,6 +2278,7 @@
]
},
{
"class" : "FunctionStruct",
"opname" : "OpPhi",
"opcode" : 245,
"operands" : [
Expand Down Expand Up @@ -2312,15 +2313,15 @@
]
},
{
"class": "Terminator",
"class": "Branch",
"opname" : "OpBranch",
"opcode" : 249,
"operands" : [
{ "kind" : "IdRef", "name" : "'Target Label'" }
]
},
{
"class": "Terminator",
"class": "Branch",
"opname" : "OpBranchConditional",
"opcode" : 250,
"operands" : [
Expand All @@ -2331,7 +2332,7 @@
]
},
{
"class": "Terminator",
"class": "Branch",
"opname" : "OpSwitch",
"opcode" : 251,
"operands" : [
Expand All @@ -2347,12 +2348,12 @@
"capabilities" : [ "Shader" ]
},
{
"class": "Terminator",
"class": "Branch",
"opname" : "OpReturn",
"opcode" : 253
},
{
"class": "Terminator",
"class": "Branch",
"opname" : "OpReturnValue",
"opcode" : 254,
"operands" : [
Expand Down
2 changes: 1 addition & 1 deletion codegen/mr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ pub fn gen_mr_builder_terminator(grammar: &structs::Grammar) -> String {
let kinds = &grammar.operand_kinds;
// Generate build methods for all types.
let elements: Vec<String> = grammar.instructions.iter().filter(|inst| {
inst.class == "Terminator"
inst.class == "Terminator" || inst.class == "Branch"
}).map(|inst| {
let (params, type_generics) = get_param_list(&inst.operands, false, kinds);
let extras = get_push_extras(&inst.operands, kinds, "inst.operands").join(";\n");
Expand Down
Loading