[LLVMdev] Proposal for new Legalization framework

Justin Holewinski justin.holewinski at gmail.com
Thu Apr 25 06:48:19 PDT 2013


On Thu, Apr 25, 2013 at 4:50 AM, David Chisnall <David.Chisnall at cl.cam.ac.uk
> wrote:

> Hi Dan,
>
> On 25 Apr 2013, at 01:01, Dan Gohman <dan433584 at gmail.com> wrote:
>
> > The main alternative approach that's been discussed is to do FastISel to
> a target-independent opcode set on MachineInstrs, and then do legalization
> and ultimately the last phase off instruction selection proper after that.
> The most obvious advantage of using LLVM IR for legalization is that it's
> (currently) more developer-friendly. The most obvious advantage of using
> MachineInstrs is that they would make it easier to do low-level
> manipulations. Also, doing legalization on MachineInstrs would mean
> avoiding having LLVM-IR-level optimization passes which lower the IR, which
> has historically been a design goal of LLVM.
>
> The approach taken in WHIRL, which has a lot of advantages, is exactly to
> lower the IR.  It seems strange that in the back end we have Machine*
> classes that correspond very closely to IR equivalents, but which don't
> share any code and often have subtly different interfaces.  The approach
> taken in WHIRL is to progressively replace machine-independent bits of the
> IR with machine-dependent ones, with abstract instructions being replaced
> with machine instructions, abstract registers with machine registers, and
> so on.
>

Couldn't we first lower LLVM IR to a (mostly) target-independent sequence
of MachineInstrs, and then progressively lower those?  That seems to be
very close to what you describe, and makes a great deal of sense to me.
 The MachineInstr could model operations and types that are not legal for
the current target, but passes could lower those until everything is legal
and all opcodes are target-specific.

Targets can still lower function arguments/returns as they please.  And
most of the infrastructure for this is already present (no new IR).


>
> I would be interested to know the rationale behind the design choice to
> avoid this, as it seems the obvious way of designing a compiler.  The down
> side would be that you couldn't take any random pass that expected
> target-independent IR and run it, but you never actually want to do this
> once you've handed off to the codegen infrastructure anyway.
>
> David
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>



-- 

Thanks,

Justin Holewinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130425/ebb50481/attachment.html>


More information about the llvm-dev mailing list