[LLVMdev] Complex regalloc contraints

Carlos Sanchez de La Lama carlos.delalama at urjc.es
Wed Sep 8 04:12:24 PDT 2010


Hi Lang,

> The PBQP allocator was designed to support a very wide range of
> constraints, and can handle something like this easily.

Glad to hear this :)

> Say you have 4 of these orX/irX registers, then for any pair of
> virtual registers used in such an add instruction you would add the
> following constraint matrix to the PBQP instance:
> 
> 
> [  0  inf inf inf ]
> [ inf  0  inf inf ]
> [ inf inf  0  inf ]
> [ inf inf inf  0  ]
> 
> 
> The rows and columns of this matrix reflect the storage locations that
> the allocator can assign, and the elements represent the cost of a
> specific assignment. Say the rows represent the set { or1, or2, or3,
> or4 } and the columns represent { ir1, ir2, ir3, ir4 }. The infinite
> cost elements constrain the valid assignments to matching pairs.

I think this is exactly what I need, also because in a future stage I
would need to assign weights to some register pairs, not being
impossible but being quite expensive in terms of performance.

> The design I have in mind is this: We add a method to
> TargetRegisterInfo which returns a PBQPProblemBuilder for the target
> architectures. I implement a base PBQPProblemBuilder by simply lifting
> the current construction process out of the PBQP allocator and into
> its own class. Anyone (such as yourself, Carlos) who wants to
> represent more esoteric constraints in their architecture just extends
> this class, calls the base class to handle all the basic constraints,
> then performs their own pass over the function to add in their
> constraints:
> 
> 
> struct MyTargetPBQPProblemBuilder : public PBQPProblemBuilder {
>   PBQP::Graph* buildProblemFor(MachineFunction *mf) {
>     PBQP::Graph* g = PBQPProblemBuilder::buildProblemFor(mf);
>     // Add additional constraints for my architecture here.
>     return g;
>   }
> }
> 
> 
> Any thoughts or comments? I think this should be a very
> straightforward extension.

I find it quite suiting my problem. If this extension is added I will
surely use it.

Thanks a lot!

Carlos




More information about the llvm-dev mailing list