[LLVMdev] Recursive Types using the llvm support library
Vladimir Merzliakov
wanderer at rsu.ru
Tue Mar 8 06:09:19 PST 2005
>> An example where something really simple like the line below was output
>> would be perfect.
>>
>> %struct.linked_list = type { %struct.linked_list*, %sbyte* }
>
> Use something like this:
>
> 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();
>
Is assert(!NewSTy->isAbstract()) must pass after this line?
Vladimir
More information about the llvm-dev
mailing list