[cfe-dev] SPIR/OpenCL size_t/ptrdiff_t as builtin types - preliminary patch

Eli Friedman eli.friedman at gmail.com
Wed Nov 7 17:18:10 PST 2012


Comments below.

On Mon, Nov 5, 2012 at 10:40 PM, Benyei, Guy <guy.benyei at intel.com> wrote:

>  Hi all,****
>
> ** **
>
> The attached patch contains implementation for turning OpenCL size_t and
> ptrdiff_t types to builtin types (on top of my previous patch).****
>
> ** **
>
> This patch needs some additional polishing, like addition of size_t
> specific tests and changing some names.****
>
> ** **
>
> In spite of the issues above, I find it very important to send this mail
> before the LLVM developers’ conference. During the conference we will hold
> a SPIR BOF session, and this patch will be used to explain some aspects of
> the SPIR approach.****
>
> ** **
>
>
> Index: lib/Analysis/PrintfFormatString.cpp
===================================================================
--- lib/Analysis/PrintfFormatString.cpp (revision 167378)
+++ lib/Analysis/PrintfFormatString.cpp (working copy)
@@ -478,6 +478,14 @@
     LM.setKind(LengthModifier::AsShort);
     break;

+  case BuiltinType::SizeT:
+  case BuiltinType::PtrDiffT:
+    if (Ctx.getTargetInfo().getPointerWidth(0) == 64)
+      LM.setKind(LengthModifier::AsLong);
+    else
+      LM.setKind(LengthModifier::None);
+    break;
+

getPointerWidth(0) isn't going to return a useful answer for SPIR.  More
generally, every place you call getPointerWidth is wrong.

Index: include/clang/Basic/TokenKinds.def
===================================================================
--- include/clang/Basic/TokenKinds.def (revision 167378)
+++ include/clang/Basic/TokenKinds.def (working copy)
@@ -448,6 +448,16 @@
 ALIAS("write_only", __write_only    , KEYOPENCL)
 ALIAS("read_write", __read_write    , KEYOPENCL)
 KEYWORD(__builtin_astype            , KEYOPENCL)
+KEYWORD(image1d_t                   , KEYOPENCL)
+KEYWORD(image1d_array_t             , KEYOPENCL)
+KEYWORD(image1d_buffer_t            , KEYOPENCL)
+KEYWORD(image2d_t                   , KEYOPENCL)
+KEYWORD(image2d_array_t             , KEYOPENCL)
+KEYWORD(image3d_t                   , KEYOPENCL)
+KEYWORD(sampler_t                   , KEYOPENCL)
+KEYWORD(event_t                     , KEYOPENCL)
+KEYWORD(size_t                      , KEYOPENCL)
+KEYWORD(ptrdiff_t                   , KEYOPENCL)

 // Borland Extensions.
 KEYWORD(__pascal                    , KEYALL)

Using KEYOPENCL will break existing OpenCL implementations; maybe add
KEYSPIR?


This patch doesn't contain any of the interesting changes related to struct
layout, IR generation, and fixing the sizeof() operator to work correctly,
so it's hard to say more.

-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20121107/7efe4cbd/attachment.html>


More information about the cfe-dev mailing list