Hi I am wondering why the following variable has a PointerTy. @foo.data = internal addrspace(3) global float 5.000000e+000, align 4 When I do a V->getType()->dump() on the variable its printed as float addrspace(3)* thanks shrey
On 10/19/11 1:17 PM, shreyas krishnan wrote:> Hi > I am wondering why the following variable has a PointerTy. > > @foo.data = internal addrspace(3) global float 5.000000e+000, align 4 > > When I do a V->getType()->dump() on the variable its printed as > > float addrspace(3)*A Global is globally allocated memory. @foo.data is a pointer to that globally allocated memory: http://llvm.org/docs/LangRef.html#globalvars -- John T.> > > thanks > shrey > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Hi Shrey, if you declare a global variable of type T, then the GlobalVariable object (call it G) always has type T*. It's a pointer to the memory in which the T is held. So to write a T value to the global, you can just store it to G. Ciao, Duncan.> I am wondering why the following variable has a PointerTy. > > @foo.data = internal addrspace(3) global float 5.000000e+000, align 4 > > When I do a V->getType()->dump() on the variable its printed as > > float addrspace(3)* > > > thanks > shrey > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev