As long as they don't have an address space explicitly defined.
This allows builtins with pointer arguments to be used with OpenCL.
Differential D8082
Sema: Accept pointers to any address space for builtin functions • tstellarAMD on Mar 5 2015, 7:28 AM. Authored by
Details
Diff Detail
Event TimelineComment Actions Shall TODO/comment be added somewhere saying that handling address space number of pointers in builtins is still to be implemented? Also what the number should be for OpenCL? Should it be taken from LangAS::ID enum?
Comment Actions This appears to be implemented already, but there are no builtins using it. What does need to be done is add a way to
Comment Actions Here is an updated patch with an entirely different approach. Instead of inserting addressspace casts, this patch rewrites the function declaration to match the address space of the call arguments. Comment Actions Much better approach, a few comments inline.
Comment Actions Hi, here is an updated patch. I've addressed all comments except I did not add a DensMap to rewriteBuiltinFunctionDecl(), I wasn't sure exactly how to use this to speed up the function. I can still add this if people think it will help. I did some profiling of a function with 100,000 __builtin_memcpy() calls and this patch doesn't seem to increase compile time. I also did not add handling for return types. I wasn't able to figure out how to get the actual call expression which had the return type used in the code. I added a TODO for this. |
Not sure if this cast might create a problem in some OpenCL-GPU architectures, because spec generally disallows conversion between constant and any other address spaces (see OpenCL C v2.0 s6.5.5).
I feel like a better way to handle this would be to create separate builtins overloads for constant and generic address space in OpenCL v2.0 and for all address spaces in OpenCL <v2.0. But this seems more work to me.