[LLVMdev] difference between pattern and dag2dag isels

Chris Lattner sabre at nondot.org
Fri Aug 19 09:01:16 PDT 2005


On Fri, 19 Aug 2005, Alkis Evlogimenos wrote:
> What's the difference between the pattern and the dag2dag instruction
> selectors?
> It seems that the pattern selector does not preserve the original dag but
> the dag2dag one does. Is this done so that scheduling/other opts can be
> performed more easily in the generated machine code?
> Thanks,

Yup that's exactly it.  The Pattern ISels perform instruction selecton on 
a legalized dag and emit machine instructions as part of their pattern 
matching walk.  The problem with this is that the order of instructions 
in the resultant code depends the order the isel happens to walk the DAG. 
The X86 backend has some hacks to try to reduce register pressure, but 
it's hard to do the right thing at this level.

The DAG->DAG selectors seperate the selection from the scheduling.  In 
particular, they take a legalized selection dag in, and produce a new dag 
with target operations.  Because it produces a DAG, the order independence 
of operations is preserved.

As the second step to this, a second pass walks to target dag and emits 
instructions.  This pass, a scheduler, can be tuned to minimize register 
pressure, cover latency, or anything else you want your scheduler to do. 
The important part of this though is that it is NOT in the target-specific 
code.  In the first rev, I'll implement a trivial scheduler that works 
but is really simple and doesn't produce good code.  Jim will be working 
on better one.

Another important part of this is that it makes the target-specific 
pattern matching part of the instruction selector (the bulk of the 
selector code) much more autogeneratable from .td files, which may 
materialize here shortly as well.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/




More information about the llvm-dev mailing list