On Thu Aug 31 13:33:32 2023 +0000, Giovanni Mascellani wrote:
The code seems fine to me. A general design question though: it seems that you could avoid introducing a new register type simply by creating "regular" temporary registers instead of SSA ones. An SSA register has the additional property that you cannot write it after the first time, essentially, but that doesn't prevent you from using a temporary and just writing it once. Would there be a fundamental problem with that approach? If not, then why did you decide to introduce a new type? And for the record I don't mean to say that I don't want SSA registers (and I see a couple of positive reasons to have them), I would just like to know what's the reasoning. Even better would be to have that reasoning documented in the commit message introducing SSA registers (yes, commit messages might not be ideal for discoverability in the long term, but we currently don't have a real place to store developer documentation and that's better than nothing).
Both DXIL and SPIR-V use SSA, so using it in the IR is by far the simplest way to handle the values. Using temps would introduce the problem of selecting an unused temp, i.e. one whose value is no longer needed, and it becomes even more complex when dealing with `PHI` instructions. Also, temps are written and read with `OpStore` and `OpLoad`, which SSA renders unnecessary. I'm not inclined to add a comment on this as I think the question won't arise when everything is upstream.