brw: Pass brw_codegen to next_offset

In the next commit we will use this to assert that we are not reading
past the end of `p->store`.

Reviewed-by: Caio Oliveira <caio.oliveira@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33101>
This commit is contained in:
Matt Turner 2025-01-16 16:31:22 -05:00 committed by Marge Bot
parent a4f0a96dda
commit ab037b5daf
3 changed files with 8 additions and 7 deletions

View file

@ -1586,8 +1586,9 @@ bool brw_validate_instructions(const struct brw_isa_info *isa,
struct disasm_info *disasm);
static inline int
next_offset(const struct intel_device_info *devinfo, void *store, int offset)
next_offset(struct brw_codegen *p, void *store, int offset)
{
const struct intel_device_info *devinfo = p->devinfo;
brw_eu_inst *insn = (brw_eu_inst *)((char *)store + offset);
if (brw_eu_inst_cmpt_control(devinfo, insn))

View file

@ -2402,7 +2402,7 @@ brw_compact_instructions(struct brw_codegen *p, int start_offset,
/* Fix up control flow offsets. */
p->next_insn_offset = start_offset + offset;
for (offset = 0; offset < p->next_insn_offset - start_offset;
offset = next_offset(devinfo, store, offset)) {
offset = next_offset(p, store, offset)) {
brw_eu_inst *insn = store + offset;
int this_old_ip = old_ip[offset / sizeof(brw_eu_compact_inst)];
int this_compacted_count = compacted_counts[this_old_ip];
@ -2494,7 +2494,7 @@ brw_compact_instructions(struct brw_codegen *p, int start_offset,
sizeof(brw_eu_inst) != group->offset) {
assert(start_offset + old_ip[offset / sizeof(brw_eu_compact_inst)] *
sizeof(brw_eu_inst) < group->offset);
offset = next_offset(devinfo, store, offset);
offset = next_offset(p, store, offset);
}
group->offset = start_offset + offset;

View file

@ -1547,9 +1547,9 @@ brw_find_next_block_end(struct brw_codegen *p, int start_offset)
int depth = 0;
for (offset = next_offset(devinfo, store, start_offset);
for (offset = next_offset(p, store, start_offset);
offset < p->next_insn_offset;
offset = next_offset(devinfo, store, offset)) {
offset = next_offset(p, store, offset)) {
brw_eu_inst *insn = store + offset;
switch (brw_eu_inst_opcode(p->isa, insn)) {
@ -1595,9 +1595,9 @@ brw_find_loop_end(struct brw_codegen *p, int start_offset)
/* Always start after the instruction (such as a WHILE) we're trying to fix
* up.
*/
for (offset = next_offset(devinfo, store, start_offset);
for (offset = next_offset(p, store, start_offset);
offset < p->next_insn_offset;
offset = next_offset(devinfo, store, offset)) {
offset = next_offset(p, store, offset)) {
brw_eu_inst *insn = store + offset;
if (brw_eu_inst_opcode(p->isa, insn) == BRW_OPCODE_WHILE) {