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