*/
#include "ir3_nir.h"
-#include "glsl/nir/nir_builder.h"
-#include "glsl/nir/nir_control_flow.h"
+#include "compiler/nir/nir_builder.h"
+#include "compiler/nir/nir_control_flow.h"
/* Based on nir_opt_peephole_select, and hacked up to more aggressively
* flatten anything that can be flattened
/* The only uses of this definition must be phi's in the
* successor or in the current block
*/
- nir_foreach_use(&dest->ssa, use) {
+ nir_foreach_use(use, &dest->ssa) {
nir_instr *dest_instr = use->parent_instr;
if (dest_instr->block == block)
continue;
static bool
block_check_for_allowed_instrs(nir_block *block)
{
- nir_foreach_instr(block, instr) {
+ nir_foreach_instr(instr, block) {
switch (instr->type) {
case nir_instr_type_intrinsic: {
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
flatten_block(nir_builder *bld, nir_block *if_block, nir_block *prev_block,
nir_ssa_def *condition, bool invert)
{
- nir_foreach_instr_safe(if_block, instr) {
+ nir_foreach_instr_safe(instr, if_block) {
if (instr->type == nir_instr_type_intrinsic) {
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
if ((intr->intrinsic == nir_intrinsic_discard) ||
flatten_block(&state->b, else_block, prev_block,
if_stmt->condition.ssa, true);
- nir_foreach_instr_safe(block, instr) {
+ nir_foreach_instr_safe(instr, block) {
if (instr->type != nir_instr_type_phi)
break;
memset(sel->src[0].swizzle, 0, sizeof sel->src[0].swizzle);
assert(exec_list_length(&phi->srcs) == 2);
- nir_foreach_phi_src(phi, src) {
+ nir_foreach_phi_src(src, phi) {
assert(src->pred == then_block || src->pred == else_block);
assert(src->src.is_ssa);
}
nir_ssa_dest_init(&sel->instr, &sel->dest.dest,
- phi->dest.ssa.num_components, phi->dest.ssa.name);
+ phi->dest.ssa.num_components, 32, phi->dest.ssa.name);
sel->dest.write_mask = (1 << phi->dest.ssa.num_components) - 1;
nir_ssa_def_rewrite_uses(&phi->dest.ssa,
state.progress = false;
nir_builder_init(&state.b, impl);
- nir_foreach_block(impl, lower_if_else_block, &state);
+ nir_foreach_block_call(impl, lower_if_else_block, &state);
if (state.progress)
nir_metadata_preserve(impl, nir_metadata_none);
{
bool progress = false;
- nir_foreach_function(shader, function) {
+ nir_foreach_function(function, shader) {
if (function->impl)
progress |= lower_if_else_impl(function->impl);
}