<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=iso-8859-1">
<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;}
@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:0in;
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:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
span.EmailStyle17
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:70.85pt 70.85pt 56.7pt 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"><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"><a name="_MailEndCompose"><span style="color:#1F497D"><o:p> </o:p></span></a></p>
<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""> cfe-dev [mailto:cfe-dev-bounces@lists.llvm.org]
<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>
</body>
</html>