<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div><blockquote type="cite"><meta http-equiv="Content-Type" content="text/html charset=windows-1252"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div></div><div><br><div>Begin forwarded message:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family: Helvetica;"><b>From: </b></span><span style="font-family:'Helvetica';">Matt Arsenault <<a href="mailto:Matthew.Arsenault@amd.com">Matthew.Arsenault@amd.com</a>><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family: Helvetica;"><b>Subject: </b></span><span style="font-family:'Helvetica';"><b>Re: [LLVMdev] Methods on addrspace pointers</b><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family: Helvetica;"><b>Date: </b></span><span style="font-family:'Helvetica';">January 20, 2014 at 3:41:07 PM PST<br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family: Helvetica;"><b>To: </b></span><span style="font-family:'Helvetica';">Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>>, Brandon Holt <<a href="mailto:bholt@cs.washington.edu">bholt@cs.washington.edu</a>><br></span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px;"><span style="font-family: Helvetica;"><b>Cc: </b></span><span style="font-family:'Helvetica';">LLVM Developers Mailing List <<a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a>><br></span></div><br><div>On 01/20/2014 03:29 PM, Hal Finkel wrote:<br><blockquote type="cite"><br>2. Is there a way to create methods that can be called with pointers<br>to different address spaces? It seems there is no way to declare<br>these in C++ using GNU attributes, and addrspace() seems to not be<br>supported by C++11 attribute syntax, which could possibly express<br>this. You can use __attribute__((address_space(N))<br><br><br><br>I have already been using that syntax to annotate pointer<br>declarations. However I don’t think it can be applied to methods the<br>way I was thinking. At least it doesn’t actually change them:<br><br><br><br>struct Foo {<br>long x;<br><br>__attribute__((address_space(7))) void bar(long y) {<br>printf("%ld %ld\n", x, y);<br>}<br>};<br><br><br>Generates this declaration still:<br><br><br>define linkonce_odr void @_ZN3Foo3barEl(%struct.Foo* %this, i64 %y)<br>ssp uwtable align 2<br><br><br>Though I think desired behavior would be:<br><br><br>define linkonce_odr void @_ZN3Foo3barEl(%struct.Foo addrspace(7) *<br>%this, i64 %y) ssp uwtable align 2<br><br><br>(actually I think it’s more tricky because the address_space<br>attribute could be applying to the return type. I’d think the<br>correct way to specify the attribute on “this” would be to put it<br>where “const” goes, after the parentheses)<br>Does it make sense for 'this' to be in one address space on some functions and in a different address space in other functions? If so, should the address space of 'this' contribute to overload resolution?<br><br> -Hal<br></blockquote><br>Yes it would. The struct itself has no specified address space, but the instances of it would.<br><br>__attribute__((address_space(1)) Foo f1;<br>__attribute__((address_space(2)) Foo f2;<br><br>f1.bar() and f2.bar() would need to call functions with different address spaced this pointers. Support for this would be required to support the OpenCL static C++ extension<br><br><blockquote type="cite"><br><blockquote type="cite"><br><br>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu/">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br><br></blockquote></blockquote><br><br></div></blockquote></div><br></div></blockquote></div><br></body></html>