[LLVMdev] Lowering intrinsic that return an int1

Mehdi Amini mehdi.amini at apple.com
Tue Apr 28 01:50:18 PDT 2015


> On Apr 28, 2015, at 1:18 AM, Jobin, Gaël <gael.jobin at switzerlandmail.ch> wrote:
> 
> Hi all,
> 
> 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?
> 
>  
> First, I have defined an instrinsic in "Intrinsics.td":
> 
> def int_antivm : Intrinsic<[llvm_i1_ty], [], [], "llvm.antivm">;
> 
>  
> Then I want to lower it in the X86 backend, so I defined a pseudo instruction in "X86InstrCompiler.td":
> 
> let usesCustomInserter = 1, Defs = [EFLAGS] in {
> 

I think pseudo-instructions should also define isPseudo = 1

> def ANTIVM : PseudoI<(outs), (ins), [(int_antivm)]>;
> }
> 
>  
> I wrote my custom inserter:
> 
> MachineBasicBlock *
> X86TargetLowering::EmitANTIVMWithCustomInserter(
>     MachineInstr *MI,
>     MachineBasicBlock *MBB) const {
> 
>   // Some stuff, 
> 
>   MI->eraseFromParent(); // The pseudo is gone now.
>   return BB;
> }
> 
> Should I put the return value to EAX (like for a standard function) ?
> 

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”.
If you run llc with —print-before-all, you should be able to see the actual sequence.

— 
Mehdi




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150428/e0eac556/attachment.html>


More information about the llvm-dev mailing list