prog_to_nir bugfixes and tidying
I tried hooking up prog_to_nir on Gallium drivers, and encountered a couple of bugs when testing on radeonsi. So, here are some patches to fix most of the issues. There's 1-2 bugs left before I can flip it on properly, so I haven't sent those patches yet.