diff options
author | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-03-07 11:07:04 -0800 |
---|---|---|
committer | Caio Marcelo de Oliveira Filho <[email protected]> | 2019-07-19 10:04:52 -0700 |
commit | 4061a3f6c96fc2029b7356ecbbb045a35f2aba78 (patch) | |
tree | ae02a4a76fd602e4e3f217c1c8570ec5bdf381c1 /src/compiler | |
parent | e8644122ed6c30b0ee353d76bdaed52bdf2c4f56 (diff) |
nir: use a switch when printing intrinsic indices
Reviewed-by: Eric Engestrom <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir_print.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index 5a626c66960..9633cb37ac7 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -803,17 +803,24 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) if (!info->index_map[idx]) continue; fprintf(fp, " /*"); - if (idx == NIR_INTRINSIC_WRMASK) { + switch (idx) { + case NIR_INTRINSIC_WRMASK: { /* special case wrmask to show it as a writemask.. */ unsigned wrmask = nir_intrinsic_write_mask(instr); fprintf(fp, " wrmask="); for (unsigned i = 0; i < 4; i++) if ((wrmask >> i) & 1) fprintf(fp, "%c", "xyzw"[i]); - } else if (idx == NIR_INTRINSIC_REDUCTION_OP) { + break; + } + + case NIR_INTRINSIC_REDUCTION_OP: { nir_op reduction_op = nir_intrinsic_reduction_op(instr); fprintf(fp, " reduction_op=%s", nir_op_infos[reduction_op].name); - } else if (idx == NIR_INTRINSIC_IMAGE_DIM) { + break; + } + + case NIR_INTRINSIC_IMAGE_DIM: { static const char *dim_name[] = { [GLSL_SAMPLER_DIM_1D] = "1D", [GLSL_SAMPLER_DIM_2D] = "2D", @@ -828,13 +835,22 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) enum glsl_sampler_dim dim = nir_intrinsic_image_dim(instr); assert(dim < ARRAY_SIZE(dim_name) && dim_name[dim]); fprintf(fp, " image_dim=%s", dim_name[dim]); - } else if (idx == NIR_INTRINSIC_IMAGE_ARRAY) { + break; + } + + case NIR_INTRINSIC_IMAGE_ARRAY: { bool array = nir_intrinsic_image_array(instr); fprintf(fp, " image_array=%s", array ? "true" : "false"); - } else if (idx == NIR_INTRINSIC_DESC_TYPE) { + break; + } + + case NIR_INTRINSIC_DESC_TYPE: { VkDescriptorType desc_type = nir_intrinsic_desc_type(instr); fprintf(fp, " desc_type=%s", vulkan_descriptor_type_name(desc_type)); - } else if (idx == NIR_INTRINSIC_TYPE) { + break; + } + + case NIR_INTRINSIC_TYPE: { nir_alu_type type = nir_intrinsic_type(instr); unsigned size = nir_alu_type_get_type_size(type); const char *name; @@ -849,7 +865,10 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) fprintf(fp, " type=%s%u", name, size); else fprintf(fp, " type=%s", name); - } else if (idx == NIR_INTRINSIC_SWIZZLE_MASK) { + break; + } + + case NIR_INTRINSIC_SWIZZLE_MASK: { fprintf(fp, " swizzle_mask="); unsigned mask = nir_intrinsic_swizzle_mask(instr); if (instr->intrinsic == nir_intrinsic_quad_swizzle_amd) { @@ -862,10 +881,15 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state) } else { fprintf(fp, "%d", mask); } - } else { + break; + } + + default: { unsigned off = info->index_map[idx] - 1; assert(index_name[idx]); /* forgot to update index_name table? */ fprintf(fp, " %s=%d", index_name[idx], instr->const_index[off]); + break; + } } fprintf(fp, " */"); } |