[LLVMdev] Recursive Types using the llvm support library

Chris Lattner sabre at nondot.org
Sun Mar 20 17:01:55 PST 2005


On Sun, 20 Mar 2005, John Carrino wrote:

> On Wed, Mar 09, 2005 at 04:05:32PM +0300, Vladimir Merzliakov wrote:
>>>> Is assert(!NewSTy->isAbstract()) must pass  after this line?
>>>
>>> In this case, yup.
>>>
>> I create test program and assert failed in it:
>>
>> { \2 *, sbyte * }
>
> How do I decode the \2 in this?  I am creating types through this
> interface and I get quite a mess seen below.  And this is relatively
> simple.  Any ideas?

"\2" is an upreference, which refers to a containing type.  For example, 
this type:

  \1*

Is a pointer to pointer to pointer to pointer....  In "{\2*}", the 
upreference refers to the structure type, not the pointer, with \4, it 
means go 4 types up etc.

In practice, this is leads to a horrible mess, as you've noticed.  As 
such, I'd suggest using Module::addTypeName to give these things names so 
that you have a hope to understand them and so they are more compact :)

-Chris


> 	alloca { { int, uint, sbyte*, \4* (), \4* (\4*), { { int, uint, sbyte*, \4* (), { { int, uint, sbyte*, \4 (), \4 (\4), \8* (\4), \4 (\4) } }* (\4*), \4* (\4*), \4* (\4*), { { int, uint, sbyte*, \4 (), \4 (\4), \8* (\4), \4 (\4) } }* (\4*), \4* (\4*, \4*), \4* (\4*, { { int, uint, sbyte*, \4 (), \4 (\4), \8* (\4), \4 (\4) } }*, { { int, uint, sbyte*, \4 (), \4 (\4), \8* (\4), \4 (\4) } }*) } }* (\4*), \4* (\4*) } }		; <{ { int, uint, sbyte*, \4* (), \4* (\4*), { { int, uint, sbyte*, \4* (), { { int, uint, sbyte*, \4 (), \4 (\4), \8* (\4), \4 (\4) } }* (\4*), \4* (\4*), \4* (\4*), { { int, uint, sbyte*, \4 (), \4 (\4), \8* (\4), \4 (\4) } }* (\4*), \4* (\4*, \4*), \4* (\4*, { { int, uint, sbyte*, \4 (), \4 (\4), \8* (\4), \4 (\4) } }*, { { int, uint, sbyte*, \4 (), \4 (\4), \8* (\4), \4 (\4) } }*) } }* (\4*), \4* (\4*) } }*>:2 [#uses=0]
>
> _______________________________________________
> 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/




More information about the llvm-dev mailing list