From 3c7dd0ccf111f0cd22f95248eeff406a6ffe4b85 Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Wed, 2 Apr 2025 16:12:45 -0700 Subject: [PATCH] brw: Make brw_builder() shader constructor use CFG if available Properly pick the end of the last block as a cursor. Also remove the default constructor since is not needed anymore. Reviewed-by: Ian Romanick Part-of: --- src/intel/compiler/brw_builder.h | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/src/intel/compiler/brw_builder.h b/src/intel/compiler/brw_builder.h index 0262cf97f59..b496d60cd91 100644 --- a/src/intel/compiler/brw_builder.h +++ b/src/intel/compiler/brw_builder.h @@ -38,29 +38,24 @@ class brw_builder { public: /** * Construct an brw_builder that inserts instructions - * at the end of \p shader. The \p dispatch_width gives - * the execution width, that may differ from the shader - * dispatch_width. + * at the end of \p shader. The optional \p dispatch_width + * gives the execution width to be used instead of the + * shader original dispatch_width. */ brw_builder(brw_shader *shader, - unsigned dispatch_width) : + unsigned dispatch_width = 0) : shader(shader), block(NULL), cursor(NULL), - _dispatch_width(dispatch_width), + _dispatch_width(dispatch_width ? dispatch_width : shader->dispatch_width), _group(0), force_writemask_all(false), annotation() { - if (shader) + if (shader->cfg && shader->cfg->num_blocks > 0) { + block = shader->cfg->last_block(); + cursor = &block->instructions.tail_sentinel; + } else { cursor = (exec_node *)&shader->instructions.tail_sentinel; - } - - /** - * Construct an brw_builder that inserts instructions into \p shader, - * using its dispatch width. - */ - explicit brw_builder(brw_shader *s = NULL) : - brw_builder(s, s ? s->dispatch_width : 0) - { + } } /**