On 11/18/21 11:28, Matteo Bruni wrote:
This and copy_propagation_transform_block() are a bit of a reimplementation of transform_ir(). It should be possible to extend transform_ir() to handle this new pass instead.
I'd introduce a struct like
struct transform_pass { bool (*initialize)(struct hlsl_ctx *hlsl_ctx, void **ctx); bool (*process_instruction)(void *ctx, struct hlsl_ir_node *, void *); void (*destroy)(void *ctx); };
and update transform_ir() and the existing passes to make use of it. I imagine we could have some generic initialize() implementation simply doing *ctx = hlsl_ctx; and an empty destroy() implementation to be used when there is no particular context to carry around (like in the existing passes).
Pretty much the whole point of transform_ir() is that it recursively iterates through CF blocks for cases where you don't care about transforming the CF blocks themselves. That's not the case here. What you're describing sounds to me like a framework that doesn't actually serve any purpose to its use case.