[LLVMdev] Inline Assembly in IR

John Criswell criswell at illinois.edu
Fri Jun 20 07:42:46 PDT 2014


On 6/20/14, 9:19 AM, David Blaikie wrote:
>
> That's probably not the right approach (best to keep this conversation 
> on list because this is certainly not my area of expertise and other 
> people might have better opinions).
>
> If your new instruction is just a better way of describing adds on 
> your chip then it should just be a custom target or sub target or CPU 
> feature in the backend (llvms lib target, specifically the x86 
> target), I'd guess.
>

I think Pratik is doing this for a research project, in which case doing 
it quickly is probably better than doing it properly.  As long as the 
code generator and/or assembler understands the new instruction, I think 
using inline assembly is the quicker way to implement it.  For a real 
product, creating a real target/subtarget feature would be the right way 
to go.

Regards,

John Criswell

> On Jun 19, 2014 11:19 PM, "pratik dand" <pratikdand143 at gmail.com 
> <mailto:pratikdand143 at gmail.com>> wrote:
>
>     Dear David,
>
>     It's done at the IR level by
>     call void asm sideeffect "addl .. .. ..",
>     "~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !0.
>
>     But I am looking for something more.
>     I am planning to replace addl of X86 by my new instruction
>     addencl. Hence, on seeing an "add nsw" in the LLVM IR I want to
>     replace it with an assembly corresponding to my new instruction.
>     The problem being, at the IR level I wouldn't know the registers
>     allocated to the tmp variables of IR.
>
>     I am looking to support a new custom add instruction without
>     adding it to the backend.
>
>     Regards,
>     Pratik
>
>
>     On Fri, Jun 20, 2014 at 1:20 PM, David Blaikie <dblaikie at gmail.com
>     <mailto:dblaikie at gmail.com>> wrote:
>
>         Oh, wait - which way. Writing inline assembly /using/ llvm IR (eg:
>         LLVM IR embedded as inline assembly in C) or writing inline
>         assembly
>         (for actual assembly) in LLVM IR?
>
>         For the former, see my first response. For the latter - I'd
>         just look
>         at what IR clang produces for inline assembly given in a c
>         file, etc.
>
>         On Thu, Jun 19, 2014 at 10:18 PM, David Blaikie
>         <dblaikie at gmail.com <mailto:dblaikie at gmail.com>> wrote:
>         > Hasn't been implemented. Could be, if someone really wanted to.
>         >
>         > On Thu, Jun 19, 2014 at 8:37 PM, pratik dand
>         <pratikdand143 at gmail.com <mailto:pratikdand143 at gmail.com>> wrote:
>         >> Dear,
>         >>
>         >> Can anybody comment on inserting inline assembly in LLVM IR?
>         >>
>         >> --
>         >> Pratik
>         >>
>         >>
>         >> _______________________________________________
>         >> LLVM Developers mailing list
>         >> LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu>
>         http://llvm.cs.uiuc.edu
>         >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>         >>
>
>
>
>
>     -- 
>     Pratik
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

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


More information about the llvm-dev mailing list