[Mesa-dev] [RFC] glsl-to-llvm
Tom Stellard
tom at stellard.net
Wed Sep 19 06:29:40 PDT 2012
On Wed, Sep 19, 2012 at 09:07:41AM +0200, Eric Anholt wrote:
> Tom Stellard <tom at stellard.net> writes:
>
> > On Tue, Sep 11, 2012 at 11:12:49PM +0200, Vincent wrote:
> >> Hi,
> >>
> >> 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
> >> possible.
> >
> > The r600 backend uses way too many intrinsics, and most of them could be
> > replaced with either one or a sequence of LLVM IR instructions.
> > However, there are several things that must be represented by intrinsics.
> > These include texture instructions, shader inputs, shader outputs, and
> > possibly others. I think if this front end is used by multiple backends,
> > it will be important to come up with some standard intrinsic definitions
> > that backends can share. Ideally GLSL->LLVM would not need to use any
> > target-specific intrinsics.
>
> That was my reaction when I saw vlj's work as well -- way too many
> intrinsics for no apparent reason, and the previous llvm stuff from Luca
> looked much nicer in that way.
>
The reason I originally created so many intrinsics (even for
instructions like multiply) was because it was unclear to me when I
should use IEEE versions or the legacy versions of instructions.
I wanted to match the functionality of the current shader compiler, so
any time it used a legacy instruction, I created an intrinsic for it.
Now that the backend is stable I really want try to drop most of these
intrinsics and just use standard LLVM IR and if necessary specify the
desired precision to the backend as one of the target options.
-Tom
> > As I mentioned above, if this will be used by multiple backends, it
> > makes sense to rename the intrinsics to something like
> > llvm.mesa.store.position.
>
> Agreed (and this is where Luca's code wasn't apparently useful -- no
> real way to get inputs and outputs hooked up to it as-is)
More information about the mesa-dev
mailing list