[LLVMdev] More kinds of recursive types in llvm
Rodney M. Bates
rodney_bates at lcwb.coop
Fri Feb 6 11:12:32 PST 2015
On 02/05/2015 04:20 PM, Rafael EspĂndola wrote:
> On 30 January 2015 at 12:00, Rodney M. Bates <rodney_bates at lcwb.coop> wrote:
>> The language I am working on connecting to an llvm back-end (Modula-3)
>> allows a fairly extensive set of recursive declarations. It looks
>> like I can translate all its high-level types using four llvm types that
>> refer to another type: function, struct, pointer, and array.
>>
>> It looks like I can alter an llvm struct type in place after it has
>> been created, using StructType::setBody. I don't see a way to do this
>> for the other three.
>
> The current idea it to go the other way actually: have a single
> pointer type and remove cycles. See
> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141201/247285.html
> for some of the discussion.
>
> You can just cast one pointer type to another for now.
>
Hmm, I have been working on a different scheme, to selectively
wrap a pointer in a one-member struct, as needed to break cycles.
I'm not sure what the pros/cons of this are, relative to a single
pointer type, say i8*. For uses, it would be a GEP vs. a cast.
I presume the wrapping would be optimized away. It does leave
more type information in the IR, but as an llvm newcomer, I have
very little idea what parts of the type info matter.
> Cheers,
> Rafael
>
--
Rodney Bates
rodney.m.bates at acm.org
More information about the llvm-dev
mailing list