[LLVMdev] Regalloc Refactoring
Evan Cheng
evan.cheng at apple.com
Tue Apr 17 15:36:22 PDT 2007
That's all implementation detail. My main point is spill weight
computation is tied to the particular allocator / spiller combo so it
should not be a separate pass.
Evan
On Apr 17, 2007, at 1:59 PM, David Greene wrote:
> Evan Cheng wrote:
>
>> While I agree spill cost computation does not belong in coalescer, I
>> am not sure if it should go into a separate pass. To me, spill cost
>> formulas should be register allocator specific. Perhaps it ought to
>> belong to a generic register allocator class. Each derivative
>> allocator is responsible for overriding it and calling it if it deems
>> necessary.
>
> I'm actually fairly nervous about using inheritance this way. I know
> it's done like this all over LLVM but the Template Method pattern is
> often better. You don't _really_ need dynamic polymorphism for things
> like this. Static polymorphism is sufficient and it has the advantage
> of more flexibility for reuse (doesn't depend on a specific base
> class).
>
> For example, if I'm writing a register allocator, one way to do what
> you're saying without inheritance is to parameterize the allocator
> with a traits class and call into that for the custom routines:
>
> template<class RegallocTraits>
> class GCRegAlloc {
> void doAlloc() {
> ...
> RegallocTraits::computeSpillCost(someValue);
> ...
> };
> };
>
> An alternative to think about during these discussions.
>
> -Dave
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list