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
On Tue, 15 Mar 2005, xavier wrote:> 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?Replace the last line with: NewSTy = cast<StructType>(StructTy.get()); -Chris> --- 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 > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >-Chris -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/
Hi, Given these C instructions: =============================struct stru { struct stru *Next; }; struct list *NewStru = malloc ( sizeof ( struct stru ) ); struct list *tmp.3; ... tmp.3 = NewStru->Next; ============================= LLVM generates something like this: %tmp.0 = malloc %struct.stru ; <%struct.stru*> %tmp.3 = getelementptr %struct.stru* %tmp.0, int 0, uint 1 ; <%struct.stru**> I have been trying to re create that code with the GetElementPtrInst class, but I always get segmentation faults. I could not find any example of how to use GetElementPtrInst for that kind of situations How can I do that? Thanks --- Chris Lattner <sabre at nondot.org> wrote:> On Tue, 15 Mar 2005, xavier wrote: > > 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? > > Replace the last line with: > > NewSTy = cast<StructType>(StructTy.get()); > > -Chris > > > --- 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 > > > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > -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!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/
Seemingly Similar Threads
- [LLVMdev] Dynamic Creation of a simple program
- [LLVMdev] Recursive Types using the llvm support library
- [LLVMdev] Recursive Types using the llvm support library
- [LLVMdev] Recursive Types using the llvm support library
- [LLVMdev] Recursive Types using the llvm support library