[cfe-dev] "generic" address space

Mon P Wang wangmp at apple.com
Mon Jul 14 22:21:29 PDT 2008


Hi,

In the llvm, I'm adding support for address spaces for builtin  
functions that take pointers.  For
example, the front end will generate slightly different code if the  
incoming pointer to the intrinsic function comes from different  
address spaces, e.g.,
   @llvm.atomic.load.add.i32.p0i32      // returns i32, i32 ptr to  
default address space
   @llvm.atomic.load.add.i32.p11i32   // return  i32, i32 ptr to  
address space 11

To generate this in Clang, I didn't want to require the user to have  
to specify what specific address spaces a builtin can take, especially  
if the intrinsic is supported on the address space for a particular  
machine.  So, I added the concept to ASQualType the concept of a  
"generic" address space that can be used in the parameter type of a  
function prototype.   This concept is used when we checking to see if  
an argument and a parameter type are compatible.  An argument of type  
pointer to an address space to a Type T1 is compatible with a  
parameter of type pointer to a generic space to a Type T1.  When we  
get to code generation, we take the type of the argument account to  
generate the different intrinsic names.

I'm also going to change clang to generate an error if the compiler  
needs to do an implicit cast between to pointers pointing at different  
address spaces.  Typically, this operation doesn't make sense.  Note  
that users can still do explicit cast between address spaces.

If you have any comments or suggestions, please let me know.

Thanks,
-- Mon Ping



More information about the cfe-dev mailing list