[cfe-dev] sizeof(long) in OpenCL C

Erik Schnetter schnetter at gmail.com
Fri Aug 30 10:49:26 PDT 2013


On 2013-08-30, at 13:39 , John McCall <rjmccall at apple.com> wrote:

> On Aug 30, 2013, at 8:15 AM, Erik Schnetter <schnetter at gmail.com> wrote:
>> I notice that, with the patch applied, "long" has 64 bits, but __INTPTR_TYPE__ is still defined as "long int" on ARM. This is now wrong; it needs to be set to "int" instead. Do you have pointers for correcting this in clang?
>> 
>> There are similar issues with e.g. __INT64_TYPE__ (should now be "long" instead of "long long”)
> 
> Specifying the size of “long” must have seemed clever to someone, but it fundamentally changes the target in some pretty intrusive ways, and frankly it ought to be represented somehow in the target triple and everything that depends on it.  That is, Open CL targeting ARM is no longer just the ordinary ARM target, and a significant amount of code (e.g. the ABI lowering code in IR-gen) needs to be revisited to see whether it’s still applicable in the face of this change.


Since OpenCL C code cannot access any system libraries, one is free to re-define the ABI in any way one sees fit (except that one must still be able to launch kernels). This opens avenues for optimization, as e.g. operating system constraints or backward compatibility are non-issues. 

On the other hand, clang (the front-end) should not be concerned with ABIs, and the back-end (llvm) should not be concerned with whether a type is called "long" or "long long" in the language syntax. In other words, maybe this issue could be addressed by mapping OpenCL C's "long" to C's "long long" on 32-bit architectures?

-erik

-- 
Erik Schnetter <schnetter at gmail.com>
http://www.perimeterinstitute.ca/personal/eschnetter/

My email is as private as my paper mail. I therefore support encrypting
and signing email messages. Get my PGP key from http://pgp.mit.edu/.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 203 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130830/8f7ae8cc/attachment.sig>


More information about the cfe-dev mailing list