tags:

views:

488

answers:

1

Hi,

im currently trying to generate LLVM IR with ANTLR3. But the problem ist, that i need the C target (C++ would be better but is not working yet, or is it?) but from C i can't call the LLVM C++ API for Building the IR.

The Tutorial from Terence Parr uses Java and the StringTemplate lib. But as i know the StringTemplate lib ist not available for C.

Does anyone have some good ideas how this can be done? :)

Thx

+1  A: 

there is a very good entry in the LLVM faq, discussing what you want to do: http://llvm.org/docs/FAQ.html#langirgen It points to llvm-c, which is a C binding to llvm, allowing to generate IR directly from C, and is integrated to llvm since at lease llvm-2.6

The approach Terence takes in its example with antlr-java and stringtemplates is to generate llvm assembly as text (and generating text is really what stringtemplates is about).

tonio
It possible to call the LLVM C++ if the ANTLR3 *.c files are compiled with a C++ Compiler. There's an example in the examples package of ANTLR3.
TheShow