> > 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.htmlI 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. Last URL is a document to generate code from scratch until a "Module", and I need generate it from a "Module" thru native code....> > 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!!)> > > 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.> -- > Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.eduApologize my inexperience with LLVM, but I *really* don't find an example to generate code into memory from a "Module".
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/
> >>> 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 > >It is not that I need, this document shows how to generate a representation of code, and I start my work from a bytecode/assembly file (maybe in memory). In pseudo code: (0) Create an empty "Module" (1) Load a source file (which contains byte/assembly code) maybe from memory (2) Compile it into a "Module" (3) Link last one with first one. (4) Go to step (1) until no more sources //In this point I have a "Module" which contains the byte code //from the sources (5) Generate native (x86) code from generated module (6) Localize entry point (¿main?) (7) Execute it (Apologize my English) I have points 0-4 working, but I am confused about point 5 and maybe 6.> > 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 >Yes, i agree. But only with one LLVM state; not with compile, link and execute stages.> 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. >Ok.> > 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? >All ok, except first step. I don't need build the program representation; in fact I read it from file/memory (bytecode/assembly).> >>> 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. >But JIT generate code **Just In Time**, and it is slower than generate all at once and then execute it. I need a real compiler not an execution environment. Last one will be build by me.> >> -- > >> 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. >¿sure?> -Chris > > -- > http://nondot.org/sabre/ > http://llvm.cs.uiuc.edu/ > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev