[LLVMdev] Primer with LLVM

Chris Lattner sabre at nondot.org
Sat Jan 8 08:49:50 PST 2005


On Sat, 8 Jan 2005, Francisco Puentes wrote:
>>> Would be great if we append into the documentation several "patters"
>>> to show how perform with LLVM. It would accelerate the learn curve for
>>> beginners like me, avoiding basic errors and mistakes. If I reach a
>>> good level with LLVM I can make these.
>>
>> I'm not sure if I understand what you mean.  Are you looking for an
>> "LLVM programmer's guide"?  If so, we have one of those:
>>
>>   http://llvm.cs.uiuc.edu/docs/ProgrammersManual.html
>
> I am a recently LLVM user, and I found that LLVM is hard to use at first
> sight. It would be nice if people like me can have documents like "howto"
> but code-oriented (versus manual-oriented). Something like code extracts
> with common (and basic) problems.

That is exactly what the ProgrammersManual *is*.  In particular, this 
section:
http://llvm.cs.uiuc.edu/docs/ProgrammersManual.html#common

is exactly the sort of thing you're looking for.  Note that we don't have 
every possible subject documented, so if you see a missing subject, please 
send in a patch to the documentation.

> Last URL is a document to generate code from scratch until a "Module", and I
> need generate it from a "Module" thru native code....

No it's not.  Working with LLVM Module's are the same no matter if you do 
it runtime, compile time, are generating C, LLVM, or native machine code. 
All of the same principles apply.

>> There are a lot of documents, both for extending LLVM and building new
>> projects _with_ LLVM here:
>>
>>   http://llvm.cs.uiuc.edu/docs/
>
> ... and nothing of these cover this topic.
>
> (If I am wrong get right me!!)

I'm not sure I understand exactly what you want to do, so let me restate 
your objective to make sure I have it correct.  You want to build a 
representation of a program in memory, then emit machine code to memory, 
then get the address of the entry point and call it.  Is this correct?

>>> Have you a sample to generate code into memory?
>>
>> Take a look at llvm/examples/HowToUseJIT and llvm/examples/Fibonacci in
>> the LLVM distribution, or online via cvsweb.
>>
>
> Looking................ (each dot is a minute)
>
> Well, these examples are JIT-based. I really need generate into memory
> native code, extract the address of a function (aka "main") and execute it.

If my characterization of your goals (above) is correct, the JIT is 
exactly what you want.

>> --
>> Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu
>
> Apologize my inexperience with LLVM, but I *really* don't find an example to
> generate code into memory from a "Module".

That is the JIT.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list