<div dir="ltr">Nice!<div><br></div><div>Thanks so much!</div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, 9 Jan 2018 at 07:20 Craig Topper <<a href="mailto:craig.topper@gmail.com">craig.topper@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">If you are using x86, you probably need to pass something like -mcpu=haswell or -mattr=bmi2 to enable support for the intrinsic. It seems to -mcpu=native doesn't work for lli so it can't just autodetect your CPU.</div><div class="gmail_extra"></div><div class="gmail_extra"><br clear="all"><div><div class="m_8547819788620438806gmail_signature" data-smartmail="gmail_signature">~Craig</div></div></div><div class="gmail_extra">
<br><div class="gmail_quote">On Sun, Jan 7, 2018 at 7:54 AM, Nemanja Ivanovic via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="auto">Hi John,</div><div dir="auto">What targer are you trying to compile this for? I imagine this is just a case of using an X86 intrinsic on a non-X86 back end. Or is this an intrinsic you added and didn't provide a selection pattern for?</div><div dir="auto"><br></div><div dir="auto">In any case, this intrinsic makes it into the selection DAG and the instruction selector tries to select a sequence of instructions for it. However, it fails to find a pattern that it can match in your back end, so you get this error.</div><div dir="auto"><br></div><div dir="auto">As far as learning LLVM, The documentation at <a href="http://llvm.org" target="_blank">llvm.org</a> is the best place to start. However, it is a huge project so you probably want to be a bit more specific in terms of what it is you want to learn. Based on your question, I imagine you want to learn how code generation works, so you might want to check out <a href="http://llvm.org/docs/CodeGenerator.html" target="_blank">http://llvm.org/docs/CodeGenerator.html</a></div><div dir="auto"><br></div><div dir="auto">Hope this helps.</div><br><div class="gmail_quote"><div><div class="m_8547819788620438806h5"><div>On Sun, Jan 7, 2018 at 4:21 PM John Ky via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_8547819788620438806h5"><div><div class="m_8547819788620438806m_-3113333542709448967m_5729780129323471537markdown-here-wrapper"><p style="margin:0px 0px 1.2em!important">Hello,</p>
<p style="margin:0px 0px 1.2em!important">I’m not sure if this is the right place to ask beginner questions.</p>
<p style="margin:0px 0px 1.2em!important">If not, please direct me to the appropriate place.</p>
<p style="margin:0px 0px 1.2em!important">I’m writing my first <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">llvm</code> program and I’m trying to call an intrinsic, but failing.</p>
<p style="margin:0px 0px 1.2em!important">So far this is what I have:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important">declare ccc i32 @llvm.x86.bmi.pdep.32(i32, i32)
@.str2 = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1
declare i32 @printf(i8*, ...) nounwind
; Definition of main function
define i32 @main() {
%res = call ccc i32 (i32, i32) @llvm.x86.bmi.pdep.32( i32 1, i32 1 )
%a = alloca i32, align 8
%1 = load i32, i32* %a, align 8
%ss = getelementptr inbounds [4 x i8], [4 x i8]* @.str2, i32 0, i32 0
call i32 (i8*, ...) @printf( i8* %ss, i32 %res)
ret i32 0
}
</code></pre><p style="margin:0px 0px 1.2em!important">When I run this code, I get the following error:</p>
<pre style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;font-size:1em;line-height:1.2em;margin:1.2em 0px"><code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline;white-space:pre-wrap;overflow:auto;border-radius:3px;border:1px solid rgb(204,204,204);padding:0.5em 0.7em;display:block!important">$ lli helloWorld.ll
LLVM ERROR: Cannot select: intrinsic %llvm.x86.bmi.pdep.32
</code></pre><p style="margin:0px 0px 1.2em!important">Where am I going wrong?</p>
<p style="margin:0px 0px 1.2em!important">Also, what’s the best resource for learning <code style="font-size:0.85em;font-family:Consolas,Inconsolata,Courier,monospace;margin:0px 0.15em;padding:0px 0.3em;white-space:pre-wrap;border:1px solid rgb(234,234,234);background-color:rgb(248,248,248);border-radius:3px;display:inline">llvm</code>?</p>
<p style="margin:0px 0px 1.2em!important">Cheers,</p>
<p style="margin:0px 0px 1.2em!important">-John</p>
<div title="MDH:SGVsbG8sPGRpdj48YnI+PC9kaXY+PGRpdj5JJ20gbm90IHN1cmUgaWYgdGhpcyBpcyB0aGUgcmln
aHQgcGxhY2UgdG8gYXNrIGJlZ2lubmVyIHF1ZXN0aW9ucy48L2Rpdj48ZGl2Pjxicj48L2Rpdj48
ZGl2PklmIG5vdCwgcGxlYXNlIGRpcmVjdCBtZSB0byB0aGUgYXBwcm9wcmlhdGUgcGxhY2UuPC9k
aXY+PGRpdj48YnI+PC9kaXY+PGRpdj5JJ20gd3JpdGluZyBteSBmaXJzdCBgbGx2bWAgcHJvZ3Jh
bSBhbmQgSSdtIHRyeWluZyB0byBjYWxsIGFuIGludHJpbnNpYywgYnV0IGZhaWxpbmcuPC9kaXY+
PGRpdj48YnI+PC9kaXY+PGRpdj5TbyBmYXIgdGhpcyBpcyB3aGF0IEkgaGF2ZTo8L2Rpdj48ZGl2
Pjxicj48L2Rpdj48ZGl2PmBgYDwvZGl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wg
SSBnZXQgdGhlIGZvbGxvd2luZyBlcnJvcjo8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PmBgYDwv
ZGl2PjxkaXY+PGRpdj4kIGxsaSBoZWxsb1dvcmxkLmxsPC9kaXY+PGRpdj5MTFZNIEVSUk9SOiBD
YW5ub3Qgc2VsZWN0OiBpbnRyaW5zaWMgJWxsdm0ueDg2LmJtaS5wZGVwLjMyPC9kaXY+PC9kaXY+
PGRpdj5gYGA8L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PldoZXJlIGFtIEkgZ29pbmcgd3Jvbmc/
PC9kaXY+PGRpdj48YnI+PC9kaXY+PGRpdj5BbHNvLCB3aGF0J3MgdGhlIGJlc3QgcmVzb3VyY2Ug
Zm9yIGxlYXJuaW5nIGBsbHZtYD88L2Rpdj48ZGl2Pjxicj48L2Rpdj48ZGl2PkNoZWVycyw8L2Rp
dj48ZGl2Pjxicj48L2Rpdj48ZGl2Pi1Kb2huPC9kaXY+PGRpdj48L2Rpdj4=" style="height:0;width:0;max-height:0;max-width:0;overflow:hidden;font-size:0em;padding:0;margin:0"></div></div><div><br></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="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>
<br>_______________________________________________<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="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></blockquote></div>