Intermediate code representations currently follow this scheme:
Code:
GLSL2 IR ---> Mesa IR ---> TGSI (Gallium) IR ---> Hardware-friendly IR
There are lots of IRs in Mesa, indeed. The following scheme depicts various optimizers:
Code:
GLSL2 compiler and optimizer --+
+---> Mesa IR optimizer ->-+
ARB_fp/vp parser --------------+ |
|
|
R300 hw-specific optimizer <---+ |
| |
R600 hw-specific optimizer <---+ |
+----<----- TGSI <---------+
NV50 hw-specific optimizer <---+
|
LLVM for software drivers <----+
Everybody has a different idea about where optimizations should be done. Gallium people would prefer to have a TGSI optimizer (that one is being worked on), while others (Intel) optimize in GLSL IR and Mesa IR.