Adding `HLSL_IR_INDEX` is not impossible, but some things get complicated, for instance, to build a deref from an index we have to move through the indexes until the base case is found, and then in reverse:
Actually I believe that lower_lhs() can't work as given, for the exact reason that this merge request exists: you can have sequences like
2: index a[0] 3: store a[0] = b 4: index @2[0]
It's basically necessary to do it one step at a time, and synthesize a temp at every step.
but I think that the base case issue was what throw me off, because the natural solution for me was having to add a new node (using `HLSL_IR_LOAD` would kill the purpose of separating between mere references or loads (that have an SSA value), unless we add a bool field to differentiate the cases.
I don't have strong feelings about it. I don't dislike HLSL_IR_LOAD—the invariant then becomes "we never generate a load at parse time with a path length greater than zero, or at least we never return one from the unary_expr rule". But I don't hate the idea of avoiding HLSL_IR_LOAD at parse time completely either.
I have to check the old HLSL_IR_DEREF and the union you mention.
Fundamentally it was something like
struct hlsl_ir_deref { struct hlsl_ir_node node; bool is_var; union { struct hlsl_ir_var *var; struct { struct hlsl_src base; struct hlsl_src offset; } array; } u; };