<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On May 26, 2011, at 7:55 AM, Anton Lokhmotov wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi Tanya,<br><br>As I indicated 2 months ago, we are not in favour of this approach:<br><a href="http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-March/014078.html">http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-March/014078.html</a><br><br>I was under the impression that neither was Chris:<br>http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-March/014123.html<br>nor was Guy:<br>http://lists.cs.uiuc.edu/pipermail/cfe-dev/2011-March/013692.html<br><br>I think more discussion is needed if this is to go in.<br></div></blockquote><div><br></div><div>Fair enough, but as you can understand its difficult to have patches live outside the tree for so long.</div><div><br></div><div>I disagree that Chris was against the approach entirely, but I do know that we have differing opinions.</div><div><br></div><div>I do believe that asType is the right approach and should be a builtin. I do not think it can be expressed in C to do a bitcast or a shuffle/bitcast. So having a built-in to do this, is the right way to go. If you have another implementation of asType, mine should not conflict with yours if you are using library functions.</div><div><br></div><div>As I have mentioned before, AsType as an ExprClass also has the added benefit as being part of the AST for the various tools that may want to take advantage of this (ie. syntax highlighting, etc).</div><div><br></div><blockquote type="cite"><div>My main concern is that 'as_type' and 'convert_type' [not 'astype' and<br>'convert'] are not that different from other overloaded OpenCL built-in<br>functions. While 'as_type' can indeed be represented in LLVM-IR as a<br>bitcast or shuffle, different flavours of 'convert_type' are effectively<br>built-in functions, to be implemented either in the library or in the<br>backend, at which level I'm not sure what e.g. __builtin_convert(i, short,<br>2, 1) buys you over convert_short_rtz_sat(i).<br><br>As I understand, this works for you as follows (please correct me if I'm<br>wrong).<br><br>OpenCL 'convert_type' functions are #define'd in your internal header file<br>as e.g.:<br>#define convert_short_rtz_sat(i) __builtin_convert(i, short, 2, 1)<br><font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#144FAE"><br></font></font></div></blockquote><blockquote type="cite"><div>Parsing a __builtin_convert by Sema::ActOnConvertExpr results in a<br>ConvertExpr expression. <br><br>This expression is then visited by ScalarExprEmitter::VisitConvertExpr,<br>which creates a call to one of the llvm::Intrinsic::convert?? intrinsics<br>with { Src, Mode, Sat } parameters [ Mode -> RoundingMode; Sat -><br>SaturatedMode ].<br><br>So why is this better than just placing declarations for the 'convert_type'<br>functions in the same header file as for all other built-in functions?<br></div></blockquote><div><br></div><div>I know understand your concerns about convert, and I will remove it from this patch at this time. We will investigate an alternative approach.</div><br><blockquote type="cite"><div><br><blockquote type="cite">+KEYWORD(__builtin_astype , KEYOPENCL)<br></blockquote><blockquote type="cite">+KEYWORD(__builtin_convert , KEYOPENCL)<br></blockquote>Please note that these are not keywords according to the OpenCL<br>specification. [astype -> as_type; convert -> convert_type]<br></div></blockquote><div><br></div><div>While not a keyword, it is for OpenCL only. I'm happy to change it back, but I think it probably should stay this way.</div><div><br></div><div>I will re-do the patch to only handle __builtin_astype.</div><div><br></div><div>-Tanya</div><br><blockquote type="cite"><div><br>Best regards,<br>Anton.<br><br><br><br></div></blockquote></div><br></body></html>