[cfe-dev] Making "generic" address space as default for pointers when address space is not specified

ranupama anupama.rasale at amd.com
Mon Mar 24 06:20:41 PDT 2014


Hi All,
   I am making modifications to clang to make the address space to be
"generic" (which is a union of global.local and private workspace, ref
Opencl2.0 specification for more information on the same) when the same is
not mentioned while declaring pointers.
   I have added "opencl_generic" as the new address space in AddressSpaces.h
and Targets.cpp and this seems to work. I verfied this by changing
"opencl_global" to "opencl_generic" in ParseOpenCLQualifiers() function of
ParseDecl.cpp and the LLVM IR rightly showed addrspace(4) in place of
addrspace(1) which represents global address space.
    Now I am trying support the following feature
int *foo(float *x)
{
   ....
}

Should generate following IR:
define spir_func i32 addrspace(4) @foo(float addrspace(4) * %x)
{
 ....
}

My idea of supporting this feature is in the Parser phase, in ParseDecl.cpp
- function ParseDeclaratorInternal() to be precise.  
In this function, from the token read it is deduced that it is reading a
pointer. At this point check if the address spaces is mentioned or not. If
not, add the address space attribute to the DS through
DS.getAttributes().addNewInteger() call.

My query is
i. Do you think this approach is reasonable?
ii. If so, then why the IR doesn't show up the address space as
addrspace(4). Are there other places I need to modify to generate in the IR? 
iii. If this is not the right approach, can you let me know how I can go
about supporting the same?

Thanks
Anupama



--
View this message in context: http://clang-developers.42468.n3.nabble.com/Making-generic-address-space-as-default-for-pointers-when-address-space-is-not-specified-tp4038577.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list