<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:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@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;}
span.hoenzb
        {mso-style-name:hoenzb;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
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]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Intrin.h does contain definitions (farther down the file), among others it has _lzcnt_u32 (~line 550), and under __x86_64__ it has _lzcnt_u64 (~line 615).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">These definitions have correct zero guards.<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>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Cribbing from clang/test/Headers/ms-intrin.cpp, I can get multiple-definition errors running on Linux with the following.<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>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">$ cat try-intrin.c<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">typedef __SIZE_TYPE__ size_t;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#include <Intrin.h><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">$ clang -c try-intrin.c -target x86_64-pc-win32 -march=bdver1 -ffreestanding<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>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">If there aren't any Windows bots catching this, then it looks like clang/test/Headers/ms-intrin.cpp needs to be beefed up.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">--paulr<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></a></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Craig Topper [mailto:craig.topper@gmail.com]
<br>
<b>Sent:</b> Sunday, November 02, 2014 11:59 AM<br>
<b>To:</b> Alex Rosenberg<br>
<b>Cc:</b> Robinson, Paul; cfe-commits@cs.uiuc.edu<br>
<b>Subject:</b> Re: r221066 - Add _lzcnt_u32 and _lzcnt_u64 to lzcntintrin.h to match Intel documentation names for these intrinsics.<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Where do the definitions for the things in Intrin.h live? It's just declarations.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Sun, Nov 2, 2014 at 10:16 AM, Alex Rosenberg <<a href="mailto:alexr@leftfield.org" target="_blank">alexr@leftfield.org</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal">Intrin.h is the MSVC-compatibility header. lzcntintrin.h is the GCC/ICC,etc. style header as well as MSVC's vendor-specific header in some cases.<br>
<span style="color:#888888"><br>
<span class="hoenzb">Alex</span></span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><br>
> On Nov 1, 2014, at 7:20 PM, Robinson, Paul <<a href="mailto:Paul_Robinson@playstation.sony.com">Paul_Robinson@playstation.sony.com</a>> wrote:<br>
><br>
> I thought these were already defined in Intrin.h?  Except only for Windows I guess.<br>
> Still can't reach my work systems so checking it myself might have to wait until<br>
> Monday.<br>
> --paulr<br>
><br>
>> -----Original Message-----<br>
>> From: <a href="mailto:cfe-commits-bounces@cs.uiuc.edu">cfe-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:cfe-commits-">cfe-commits-</a><br>
>> <a href="mailto:bounces@cs.uiuc.edu">bounces@cs.uiuc.edu</a>] On Behalf Of Craig Topper<br>
>> Sent: Saturday, November 01, 2014 3:51 PM<br>
>> To: <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>> Subject: r221066 - Add _lzcnt_u32 and _lzcnt_u64 to lzcntintrin.h to match<br>
>> Intel documentation names for these intrinsics.<br>
>><br>
>> Author: ctopper<br>
>> Date: Sat Nov  1 17:50:57 2014<br>
>> New Revision: 221066<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221066&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=221066&view=rev</a><br>
>> Log:<br>
>> Add _lzcnt_u32 and _lzcnt_u64 to lzcntintrin.h to match Intel<br>
>> documentation names for these intrinsics.<br>
>><br>
>> Modified:<br>
>>    cfe/trunk/lib/Headers/lzcntintrin.h<br>
>>    cfe/trunk/test/CodeGen/lzcnt-builtins.c<br>
>><br>
>> Modified: cfe/trunk/lib/Headers/lzcntintrin.h<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
>> project/cfe/trunk/lib/Headers/lzcntintrin.h?rev=221066&r1=221065&r2=221066<br>
>> &view=diff<br>
>> ==========================================================================<br>
>> ====<br>
>> --- cfe/trunk/lib/Headers/lzcntintrin.h (original)<br>
>> +++ cfe/trunk/lib/Headers/lzcntintrin.h Sat Nov  1 17:50:57 2014<br>
>> @@ -44,12 +44,24 @@ __lzcnt32(unsigned int __X)<br>
>>   return __X ? __builtin_clz(__X) : 32;<br>
>> }<br>
>><br>
>> +static __inline__ unsigned int __attribute__((__always_inline__,<br>
>> __nodebug__))<br>
>> +_lzcnt_u32(unsigned int __X)<br>
>> +{<br>
>> +  return __X ? __builtin_clz(__X) : 32;<br>
>> +}<br>
>> +<br>
>> #ifdef __x86_64__<br>
>> static __inline__ unsigned long long __attribute__((__always_inline__,<br>
>> __nodebug__))<br>
>> __lzcnt64(unsigned long long __X)<br>
>> {<br>
>>   return __X ? __builtin_clzll(__X) : 64;<br>
>> }<br>
>> +<br>
>> +static __inline__ unsigned long long __attribute__((__always_inline__,<br>
>> __nodebug__))<br>
>> +_lzcnt_u64(unsigned long long __X)<br>
>> +{<br>
>> +  return __X ? __builtin_clzll(__X) : 64;<br>
>> +}<br>
>> #endif<br>
>><br>
>> #endif /* __LZCNTINTRIN_H */<br>
>><br>
>> Modified: cfe/trunk/test/CodeGen/lzcnt-builtins.c<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lzcnt-" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/lzcnt-</a><br>
>> builtins.c?rev=221066&r1=221065&r2=221066&view=diff<br>
>> ==========================================================================<br>
>> ====<br>
>> --- cfe/trunk/test/CodeGen/lzcnt-builtins.c (original)<br>
>> +++ cfe/trunk/test/CodeGen/lzcnt-builtins.c Sat Nov  1 17:50:57 2014<br>
>> @@ -22,3 +22,15 @@ unsigned long long test__lzcnt64(unsigne<br>
>>   // CHECK: @llvm.ctlz.i64<br>
>>   return __lzcnt64(__X);<br>
>> }<br>
>> +<br>
>> +unsigned int test_lzcnt_u32(unsigned int __X)<br>
>> +{<br>
>> +  // CHECK: @llvm.ctlz.i32<br>
>> +  return _lzcnt_u32(__X);<br>
>> +}<br>
>> +<br>
>> +unsigned long long test__lzcnt_u64(unsigned long long __X)<br>
>> +{<br>
>> +  // CHECK: @llvm.ctlz.i64<br>
>> +  return _lzcnt_u64(__X);<br>
>> +}<br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
><br>
> _______________________________________________<br>
> cfe-commits mailing list<br>
> <a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <br>
~Craig <o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>