[ir][spirv-writer] Fail when errors are present

Make sure we return `false` when something goes wrong during
codegen. Also, add some more TINT_ICE calls in places where we know
stuff is unimplemented. This makes it easier to track current progress
against Tint's E2E tests.

Bug: tint:1906
Change-Id: Ic5885201d7b4f286d8f282df5a2074a017a98477
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/132421
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: James Price <jrprice@google.com>
This commit is contained in:
James Price 2023-05-11 10:37:42 +00:00 committed by Dawn LUCI CQ
parent 732791fa79
commit fd60f17236
1 changed files with 11 additions and 0 deletions

View File

@ -45,12 +45,20 @@ bool GeneratorImplIr::Generate() {
// TODO(crbug.com/tint/1906): Emit variables.
(void)zero_init_workgroup_memory_;
if (ir_->root_block) {
TINT_ICE(Writer, diagnostics_) << "root block is unimplemented";
return false;
}
// Emit functions.
for (auto* func : ir_->functions) {
EmitFunction(func);
}
if (diagnostics_.contains_errors()) {
return false;
}
// Serialize the module into binary SPIR-V.
writer_.WriteHeader(module_.IdBound());
writer_.WriteModule(&module_);
@ -231,6 +239,9 @@ void GeneratorImplIr::EmitBlock(const ir::Block* block) {
block->branch.target,
[&](const ir::FunctionTerminator*) {
// TODO(jrprice): Handle the return value, which will be a branch argument.
if (!block->branch.args.IsEmpty()) {
TINT_ICE(Writer, diagnostics_) << "unimplemented return value";
}
current_function_.push_inst(spv::Op::OpReturn, {});
},
[&](Default) { TINT_ICE(Writer, diagnostics_) << "unimplemented branch target"; });