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.
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
Hi James,
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