[Mesa-dev] [RFC PATCH 00/16] A new IR for Mesa

Matt Turner mattst88 at gmail.com
Tue Aug 26 10:59:04 PDT 2014


On Tue, Aug 26, 2014 at 9:00 AM, Jose Fonseca <jfonseca at vmware.com> wrote:
> If LLVM was a useless piece of junk, we wouldn't have any trouble adding it
> as a dependency, as we would be the sole user.  But precisely because LLVM
> is successful in so many use cases, hence several packages depend on it, we
> shouldn't depend, so we can avoid the dealing with the oh-so-hard dependency
> issue!?  I find it ridiculous: it's precisely because LLVM is potentially
> that good that it makes sense for us/distros/everybody to put up with the
> dependencies issues it may bring, and worth considering.

It sounds like there are enough people in the Mesa community that are
familiar with LLVM and interested in using it in the GLSL compiler
that there would be someone willing to start working on it. Hopefully
that's the case.

I tried going through the LLVM language frontend tutorial on LLVM.org
and only had to get to chapter 4 (the first two chapters don't use
LLVM) before the code didn't compile (and I couldn't figure out why)
with LLVM 3.4 on my system. I found this [1] tiny example (not updated
for 2 years) using the C API and thought it'd probably not work
either, but was happily surprised that it compiled and worked fine. I
see that the C API is used in radeonsi and gallivm in Mesa.

Here's what I think would be compelling: Using the stable C API,
translate from GLSL IR into LLVM IR. Call LLVM's optimizations. Give
backends the option to consume LLVM IR. From here we can evaluate just
how significant the improvement from LLVM's optimizer is. At least two
people have written GLSL IR -> LLVM translators in the past -- Luca
Barbieri (what ever happened to him?!) and Vincent Lejeune (Cc'd).
Their code is [2] and [3]. I think this plan would also fit nicely
with existing LLVM backends, potentially avoiding a trip through TGSI.

I think this is strictly superior to other ideas like throwing out the
GLSL frontend and translating LLVM IR back "up" to the higher level
GLSL IR.

So, maybe some people experienced with LLVM from VMware and AMD are
interested in taking the lead?

[1] https://github.com/wickedchicken/llvm-c-example
[2] http://cgit.freedesktop.org/~anholt/mesa/log/?h=llvm-4 (Eric's
branch based on Luca's code)
[3] http://cgit.freedesktop.org/~vlj/mesa/ (one of the glsl-to-llvm* branches)


More information about the mesa-dev mailing list