Currently, we can't use `add_load_index()` or `add_load_component()` on the loads to the `"retval"` variables that come from `add_call()` because these functions assume that the loaded value (`var_instr`) won't change between its location and the location and the new load to be created.
We can't get rid of this assumptions either, because, at least
`add_load_index()` may be used in the lhs of an assignment, and in that case we
can't store to the "deref" synthetic:
```
x[0] = 20;
```
Here I implemented the alternative solution of copying `"retval"` into a synthetic variable after each function call, but we may want to discuss this approach.
--
v2:
https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/93
--
v3: Release 7.0.2.
gitlab: Add workaround for more strict git ownership check.
This merge request has too many patches to be relayed via email.
Please visit the URL below to see the contents of the merge request.
https://gitlab.winehq.org/wine/wine/-/merge_requests/2402
This node type is intended for use during parse-time.
While we parse an indexing expression such as `a[3]`, we don't know if
it will end up as part of an expression (in which case it must be folded
into a load) or it is for the lhs of a store (in which case it must be
folded into the store's deref). This node type is used to represent these accesses and no longer rely on building an `hlsl_ir_load` for each array index or struct record access.
`hlsl_ir_index` chains are lowered into derefs when (and if) they are used to specify the lhs of an assignment. All `hlsl_ir_index`es are lowered into `hlsl_ir_load`s with a compilation pass.
The changes introduced in these series allow to solve the problem with the return variable of function calls presented in !93, and to properly support assignment to matrix indexes, which is something we are not doing correctly.
Further patches (in my [index node](https://gitlab.winehq.org/fcasas/vkd3d/-/commits/index_node) branch) add support for indexing non-load expressions, such as `(a + b)[1]` and allowing to represent resource loads through `hlsl_ir_index`, so that `hlsl_ir_resource_store`s don't have to rely on `hlsl_ir_resource_load`s.
--
v5: vkd3d-shader/hlsl: Evaluate index before array.
vkd3d-shader/hlsl: Support column-major matrix indexing in the lhs.
vkd3d-shader/hlsl: Always load from a synthetic copy in add_load_component().
vkd3d-shader/hlsl: Remove add_load_index().
vkd3d-shader/hlsl: Use hlsl_ir_index for array and record access.
https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/124