[llvm-dev] What was the IR made for precisely?

Renato Golin via llvm-dev llvm-dev at lists.llvm.org
Fri Oct 28 12:45:10 PDT 2016


On 28 October 2016 at 20:13, Chris Lattner <clattner at apple.com> wrote:
> Is there a specific design that you think would work?  One of the major problems with this sort of proposal is that you need the entire clang type system to do this, which means it depends on a huge chunk of the Clang AST.  At that point, this isn’t a small library that clang uses, this is a library layered on top of Clang itself.

Hi Chris,

I personally don't think we can (should) make IR completely target
independent, but we could reduce the lowering complexity by adding
some (more?) intermediate steps between the AST and IR. This was
discussed a long time ago and I haven't kept track, so I may be
completely out of reality here.

The idea was not to create another representation, but to have some
wrapper classes around the IRBuilder that would know about
target-specific knowledge and simplify the lowering. The example we
used was mostly around argument marshaling (byval, sret), so that
front-ends could be simplified a bit.

For example, Clang would lower all function calls using structures
with structs and this wrapper would transform into arrays and casts,
move the arguments around, return void, etc. to make sure that the PCS
is understood by the middle/back-end of choice.

This could start as a GSoC project, but it may have to be split
between investigation (ie break everything) and implementation (fix
everything back again). But since this is just a wrapper, other
front-ends can still use their old ways and migrate to this wrapper
later on.

Or this could be done already, and I'm out of ideas. :)

cheers,
--renato


More information about the llvm-dev mailing list