SPIRV-Cross Id Use Count

I’m writing a compiler that translates SPIRV to some custom GPU architecture. I’m basing my compiler on SPIRV-Cross. The unfortunate part is that my compiler allocates wayyy too many temporary registers (almost one for each spirv instruction that writes to a % token), so I want to implement register counting.

The issue is that I’m not sure if SPIRV-Cross implements id counting for me (and it would be super helpful if it did). I found SPIRFunction::Parameter::read_count and write_count, but I don’t need register counts for function arguments (I’m passing by reference for now). It would be really handy if it did this for me, considering it looks over each instruction while creating a block anyway.

Is there some kind of meta data that has read/write counts by id so I know when I can free registers? I wouldn’t be surprised if it didn’t support it (since it doesn’t need to do any memory management to create glsl variables)- but if so are my only options to count usages manually or switch to another reflection tool?

I this should be a question or request for the SPIRV-Cross project itself: GitHub - KhronosGroup/SPIRV-Cross: SPIRV-Cross is a practical tool and library for performing reflection on SPIR-V and disassembling SPIR-V back to high level languages.

I realize I should’ve filed an issue by now :confused:

I was under the impression that SPIRV-Cross is a Khronos project (due to the github user and all). Managed to just go over any and every instruction and count it myself (although not very well… it overcounts a bunch)

Feel free to close this I suppose…