<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" 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:36 PM Xuan Tang via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">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://llvm.org/docs/LangRef.html#constrained-floating-point-intrinsics" 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://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>