<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<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;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
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;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle20
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:#1F497D;}
span.EmailStyle22
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
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="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Many thanks for that answer! Now I understand better!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> paul.robinson@sony.com <paul.robinson@sony.com>
<br>
<b>Sent:</b> Freitag, 30. August 2019 16:33<br>
<b>To:</b> Gaier, Bjoern <Bjoern.Gaier@horiba.com><br>
<b>Cc:</b> cfe-dev@lists.llvm.org<br>
<b>Subject:</b> RE: Understanding __builtin_-functions<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="color:#1F497D">> </span>In my code I used the function “__builtin_signbitd64” which I picked up from the GCC list of builtin functions.
<o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">As a rule, Clang does not view the GCC list of builtins as a set of API requirements. Clang generally views builtins as a convenient implementation detail. Because builtins use a function-like syntax, Clang
identifies builtins by name. If the name doesn't match the list of known builtins, even if the name starts with "__builtin_", Clang will treat it as a normal function.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">Intrinsics (e.g. those defined by Intel) are the user-facing API. They might or might not use builtins in their implementations; over the years I have seen Clang remove many builtins as the optimizers and code
generators became better able to select the optimal instruction sequences that previously required builtins. If there's an intrinsic that does what you want, it should be the stable API.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D">--paulr<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<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"> cfe-dev [<a href="mailto:cfe-dev-bounces@lists.llvm.org">mailto:cfe-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Gaier, Bjoern via cfe-dev<br>
<b>Sent:</b> Friday, August 30, 2019 6:12 AM<br>
<b>To:</b> 'Clang Dev'<br>
<b>Subject:</b> [cfe-dev] Understanding __builtin_-functions<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="DE">Hey Clang-Experts,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="DE"><o:p> </o:p></span></p>
<p class="MsoNormal">I’m currently working with Clang-CL based on the LLVM 8.0.0 (is that the right term? Or is it just Clang 8.0.0?) and targeting Windows with 64bit.<o:p></o:p></p>
<p class="MsoNormal">In my code I used the function “__builtin_signbitd64” which I picked up from the GCC list of builtin functions.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">In my understanding, builtin functions are not really functions, but instead they get replaced with assembly instructions, like intrinsic functions. However, when I printed the resulting assembly code I got:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-family:Consolas">#DEBUG_VALUE: signbit:_X <- $xmm6<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">#DEBUG_VALUE: preSqrt <- $xmm6<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">.cv_inline_site_id 70 within 58 inlined_at 6 588 0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">.cv_loc 70 7 312 0 # C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\ucrt\corecrt_math.h:312:0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">movapd xmm0, xmm6<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas;color:red">call __builtin_signbitd64<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">xorpd xmm0, xmm0<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family:Consolas">test eax, eax<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">And later an undefined reference to said “__builtin_signbitd64” function. Why? How do builtin functions work then? What is there purpose?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Kind greetings<o:p></o:p></p>
<p class="MsoNormal">Björn<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko
Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika <o:p></o:p></span></p>
</div>
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr. DE 114 165 789 Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko Lampert, Takashi Nagano, Takeshi Fukushima. Junichi Tajika
</body>
</html>