SPIRV-Cross Id Use Count

#1

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?