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

David Tweed david.tweed at arm.com
Thu Aug 29 09:44:31 PDT 2013


Hi,

That approach would work: I did post a patch that included that, amongst
other OpenCL things, last year. However, it was felt that this wasn't an
area where the community wanted to put this in to the open source clang but
let different implementers do it according to their own designs in their own
code. If you do try this, you can use

if(Opts.OpenCL)....

to detect OpenCL. (If you look in clang there are certain uses of this to
deal with constant-folding/generating good error messages in cases where
OpenCL differs from C (mostly by being defined in more circumstances)).

Cheers,
Dave

-----Original Message-----
From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] On
Behalf Of Erik Schnetter
Sent: 29 August 2013 16:42
To: cfe-dev at cs.uiuc.edu
Subject: [cfe-dev] sizeof(long) in OpenCL C

The OpenCL C language requires that sizeof(long)=8, independent of the
architecture. This is not what Clang currently implements.

How would I change this in clang? This issue is currently preventing
supporting the "long" and (as a consequence) "double" type for 32-bit
architectures in pocl <http://pocl.sourceforge.net/>.

I see that the file lib/Basic/TargetInfo.cpp defines e.g. "LongWidth =
LongAlign = 32;". It seems that this definition should depend on the
language chosen (-x cl) -- would this be the correct approach? What about
all the targets that inherit from TargetInfo -- should they also receive the
corresponding modification? How do I determine the current language in
Clang?

Or would it be better to override these values after the TargetInfo object
has been created? Is there already a language hook for this?

Any pointers, suggestions, or ideas for this would be appreciated.

-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/.






More information about the cfe-dev mailing list