<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 28, 2015, at 1:18 AM, Jobin, Gaël <<a href="mailto:gael.jobin@switzerlandmail.ch" class="">gael.jobin@switzerlandmail.ch</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" class=""><div style="font-size: 10pt; font-family: Verdana,Geneva,sans-serif" class=""><p class="">Hi all,</p><p class="">I'm playing with intrinsics and I was wondering how to lower an intrinsic that should return, for example, an int1? More precisely, how to return the value when working with MachineInst?</p><div class=""> <br class="webkit-block-placeholder"></div><p class="">First, I have defined an instrinsic in "Intrinsics.td":</p><p class=""><em class="">def int_antivm : Intrinsic<[llvm_i1_ty], [], [], "llvm.antivm">;</em></p><div class=""> <br class="webkit-block-placeholder"></div><p class="">Then I want to lower it in the X86 backend, so I defined a pseudo instruction in "X86InstrCompiler.td":</p><p class=""><em class="">let usesCustomInserter = 1, Defs = [EFLAGS] in {</em><br class=""></p></div></div></blockquote><div><br class=""></div><div>I think pseudo-instructions should also define isPseudo = 1</div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-size: 10pt; font-family: Verdana,Geneva,sans-serif" class=""><p class=""><em class="">def ANTIVM : PseudoI<(outs), (ins), [(int_antivm)]>;</em><br class=""><em class="">}</em></p><div class=""> <br class="webkit-block-placeholder"></div><p class="">I wrote my custom inserter:</p><p class=""><em class="">MachineBasicBlock *</em><br class=""><em class="">X86TargetLowering::EmitANTIVMWithCustomInserter(</em><br class=""><em class=""> MachineInstr *MI,</em><br class=""><em class=""> MachineBasicBlock *MBB) const {</em><br class=""><br class=""><em class=""> // Some stuff, </em><br class=""><br class=""><em class=""> MI->eraseFromParent(); // The pseudo is gone now.</em><br class=""><em class=""> return BB;</em><br class=""><em class="">}</em></p><p class="">Should I put the return value to EAX (like for a standard function) ?</p></div></div></blockquote><div><br class=""></div><div>I expect that before your custom inserter, the value produced by your pseudo instruction was in a vreg. You just have to reuse this vreg to put the result of your “stuff”.</div><div>If you run llc with —print-before-all, you should be able to see the actual sequence.</div><div><br class=""></div><div>— </div><div>Mehdi</div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div><br class=""></div></div></body></html>