Vladimir Merzliakov
2005-Mar-08 14:09 UTC
[LLVMdev] Recursive Types using the llvm support library
>> 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
Chris Lattner
2005-Mar-08 15:31 UTC
[LLVMdev] Recursive Types using the llvm support library
On Tue, 8 Mar 2005, Vladimir Merzliakov wrote:>>> 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?In this case, yup. -Chris -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/
Vladimir Merzliakov
2005-Mar-09 13:05 UTC
[LLVMdev] Recursive Types using the llvm support library
----- Original Message ----- From: "Chris Lattner" <sabre at nondot.org> To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu> Sent: Tuesday, March 08, 2005 6:31 PM Subject: Re: [LLVMdev] Recursive Types using the llvm support library> On Tue, 8 Mar 2005, Vladimir Merzliakov wrote: > >>>> 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? > > In this case, yup. >I create test program and assert failed in it: { \2 *, sbyte * } Assertion failed: (!NewSTy->isAbstract()), function main, file /usr/home/wanderer/work/LLVMTest/obj/../src/tools/tool/Test.cc, line 28. Testcase source attached. Vladimir -------------- next part -------------- A non-text attachment was scrubbed... Name: Test.cc Type: application/octet-stream Size: 796 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050309/f9463a01/attachment.obj>
Apparently Analagous Threads
- [LLVMdev] Recursive Types using the llvm support library
- [LLVMdev] Recursive Types using the llvm support library
- [LLVMdev] Recursive Types using the llvm support library
- [LLVMdev] Recursive Types using the llvm support library
- [LLVMdev] Recursive Types using the llvm support library