|
|
## Register Allocator Code
|
|
|
|
|
|
|
|
|
|
|
|
The register allocator code is split into two main sections, the register allocator proper and a generic graph coloring library. The graph coloring library is also used by the Stg-\>Cmm converter.
|
|
|
|
|
|
|
|
|
### The register allocator
|
|
|
|
|
|
|
|
|
- [compiler/nativeGen/RegLiveness.hs](/trac/ghc/browser/ghc/compiler/nativeGen/RegLiveness.hs)
|
|
|
|
|
|
Defines `LiveInstr` and `LiveCmmTop` which carry native machine instructions annotated with register liveness information. It also provides functions to annotate native code (`NatCmmTop`) with this liveness information, and to slurp out sets of register conflicts for feeding into the coloring allocator.
|
... | ... | @@ -29,6 +32,10 @@ The register allocator code is split into two main sections, the register alloca |
|
|
|
|
|
Defines `regSpill` which takes `LiveCmmTop`s and inserts spill/reload instructions virtual regs that wouldn't fit in real regs. `regSpill`'s strategy is to simply inserts spill/reloads for every use/def of a particular virtual reg. This inefficient code is cleaned up by the spill cleaner after allocation.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- [compiler/nativeGen/RegSpillClean.hs](/trac/ghc/browser/ghc/compiler/nativeGen/RegSpillClean.hs)
|
|
|
|
|
|
The spill cleaner is run after real regs have been allocated. It erases spill/reload instructions inserted by `regSpill` that weren't strictly nessesary.
|
... | ... | @@ -39,6 +46,7 @@ The register allocator code is split into two main sections, the register alloca |
|
|
|
|
|
### Graph coloring
|
|
|
|
|
|
|
|
|
- [compiler/utils/GraphBase.hs](/trac/ghc/browser/ghc/compiler/utils/GraphBase.hs)
|
|
|
|
|
|
Defines the basic `Graph`, `Node` and `Triv` types used by the coloring algorithm.
|
... | ... | @@ -57,6 +65,7 @@ The register allocator code is split into two main sections, the register alloca |
|
|
|
|
|
### Miscellanea
|
|
|
|
|
|
|
|
|
- [compiler/nativeGen/RegCoalesce.hs](/trac/ghc/browser/ghc/compiler/nativeGen/RegCoalesce.hs)
|
|
|
|
|
|
Defines a function `regCoalesce` that does aggressive coalescing directly on `LiveCmmTops`, without using the graph. This isn't used at the moment but has been left in incase we want to rejig the allocator when the new CPS converter comes online.
|
... | ... | |