<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:p="urn:schemas-microsoft-com:office:powerpoint" xmlns:a="urn:schemas-microsoft-com:office:access" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns:b="urn:schemas-microsoft-com:office:publisher" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:c="urn:schemas-microsoft-com:office:component:spreadsheet" xmlns:odc="urn:schemas-microsoft-com:office:odc" xmlns:oa="urn:schemas-microsoft-com:office:activation" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:q="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rtc="http://microsoft.com/officenet/conferencing" xmlns:D="DAV:" xmlns:Repl="http://schemas.microsoft.com/repl/" xmlns:mt="http://schemas.microsoft.com/sharepoint/soap/meetings/" xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml" xmlns:ppda="http://www.passport.com/NameSpace.xsd" xmlns:ois="http://schemas.microsoft.com/sharepoint/soap/ois/" xmlns:dir="http://schemas.microsoft.com/sharepoint/soap/directory/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:dsp="http://schemas.microsoft.com/sharepoint/dsp" xmlns:udc="http://schemas.microsoft.com/data/udc" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sub="http://schemas.microsoft.com/sharepoint/soap/2002/1/alerts/" xmlns:ec="http://www.w3.org/2001/04/xmlenc#" xmlns:sp="http://schemas.microsoft.com/sharepoint/" xmlns:sps="http://schemas.microsoft.com/sharepoint/soap/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:udcs="http://schemas.microsoft.com/data/udc/soap" xmlns:udcxf="http://schemas.microsoft.com/data/udc/xmlfile" xmlns:udcp2p="http://schemas.microsoft.com/data/udc/parttopart" xmlns:wf="http://schemas.microsoft.com/sharepoint/soap/workflow/" xmlns:dsss="http://schemas.microsoft.com/office/2006/digsig-setup" xmlns:dssi="http://schemas.microsoft.com/office/2006/digsig" xmlns:mdssi="http://schemas.openxmlformats.org/package/2006/digital-signature" xmlns:mver="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns:mrels="http://schemas.openxmlformats.org/package/2006/relationships" xmlns:spwp="http://microsoft.com/sharepoint/webpartpages" xmlns:ex12t="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ex12m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:pptsl="http://schemas.microsoft.com/sharepoint/soap/SlideLibrary/" xmlns:spsl="http://microsoft.com/webservices/SharePointPortalServer/PublishedLinksService" xmlns:Z="urn:schemas-microsoft-com:" xmlns:st="" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="2050" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple style='word-wrap: break-word;-webkit-nbsp-mode: space;-webkit-line-break: after-white-space'><div class=WordSection1><p class=MsoNormal>Hi Tanya,<span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'><o:p></o:p></span></p><p class=MsoNormal>Thanks for the patch; it’s great to get your contribution for the OpenCL support.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Creating operators that may get types as arguments for as_typen and convert is a very elegant solution; however it’s quite intrusive, as these features might be implemented as standard functions, and linked to the user’s code later. As_typen needs some special checks, so it could be a clang built-in, but conversions basically could be implemented without changing clang at all.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Vec_step is very similar to the sizeof and the alignof operators, so I think it’s OK to implement it using the same expression type, instead of code duplication.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Index: include/clang/Basic/DiagnosticSemaKinds.td<o:p></o:p></p><p class=MsoNormal>===================================================================<o:p></o:p></p><p class=MsoNormal>--- include/clang/Basic/DiagnosticSemaKinds.td                (revision 125808)<o:p></o:p></p><p class=MsoNormal>+++ include/clang/Basic/DiagnosticSemaKinds.td             (working copy)<o:p></o:p></p><p class=MsoNormal>@@ -3723,6 +3723,26 @@<o:p></o:p></p><p class=MsoNormal>   "%0 does not refer to the name of a parameter pack; did you mean %1?">;<o:p></o:p></p><p class=MsoNormal>def note_parameter_pack_here : Note<"parameter pack %0 declared here">;<o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>…</span><o:p></o:p></p><p class=MsoNormal>+def err_cvt_arg_must_be_constant : Error<<o:p></o:p></p><p class=MsoNormal>+  "__builtin_convert requires constant 3rd and 4th argument">;<o:p></o:p></p><p class=MsoNormal>+def err_invalid_astype_of_different_size : Error<<o:p></o:p></p><p class=MsoNormal>+  "invalid astype between type '%0' and '%1' of different size">;<o:p></o:p></p><p class=MsoNormal>+def err_vec_step_bitfield : Error<<o:p></o:p></p><p class=MsoNormal>+  "invalid application of 'vec_step' to bitfield">;<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Bitfields are not supported in OpenCL at all – is this error message really needed?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Index: include/clang/Basic/TokenKinds.def<o:p></o:p></p><p class=MsoNormal>===================================================================<o:p></o:p></p><p class=MsoNormal>--- include/clang/Basic/TokenKinds.def (revision 125808)<o:p></o:p></p><p class=MsoNormal>+++ include/clang/Basic/TokenKinds.def              (working copy)<o:p></o:p></p><p class=MsoNormal>@@ -356,6 +356,11 @@<o:p></o:p></p><p class=MsoNormal>KEYWORD(__vector                    , KEYALTIVEC)<o:p></o:p></p><p class=MsoNormal>KEYWORD(__pixel                     , KEYALTIVEC)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>+// OpenCL Extensions.<o:p></o:p></p><p class=MsoNormal>+KEYWORD(__builtin_astype            , KEYALL)<o:p></o:p></p><p class=MsoNormal>+KEYWORD(__builtin_convert           , KEYALL)<o:p></o:p></p><p class=MsoNormal>+KEYWORD(__builtin_vec_step          , KEYALL)<o:p></o:p></p><p class=MsoNormal>+<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The latest version of CLANG already has KEYOPENCL flag, so keywords can be flagged as OpenCL only. This way vec_step could be a keyword, instead of using macros later to turn it to __builtin_vec_step. Also, it saves later checking of right target language.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Index: lib/CodeGen/CGExprScalar.cpp<o:p></o:p></p><p class=MsoNormal>===================================================================<o:p></o:p></p><p class=MsoNormal>--- lib/CodeGen/CGExprScalar.cpp           (revision 125808)<o:p></o:p></p><p class=MsoNormal>+++ lib/CodeGen/CGExprScalar.cpp        (working copy)<o:p></o:p></p><p class=MsoNormal>@@ -2534,6 +2537,86 @@<o:p></o:p></p><p class=MsoNormal>   return CGF.EmitBlockLiteral(block);<o:p></o:p></p><p class=MsoNormal>}<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>+Value *ScalarExprEmitter::VisitAsTypeExpr(AsTypeExpr *E) {<o:p></o:p></p><p class=MsoNormal>+  Value *Src  = CGF.EmitScalarExpr(E->getSrcExpr());<o:p></o:p></p><p class=MsoNormal>+  const llvm::Type * DstTy = ConvertType(E->getDstType());<o:p></o:p></p><p class=MsoNormal>+  <o:p></o:p></p><p class=MsoNormal>+  // Going from vec4->vec3 or vec3->vec4 is a special case and requires<o:p></o:p></p><p class=MsoNormal>+  // a shuffle vector instead of a bitcast.<o:p></o:p></p><p class=MsoNormal>+  const llvm::Type *SrcTy = Src->getType();<o:p></o:p></p><p class=MsoNormal>+  if (isa<llvm::VectorType>(DstTy) && isa<llvm::VectorType>(SrcTy)) {<o:p></o:p></p><p class=MsoNormal>+    unsigned numElementsDst = cast<llvm::VectorType>(DstTy)->getNumElements();<o:p></o:p></p><p class=MsoNormal>+    unsigned numElementsSrc = cast<llvm::VectorType>(SrcTy)->getNumElements();<o:p></o:p></p><p class=MsoNormal>+    <o:p></o:p></p><p class=MsoNormal>+    if ((numElementsDst == 3 && numElementsSrc == 4) <o:p></o:p></p><p class=MsoNormal>+        || (numElementsDst == 4 && numElementsSrc == 3)) {<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>The OpenCL spec defines the behavior of vec4->vec3, but about vec3->vec4 it writes:<o:p></o:p></p><p class=MsoNormal>  float3 f;<o:p></o:p></p><p class=MsoNormal>  // Error. Result and operand have different sizes<o:p></o:p></p><p class=MsoNormal>  float4 g = as_float4(f);<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Also, shuffle vector is not enough – there might be a conversion from int4 to float3, which is legal, but will crash the compiler if it’s done only by shuffle. There must be a bitcast here.<o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal>+  if (dst_fp && src_fp)<o:p></o:p></p><p class=MsoNormal>+    ID = llvm::Intrinsic::convertff;<o:p></o:p></p><p class=MsoNormal>+  else if (dst_fp && !src_fp)<o:p></o:p></p><p class=MsoNormal>+    ID = src_s ? llvm::Intrinsic::convertfsi : llvm::Intrinsic::convertfui;<o:p></o:p></p><p class=MsoNormal>+  else if (!dst_fp && src_fp)<o:p></o:p></p><p class=MsoNormal>+    ID = dst_s ? llvm::Intrinsic::convertsif : llvm::Intrinsic::convertuif;<o:p></o:p></p><p class=MsoNormal>+  else if (dst_s && src_s)<o:p></o:p></p><p class=MsoNormal>+    ID = llvm::Intrinsic::convertss;<o:p></o:p></p><p class=MsoNormal>+  else if (dst_s && !src_s)<o:p></o:p></p><p class=MsoNormal>+    ID = llvm::Intrinsic::convertsu;<o:p></o:p></p><p class=MsoNormal>+  else if (!dst_s && src_s)<o:p></o:p></p><p class=MsoNormal>+    ID = llvm::Intrinsic::convertus;<o:p></o:p></p><p class=MsoNormal>+  else<o:p></o:p></p><p class=MsoNormal>+    ID = llvm::Intrinsic::convertuu;<o:p></o:p></p><p class=MsoNormal>+  <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>These intrinsics are not documented. Are they safe to use? Do they fulfill the OpenCL spec’s precision requirements?<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Index: lib/Parse/ParseExpr.cpp<o:p></o:p></p><p class=MsoNormal>===================================================================<o:p></o:p></p><p class=MsoNormal>--- lib/Parse/ParseExpr.cpp         (revision 125808)<o:p></o:p></p><p class=MsoNormal>+++ lib/Parse/ParseExpr.cpp      (working copy)<o:p></o:p></p><p class=MsoNormal><span style='color:#1F497D'>…</span><o:p></o:p></p><p class=MsoNormal>+  // We know that it is either a parenthesized type-name, or it is a<o:p></o:p></p><p class=MsoNormal>+  // unary-expression that starts with a compound literal, or starts with<o:p></o:p></p><p class=MsoNormal>+  // a primary-expression that is a parenthesized expression.<o:p></o:p></p><p class=MsoNormal>+  ParenParseOption ExprType = CastExpr;<o:p></o:p></p><p class=MsoNormal>+  ParsedType CastTy;<o:p></o:p></p><p class=MsoNormal>+  SourceLocation LParenLoc = Tok.getLocation(), RParenLoc;<o:p></o:p></p><p class=MsoNormal>+  <o:p></o:p></p><p class=MsoNormal>+  // C++0x [expr.sizeof]p1:<o:p></o:p></p><p class=MsoNormal>+  //   [...] The operand is either an expression, which is an unevaluated<o:p></o:p></p><p class=MsoNormal>+  //   operand (Clause 5) [...]<o:p></o:p></p><p class=MsoNormal>+  //<o:p></o:p></p><p class=MsoNormal>+  // The GNU typeof and alignof extensions also behave as unevaluated<o:p></o:p></p><p class=MsoNormal>+  // operands.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sizeof, alignof and typeof are not relevant here – I think vec_step should use the same infrastructure as sizeof, instead of code duplication.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks<o:p></o:p></p><p class=MsoNormal>      Guy Benyei<o:p></o:p></p><p class=MsoNormal>      Intel<o:p></o:p></p><p class=MsoNormal>      SSG – MGP OpenCL Development Center<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><img width=420 height=116 id="Picture_x0020_1" src="cid:image001.png@01CBD204.C07EF900" alt="email_signature_guy_new2"><o:p></o:p></span></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div><font face="monospace">---------------------------------------------------------------------<br>
Intel Israel (74) Limited<br>
<br>
This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</font></body></html>