<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
When adding C11 atomics support to the Hexagon backend, I ended up
adding almost exactly the same line. I suspect that the reason it
wasn't already there is that the people adding C11 and C++11 didn't
want to try and modify backends they were unfamiliar with.<br>
<br>
<div class="moz-cite-prefix">On 1/14/2016 10:02 PM, Luo, Xionghu via
cfe-dev wrote:<br>
</div>
<blockquote
cite="mid:894E4BC922C573429354F1EC4342D61C4C4626FC@SHSMSX101.ccr.corp.intel.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@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:SimSun;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
text-align:justify;
text-justify:inter-ideograph;
font-size:10.5pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
font-family:"Calibri",sans-serif;}
/* Page Definitions */
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US">Hello,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">We are developing the
atomic built-in function for OpenCL 2.0. we use SPIR64 as
the target and hope to lower the llvm built-in functions
like ‘__c11_atomic_fetch_and_sub’ to instructions like
‘atomicrmw’, but the MaxAtomicInlineWidth of
SPIR64TargetInfo is not set by default, so the
EmitAtomicExpr goes to libcall path and got function
‘__atomic_fetch_sub_4’, which is unexpected.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">After set the variable <b><i>MaxAtomicInlineWidth,
the
</i></b>EmitAtomicExpr take the non-libcall path and get
instruction: ‘%1 = atomicrmw volatile sub i32*
%arrayinit.begin, i32 1 acquire’<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><i><span lang="EN-US">class
SPIR64TargetInfo : public SPIRTargetInfo {<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">public:<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">
SPIR64TargetInfo(const llvm::Triple &Triple) :
SPIRTargetInfo(Triple) {<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> PointerWidth =
PointerAlign = 64;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> SizeType =
TargetInfo::UnsignedLong;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> PtrDiffType =
IntPtrType = TargetInfo::SignedLong;<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> DataLayoutString
= "e-i64:64-v16:16-v24:32-v32:32-v48:64-"<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">
"v96:128-v192:256-v256:256-v512:512-v1024:1024";<o:p></o:p></span></i></p>
<p class="MsoNormal"><b><i><span lang="EN-US">+
MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;<o:p></o:p></span></i></b></p>
<p class="MsoNormal"><i><span lang="EN-US"> }<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> void
getTargetDefines(const LangOptions &Opts,<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">
MacroBuilder &Builder) const override {<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">
DefineStd(Builder, "SPIR64", Opts);<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> }<o:p></o:p></span></i></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">So the question is why
some other targets set the MaxAtomicInlineWidth when created
but SPIR64TargetInfo did NOT? Shall we add it as above?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">The mentioned OpenCL
test kernel is as below, command is ‘./clang -cc1 -emit-llvm
-triple spir64 -cl-std=CL2.0 atomic_functions.cl -o
atomic_functions.spir’:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><i><span lang="EN-US">__kernel void
atomic_functions()<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">{<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> volatile
atomic_uint ptest[2] = {0};<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"> int test =
__c11_atomic_fetch_sub(&ptest[0], 1, 1);<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US">}<o:p></o:p></span></i></p>
<p class="MsoNormal"><i><span lang="EN-US"><o:p> </o:p></span></i></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Verdana",sans-serif;color:#44546A"
lang="EN-US">Luo
</span><span
style="font-family:"Verdana",sans-serif;color:#1F497D"
lang="EN-US">Xionghu</span><span
style="font-family:"Verdana",sans-serif;color:#44546A"
lang="EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-family:"Verdana",sans-serif;color:#44546A"
lang="EN-US">Best Regards<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><o:p> </o:p></span></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
</pre>
</body>
</html>