[LLVMdev] [PATCH] Re: Pluggable Register Coalescers

Evan Cheng evan.cheng at apple.com
Mon Jul 16 16:19:21 PDT 2007


Hi David,

Sorry I should have replied earlier. I really don't like this dual  
interface approach. To me, this muddles things without offering any  
real useful new functionalities.

IMHO, if a register coalescer is tied to a particular allocator. Then  
either it should simply belong to that allocator or that we have to  
allow the allocator to act as a pass manager itself, i.e. it can  
control what passes to run as part the allocating process. I don't  
know if the pass manager allows that functionality. If not, then  
that's something we should add because there are other passes that  
can benefit from it.

Also, on this particular file below. Seems to me these queries do not  
belong to the register allocator. Perhaps a utility class that tracks  
interference information that can be accessed by both the allocator  
and the coalescer? Also, why is coalesceThisCopy() needed? Shouldn't  
the coalescer be responsible for making the decision?

Evan

Index: llvm/include/llvm/CodeGen/RegisterAllocator.h
===================================================================
--- llvm/include/llvm/CodeGen/RegisterAllocator.h	(revision 0)
+++ llvm/include/llvm/CodeGen/RegisterAllocator.h	(revision 0)
@@ -0,0 +1,41 @@
+//===-- RegisterAllocator.h - Register Coalescing Interface ------*-  
C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is  
distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT  
for details.
+//
+// 
===--------------------------------------------------------------------- 
-===//
+//
+// This file contains the abstract interface for register allocators,
+// allowing them to provide information to coalescers.
+//
+// 
===--------------------------------------------------------------------- 
-===//
+
+#ifndef LLVM_CODEGEN_REGISTER_ALLOCATOR_H
+#define LLVM_CODEGEN_REGISTER_ALLOCATOR_H
+
+#include <llvm/CodeGen/LiveInterval.h>
+
+namespace llvm
+{
+  class MachineInstruction;
+
+  class RegisterAllocator {
+  public:
+    /// Return whether this copy should be considered for coalescing.
+    virtual bool coalesceThisCopy(const MachineInstruction &) {
+      // Be aggressive, but possibly bad
+      return(true);

This is, stylistically inconsistent with the rest of the code base.  
Just "return true;" please.

+    };
+
+    /// Return whether two live ranges interfere.
+    virtual bool interfere(const LiveInterval &a,
+                           const LiveInterval &b) {
+      // A naive test
+      return(a.overlaps(b));
+    };
+  };
+}
+
+#endif

Property changes on: llvm/include/llvm/CodeGen/RegisterAllocator.h
___________________________________________________________________
Name: svn:eol-style
    + LF

What's this?






On Jul 13, 2007, at 11:32 AM, David A. Greene wrote:

> On Wednesday 11 July 2007 15:07, Christopher Lamb wrote:
>
>> Could it be possible for there to be a harness type interface that
>> would allow coalescers that support both modes to be hooked into the
>> pass registration, and those that depend on the allocator not be
>> registered as passes?
>
> I have a patch for this kind of thing attached.  Please take a look  
> and let
> me know if it looks reasonable.  It's not complete yet.  I'm about  
> to embark
> on implementing a new coalescer that will not be managed by  
> PassManager
> and as I do that I'll figure out any additional interfaces that are  
> needed.
>
> If this looks good, I'll commit it and later on I'll commit any  
> additions I
> make to this basic interface.
>
>                                                   -Dave
> <coalscing_patch.txt>
> _______________________________________________
> 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