<div dir="ltr"><div>I just pasted that code and ran it through llc, opt, and llvm-as. All passed without issue. What version of llvm are you using?</div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 3, 2020 at 5:53 PM Xuan Tang <<a href="mailto:xt585@nyu.edu">xt585@nyu.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">



<div>
<div name="messageBodySection">
<div dir="auto">Hi Craig:<br>
<br>
I tried that, now the function is like this:<br>
<em style="color:rgb(187,187,187);font-size:12px">; Function Attrs: norecurse nounwind readnone ssp uwtable</em><span style="font-size:12px"><br></span><strong style="color:rgb(184,119,219);font-size:12px">define</strong><span style="color:rgb(187,187,187);font-size:12px"> { </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> } </span><em style="color:rgb(250,194,154);font-size:12px">@add</em><span style="color:rgb(187,187,187);font-size:12px">(</span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px">) local_unnamed_addr #</span><span style="color:rgb(240,148,131);font-size:12px">0</span><span style="color:rgb(187,187,187);font-size:12px"> {</span><span style="font-size:12px"><br></span><span style="color:rgb(187,187,187);font-size:12px">  </span><em style="color:rgb(250,194,154);font-size:12px">%5</em><span style="color:rgb(187,187,187);font-size:12px"> = </span><strong style="color:rgb(184,119,219);font-size:12px">call</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><em style="color:rgb(250,194,154);font-size:12px">@llvm.experimental.constrained.fadd</em><span style="color:rgb(187,187,187);font-size:12px">(</span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><em style="color:rgb(250,194,154);font-size:12px">%0</em><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><em style="color:rgb(250,194,154);font-size:12px">%2</em><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">metadata</strong><span style="color:rgb(187,187,187);font-size:12px"> !</span><span style="color:rgb(250,183,149);font-size:12px">"round</span><span style="color:rgb(37,176,188);font-size:12px">.d</span><span style="color:rgb(250,183,149);font-size:12px">ownward"</span><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">metadata</strong><span style="color:rgb(187,187,187);font-size:12px"> !</span><span style="color:rgb(250,183,149);font-size:12px">"fpexcept</span><span style="color:rgb(37,176,188);font-size:12px">.i</span><span style="color:rgb(250,183,149);font-size:12px">gnore"</span><span style="color:rgb(187,187,187);font-size:12px">)</span><span style="font-size:12px"><br></span><span style="color:rgb(187,187,187);font-size:12px">  </span><em style="color:rgb(250,194,154);font-size:12px">%6</em><span style="color:rgb(187,187,187);font-size:12px"> = </span><strong style="color:rgb(184,119,219);font-size:12px">fadd</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><em style="color:rgb(250,194,154);font-size:12px">%1</em><span style="color:rgb(187,187,187);font-size:12px">, </span><em style="color:rgb(250,194,154);font-size:12px">%3</em><span style="font-size:12px"><br></span><span style="color:rgb(187,187,187);font-size:12px">  </span><em style="color:rgb(250,194,154);font-size:12px">%7</em><span style="color:rgb(187,187,187);font-size:12px"> = </span><strong style="color:rgb(184,119,219);font-size:12px">insertvalue</strong><span style="color:rgb(187,187,187);font-size:12px"> { </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> } undef, </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><em style="color:rgb(250,194,154);font-size:12px">%5</em><span style="color:rgb(187,187,187);font-size:12px">, </span><span style="color:rgb(240,148,131);font-size:12px">0</span><span style="font-size:12px"><br></span><span style="color:rgb(187,187,187);font-size:12px">  </span><em style="color:rgb(250,194,154);font-size:12px">%8</em><span style="color:rgb(187,187,187);font-size:12px"> = </span><strong style="color:rgb(184,119,219);font-size:12px">insertvalue</strong><span style="color:rgb(187,187,187);font-size:12px"> { </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> } </span><em style="color:rgb(250,194,154);font-size:12px">%7</em><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><em style="color:rgb(250,194,154);font-size:12px">%6</em><span style="color:rgb(187,187,187);font-size:12px">, </span><span style="color:rgb(240,148,131);font-size:12px">1</span><span style="font-size:12px"><br></span><span style="color:rgb(187,187,187);font-size:12px">  </span><strong style="color:rgb(184,119,219);font-size:12px">ret</strong><span style="color:rgb(187,187,187);font-size:12px"> { </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> } </span><em style="color:rgb(250,194,154);font-size:12px">%8</em><span style="font-size:12px"><br></span><span style="color:rgb(187,187,187);font-size:12px">}</span><span style="font-size:12px"><br></span><span style="font-size:12px"><br></span><strong style="color:rgb(184,119,219);font-size:12px">declare</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><em style="color:rgb(250,194,154);font-size:12px">@llvm.experimental.constrained.fadd</em><span style="color:rgb(187,187,187);font-size:12px">(</span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">metadata</strong><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">metadata</strong><span style="color:rgb(187,187,187);font-size:12px">)</span><span style="font-size:12px"><br></span><span style="font-size:12px"><br></span>But now I get the error at the line of declaration:<br>
error: expected function name<br>
<br>
I tried the example at <a href="https://llvm.org/docs/LangRef.html#variable-argument-handling-intrinsics" target="_blank">https://llvm.org/docs/LangRef.html#variable-argument-handling-intrinsics</a> and that compiles fine, which means the declaration code should work as well.<br></div>
</div>
<div name="messageSignatureSection"><br>
<div>Thank you
<div>Xuan Tang</div>
</div>
</div>
<div name="messageReplySection">On Sep 3, 2020, 19:41 -0500, Craig Topper <<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>>, wrote:<br>
<blockquote type="cite" style="border-left:thin solid grey;margin:5px;padding-left:10px">
<div dir="ltr">
<div>I think you need a declaration like this at module scope in your IR file. Everything that's called either needs to be defined or declared even if it is an intrinsic. It doesn't matter if the declaration is before or after the use.</div>
<div><br></div>
<div><strong style="color:rgb(184,119,219);font-size:12px">declare double</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><em style="color:rgb(250,194,154);font-size:12px">@llvm.experimental.constrained.fadd</em><span style="color:rgb(187,187,187);font-size:12px">(</span><strong style="color:rgb(184,119,219);font-size:12px">double,</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">metadata</strong><span style="color:rgb(250,183,149);font-size:12px">"</span><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">metadata</strong><span style="color:rgb(187,187,187);font-size:12px">)</span>  <br></div>
<div><br></div>
<div>
<div dir="ltr">~Craig</div>
</div>
<br></div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Thu, Sep 3, 2020 at 5:36 PM Xuan Tang via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<div name="messageBodySection">
<div dir="auto">Hi:<br>
<br>
Sorry I need to send email directly. I am new to llvm and trying to write interval arithmetic, which requires changing rounding mode during computation.<br>
<br>
The document I found <a style="background-color:rgba(0,0,0,0);font-family:Slack-Lato,appleLogo,sans-serif;font-size:15px" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__llvm.org_docs_LangRef.html-23constrained-2Dfloating-2Dpoint-2Dintrinsics&d=DwMFaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=hLa09n1yvyXy9ubp1REixw&m=dfQEfUhbjIQmr4ORw7fkG8wv0VKl4Rf0QVcMJwAmQGA&s=7N7tSGQ2qieHYkFTYdM5hRvGW564X0nUZFD4S75z_Vs&e=" target="_blank">https://llvm.org/docs/LangRef.html#constrained-floating-point-intrinsics</a>, seems to be doing the trick. Here is the piece of code that I did:<br>
<br>
<em style="color:rgb(250,194,154);font-size:12px">%5</em><span style="color:rgb(187,187,187);font-size:12px"> = </span><strong style="color:rgb(184,119,219);font-size:12px">call</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><em style="color:rgb(250,194,154);font-size:12px">@llvm.experimental.constrained.fadd</em><span style="color:rgb(187,187,187);font-size:12px">(</span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><em style="color:rgb(250,194,154);font-size:12px">%0</em><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">double</strong><span style="color:rgb(187,187,187);font-size:12px"> </span><em style="color:rgb(250,194,154);font-size:12px">%2</em><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">metadata</strong><span style="color:rgb(187,187,187);font-size:12px"> !</span><span style="color:rgb(250,183,149);font-size:12px">"round</span><span style="color:rgb(37,176,188);font-size:12px">.d</span><span style="color:rgb(250,183,149);font-size:12px">ownward"</span><span style="color:rgb(187,187,187);font-size:12px">, </span><strong style="color:rgb(184,119,219);font-size:12px">metadata</strong><span style="color:rgb(187,187,187);font-size:12px"> !</span><span style="color:rgb(250,183,149);font-size:12px">"fpexcept</span><span style="color:rgb(37,176,188);font-size:12px">.i</span><span style="color:rgb(250,183,149);font-size:12px">gnore"</span><span style="color:rgb(187,187,187);font-size:12px">)</span><span style="font-size:12px"><br></span><span style="font-size:12px"><br></span>It is taking the first and third argument and adding them together with the downward rounding mode. However, when I try to convert it to bit code, I got the error:<br>
<br>
error: use of undefined value '@llvm.experimental.constrained.fadd'<br>
<br>
Is there any flags I need to add in order to use this intrinsic? Or this is just a wrong function call. I am using the llvm version 10.0.1.</div>
</div>
<div name="messageSignatureSection"><br>
<div>Thank you
<div>Xuan Tang</div>
</div>
</div>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Ddev&d=DwMFaQ&c=slrrB7dE8n7gBJbeO0g-IQ&r=hLa09n1yvyXy9ubp1REixw&m=dfQEfUhbjIQmr4ORw7fkG8wv0VKl4Rf0QVcMJwAmQGA&s=2ZFnMljwFjusSuon3DD_qfwDIwvVBECfEzEATQrTmdQ&e=" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br></blockquote>
</div>
</blockquote>
</div>
</div>

</blockquote></div>