[Mesa-dev] [RFC] glsl-to-llvm
vljn at ovi.com
Tue Sep 11 14:12:49 PDT 2012
I'm currently working on a glsl to llvm pass that generates LLVM IR from
glsl tree for drivers that ships with a LLVM backend. The current code
is located here : http://cgit.freedesktop.org/~vlj/mesa in branch
glsl-to-llvm3. It is still a work in progress (I'm not fully satisfied
by some factorisation and coding style is not consistant atm)
I'm testing it against evergreen at the moment thus namespace are r600
oriented (all the intrinsics are prefixed with llvm.AMDGPU. or
llvm.R600.). However I'm trying to make it as driver agnostic as
This pass does not try to optimise the code : it does not generate MAD
instructions, it does not propagate constant, it does not eliminate dead
code like glsl-to-tgsi does. I chose to leave this to LLVM own pass. On
the other hand, I try to make the result code as close as possible from
the glsl tree : it preserves vector structure (tgsi to llvm does not),
it does not convert boolean to int... This allows to find some bugs in
the backend that were hidden by glsl-to-tgsi but could appear with a
futur OpenCl support.
On the other hand r600 backend does not like vectorised input : it
generates much more MOV instruction than necessary. I've narrowed the
issue : the COPY llvm internal instructions is lowered to 4 MOV even if
following instruction overwrite some registers, and the store output
instruction fixes the exported register, which is not optimal wrt
register coalescing pass.
So far I managed to get something like 200 regressions on 7000 passing
tests in piglit, but recent changes (ie moving the interpolation logic
inside backend) added 100 others regressions in current trunk, because
of failing front/back face color issue I'm working on.
However I meet some "standardisation" issue at the moment. I work with a
single driver that has its own constraint and feature.
For instance, I use a single intrinsic to export everything :
llvm.AMDGPU.store.output. However there are some special outputs like
vertex position and pixel color. I'm planning to add a
llvm.AMDGPU.store.position and llvm.AMDGPU.store.color. Transform and
Feedback also needs a similar special intrinsic.
I'd like to request your feedback and suggestion on my work.
Glsl-to-llvm does not calls any gallium function and can also be used by
classic dri drivers. I don't know what is the current status of the
recently announced llvm i965 compiler, I don't know if it has already
its own glsl-to-llvm pass or not. If not, it would be really great if
this pass was also shared by i965, as the more drivers use it, the more
reliable it is.
More information about the mesa-dev