nir: Add alignment information to cast derefs
Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6472>
This commit is contained in:

committed by
Marge Bot

parent
a0b82c24b6
commit
878a8daca6
@@ -1462,6 +1462,8 @@ typedef struct {
|
||||
|
||||
struct {
|
||||
unsigned ptr_stride;
|
||||
unsigned align_mul;
|
||||
unsigned align_offset;
|
||||
} cast;
|
||||
};
|
||||
|
||||
|
@@ -339,6 +339,8 @@ clone_deref_instr(clone_state *state, const nir_deref_instr *deref)
|
||||
|
||||
case nir_deref_type_cast:
|
||||
nderef->cast.ptr_stride = deref->cast.ptr_stride;
|
||||
nderef->cast.align_mul = deref->cast.align_mul;
|
||||
nderef->cast.align_offset = deref->cast.align_offset;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@@ -172,6 +172,8 @@ hash_deref(uint32_t hash, const nir_deref_instr *instr)
|
||||
|
||||
case nir_deref_type_cast:
|
||||
hash = HASH(hash, instr->cast.ptr_stride);
|
||||
hash = HASH(hash, instr->cast.align_mul);
|
||||
hash = HASH(hash, instr->cast.align_offset);
|
||||
break;
|
||||
|
||||
case nir_deref_type_var:
|
||||
@@ -619,7 +621,9 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2)
|
||||
break;
|
||||
|
||||
case nir_deref_type_cast:
|
||||
if (deref1->cast.ptr_stride != deref2->cast.ptr_stride)
|
||||
if (deref1->cast.ptr_stride != deref2->cast.ptr_stride ||
|
||||
deref1->cast.align_mul != deref2->cast.align_mul ||
|
||||
deref1->cast.align_offset != deref2->cast.align_offset)
|
||||
return false;
|
||||
break;
|
||||
|
||||
|
@@ -1037,6 +1037,8 @@ write_deref(write_ctx *ctx, const nir_deref_instr *deref)
|
||||
case nir_deref_type_cast:
|
||||
write_src(ctx, &deref->parent);
|
||||
blob_write_uint32(ctx->blob, deref->cast.ptr_stride);
|
||||
blob_write_uint32(ctx->blob, deref->cast.align_mul);
|
||||
blob_write_uint32(ctx->blob, deref->cast.align_offset);
|
||||
if (!header.deref.cast_type_same_as_last) {
|
||||
encode_type_to_blob(ctx->blob, deref->type);
|
||||
ctx->last_type = deref->type;
|
||||
@@ -1101,6 +1103,8 @@ read_deref(read_ctx *ctx, union packed_instr header)
|
||||
case nir_deref_type_cast:
|
||||
read_src(ctx, &deref->parent, &deref->instr);
|
||||
deref->cast.ptr_stride = blob_read_uint32(ctx->blob);
|
||||
deref->cast.align_mul = blob_read_uint32(ctx->blob);
|
||||
deref->cast.align_offset = blob_read_uint32(ctx->blob);
|
||||
if (header.deref.cast_type_same_as_last) {
|
||||
deref->type = ctx->last_type;
|
||||
} else {
|
||||
|
@@ -418,6 +418,12 @@ validate_deref_instr(nir_deref_instr *instr, validate_state *state)
|
||||
/* We just validate that the type and mode are there */
|
||||
validate_assert(state, instr->mode);
|
||||
validate_assert(state, instr->type);
|
||||
if (instr->cast.align_mul > 0) {
|
||||
validate_assert(state, util_is_power_of_two_nonzero(instr->cast.align_mul));
|
||||
validate_assert(state, instr->cast.align_offset < instr->cast.align_mul);
|
||||
} else {
|
||||
validate_assert(state, instr->cast.align_offset == 0);
|
||||
}
|
||||
} else {
|
||||
/* We require the parent to be SSA. This may be lifted in the future */
|
||||
validate_assert(state, instr->parent.is_ssa);
|
||||
|
Reference in New Issue
Block a user