[LLVMdev] Dynamic Creation of a simple program

xavier llvmdev at yahoo.com
Tue Mar 15 03:22:42 PST 2005


Thanks for the information

I am trying to use one of your examples for recursive data structures:

=========================
PATypeHolder StructTy = OpaqueType::get();
std::vector<const Type*> Elts;
Elts.push_back(PointerType::get(StructTy));
Elts.push_back(PointerType::get(Type::SByteTy));
StructType *NewSTy = StructType::get(Elts);

// At this point, NewSTy = "{ opaque*, sbyte* }", tell VMCore that
// the struct and the opaque type are actually the same.
cast<OpaqueType>(StructTy.get())->refineAbstractTypeTo(NewSTy);

// NewSTy is potentially invalidated, but StructTy (a PATypeHolder) is
// kept up-to-date.
NewSTy = StructTy.get();
=========================

It gives this error in the last line:

         invalid conversion from `llvm::Type*' to `llvm::StructType*'

How can I create such a recursive DS?

Thanks!





--- Chris Lattner <sabre at nondot.org> wrote:
> On Mon, 14 Mar 2005, xavier wrote:
> 
> > 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
> 
> Check out these directories:
> 
> examples/ModuleMaker/ : Builds a module from scratch
> 
> examples/Fibonacci/
> examples/HowToUseJIT/ : Examples building a module and JIT'ing them.
> 
> -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
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




More information about the llvm-dev mailing list