[LLVMdev] templates vs code to generate IR

Terence Parr parrt at cs.usfca.edu
Thu Apr 24 10:35:58 PDT 2008


On Apr 23, 2008, at 5:08 PM, Gordon Henriksen wrote:

> Hi Terence,
>
> The reason I remarked, actually, is that for LLVM in particular the C+
> + API offers more safety, and emitting .ll generally requires at least
> partially reimplementing the IR object model. I think this is a topic
> in the FAQ. But both are perfectly valid approaches!

:)  Yep,The advantage of the code-based mechanism is that the  
compiler, because of that static typing, can do all sorts of well  
formedness checking for you. A major advantage of that approach and a  
weakness of the template-based approach.

My main goal is programmer productivity. An extreme example  
illustrates my point:  imagine a bunch of support functions you need  
to generate in the output code (that cannot be linked in from C, for  
example). What would you rather type in: IR in text or the massive  
amount of code to build up the object model?  Surely, in your head you  
are imagining the target IR language (we evolved over millions of  
years to be good at extracting and generating structure from linear  
sequences of symbols). :)

Ter



More information about the llvm-dev mailing list