summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2019-11-05 18:24:27 -0500
committerMarek Olšák <[email protected]>2019-11-23 00:02:10 -0500
commited6b01d5e034faae08bbed0198a780e18bd0a1d9 (patch)
tree52fb29f87bd577930990b3b178eeec76c950d91f /src/compiler
parenta0cd67d29203755cec7017a6894704d2a55bee06 (diff)
nir/serialize: cleanup - fold nir_deref_type_var cases into switches
Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/nir/nir_serialize.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/compiler/nir/nir_serialize.c b/src/compiler/nir/nir_serialize.c
index ddf12ae9b8d..c080d30a74f 100644
--- a/src/compiler/nir/nir_serialize.c
+++ b/src/compiler/nir/nir_serialize.c
@@ -867,25 +867,25 @@ write_deref(write_ctx *ctx, const nir_deref_instr *deref)
write_dest(ctx, &deref->dest, header);
- if (deref->deref_type == nir_deref_type_var) {
+ switch (deref->deref_type) {
+ case nir_deref_type_var:
if (!header.deref_var.object_idx)
blob_write_uint32(ctx->blob, var_idx);
- return;
- }
-
- write_src(ctx, &deref->parent);
+ break;
- switch (deref->deref_type) {
case nir_deref_type_struct:
+ write_src(ctx, &deref->parent);
blob_write_uint32(ctx->blob, deref->strct.index);
break;
case nir_deref_type_array:
case nir_deref_type_ptr_as_array:
+ write_src(ctx, &deref->parent);
write_src(ctx, &deref->arr.index);
break;
case nir_deref_type_cast:
+ write_src(ctx, &deref->parent);
blob_write_uint32(ctx->blob, deref->cast.ptr_stride);
if (!header.deref.cast_type_same_as_last) {
encode_type_to_blob(ctx->blob, deref->type);
@@ -894,7 +894,7 @@ write_deref(write_ctx *ctx, const nir_deref_instr *deref)
break;
case nir_deref_type_array_wildcard:
- /* Nothing to do */
+ write_src(ctx, &deref->parent);
break;
default:
@@ -910,22 +910,20 @@ read_deref(read_ctx *ctx, union packed_instr header)
read_dest(ctx, &deref->dest, &deref->instr, header);
- if (deref_type == nir_deref_type_var) {
+ nir_deref_instr *parent;
+
+ switch (deref->deref_type) {
+ case nir_deref_type_var:
if (header.deref_var.object_idx)
deref->var = read_lookup_object(ctx, header.deref_var.object_idx);
else
deref->var = read_object(ctx);
deref->type = deref->var->type;
- deref->mode = deref->var->data.mode;
- return deref;
- }
-
- read_src(ctx, &deref->parent, &deref->instr);
- nir_deref_instr *parent;
+ break;
- switch (deref->deref_type) {
case nir_deref_type_struct:
+ read_src(ctx, &deref->parent, &deref->instr);
parent = nir_src_as_deref(deref->parent);
deref->strct.index = blob_read_uint32(ctx->blob);
deref->type = glsl_get_struct_field(parent->type, deref->strct.index);
@@ -933,6 +931,7 @@ read_deref(read_ctx *ctx, union packed_instr header)
case nir_deref_type_array:
case nir_deref_type_ptr_as_array:
+ read_src(ctx, &deref->parent, &deref->instr);
parent = nir_src_as_deref(deref->parent);
if (deref->deref_type == nir_deref_type_array)
deref->type = glsl_get_array_element(parent->type);
@@ -942,6 +941,7 @@ read_deref(read_ctx *ctx, union packed_instr header)
break;
case nir_deref_type_cast:
+ read_src(ctx, &deref->parent, &deref->instr);
deref->cast.ptr_stride = blob_read_uint32(ctx->blob);
if (header.deref.cast_type_same_as_last) {
deref->type = ctx->last_type;
@@ -952,6 +952,7 @@ read_deref(read_ctx *ctx, union packed_instr header)
break;
case nir_deref_type_array_wildcard:
+ read_src(ctx, &deref->parent, &deref->instr);
parent = nir_src_as_deref(deref->parent);
deref->type = glsl_get_array_element(parent->type);
break;
@@ -960,7 +961,9 @@ read_deref(read_ctx *ctx, union packed_instr header)
unreachable("Invalid deref type");
}
- if (deref->deref_type == nir_deref_type_cast) {
+ if (deref_type == nir_deref_type_var) {
+ deref->mode = deref->var->data.mode;
+ } else if (deref->deref_type == nir_deref_type_cast) {
deref->mode = header.deref.mode;
} else {
assert(deref->parent.is_ssa);