[llvm-dev] how to type-legalize a dag

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Fri Mar 18 12:27:55 PDT 2016


On 18 March 2016 at 12:20, Rail Shafigulin via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Given that the action is "Expand" how does legalizer know which replacement
> to use for a given operation?

It's pretty random, and the only way to be sure is to read
LegalizeDAG.cpp. The two basic variants are:

  + Check whether the intended opcode is Legal, use that if possible,
otherwise keep trying until you run out of ideas.
  + Expand it to something, legal or not. Then that node will be
expanded in turn.

Obviously neither is guaranteed to terminate in a legal node (for
example you could set absolutely everything to Expand in which case
there's no solution).

These heuristics tend to cover the common cases, but most targets need
to mark at least a few nodes as Custom and handle them manually.

Cheers.

Tim.


More information about the llvm-dev mailing list