[LLVMdev] LLVM related question

Eli Friedman eli.friedman at gmail.com
Sat May 9 07:23:45 PDT 2009


On Sat, May 9, 2009 at 5:35 AM, Rotem Varon <varonrotem at gmail.com> wrote:
> I need to add a new optimization to the LLVM compiler.

Knowing what the optimization does would be very helpful here.

> The optimization ALREADY written for x86 IR (i mean that the code that
> handles the optimization is designated to work on assembly 86) .

It's designed to work on x86 assembly, or "x86 IR"?  If it's really
x86 assembly, you can use LLVM's code generator to get x86 assembly,
but it's extremely difficult to get back to LLVM IR.  If it's
something higher-level, it might not be so bad.

> So, this is what i think -
> I will add a Basic Block Pass to the LLVM, the code of the pass will iterate
> etch instruction and convert it to x86 IR, now the optimization will take
> place, after the optimization i will convert the x86 IR code back into LLVM
> IR.
> To the question(s):
> Do you think my idea is a good one (if yes, do you see any
> problems implementing this)?
> Do you have another idea?

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.  It depends on
how complicated the pass is, though.

> Is the LLVM have such built in capability ( converting LLVM IR to other IRs
> ) ?

If you need a different IR, I think you'll have to write your own
converter.  Converting from LLVM IR to another language generally
isn't very difficult if you don't care about the quality of the
generated code too much, but it's a lot of work, and it seems like
code quality is important here.

-Eli




More information about the llvm-dev mailing list