nir: use enum operator helper for nir_variable_mode and nir_metadata
those are used quite a bit Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6520>
This commit is contained in:
@@ -205,8 +205,7 @@ sanitize_if(nir_function_impl *impl, nir_if *nif)
|
|||||||
* correct because of the specific type of transformation we did. Block
|
* correct because of the specific type of transformation we did. Block
|
||||||
* indices are not valid except for block_0's, which is all we care about for
|
* indices are not valid except for block_0's, which is all we care about for
|
||||||
* nir_block_is_unreachable(). */
|
* nir_block_is_unreachable(). */
|
||||||
impl->valid_metadata =
|
impl->valid_metadata = impl->valid_metadata | nir_metadata_dominance | nir_metadata_block_index;
|
||||||
(nir_metadata)(impl->valid_metadata | nir_metadata_dominance | nir_metadata_block_index);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -568,7 +567,7 @@ void init_context(isel_context *ctx, nir_shader *shader)
|
|||||||
/* sanitize control flow */
|
/* sanitize control flow */
|
||||||
nir_metadata_require(impl, nir_metadata_dominance);
|
nir_metadata_require(impl, nir_metadata_dominance);
|
||||||
sanitize_cf_list(impl, &impl->body);
|
sanitize_cf_list(impl, &impl->body);
|
||||||
nir_metadata_preserve(impl, (nir_metadata)~nir_metadata_block_index);
|
nir_metadata_preserve(impl, ~nir_metadata_block_index);
|
||||||
|
|
||||||
/* we'll need this for isel */
|
/* we'll need this for isel */
|
||||||
nir_metadata_require(impl, nir_metadata_block_index);
|
nir_metadata_require(impl, nir_metadata_block_index);
|
||||||
@@ -1323,22 +1322,22 @@ setup_nir(isel_context *ctx, nir_shader *nir)
|
|||||||
nir_variable_mode robust_modes = (nir_variable_mode)0;
|
nir_variable_mode robust_modes = (nir_variable_mode)0;
|
||||||
|
|
||||||
if (ctx->options->robust_buffer_access) {
|
if (ctx->options->robust_buffer_access) {
|
||||||
robust_modes = (nir_variable_mode)(nir_var_mem_ubo |
|
robust_modes = nir_var_mem_ubo |
|
||||||
nir_var_mem_ssbo |
|
nir_var_mem_ssbo |
|
||||||
nir_var_mem_global |
|
nir_var_mem_global |
|
||||||
nir_var_mem_push_const);
|
nir_var_mem_push_const;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nir_opt_load_store_vectorize(nir,
|
if (nir_opt_load_store_vectorize(nir,
|
||||||
(nir_variable_mode)(nir_var_mem_ssbo | nir_var_mem_ubo |
|
nir_var_mem_ssbo | nir_var_mem_ubo |
|
||||||
nir_var_mem_push_const | nir_var_mem_shared |
|
nir_var_mem_push_const | nir_var_mem_shared |
|
||||||
nir_var_mem_global),
|
nir_var_mem_global,
|
||||||
mem_vectorize_callback, robust_modes)) {
|
mem_vectorize_callback, robust_modes)) {
|
||||||
lower_to_scalar = true;
|
lower_to_scalar = true;
|
||||||
lower_pack = true;
|
lower_pack = true;
|
||||||
}
|
}
|
||||||
if (nir->info.stage != MESA_SHADER_COMPUTE)
|
if (nir->info.stage != MESA_SHADER_COMPUTE)
|
||||||
nir_lower_io(nir, (nir_variable_mode)(nir_var_shader_in | nir_var_shader_out), type_size, (nir_lower_io_options)0);
|
nir_lower_io(nir, nir_var_shader_in | nir_var_shader_out, type_size, (nir_lower_io_options)0);
|
||||||
|
|
||||||
lower_to_scalar |= nir_opt_shrink_vectors(nir);
|
lower_to_scalar |= nir_opt_shrink_vectors(nir);
|
||||||
|
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
#include "util/set.h"
|
#include "util/set.h"
|
||||||
#include "util/bitscan.h"
|
#include "util/bitscan.h"
|
||||||
#include "util/bitset.h"
|
#include "util/bitset.h"
|
||||||
|
#include "util/enum_operators.h"
|
||||||
#include "util/macros.h"
|
#include "util/macros.h"
|
||||||
#include "util/format/u_format.h"
|
#include "util/format/u_format.h"
|
||||||
#include "compiler/nir_types.h"
|
#include "compiler/nir_types.h"
|
||||||
@@ -123,6 +124,7 @@ typedef enum {
|
|||||||
nir_num_variable_modes = 11,
|
nir_num_variable_modes = 11,
|
||||||
nir_var_all = (1 << nir_num_variable_modes) - 1,
|
nir_var_all = (1 << nir_num_variable_modes) - 1,
|
||||||
} nir_variable_mode;
|
} nir_variable_mode;
|
||||||
|
MESA_DEFINE_CPP_ENUM_BITFIELD_OPERATORS(nir_variable_mode)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rounding modes.
|
* Rounding modes.
|
||||||
@@ -2818,6 +2820,7 @@ typedef enum {
|
|||||||
*/
|
*/
|
||||||
nir_metadata_all = ~nir_metadata_not_properly_reset,
|
nir_metadata_all = ~nir_metadata_not_properly_reset,
|
||||||
} nir_metadata;
|
} nir_metadata;
|
||||||
|
MESA_DEFINE_CPP_ENUM_BITFIELD_OPERATORS(nir_metadata)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
nir_cf_node cf_node;
|
nir_cf_node cf_node;
|
||||||
|
@@ -3122,8 +3122,7 @@ Converter::run()
|
|||||||
NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_function_temp, nir_address_format_32bit_offset);
|
NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_function_temp, nir_address_format_32bit_offset);
|
||||||
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL);
|
NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL);
|
||||||
|
|
||||||
NIR_PASS_V(nir, nir_lower_io,
|
NIR_PASS_V(nir, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
|
||||||
(nir_variable_mode)(nir_var_shader_in | nir_var_shader_out),
|
|
||||||
type_size, (nir_lower_io_options)0);
|
type_size, (nir_lower_io_options)0);
|
||||||
|
|
||||||
NIR_PASS_V(nir, nir_lower_subgroups, &subgroup_options);
|
NIR_PASS_V(nir, nir_lower_subgroups, &subgroup_options);
|
||||||
|
@@ -636,8 +636,7 @@ r600_nir_lower_atomics(nir_shader *shader)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (impl_progress) {
|
if (impl_progress) {
|
||||||
nir_metadata_preserve(function->impl, (nir_metadata)(nir_metadata_block_index |
|
nir_metadata_preserve(function->impl, nir_metadata_block_index | nir_metadata_dominance);
|
||||||
nir_metadata_dominance));
|
|
||||||
progress = true;
|
progress = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -141,9 +141,7 @@ bool NirLowerIOToVector::run(nir_function_impl *impl)
|
|||||||
|
|
||||||
bool progress = vectorize_block(&b, nir_start_block(impl));
|
bool progress = vectorize_block(&b, nir_start_block(impl));
|
||||||
if (progress) {
|
if (progress) {
|
||||||
nir_metadata_preserve(impl, (nir_metadata )
|
nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance);
|
||||||
(nir_metadata_block_index |
|
|
||||||
nir_metadata_dominance));
|
|
||||||
}
|
}
|
||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
@@ -201,8 +201,7 @@ module clover::nir::spirv_to_nir(const module &mod, const device &dev,
|
|||||||
|
|
||||||
nir_validate_shader(nir, "clover after function inlining");
|
nir_validate_shader(nir, "clover after function inlining");
|
||||||
|
|
||||||
NIR_PASS_V(nir, nir_lower_variable_initializers,
|
NIR_PASS_V(nir, nir_lower_variable_initializers, ~nir_var_function_temp);
|
||||||
static_cast<nir_variable_mode>(~nir_var_function_temp));
|
|
||||||
|
|
||||||
// copy propagate to prepare for lower_explicit_io
|
// copy propagate to prepare for lower_explicit_io
|
||||||
NIR_PASS_V(nir, nir_split_var_copies);
|
NIR_PASS_V(nir, nir_split_var_copies);
|
||||||
|
@@ -8450,9 +8450,8 @@ brw_nir_move_interpolation_to_top(nir_shader *nir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nir_metadata_preserve(f->impl, (nir_metadata)
|
nir_metadata_preserve(f->impl, nir_metadata_block_index |
|
||||||
((unsigned) nir_metadata_block_index |
|
nir_metadata_dominance);
|
||||||
(unsigned) nir_metadata_dominance));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return progress;
|
return progress;
|
||||||
@@ -8496,9 +8495,8 @@ brw_nir_demote_sample_qualifiers(nir_shader *nir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nir_metadata_preserve(f->impl, (nir_metadata)
|
nir_metadata_preserve(f->impl, nir_metadata_block_index |
|
||||||
((unsigned) nir_metadata_block_index |
|
nir_metadata_dominance);
|
||||||
(unsigned) nir_metadata_dominance));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return progress;
|
return progress;
|
||||||
|
@@ -264,9 +264,8 @@ st_nir_opts(nir_shader *nir)
|
|||||||
* might be able to make progress after it.
|
* might be able to make progress after it.
|
||||||
*/
|
*/
|
||||||
NIR_PASS(progress, nir, nir_remove_dead_variables,
|
NIR_PASS(progress, nir, nir_remove_dead_variables,
|
||||||
(nir_variable_mode)(nir_var_function_temp |
|
nir_var_function_temp | nir_var_shader_temp |
|
||||||
nir_var_shader_temp |
|
nir_var_mem_shared,
|
||||||
nir_var_mem_shared),
|
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
NIR_PASS(progress, nir, nir_opt_copy_prop_vars);
|
NIR_PASS(progress, nir, nir_opt_copy_prop_vars);
|
||||||
@@ -383,8 +382,7 @@ st_nir_preprocess(struct st_context *st, struct gl_program *prog,
|
|||||||
* calls below do a little extra work but should otherwise have no impact.
|
* calls below do a little extra work but should otherwise have no impact.
|
||||||
*/
|
*/
|
||||||
if (!_mesa_is_gles(st->ctx) || !nir->info.separate_shader) {
|
if (!_mesa_is_gles(st->ctx) || !nir->info.separate_shader) {
|
||||||
nir_variable_mode mask =
|
nir_variable_mode mask = nir_var_shader_in | nir_var_shader_out;
|
||||||
(nir_variable_mode) (nir_var_shader_in | nir_var_shader_out);
|
|
||||||
nir_remove_dead_variables(nir, mask, NULL);
|
nir_remove_dead_variables(nir, mask, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,8 +506,8 @@ st_glsl_to_nir_post_opts(struct st_context *st, struct gl_program *prog,
|
|||||||
st_nir_opts(nir);
|
st_nir_opts(nir);
|
||||||
}
|
}
|
||||||
|
|
||||||
nir_variable_mode mask = (nir_variable_mode)
|
nir_variable_mode mask =
|
||||||
(nir_var_shader_in | nir_var_shader_out | nir_var_function_temp );
|
nir_var_shader_in | nir_var_shader_out | nir_var_function_temp;
|
||||||
nir_remove_dead_variables(nir, mask, NULL);
|
nir_remove_dead_variables(nir, mask, NULL);
|
||||||
|
|
||||||
if (!st->has_hw_atomics && !screen->get_param(screen, PIPE_CAP_NIR_ATOMICS_AS_DEREF))
|
if (!st->has_hw_atomics && !screen->get_param(screen, PIPE_CAP_NIR_ATOMICS_AS_DEREF))
|
||||||
|
Reference in New Issue
Block a user