[LLVMdev] LLVM IR immediately from frontend

Misha Brukman brukman at uiuc.edu
Sat Nov 6 17:43:41 PST 2004


On Sun, Nov 07, 2004 at 01:19:07AM +0000, Umar Janjua wrote:
> Perhaps I am missing some link. Need a bit clarification.
> 
> For the C language, I want to access the LLVM code immediately
> generated by llvmgcc(cfrontend/bin/gcc) before it undergoes any
> further transformation or optimization.

llvm-gcc -Wa,-disable-opt -Wl,-disable-opt file.c file2.c -o stuff.o
 
This will run gccas and gccld without running the optimizations that
they would run by default.
 
> 1) Are there any libraries that enable me to parse   C code and create
> the Module instance.

This is all part of llvm-gcc, and tied to the way GCC does things.
There are no LLVM-style libraries for llvm-gcc.

> 2) If answer to 1) is no, then is there some other way to create
> Module instance from C code than issuing llvmgcc -S command in my
> program, then parsing the output through Asmparser, and then creating
> Module instance as a result.

There is currently no such library because the GCC front-end is
completely disjoint from the LLVM libraries.  To change this would
require a significant job of restructuring llvm-gcc (which is to say GCC
itself), which is problematic in its own ways -- we are trying to have
minimal differences with the GCC CVS tree so that we can update to get
their bugfixes easily.  If we switch to something which is wildly
different from the main GCC tree, we have to maintain it ourselves, and
no one has volunteered to handle this task (this is, again,
non-trivial).

> I believe there should also be a directory frontend  in the llvm
> source, that provides libraries for parsing different source languages
> and translating these into LLVM bytecode.

Sure, that would be nice to have, but again, it involves a significant
amount of effort that no one has volunteered to provide.

Patches accepted. :)

-- 
Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu




More information about the llvm-dev mailing list