[LLVMdev] Dynamic Creation of a simple program

xavier llvmdev at yahoo.com
Mon Mar 14 19:10:50 PST 2005


Hi,

I would like to dynamically create a program at run time using the LLVM classes. I am wondering if
there are some examples available. For example, for a very simple "Hello World" program, I will
have something like this (pseudo code):

Module M = new Module();
Function FMain = new Function("main");
M.addFunction(FMain);
BasicBlock B = new BasicBlock();
FMain.add(B);

// maybe adding here a symboltable 

CallInst CIPrintf = new CallInst("printf", "Hello World", B);

...

Something like that (although obviously not accurate). Once I have this program, I can apply some
analyses to it without really having to compile a real program. This would be useful if I want to
create my own intermediate representation and then create that program in memory using the LLVM
classes. I, for example, could apply the alias analysis to it. 

Could please somebody give some guidelines? Maybe I can compile a program with the LLVM and then
load the bytecode in memory and finally dump some kind of text/XML representation which I will use
to understand the set of classes needed to dynamically create the sample program

Thanks!





		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 




More information about the llvm-dev mailing list