[LLVMdev] LLVM related question

Rotem Varon varonrotem at gmail.com
Sun May 10 07:39:55 PDT 2009


Thank you you answer.

On Sun, May 10, 2009 at 12:48 AM, Eli Friedman <eli.friedman at gmail.com>wrote:

> On Sat, May 9, 2009 at 8:37 AM, Rotem Varon <varonrotem at gmail.com> wrote:
> > Its not x86 IR nor  x86 assembly. I have x86 IR "like" instructions ( add
> > R1, R2, R3    and so...)
> >>
> >>  If it's really
> >> x86 assembly, you can use LLVM's code generator to get x86 assembly,
> >
> > Do you mean the "llvm-gcc -S file.c" , or can i have the same effect with
> > C++ code (API) ?
>
> Everything in LLVM is accessible through the C++ APIs.
>
> >> but it's extremely difficult to get back to LLVM IR.
> >
> > Please, its vary important for me that you elaborate why it will
> > be extremely difficult ( i can imagine it would hard, but if you inlight
> me
> > i would probably create a better design...)?
>
> A lot of information gets lost when converting to assembly, like
> types, switches, the SSA form, etc.  It's not impossible, especially
> if you make some assumptions about the compiler, but it's difficult
> enough that I wouldn't suggest it.  It looks like this doesn't apply
> here, though.
>
> >>  If it's
> >> something higher-level, it might not be so bad.
> >
> >  Do you mean, higher than IR ? like c or C++ code ...
>
> Your IR looks high-level enough that it wouldn't be so bad.  It would
> still be a pain to write, though.
>
> >> If you're going to need conversions both ways, my guess is that it'll
> >> be faster to just rewrite the pass as an LLVM IR pass.
> >
> > Can you tall me where can i fined more information about the  LLVM IR
> pass?
>
> http://llvm.org/docs/WritingAnLLVMPass.html . Also, a bunch of other
> stuff in http://llvm.org/docs/ is likely to be useful.
>
> >>  It depends on
> >> how complicated the pass is, though.
> >
> > Lets say its only a project (academic)  ...
>
> Then it's probably easier to rewrite as an LLVM IR pass.  There's less
> to worry about when you're not converting back and forth.
>
> > If i have a pointer to Instruction, how can i get or set the VALUE
> > of  Instruction's operands ?
>
> I->getOperand(0) gets the first operand, I->setOperand(0) sets it,
> etc.  Note that in general, the best way to get used to the API is to
> look at existing passes, espcecially if there's already a pass that's
> does stuff that's related to what you're doing.
>
> -Eli
>
> _______________________________________________
> 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/20090510/60338093/attachment.html>


More information about the llvm-dev mailing list