Hi, I'm having a play with LLVM to implement a custom language (for my intellectual curiosity only). I'm wondering how, when using IRBuilder, one can can it to emit a recursive type definition? The code for TypeBuilder explicitly states that it doesn't handle recursive types... I'm after being able to emit, programmatically, stuff like the Named Types example in the Language Reference: %mytype = type { %mytype*, i32 } I'd welcome any advice! Yours, James Jackson. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130217/030988e7/attachment.html>
Hi James, Last time I did this, there used to be PATypeHolder, which would take care of incomplete types and replace all by complete when you finished, but more than a year ago the StructType class was changed to accommodate that use and the PATypeHolder was deprecated. I believe you should use isOpaque and setBody functions from StructType. Have a look at how Clang does it. cheers, --renato On 17 February 2013 17:00, James Jackson <james.a.f.jackson.2 at googlemail.com> wrote:> Hi, > > I'm having a play with LLVM to implement a custom language (for my > intellectual curiosity only). I'm wondering how, when using IRBuilder, one > can can it to emit a recursive type definition? The code for TypeBuilder > explicitly states that it doesn't handle recursive types... > > I'm after being able to emit, programmatically, stuff like the Named Types > example in the Language Reference: > > %mytype = type { %mytype*, i32 } > > I'd welcome any advice! > > Yours, > James Jackson. > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130217/58f19456/attachment.html>
Hi James, Am Sonntag, 17. Februar 2013, 18:00:56 schrieb James Jackson:> Hi, > > I'm having a play with LLVM to implement a custom language (for my > intellectual curiosity only). I'm wondering how, when using IRBuilder, one > can can it to emit a recursive type definition? The code for TypeBuilder > explicitly states that it doesn't handle recursive types... > [...]You have to create an opaque identified struct: StructType *x = StructType::create(context, "name of your type"); And then set its body: x->setBody(<Array which contains x>)> Yours, > James Jackson.-- Christoph Grenz
Maybe Matching Threads
- [LLVMdev] StructType opaque->sized
- [LLVMdev] inefficiencies in ConstantUniqueMap ?
- [LLVMdev] Cannot interchange "literal" and "identified" structs
- [LLVMdev] inefficiencies in ConstantUniqueMap ?
- [LLVMdev] Cannot interchange "literal" and "identified" structs