[LLVMdev] ComplexPattern

Greg Chadwick gac43 at cam.ac.uk
Tue Jan 19 06:57:42 PST 2010


Hi,

I was wondering if someone could explain precisely what the 
ComplexPattern tablegen class does?

Here's the first line of the definition (from TargetSelectionDAG.td) for 
reference:

class ComplexPattern<ValueType ty, int numops, string fn,
                      list<SDNode> roots = [],
                      list<SDNodeProperty> props = [],
                      list<CPAttribute> attrs = []>

As far as I can tell it gives the name of a selection function (fn) that 
will be called to match that particular ComplexPattern.  Should that 
function return true that pattern has matched.  The match function can 
also fill in some operands that can be used later on (Number is 
specified by numops), ty presumably specifies the type of node that this 
match can be attempted on.  Is my understanding of this correct?

The thing I'm still unsure about is roots, what exactly does this do? 
The comment above the definition specifies that 'RootNodes are the list 
of possible root nodes of the sub-dags to match' (RootsNodes is assigned 
to root so they're the same) but I can't make any sense of this.

Cheers,

Greg Chadwick



More information about the llvm-dev mailing list